views:

36

answers:

1

hello all,

in my app i use AudioToolbox framework and i need to play a loop can i ?

this is the AVAudioplayer code that goes slowly with 2 touches simultaneously

- (AVAudioPlayer *)getNoteFromFilename:(NSString *)name andoftype:(NSString *)type{
    NSString *soundPath = [[NSBundle mainBundle] pathForResource:name
                                                          ofType:type];
    NSURL *fileURL = [NSURL fileURLWithPath:soundPath];
    AVAudioPlayer *note = [[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL
                                                                  error:nil] autorelease];
    return note;

}

in the viewdidload

ViewDidLoad {

    self.Note = [self getNoteFromFilename:@"Note" andoftype:@"wav"];


}

calling it by this in IBAction :

[Note prepareToPlay];
[Note play];

NB: i have retaind all the button and the AVAudioPlayer

A: 

Use AVAudioPlayer instead. There you can easily loop using the numberOfLoops property.

zoul
hello if i want use the AVAudioPLayer i will lose the volume control because all the sounds load with audiotoolbox will be fix no increase and decrease volume for it
Bobj-C
There’s a `[AVAudioPlayer volume]` property, does that solve your problem?
zoul
no problem with AVAudioPlayer but the problem with the sounds that called from the function that contains AudioServicesPlaySystemSound
Bobj-C
Aha, got it. How about playing all sounds using `AVAudioPlayer`?
zoul
i notice that if all sounds using AVAudioplayer the interact with user will be slow ie. the AudioToolbox much better than AVfoundaion specially when u play two sound with the same time
Bobj-C
That sounds unlikely. Do you use uncompressed audio?
zoul
no but i used .wav but every sounds 1 second and about max 200 KB
Bobj-C
Then the sounds should not slow down the user interaction, unless you’re doing something wrong (which we cannot say without the code).
zoul
Please see the edited question
Bobj-C
If you’re having problems with latency, you might want to check out [Finch](http://github.com/zoul/Finch).
zoul