Tscope5
audio03.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// audio03.c
// - Record an audio sample.
// - Save it to a file.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
#include <stdio.h>
int main()
{
// install a display
// define the escape key
ts5_define_keyboard_button(TS5_KEY_ESCAPE);
// set some audio parameters
// default is CD quality but that's
// probably overkill
// start the audio recorder
// allocate an audio sample
TS5_SAMPLE *test = ts5_alloc_sample(10.0);
// fixation point
ts5_printf(0.0, 0.0, "+");
ts5_wait(0.5);
// blank
ts5_wait(0.5);
// stimulus
ts5_printf(0.0, 0.0, "tscope is de max");
// display the stimulus, start timing and start recording
// record until the buffer is full or
// until the user presses escape
while (!ts5_get_sample_fragments(test) && !ts5_check_response(NULL, NULL)) {
// here you can do whatever you want
// the recording buffer is around 10 seconds
};
// save the recording
ts5_write_sample("test.wav", test);
// stop the audio recorder
return 0;
}