Discussion:
SDL Audio questions
(too old to reply)
Neil Bradley
2002-07-27 22:08:01 UTC
Permalink
I'm currently writing a sound engine that works on top of SDL - one that
mixes many channels, does mute groups, delays, panning, effects, etc.. and
allows "plug-ins" for each of the channels. I'm mixing this down to one
stereo stream that I'm handing to SDL's callback function.

My question is this - All of the examples pass an SDL_AudioSpec structure
to the SDL_OpenAudio stream as a request. Does this mean I need to keep
this structure around, or is the data pulled from this structure and
placed somewhere else? I have the SDL_AudioSpec structure declared as an
autovariable and don't want to make SDL take a dump.

That leads to my second question. Rather than having the SDL routines deal
with the different format changes, I'm dealing with the conversion of the
various sample types in my own code since it's more efficient to do that
way. I'd like to pass information in to the callback (userdata) that
indicates the sample type. However, with the current API, I need to know
what that is before I do an SDL_OpenAudio, and it looks like the only way
I can set userdata to anything is by doing an SDL_OpenAudio. Is there any
way to change the user data callback after SDL_OpenAudio has been called?

I'm also interested in updating some of the documentation as I find
issues/omissions. Who is the keeper of the docs and what is the process
for submitting modifications?

I noticed the sample rate converter in SDL_ConvertAudio() won't convert
sample rates of odd values. For example, if I have a 16Khz sample rate
wave file and I need to convert it to 44.1khz, the frequency comes out
wrong (not sure what it is, but it's definitley wrong). Plus, there's a
good amount of noise/grainyness introduced.

Is there any interest in me submitting a sample rate converter that has
antialiasing? What is the process for submitting code?

Thanks!

-->Neil

-------------------------------------------------------------------------------
Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 "It tastes like it came off the back porch." - Me
Ryan C. Gordon
2002-07-29 02:16:35 UTC
Permalink
Post by Neil Bradley
My question is this - All of the examples pass an SDL_AudioSpec structure
to the SDL_OpenAudio stream as a request. Does this mean I need to keep
this structure around, or is the data pulled from this structure and
placed somewhere else? I have the SDL_AudioSpec structure declared as an
autovariable and don't want to make SDL take a dump.
SDL_OpenAudio() makes a copy of the structure; it's acceptable to pass it
a pointer to the stack.
Post by Neil Bradley
That leads to my second question. Rather than having the SDL routines deal
with the different format changes, I'm dealing with the conversion of the
various sample types in my own code since it's more efficient to do that
way. I'd like to pass information in to the callback (userdata) that
indicates the sample type. However, with the current API, I need to know
what that is before I do an SDL_OpenAudio, and it looks like the only way
I can set userdata to anything is by doing an SDL_OpenAudio. Is there any
way to change the user data callback after SDL_OpenAudio has been called?
Could you pass it a pointer to data that you update? The callback will get
the original pointer, but what it points to can be changed.
Post by Neil Bradley
I noticed the sample rate converter in SDL_ConvertAudio() won't convert
sample rates of odd values. For example, if I have a 16Khz sample rate
wave file and I need to convert it to 44.1khz, the frequency comes out
wrong (not sure what it is, but it's definitley wrong). Plus, there's a
good amount of noise/grainyness introduced.
The SDL sample rate converter only successfully converts between rates
that are powers of two (and even there, some would argue, not very well).

We have a more accurate converter in the works that is being developed in
the SDL_sound project (http://icculus.org/SDL_sound/)...the hope is that
after SDL_sound is finished being a good testbed for it, we can adapt it
to SDL for the 2.0 revision of the library. Might be worth your time to
look at.
Post by Neil Bradley
Is there any interest in me submitting a sample rate converter that has
antialiasing? What is the process for submitting code?
Generally, send patches to the list against the latest CVS. After we are
done making fun of your code (no, we don't really. Honest.), we can decide
if it's right for SDL. I tend to commit fixes, but leave it up to Sam to
decide on big changes. (However, I'm the dictator for SDL_sound. :) )

--ryan.
s***@froup.com
2002-07-29 02:38:18 UTC
Permalink
Post by Ryan C. Gordon
Generally, send patches to the list against the latest CVS. After we are
done making fun of your code (no, we don't really. Honest.), we can decide
if it's right for SDL. I tend to commit fixes, but leave it up to Sam to
decide on big changes. (However, I'm the dictator for SDL_sound. :) )
Aw, nobody ever applied my Mac OS X joystick bugfix. Well, cvs diff
says it's still unapplied. :(
--
___________ ____________________________
| Screwtape | Reply-To: munged on Usenet |________ ______ ____ __ _ _ _
|
| I'm sorry, but all questions must be in the form of a question.
|
Micah Dowty
2002-07-30 16:14:36 UTC
Permalink
Post by s***@froup.com
Post by Ryan C. Gordon
Generally, send patches to the list against the latest CVS. After we are
done making fun of your code (no, we don't really. Honest.), we can decide
if it's right for SDL. I tend to commit fixes, but leave it up to Sam to
decide on big changes. (However, I'm the dictator for SDL_sound. :) )
Aw, nobody ever applied my Mac OS X joystick bugfix. Well, cvs diff
says it's still unapplied. :(
Hmm.. While we're complaining, anybody thought about committing the PicoGUI patch I posted? :)
Post by s***@froup.com
--
___________ ____________________________
| Screwtape | Reply-To: munged on Usenet |________ ______ ____ __ _ _ _
|
| I'm sorry, but all questions must be in the form of a question.
|
_______________________________________________
SDL mailing list
http://www.libsdl.org/mailman/listinfo/sdl
--
Only you can prevent creeping featurism!
Ryan C. Gordon
2002-07-31 02:45:46 UTC
Permalink
Post by Micah Dowty
Post by s***@froup.com
Aw, nobody ever applied my Mac OS X joystick bugfix. Well, cvs diff
says it's still unapplied. :(
Hmm.. While we're complaining, anybody thought about committing the PicoGUI patch I posted? :)
Can you both resend the patches? I never saw them in the first
place...which is entirely my fault. (Sorry.)

--ryan.
Tim Allen
2002-07-31 03:20:42 UTC
Permalink
Post by Ryan C. Gordon
Post by Micah Dowty
Post by s***@froup.com
Aw, nobody ever applied my Mac OS X joystick bugfix. Well, cvs diff
says it's still unapplied. :(
Hmm.. While we're complaining, anybody thought about committing the
PicoGUI patch I posted? :)
Can you both resend the patches? I never saw them in the first
place...which is entirely my fault. (Sorry.)
Sam mailed me privately and applied my patch, so I'm OK.

Neil Bradley
2002-07-29 05:12:01 UTC
Permalink
Post by Ryan C. Gordon
Post by Neil Bradley
indicates the sample type. However, with the current API, I need to know
what that is before I do an SDL_OpenAudio, and it looks like the only way
I can set userdata to anything is by doing an SDL_OpenAudio. Is there any
way to change the user data callback after SDL_OpenAudio has been called?
Could you pass it a pointer to data that you update? The callback will get
the original pointer, but what it points to can be changed.
I'm not quite sure what you're suggesting. As you mentioned above, a copy
of the structure is made, so updating my SDL_AudioSpec structure locally
won't have any effect. Is there a way to change the user data area pointer
after a stream has been opened?
Post by Ryan C. Gordon
Post by Neil Bradley
wrong (not sure what it is, but it's definitley wrong). Plus, there's a
good amount of noise/grainyness introduced.
The SDL sample rate converter only successfully converts between rates
that are powers of two (and even there, some would argue, not very well).
We have a more accurate converter in the works that is being developed in
the SDL_sound project (http://icculus.org/SDL_sound/)...the hope is that
after SDL_sound is finished being a good testbed for it, we can adapt it
to SDL for the 2.0 revision of the library. Might be worth your time to
look at.
I took a look, but SDL_Sound looks like it's overkill for what I'm
needing/looking for. While very useful to others, it's not useful in my
case.

I guess my fundamental issue is that SDL_ConvertAudio doesn't work as
advertised. The documentation says it'll convert from one sample rate to
another, but it makes no mention of powers of two rate conversions nor
will it return an error if an "odd" conversion rate is chosen. So I see it
that the current implementation is "wrong" according to the documentation,
and either one of two things need to be done:

1) Modify the SDL_Convert routine so it'll correctly resample audio at odd
rates

2) Modify the documentation to stipulate that only powers of 2 conversions
will be performed, and modify the code to return an error if an "odd"
sample rate is provided

And I'm willing to do either for the good of the project. While the
SDL_sound stuff is a solution, it seems like overkill to have to go to yet
another library when the default API would be sufficient if #1 or #2 above
were met.
Post by Ryan C. Gordon
Post by Neil Bradley
Is there any interest in me submitting a sample rate converter that has
antialiasing? What is the process for submitting code?
Generally, send patches to the list against the latest CVS. After we are
done making fun of your code (no, we don't really. Honest.), we can decide
if it's right for SDL. I tend to commit fixes, but leave it up to Sam to
decide on big changes. (However, I'm the dictator for SDL_sound. :) )
Really? So sending ZIP or tar files of changes is appropriate for this
mailing list?

-->Neil

-------------------------------------------------------------------------------
Neil Bradley What are burger lovers saying
Synthcom Systems, Inc. about the new BK Back Porch Griller?
ICQ #29402898 "It tastes like it came off the back porch." - Me
Continue reading on narkive:
Loading...