hi all,
i’m using SDL and SD_mixer to present very short audio probes (50msec) to a test subject in a psychology experiment. However, it is rather important that we can present these probes as accurate as possible, time-wise. So when I call Mix_PlayChannel() at a certain time, I really really need to be sure that that sound is coming out of the headphones as fast as possible (preferably the same millisecond although I realize that that is a bit much to expect) but definitely with a CONSTANT delay.
i’ve been doing some tests with a sound trigger setup (which reads out the audio and records the exact time sound happens above a certain threshold) and it looks like as if the audio sometimes comes 50msec too late, but sometimes up to 140msec too late.
is that possible ? has anyone any experience with this ? Are there parameters I can play with to improve timing accuracy ?
the code I use to initialize is like this (code for return value checking omitted for clarity)
Mix_OpenAudio(22050, AUDIO_S16SYS, 2, SDL_AUDIO_BUFFER_SIZE); Mix_AllocateChannels(16); memset(m_chunk_buffer, 0, sizeof(m_chunk_buffer)); m_chunk_movie = Mix_QuickLoad_RAW((Uint8 *)m_chunk_buffer, SDL_AUDIO_BUFFER_SIZE); Mix_PlayChannel(0, m_chunk_movie, -1); Mix_RegisterEffect(0, mixer_effect_ffmpeg_cb, NULL, &m_video); SDL_PauseAudio(0);
and playing audio is simply a call to
Mix_PlayChannel(0, m_wave, 0);
where m_wave is a Mix_chunk loaded way before with
m_wave = Mix_LoadWAV(ascii.c_str());
any advice would be much appreciated !