How do i play multiple audio files simultaneously using AudioQueue?

I've basically gutted what I don't need from the "Speakhere" sample app and I'm left with something I can use to play audio files. I converted wav files to aiff and then renamed the aiff to caf (Just in case this matters). I even tried shortening the files to 10 seconds long, but no difference. I am able to play files singly, but am unable to play more than one file at the same time. When I try to play multiple files, the first one plays correctly but the second will play a horrible long beeping sound. Sounds almost like a buzzer and sometimes will sound like a high pitched beep. My code has all the audio components like the speakhere app (AudioQueueObject, AudioPlayer, AudioViewController). I've changed the AudioViewController to be just my "AudioController" class where when I initialize, I pass in the name of the file and it replaces this line of code:
CFStringRef fileString = (CFStringRef) [NSString stringWithFormat: @"%@/Recording.caf", self.recordingDirectory];
with this:
CFStringRef fileString = (CFStringRef) [NSString stringWithFormat: fileName, self.recordingDirectory];
Any suggestions? I've been yanking my hair out trying to figure this out and I simply can't. I'm about ready to pull an "Office Space" but instead of beating up a printer, I'm going to destroy my macbook.
*NOTE: I have only tried this in the simulator, but I'm assuming it will do this on the real thing so I haven't bothered to try.

Unless I'm mistaken, you need one AudioQueue object for each audio file you want to play. In one of my apps, I basically copied the code provided in the [AudioQueue programming guide|http://developer.apple.com/iphone/library/documentation/MusicAudio/Concep tual/AudioQueueProgrammingGuide/AQPlayback/chapter4_section_1.html#//appleref/doc/uid/TP40005343-CH3-SW1] and made a wrapper object for playback. So then you can do something like this:
MyAudioManager *manager1 = [[MyAudioManager alloc] initWithFile:@"file1.caf"];
[manager1 play];
MyAudioManager *manager2 = [[MyAudioManager alloc] initWithFile:@"file2.caf"];
[manager2 play];
// etc...
If you want to play short files (~10s or less), you can use the simpler AudioServices functions along with SystemSoundID's. It will work fine if you have playback from AudioQueue and AudioServices at the same time.

