-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWaveformView.h
More file actions
34 lines (24 loc) · 1.52 KB
/
Copy pathWaveformView.h
File metadata and controls
34 lines (24 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface WaveformView : UIView
// Appearance
@property (nonatomic, strong) UIColor *waveColor; // main waveform color
@property (nonatomic, strong) UIColor *secondaryWaveColor; // slightly faded for tail / smoothing
@property (nonatomic, strong) UIColor *progressColor; // playhead / played region color
@property (nonatomic) CGFloat lineWidth; // stroke width for waveform
@property (nonatomic) BOOL symmetric; // draw symmetric (top+bottom) or single-line
@property (nonatomic, assign) CGFloat progress; // 0.0 – 1.0 playback position
// Realtime update (recording): pass the latest float samples [-1..1] from mic buffers.
// samples are not copied (read-only); method copies internally so you can free/retain as usual.
- (void)updateWithFloatSamples:(const float *)samples count:(NSUInteger)count;
// Static render: render full waveform from sample array (float [-1..1]). Ideally called after downsampling
- (void)renderSamples:(const float *)samples count:(NSUInteger)count;
// Convenience: read audio file and render compressed waveform asynchronously.
// Supported formats: any AVAsset-supported audio (it will be converted to 32-bit float PCM internally).
- (void)loadAudioFileAtURL:(NSURL *)fileURL completion:(void(^_Nullable)(BOOL success, NSError * _Nullable error))completion;
// Playback progress [0..1]
- (void)setProgress:(CGFloat)progress animated:(BOOL)animated;
// Clear waveform
- (void)clear;
@end
NS_ASSUME_NONNULL_END