我正在使用 libpd 创建一个音乐应用程序,它有两种控制波形的音量和音高的方法——两个独立的 UISlider 和一个使用 UIPanGestureRecognizer 的 XY 垫。
我想做的是让滑块反映 XY 垫的动作,所以想知道这怎么可能?(即 Y 轴已经在控制音量,但要看到滑块也对其做出反应)
这就是我使用单独控件的地方。
// Volume slider
-(IBAction)sineVol:(id)sender
{
UISlider *vslider = (UISlider *)sender;
[PdBase sendFloat:vslider.value toReceiver:@"sine_vol"];
}
// Pitch slider
-(IBAction)sinePitch:(id)sender
{
UISlider *pslider = (UISlider *)sender;
[PdBase sendFloat:pslider.value toReceiver:@"sine_pitch"];
}
// XY Pad
-(IBAction)sineXYPad:(UIPanGestureRecognizer *)trigger
{
float sinepadHeight = sinexyview.bounds.size.height;
float sinepadWidth = sinexyview.bounds.size.width;
CGPoint location = [trigger locationInView:sinexyview];
if ((location.y >= 0) && (location.y < sinepadHeight) && (location.x >= 0) && (location.x < sinepadWidth))
{
float sineVolXY = ((location.y) / 250);
[PdBase sendFloat:sineVolXY toReceiver:@"sine_vol"];
}
if ((location.y >= 0) && (location.y < sinepadHeight) && (location.x >= 0) && (location.x < sinepadWidth))
{
float sinePitchXY = ((location.x) / 5);
[PdBase sendFloat:sinePitchXY toReceiver:@"sine_pitch"];
}
}