3. Basic notions - sample
Each square ( <fi
> i=1..12
) represents a sample
4. Basic notions - sample rate
Sample rate = number of samples in a second
greater T -> smaller sample rate -> lower quality
smaller T -> greater sample rate -> higher quality
5. Basic notions - audio bit depth
Bit depth = number of bits in each sample
Common bit depths
●8 bit (signed/unsigned)
●16 bit (signed) - CD quality
●32 bit integer (signed)
●32 bit float (values ranging from -1 to 1)
Greater bit depth -> better sound quality -> more space needed
6. Example - portaudio (init/terminate)
Tipical portaudio usage:
Pa_Initialize();
...
DoMyPortaudioSoundOperations();
...
Pa_Terminate();
hg clone http://minvg.hg.sourceforge.net:8000/hgroot/minvg; cd minvg/trunk/PortaudioSoundPlayer
7. Example - portaudio init/close stream
In portaudio, the stream is the primitive for sound
processing
Pa_Open(Default)Stream(
....
);
Pa_CloseStream(createdStream);
hg clone http://minvg.hg.sourceforge.net:8000/hgroot/minvg; cd minvg/trunk/PortaudioSoundPlayer
8. Example - portaudio stream parameters
The stream creation function receives the following
parameters:
●number of Input/Output channels
●sample rate, bit depth
●processing callback and callback buffer size
●user data that can be passed to the callback
hg clone http://minvg.hg.sourceforge.net:8000/hgroot/minvg; cd minvg/trunk/PortaudioSoundPlayer
9. Example - portaudio callback
The callback is (asynchronously!) called periodically when:
●new input data arrived (when recording)
●new output data requested
int Callback(const void *input, void *output, ... );
Return values:
●paComplete - to end playing/recording after this call
●paContinue - to continue playing/recording
●paAbort - to end playing/recording ASAP
hg clone http://minvg.hg.sourceforge.net:8000/hgroot/minvg; cd minvg/trunk/PortaudioSoundPlayer
10. Other audio libraries
●RtAudio
○similar to portaudio (callback mechanism)
○object oriented design (C++)
●libsdl (audio component)
○similar to portaudio (callback mechanism)
○game development oriented
●OpenAL
○API similar to OpenGL
○higher level interface (compared to portaudio)
○game development oriented