I am working in Xcode on a synthesizer application. I am using custom sliders and knobs. I want these to send control values to receivers in an embedded Pure Data patch (I am using libpd as a Pure Data library and wrapper).
I have multiple custom sliders and knobs on my interface. I want each one to send only their own control values independently of the other sliders/knobs.
I am using tags and a switch statement.
The problem is that only the first case is working and all of the sliders and knobs are sending control values to the same receiver.
- (void)viewDidLoad {
[super viewDidLoad];
// Slider 1
slider.tag = 0;
slider = [[[DCSlider alloc] initWithDelegate:self] autorelease];
slider.frame = CGRectMake(0,0,20,100);
[self.sliderContainer addSubview: slider];
// Slider 2
slider2.tag = 1;
slider2 = [[[DCSlider alloc] initWithDelegate:self] autorelease];
slider2.frame = CGRectMake(0,0,20,100);
[self.sliderContainer2 addSubview: slider2];
}
and then I implement the method here…
- (void)controlValueDidChange:(float)value sender:(id)sender {
DCSlider *slidertag = (DCSlider *)sender;
switch (slidertag.tag)
{
case 0:
{
[PdBase sendFloat:value toReceiver:@"beatvol"];
}
break;
case 1:
{
[PdBase sendFloat:value toReceiver:@"bassvol"];
}
break;
}
}
Can anyone help please? Thanks.
Geez, still at it?
You obviously need to assign a separate target for each slider!
Also, in your example, you assign the tag before you create the slider, no good. You should always place your
initbefore setting any properties.And if you are going to use my answer to your other question, the least you could do is give it an upvote. ;—]