Audio problems - losing audio

I started using SDL last week for audio playback in a plugin for Maya…

I’ve run through the audio examples, and I can usually get sound
playing fine… But I do keep losing it…

When the plugin is initialized, SDL_Init(SDL_INIT_AUDIO); is called,
and when it is uninitialized, SDL_Quit(); is called…

My problem seems to lie when I need to re-open the audio (with a
different sample rate/channels/etc) - at the moment, I’m calling
SDL_CloseAudio(); (if it’s already been opened) followed by finding
the new details, and then calling SDL_OpenAudio(sndSpec, NULL); again.

The first audio file I open works fine - before SDL_CloseAudio() is
ever called. However, after I close and re-open, it’s really stuttery,
followed by going silent with the occasional slight ‘tick’.

Is there a better way of changing the sample rate? Am I missing
something obvious?

Cheers–
Hugh Macdonald

I started using SDL last week for audio playback in a plugin for Maya…

I’ve run through the audio examples, and I can usually get sound
playing fine… But I do keep losing it…

When the plugin is initialized, SDL_Init(SDL_INIT_AUDIO); is called,
and when it is uninitialized, SDL_Quit(); is called…

My problem seems to lie when I need to re-open the audio (with a
different sample rate/channels/etc) - at the moment, I’m calling
SDL_CloseAudio(); (if it’s already been opened) followed by finding
the new details, and then calling SDL_OpenAudio(sndSpec, NULL); again.

The first audio file I open works fine - before SDL_CloseAudio() is
ever called. However, after I close and re-open, it’s really stuttery,
followed by going silent with the occasional slight ‘tick’.

The value for samples in the audiospec needs to be appropriate for the
audio rate you’re setting. These are the values that I’ve found to be
fairly good for stereo data:

11Khz: 512
22Khz: 1024
44Khz: 2048

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Cheers - I’ll have a go with those…

Best to go with 2048 for 48kHz too?On Mon, 15 Nov 2004 13:38:29 -0800, Sam Lantinga wrote:

I started using SDL last week for audio playback in a plugin for Maya…

I’ve run through the audio examples, and I can usually get sound
playing fine… But I do keep losing it…

When the plugin is initialized, SDL_Init(SDL_INIT_AUDIO); is called,
and when it is uninitialized, SDL_Quit(); is called…

My problem seems to lie when I need to re-open the audio (with a
different sample rate/channels/etc) - at the moment, I’m calling
SDL_CloseAudio(); (if it’s already been opened) followed by finding
the new details, and then calling SDL_OpenAudio(sndSpec, NULL); again.

The first audio file I open works fine - before SDL_CloseAudio() is
ever called. However, after I close and re-open, it’s really stuttery,
followed by going silent with the occasional slight ‘tick’.

The value for samples in the audiospec needs to be appropriate for the
audio rate you’re setting. These are the values that I’ve found to be
fairly good for stereo data:

11Khz: 512
22Khz: 1024
44Khz: 2048


Hugh Macdonald