EZAudio的效果有很多种 可以根据你要的效果设定,具体看我另外一篇文章或者登陆
https://github.com/syedhali/EZAudio 查看是否有你想要看到的效果
当看见需求是要这样的(我整个人都懵逼了)

幸亏有EZAudio,之前找了N 多个框架都不像.
这里解读下需求,根据用户实时的声音大小改变波纹,并自动滚动画面

可能美工画的和最后效果有一点点区别,但是已经是美工想要的效果,
下面就开始说怎么做出来的,附带说明怎么使用框架
1.导入框架,在控制器下写入 #import "EZAudio.h"
2.拖一个view 到控制器下 这个View 就是录音效果你想要的大小,并且改变View 隶属于EZAudioPlot(下图)

3.成为EZMicrophoneDelegate代理

4.牵线拿到Audio Plot 并在控制器中设置效果的背景颜色和波纹颜色等

5.这里的plotType 有2种 一种是我们苹果录音的效果 EZPlotTypeRolling,另外一种是类似siri 效果 EZPlotTypeBuffer

6.配置输出设备及开启麦克风

7.麦克风设备切换的一些方法及控制声音流产生的效果


附上代码得了 这么多....
#pragma mark - EZAudioAction
- (void)microphone:(EZMicrophone *)microphone
hasAudioReceived:(float **)buffer
withBufferSize:(UInt32)bufferSize
withNumberOfChannels:(UInt32)numberOfChannels
{ __weak typeof (self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.audioPlot updateBuffer:buffer[0] withBufferSize:bufferSize];
});
}
- (void)microphone:(EZMicrophone *)microphone hasAudioStreamBasicDescription:(AudioStreamBasicDescription)audioStreamBasicDescription
{
//
// The AudioStreamBasicDescription of the microphone stream. This is useful
// when configuring the EZRecorder or telling another component what
// audio format type to expect.
//
[EZAudioUtilities printASBD:audioStreamBasicDescription];
}
- (void)microphone:(EZMicrophone *)microphone changedDevice:(EZAudioDevice *)device
{
NSLog(@"Microphone changed device: %@", device.name);
//
// Called anytime the microphone's device changes
//
__weak typeof(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
NSString *name = device.name;
NSString *tapText = @" (Tap To Change)";
NSString *microphoneInputToggleButtonText = [NSString stringWithFormat:@"%@%@", device.name, tapText];
NSRange rangeOfName = [microphoneInputToggleButtonText rangeOfString:name];
NSMutableAttributedString *microphoneInputToggleButtonAttributedText = [[NSMutableAttributedString alloc] initWithString:microphoneInputToggleButtonText];
[microphoneInputToggleButtonAttributedText addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:13.0f] range:rangeOfName];
// [weakSelf.microphoneInputToggleButton setAttributedTitle:microphoneInputToggleButtonAttributedText forState:UIControlStateNormal];
//
// Reset the device list (a device may have been plugged in/out)
//
weakSelf.inputs = [EZAudioDevice inputDevices];
// [weakSelf.microphoneInputPickerView reloadAllComponents];
// [weakSelf setMicrophonePickerViewHidden:YES];
});
}
最后这里要注意的也是重点在别的技术文章里可能没写到
1.audioplot View 记得勾选clip to bounds (否则会超出view)
2.动画效果如果在viewDidLoad里没效果 那就要写在viewWillAppear 里
3.其实这个波纹大小想要控制可以借用audioPlot.gain = 3.0 这个3.0系数自己调整
网友评论