How to prepend silence before audio file playback
How to prepend silence before audio file playback
- Subject: How to prepend silence before audio file playback
- From: Howard Soroka <email@hidden>
- Date: Wed, 27 Apr 2016 14:03:45 -0700
I want to replace my previous question with the following:
I am playing back audio files from disk successfully, with an AUGraph that includes the file player, a sampler instrument AU, a mixer, speed and pitch controls, and the default output unit. It all works very well.
Now, I need to PREPEND a period of silence in front of the beginning of the audio file. In other words, when playback of the audio file is needed (from its start), a period of silence will play first, followed immediately by the audio file. I know I can delay the start of the file playback to get the same audible effect, but I want to actually play the silence so that I can monitor a continuous stream of silent samples played, in order to synchronize external events with sample accuracy.
I want to generate a single buffer of silence, and play it once (it won't need to be more than a few seconds, typically, and can be mono), before the file playback begins. I can of course match the sample rate of the silence to that of the audio file, since I'll generate the silence programmatically.
I'm not aware of any mechanism in Core Audio that would let me "sequence" the silence buffer followed by the audio file, so playback of the two would just happen in order seamlessly. If such a thing exists, please tell me!
So what I think I want is the simplest tactic for playing a single buffer, once, into an AU (mixer input, output unit, whatever). There are examples of playing a FILE, but I don't need a file for silence, I just want to generate a buffer of zeros, and play that. What's the simplest way to do that? Conceptually, I don't need a callback, because there's nothing to do after the silence buffer plays - the audio file will simply start playing, having been delayed (scheduled) by the duration of the silent buffer.
Playing a simple buffer without an audio file should be easy, but I'm not finding any sample code. Advice is solicited.
Thank you!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden