I'd like to be able to loop certain sections of a sample using c4. I'd also like to skip between loops without waiting for the current loop to end. So for example if I have the last bar looping and I'm halfway through and I want to skip to the first bar, it would do so without waiting for the last bar to end.
I was using "currentTime" and "touchesBegan" to try to set it up but I can't get it to work like I want it. I was reading around on stack overflow about it and it looks like I'm supposed to NSTimer? or some sort of callback or something? How can I do this?
Here's what I've got:
@implementation C4WorkSpace {
C4Sample *audioSample;
}
-(void)setup {
audioSample = [C4Sample sampleNamed:@"C4Loop.aif"];
[audioSample play];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
audioSample.currentTime = 1.0f;
//NSTimer? wait some time and then ?
//callback? I don't know how to do that, but is that what I would do here?
}
@end
The C4Sample class doesn't have any ability to loop right now. If you want to do this you'll have to construct the looping mechanism yourself. Off the top of my your first question about using an NSTimer would be pretty straightforward.
You could:
... then the timer triggers a method that sets audioSample.currentTime = loopStartTimer;
similar to how you're doing this in the touchesBegan:
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With