多DCSliders发送不同的控制值(X code) [英] Multiple DCSliders sending different control values (Xcode)

查看:145
本文介绍了多DCSliders发送不同的控制值(X code)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这的问题可能是很具体的,但我是新来的这一切,真的需要一些帮助。

This question may be very specific, but I'm new to all this and really need some help.

我要建一个iPhone应用程序合成。
我使用的DCSliders DCKnobs(它们比标准UISliders看起来更漂亮)。

I'm building an iPhone synth app. I am using DCSliders an DCKnobs (they look nicer than the standard UISliders).

https://github.com/domesticcatsoftware/DCControls#readme

我也libpd(纯数据库),使音频DSP的工作是通过一个嵌入式纯数据处理的补丁。

I am also working with libpd (a Pure Data library) so the audio DSP is handled by an embedded Pure Data patch.

https://gitorious.org/pdlib

我在接口有多个DCSliders和DCKnobs。我能够通过一类DCSlider ...

I have got multiple DCSliders and DCKnobs in my interface. I am able to send control values from the sliders/knobs to Pure Data by making a class the delegate of the DCSlider...

- (void)loadView {
  [super loadView];
  self.mySlider = [[[DCSlider alloc] initWithDelegate:self] autorelease];
  self.mySlider.frame = CGRectMake(10.0, 10.0, 20.0, 120.0);

  [self.view addSubview:self.mySlider];
}

然后我实现一个方法来发送控制值的接收器在纯数据...

Then I implement a method to send control values to a receiver in Pure Data...

- (void)controlValueDidChange:(float)value sender:(id)sender {  
    [PdBase sendFloat:value toReceiver:@"beatvol"];
}

这一切工作正常。

的问题是,所有的滑块的发送相同的控制值。

The problem is that all of the sliders are sending the same control values.

我如何获得每个DCSliders派独立控制值不同的接收器在纯数据?

How do I get each of the DCSliders to send independent control values to different receivers in Pure Data?

推荐答案

您需要一个标记分配给您的滑块。然后在 controlValueDidChange:需要根据标签来获取标签,做你的行动:

You need to assign a tag to your sliders. Then in controlValueDidChange: you need to get that tag and do your actions according to the tags:

- (void)loadView 
{
    [super loadView];
    mySlider = [[[DCSlider alloc] initWithDelegate:self] autorelease];
    mySlider.frame = CGRectMake(10.0, 10.0, 20.0, 120.0);
    mySlider.tag = 0;
    [self.view addSubview: mySlider];
}
- (void)controlValueDidChange:(float)value sender:(id)sender 
{  
    DCSlider * slider = (DCSlider *)sender;

    switch (slider.tag) 
    {
        case 0: 
        { 
            [PdBase sendFloat:value toReceiver:@"beatvol"];
        }
            break;
        case 1: 
        { 
            /*  do something for the 2nd slider  */;
        }
            break;
    }        
}

这篇关于多DCSliders发送不同的控制值(X code)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