Similar Messages

  • Is it possible to play two audio files simultaneously.

    Hi,
    Is it possible to play two audio files simultaneously.
    I modified the 'SpeakHere' to play two audio files simultaneously, it worked perfectly on simulator but get hanged on iphone.
    To this I implemented NSTimer, which regularly checks for both player instance every second.As soon as any player gets stopped Timer task stops the second one forcefully and again starts both.
    thanks.

    Hi Jay
    Do you have the eLearning Suite? If so, you have Adobe Presenter available to you. If you don't, you should be able to download the Presenter installation file and evaluate it.
    Presenter is an add in for PowerPoint. The neat thing about it is that it provides for a Table of Contents type of functionality as you see is configured in Captivate. But the twist with that is you are able to do something you cannot do in Captivate. You are able to insert videos inside the TOC area!
    Just musing out loud... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • How do I play an audio file as a soundtrack for entire keynot

    How do I play an audio file as a soundtrack for entire keynote?

    https://developer.apple.com/mac/library/samplecode/PlayFile/Introduction/Intro.h tml
    Docs are your friend....mac os has it's own just like iPhone.

  • How to play multiple audio tracks simultaneously?

    Hi there,
    I am having problem with playing multiple audio tracks. I want to play 2 or more audio tracks at exact time (without delay) - is it possible? how can it be done?

    So, essentially, you're trying to take a recording of say, a singer and a guitar player, and end up with the singer in one file and the guitar in the other. Got it.
    [http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/Merge.html]
    That sample will merge multiple input files into a single file. Because you want to play the files together rather than save them, just take the sample and strip out all of the DataSink stuff, and add the following line right after the Processor "outputProcessor" is realized...
    outputProcessor.setContentDescriptor(null);
    So, it'll make the following revision to the code:
         // Create the output processor
         ProcessorModel outputPM = new MyPMOut(merger);
         try {
             outputProcessor = Manager.createRealizedProcessor(outputPM);
                        outputProcessor.setContentDescriptor(null);
             outputDataSource = outputProcessor.getDataOutput();
         } catch (Exception exc) {
             System.err.println("Failed to create output processor: " + exc);
             System.exit(-1);
         }That'll make the outputProcessor play the file, as if it was a Player object. You won't have any visual controls, but if you need visual controls, then don't do that, and just create a Player object to play the outputDataSource.

  • HT3775 How can I play an audio file in 3GP format?

    Hi,
    I have an audio file in 3GP format, which was recorded in a mobile phone and transferred to me.
    I am not able to play it using QuickTim and VLC Player.
    Can someone please help me how to play this?
    Regards
    Sharath Arun

    Is that file played in a tab in the current window or in a separate pop-up window?
    Are you allowing pop-up to modify the window size (dom.disable_window_move_resize = false)?
    *http://kb.mozillazine.org/JavaScript#Advanced_JavaScript_settings
    You can try set the Boolean pref <b>media.windows-media-foundation.enabled</b> to <i>false</i> on the <b>about:config</b> page to disable the built-in HTML5 media player.
    *http://kb.mozillazine.org/about:config

  • How do i add multiple Audio files into an Interactive PDF

    I am making a band EPK (Electronic Press Kit) and one one page there are 3 songs the band wants to put in a play and stop feature so the client can hear the music. I have not been able to get the audio files to export in the document in either MP3 or WAV format. Please help.

    Not really,
    but I am happy to report that I found the solution:
    AVOID Logic's "Audio>Import Audio File..." window, if you need to import 54 tracks.
    Make sure you have enough Audio Tracks available in Logic's arrange window.
    Select Audio Track 1 in Logic.
    Highlight (select all) tracks) from your source DVD or disk.
    Drag all of them to Audio track 1 in Logic and the position you determined in transport.
    Beautiful.
    Why don't we get this within the Logic application?
    Thanks everyone.

  • How can I play an audio file without the whole screen going black?

    When I play the mp3 file on IE it opens in a small screen so I can still see the web page.
    On Firefox the whole screen is taken up with the sound file being played.
    Can this be changed?

    Is that file played in a tab in the current window or in a separate pop-up window?
    Are you allowing pop-up to modify the window size (dom.disable_window_move_resize = false)?
    *http://kb.mozillazine.org/JavaScript#Advanced_JavaScript_settings
    You can try set the Boolean pref <b>media.windows-media-foundation.enabled</b> to <i>false</i> on the <b>about:config</b> page to disable the built-in HTML5 media player.
    *http://kb.mozillazine.org/about:config

  • How do I play an audio file in Xcode for Mac OS X?

    I have been looking and looking, and I still can't find out how I can play a sound in Xcode. I have done it for the iPhone, but I'm trying to do it for Mac OS X. I am a beginner and so I am going to need some explaining as to what is going on. I just need to play a short sound (max of 10 seconds) when a timer goes off. Any help is very greatly appreciated (I have been trying to get this to work for WEEKS)! Thanks in advance.

    https://developer.apple.com/mac/library/samplecode/PlayFile/Introduction/Intro.h tml
    Docs are your friend....mac os has it's own just like iPhone.

  • How do I play an audio file on shutdown?

    I have a .aif file that plays the "auto shutdown sequence in progress" parody from Star Trek.
    In classic, I put it into a shutdown folder and it played on shut down. It won't work on Tiger, no such folder.
    I don't know anything about scripting and if I did, I don't know where to put the finished script so it activates on shutdown.
    I attempted:
    tell application "Finder"
    activate
    select window of desktop
    select window of desktop
    open document file "autoshutdown.aif" of folder "Desktop" of folder "ttruscott" of folder "Users" of startup disk
    select window of desktop
    end tell
    which on run does open QuickTime but doesn't start to play...
    And if it did run, where do I store it?

    You're taking a too-literal approach with your script.
    The Finder doesn't need to be involved in this at all. All you're doing with your script is opening some windows (not needed) and telling the Finder to open a document. As you've found there's nothing that actually tells anything to play the sound (for all the Finder knows you could be telling it to open a Word document, or a JPEG image, or any number of other files.
    An alternative approach is to target the application directly. Since you're opening the sound file in QuickTime Player you'd be better off with something like:
    tell application "QuickTime Player"
    play (alias "HD:Users:ttruscott:Desktop:autoshutdown.aif")
    end tell
    The issue you may have is in launching this. The OS will balk at launching a new application (e.g. QuickTime Player) once it's been told to shut down. This may mean that you need to have QuickTime Player running before you initiate the shutdown, which is going to be harder to manage.

  • How do you start 2+ audio files playing at the same time?

    I am trying to play 2 audio files at the same time, but I cannot figure out how to start them playing at the same time without latency issues.
    If someone can please explain the process for doing this using Audio Queue Services, I will forever be in your debt.
    This is for iPhone, but I was getting no love in those forums on this issue.

    Thanks for your reply. Apple's iPhone Application Programming Guide states the Following:
    *Playing Multiple Sounds Simultaneously*
    To play multiple sounds simultaneously, create one playback audio queue object for each sound. For each audio queue, schedule the first buffer of audio to start at the same time using the AudioQueueEnqueueBufferWithParameters function.
    This leads me to believe that it is possible. I have just not been able to get them to play precisely the same time, there is always delay.

  • HT201066 How can I split a long recording audio file into multiple audio files?

    Hi,
    How can I split a long recording audio file into multiple audio files?
    With Windows I was using Nero software, which is not available for Mac. Is there any similar app for free for Mac?
    Thanks!

    Hello ingiorgio
    You can import the track into GarageBand and then split the tracks there. Once that it is done you can highlight the ruler section and then share the song to iTunes to get them separated out. 
    GarageBand - Split regions in the Tracks area
    http://help.apple.com/garageband/mac/10.0/#gbnd76fcce04
    GarageBand - Share songs to iTunes
    http://help.apple.com/garageband/mac/10.0/#gbndfb96a96f
    Regards,
    -Norm G.

  • How do you consolidate audio files in Premiere? (Make multiple audio files on a track one file)

    How do you consolidate audio files in Premiere? (Make multiple audio files on a track one file). Also, my client is having a hard time making an omf that Pro Tools can read. The files can not be found by Pro Tools. How do you make an omf that Pro Tools can read?

    Multichannel export;
    http://strypesinpost.com/2012/11/exporting-multichannel-quicktimes-in-premiere-pro/
    When you export the OMF, select Encapulate Files in the Settings window

  • How to play an audio file from the begin.........

    Hello to everybody,
    I am working on a application that is supposed to manage audio file. At the moment I 'm using the SourceDataLine instead of the Clip. But I've got a problem. When the user pushes the Stop button I want that if he pushes Play again the track starts from the begin. I've used the drain() and flush() method but it doesn't work because the track resumes from the point when has been interrupted. Here part of the code:
    @Override
    public void run()
    try
    if(dataline!=null)
    dataline.open(audio_format);
    dataline.start();
    int i=0;
    while((i=audio_input_stream.read(buffer, 0, buffer.length))!=-1 && flag==false)
    if(i>0)
    dataline.write(buffer, 0, i);
    dataline.drain();
    dataline.stop();
    dataline.flush();
    dataline=null;
    dataline.close();
    And also I'd like to know how to navigate through the audio file by a slider or something like that, so how much time is passed.
    Thank you in advance.
    Maurizio Di Vitto

    mauriziodvt wrote:
    I've tried to use it but I found out that if I use quite large wav files an exception is thrown, Aha! I expected as much. That is why I developed BigClip.
    ..so I thought to change to SourceDataLine even if Clip has the right stuff to manage my audio files. So what do you suggest? Is there a way to avoid such problem? I mean, how can I be sure that I'm able to use every wav files? Not every WAV file can be opened using SourceDataLine, but if SDL can open it, so can BigClip.

  • Multiple Audio files on one slide

    Hello,
    I want to have multiple audio files in a table on a single slide.
    Also, these audio files should play when I click on that particular file (which will be placed in a cell in the table)
    How do I do this?
    I see an option with "Play sound on click" but it plays when I click anywhere.
    This doesn't give me the ability to place multiple files and thus be able to play them as needed.
    Thanks.

    nope, Keynote doesn't have "triggers" though I figure this has to be on Apple's radar as it's been brought up every time a new version comes out.
    I suppose one work around would be to make a slide for each sound, and have the sound play when you go to that slide. Then make your table a series of buttons that go to each "sound slide" (you can make link buttons, just not triggers). It would give you the effect of clicking to play the sound, it's just that instead, Keynote would be jumping to a slide and playing a sound. All the slides would LOOK the same, and you wouldn't use transitions between them. The effect would get you what you want, it just takes longer to build.

  • How can I play multiple movies on quicktime like I can on windows medplayer

    How can I play multiple movies on quicktime. When i click on open file it will only let me choose one movie to play.For example When ever I used windows media player I could drag my mouse over numerous files and it would play them one after another like in a list format. Can anyone help with this?
    Thank you

    Hi Brennan,
    Only HDMI is going to support audio & video on the single cable. Which MacBook Air do you have? Here's a great article regarding this - http://support.apple.com/kb/HT4241. Also keep in mind that only the current generation of MacBook Airs support this. The previous generation, also with MiniDisplay Port would support HDMI but you'd need to run a separate line from the headphone port over AUX for audio.
    The first and second generation models, which have micro-DVI, do not support audio. Regarding the RCA cables, Apple offers adapters that allow you to go to VGA and that would probably be your best bet. I do not believe there's a MiniDisplay Port to RCA solution out there, you'd need to do multiple adapters and that's always a questionable performance solution.

Maybe you are looking for