Tscope5
|
Definitions of audio functions. More...
Go to the source code of this file.
Functions | |
Audio parameters | |
The parameters of the audio output device (sound card) can be set using the functions below. The audio gain (amplification factor) can be changed at any time. All other functions functions in this group have to be called before the audio subsystem is loaded (i.e. before the first sample is loaded and played) and their settings remain unchanged until the end of the program. The parameter functions also define the settings for samples that are created with ts5_alloc_sample(). | |
unsigned int | ts5_set_audio_frequency (unsigned int frequency) |
Set the requested sample rate for the audio system. | |
unsigned int | ts5_get_audio_frequency () |
Get the sample rate of the audio system. | |
unsigned int | ts5_set_audio_channels (unsigned int channels) |
Set the requested number of channels for the audio system. | |
unsigned int | ts5_get_audio_channels () |
Get the number of channels of the audio system. | |
int | ts5_set_audio_depth (int depth) |
Set the sample depth for the audio system. | |
int | ts5_get_audio_depth () |
Get the sample depth of the audio system. | |
double | ts5_set_audio_gain (double gain) |
Set the gain (amplification factor) of the audio system. | |
double | ts5_get_audio_gain () |
Get the gain of the audio system. | |
Loading samples | |
Samples can either be read from a file, or empty samples can be generated. Empty samples can be used for recording vocal responses (tbd). Most samples (samples that contain less than 2^24 sample values) can be read completely into memory using ts5_read_sample(). Longer samples should be loaded with ts5_read_long_sample(). These will be streamed (i.e. they will be divided in parts that are read when necessary). | |
TS5_SAMPLE * | ts5_alloc_sample (double length) |
Create an empty sample. | |
TS5_SAMPLE * | ts5_read_sample (const char *file) |
Open a sample from a file. | |
TS5_SAMPLE * | ts5_read_long_sample (const char *file) |
Open a long sample from a file. | |
void | ts5_write_sample (const char *file, TS5_SAMPLE *sample) |
Write a sample. | |
void | ts5_free_sample (TS5_SAMPLE *sample) |
Free the memory used by a sample. | |
Playing samples | |
Audio samples can be played using the functions below. Playing a sample will not block the flow of your program. Once a sample starts playing the function call following ts5_play_sample() will be executed immediately. | |
void | ts5_play_sample (TS5_SAMPLE *sample) |
Start playing a sample. | |
void | ts5_pause_sample (TS5_SAMPLE *sample) |
Pause playing a sample. | |
void | ts5_stop_sample (TS5_SAMPLE *sample) |
Stop playing a sample. | |
Sample parameters | |
For each sample the parameters can be queried/set using the functions below:
| |
int | ts5_get_sample_status (TS5_SAMPLE *sample) |
Query whether a sample is playing. | |
unsigned int | ts5_get_sample_frequency (TS5_SAMPLE *sample) |
Get the sample rate of a sample. | |
unsigned int | ts5_get_sample_channels (TS5_SAMPLE *sample) |
Get the number of channels of a sample. | |
int | ts5_get_sample_depth (TS5_SAMPLE *sample) |
Get the sample depth of a sample. | |
unsigned int | ts5_get_sample_length (TS5_SAMPLE *sample) |
Get the length of a sample. | |
unsigned int | ts5_set_sample_position (TS5_SAMPLE *sample, unsigned int position) |
Set the playback position of a sample. | |
unsigned int | ts5_get_sample_position (TS5_SAMPLE *sample) |
Get the playback position of a sample. | |
double | ts5_set_sample_speed (TS5_SAMPLE *sample, double speed) |
Set the playback speed of a sample. | |
double | ts5_get_sample_speed (TS5_SAMPLE *sample) |
Get the playback speed of a sample. | |
double | ts5_set_sample_gain (TS5_SAMPLE *sample, double gain) |
Set the playback gain of a sample. | |
double | ts5_get_sample_gain (TS5_SAMPLE *sample) |
Get the playback gain of a sample. | |
double | ts5_set_sample_pan (TS5_SAMPLE *sample, double pan) |
Set the playback pan of a sample. | |
double | ts5_get_sample_pan (TS5_SAMPLE *sample) |
Get the playback pan of a sample. | |
int | ts5_set_sample_playmode (TS5_SAMPLE *sample, int playmode) |
Set the playmode of a sample. | |
int | ts5_get_sample_playmode (TS5_SAMPLE *sample) |
Get the playmode of a sample. |
Definitions of audio functions.
Definition in file audio.c.
unsigned int ts5_set_audio_frequency | ( | unsigned int | frequency | ) |
Set the requested sample rate for the audio system.
frequency | The sample rate. Can be TS5_11025, TS5_22050 or TS5_44100. |
This function has to be called before the (automatic) installation of the audio system.
Once the audio system is installed, the sample rate of the system cannot be changed.
This is only a request, the audio driver can choose non-matching values. Query the audio system after installation with ts5_get_audio_frequency() for the actual sample rate.
This function also influences the sample rate of samples made by ts5_alloc_sample().
The default frequency is TS5_44100.
unsigned int ts5_get_audio_frequency | ( | ) |
unsigned int ts5_set_audio_channels | ( | unsigned int | channels | ) |
Set the requested number of channels for the audio system.
channels | The number of channels. Can be TS5_MONO or TS5_STEREO. |
This function has to be called before the (automatic) installation of the audio system.
Once the audio system is installed, the number of channels of the system cannot be changed.
This is only a request, the audio driver can choose non-matching values. Query the audio system after installation with ts5_get_audio_channels() for the actual number of channels.
This function also influences the number of channels of samples made by ts5_alloc_sample().
The default number of channels is TS5_STEREO.
unsigned int ts5_get_audio_channels | ( | ) |
int ts5_set_audio_depth | ( | int | depth | ) |
Set the sample depth for the audio system.
depth | The sample depth. Can be TS5_INTEGER or TS5_FLOAT. |
This function has to be called before the (automatic) installation of the audio system.
Once the audio system is installed, the sample depth of the system cannot be changed.
This is only a request, the audio driver can choose non-matching values. Query the audio system after installation with ts5_get_audio_depth() for the actual sample depth.
This function also influences the sample depth of samples made by ts5_alloc_sample().
The default sample depth is TS5_FLOAT.
int ts5_get_audio_depth | ( | ) |
double ts5_set_audio_gain | ( | double | gain | ) |
double ts5_get_audio_gain | ( | ) |
TS5_SAMPLE* ts5_alloc_sample | ( | double | length | ) |
Create an empty sample.
length | Length of the sample in seconds. |
Sample frequency, channels and depth are set by ts5_set_audio_frequency(), ts5_set_audio_channels() and ts5_set_audio_depth()
TS5_SAMPLE* ts5_read_sample | ( | const char * | file | ) |
TS5_SAMPLE* ts5_read_long_sample | ( | const char * | file | ) |
void ts5_write_sample | ( | const char * | file, |
TS5_SAMPLE * | sample | ||
) |
void ts5_free_sample | ( | TS5_SAMPLE * | sample | ) |
void ts5_play_sample | ( | TS5_SAMPLE * | sample | ) |
void ts5_pause_sample | ( | TS5_SAMPLE * | sample | ) |
void ts5_stop_sample | ( | TS5_SAMPLE * | sample | ) |
int ts5_get_sample_status | ( | TS5_SAMPLE * | sample | ) |
unsigned int ts5_get_sample_frequency | ( | TS5_SAMPLE * | sample | ) |
unsigned int ts5_get_sample_channels | ( | TS5_SAMPLE * | sample | ) |
int ts5_get_sample_depth | ( | TS5_SAMPLE * | sample | ) |
unsigned int ts5_get_sample_length | ( | TS5_SAMPLE * | sample | ) |
unsigned int ts5_set_sample_position | ( | TS5_SAMPLE * | sample, |
unsigned int | position | ||
) |
unsigned int ts5_get_sample_position | ( | TS5_SAMPLE * | sample | ) |
double ts5_set_sample_speed | ( | TS5_SAMPLE * | sample, |
double | speed | ||
) |
double ts5_get_sample_speed | ( | TS5_SAMPLE * | sample | ) |
double ts5_set_sample_gain | ( | TS5_SAMPLE * | sample, |
double | gain | ||
) |
double ts5_get_sample_gain | ( | TS5_SAMPLE * | sample | ) |
double ts5_set_sample_pan | ( | TS5_SAMPLE * | sample, |
double | pan | ||
) |
double ts5_get_sample_pan | ( | TS5_SAMPLE * | sample | ) |
int ts5_set_sample_playmode | ( | TS5_SAMPLE * | sample, |
int | playmode | ||
) |