Recording routines



int install_sound_input(int digi, int midi);
Initialises the sound recorder module, returning zero on success. You must install the normal sound playback system before calling this routine. The two card parameters should use the same constants as install_sound(), including DIGI_NONE and MIDI_NONE to disable parts of the module, or DIGI_AUTODETECT and MIDI_AUTODETECT to guess the hardware.

void remove_sound_input();
Cleans up after you are finished with the sound input routines. You don't normally need to call this, because remove_sound() and/or allegro_exit() will do it for you.

int get_sound_input_cap_bits();
Checks which sample formats are supported by the current audio input driver, returning one of the bitfield values:

0 = audio input not supported
8 = eight bit audio input is supported
16 = sixteen bit audio input is supported
24 = both eight and sixteen bit audio input are supported

int get_sound_input_cap_stereo();
Checks whether the current audio input driver is capable of stereo recording.

int get_sound_input_cap_rate(int bits, int stereo);
Returns the maximum possible sample frequency for recording in the specified format, or zero if these settings are not supported.

int get_sound_input_cap_parm(int rate, int bits, int stereo);
Checks whether the specified recording frequency, number of bits, and mono/stereo mode are supported by the current audio driver, returning one of the values:

0 = it is impossible to record in this format
1 = recording is possible, but audio output will be suspended
2 = recording is possible at the same time as playing other sounds
-n = sampling rate not supported, but rate 'n' would work instead

int set_sound_input_source(int source);
Selects the audio input source, returning zero on success or -1 if the hardware does not provide an input select register. The parameter should be one of the values:

SOUND_INPUT_MIC
SOUND_INPUT_LINE
SOUND_INPUT_CD

int start_sound_input(int rate, int bits, int stereo);
Starts recording in the specified format, suspending audio playback as necessary (this will always happen with the current drivers). Returns the buffer size in bytes if successful, or zero on error.

void stop_sound_input();
Stops audio recording, switching the card back into the normal playback mode.

int read_sound_input(void *buffer);
Retrieves the most recently recorded audio buffer into the specified location, returning non-zero if a buffer has been copied or zero if no new data is yet available. The buffer size can be obtained by checking the return value from start_sound_input(). You must be sure to call this function at regular intervals during the recording (typically around 100 times a second), or some data will be lost. If you are unable to do this often enough from the mainline code, use the digi_recorder() callback to store the waveform into a larger buffer of your own. Note: many cards produce a click or popping sound when switching between record and playback modes, so it is often a good idea to discard the first buffer after you start a recording. The waveform is always stored in unsigned format, with stereo data consisting of alternate left/right samples.

extern void (*digi_recorder)();
If set, this function is called by the input driver whenever a new sample buffer becomes available, at which point you can use read_sound_input() to copy the data into a more permenent location. This routine runs in an interrupt context, so it must execute very quickly, the code and all memory that it touches must be locked, and you cannot call any operating system routines or access disk files.

extern void (*midi_recorder)(unsigned char data);
If set, this function is called by the MIDI input driver whenever a new byte of MIDI data becomes available. It runs in an interrupt context, so it must execute very quickly and all the code/data must be locked.




Back to Contents