我想要实现的是通过从UISlider
示例1(正常状态)发送值以编程方式更改截止参数:
Float32 highPassFilterCutoff = 4000.0;
CheckError(AudioUnitSetParameter(_auHighPassFilter,
kHipassParam_CutoffFrequency,
kAudioUnitScope_Global,
0,
highPassFilterCutoff,
0),
"Coulnd't set kHipassParam_CutoffFrequency ");
我想要的是什么:
NSLog(@"cutOffSlider.value in effect %f",cutOffslider.value );
Float32 highPassFilterCutoff = cutOffslider.value;
CheckError(AudioUnitSetParameter(_auHighPassFilter,
kHipassParam_CutoffFrequency,
kAudioUnitScope_Global,
0,
highPassFilterCutoff,
0),
"Coulnd't set kHipassParam_CutoffFrequency ");
我这样想......
-(IBAction)cutOffslider:(id)sender {
[cutOffslider setMinimumValue:0.0];
[cutOffslider setMaximumValue:6000.0];
NSLog(@"SliderValue ... %d",(int)sender);
}
调试控制台上的输出
PlayBasic[567:c07] cutOffSlider.value in effect 0.500000
如何看到我可以从滑块获取浮点值,但是当我在模拟器上通过滑块递增或递减值时,效果不会改变截止参数。有关运行时更改参数的想法吗?
答案 0 :(得分:1)
首先是
NSLog(@"SliderValue ... %d", (int)sender);
错了。 Sender
是一个对象,即发送消息的对象:UISliderView,这不能仅仅转换为int
您需要将(IBAction)cutoffSlider:(id)sender
连接到UISliderView的操作,然后在其中设置过滤器值,如:
-(IBAction)cutOffslider:(id)sender {
[cutOffslider setMinimumValue:0.0];
[cutOffslider setMaximumValue:6000.0];
NSLog(@"SliderValue ... %d",(int)sender);
Float32 highPassFilterCutoff = cutOffslider.value;
CheckError(AudioUnitSetParameter(_auHighPassFilter,
kHipassParam_CutoffFrequency,
kAudioUnitScope_Global,
0,
highPassFilterCutoff,
0),
"Couldn't set kHipassParam_CutoffFrequency ");
}