Top |
struct audio_signal * | audio_signal_init () |
void | audio_signal_fini () |
int | audio_signal_add_frequency () |
void | audio_signal_synthesize () |
void | audio_signal_reset () |
void | audio_signal_fill () |
bool | audio_signal_detect () |
size_t | audio_extract_channel_s32_le () |
void | audio_convert_to () |
int | audio_create_wav_file_s32_le () |
This library contains helpers for audio-related tests. More specifically, it allows generating additions of sine signals as well as detecting them.
struct audio_signal * audio_signal_init (int channels
,int sampling_rate
);
Allocate and initialize an audio signal structure with the given parameters.
int audio_signal_add_frequency (struct audio_signal *signal
,int frequency
,int channel
);
Add a frequency to the signal.
void
audio_signal_synthesize (struct audio_signal *signal
);
Synthesize the data tables for the audio signal, that can later be used to fill audio buffers. The resources allocated by this function must be freed with a call to audio_signal_clean when the signal is no longer used.
void
audio_signal_reset (struct audio_signal *signal
);
Free the resources allocated by audio_signal_synthesize and remove the previously-added frequencies.
void audio_signal_fill (struct audio_signal *signal
,double *buffer
,size_t samples
);
Fill the requested number of samples to the target buffer with the audio signal data (in interleaved double format), at the requested sampling rate and number of channels.
Each sample is normalized (ie. between 0 and 1).
bool audio_signal_detect (struct audio_signal *signal
,int sampling_rate
,int channel
,const double *samples
,size_t samples_len
);
size_t audio_extract_channel_s32_le (double *dst
,size_t dst_cap
,int32_t *src
,size_t src_len
,int n_channels
,int channel
);
void audio_convert_to (void *dst
,double *src
,size_t len
,snd_pcm_format_t format
);
int audio_create_wav_file_s32_le (const char *qualifier
,uint32_t sample_rate
,uint16_t channels
,char **path
);
Creates a new WAV file.
After calling this function, the caller is expected to write S32_LE PCM data to the returned file descriptor.
See http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html for a WAV file format specification.