[Openal] Square wave with different frequencies
Jason Daly
jdaly at ist.ucf.edu
Fri Sep 7 11:08:54 PDT 2007
etxmato wrote:
> So now my question is, does anyone have any recommendation on how to
> generate wave sounds (in my case a simple square wave is needed) with
> different frequencies. i.e:
> - Do I need to have 1 buffer for every frequency I might need?
>
This would probably be the best way, although if you like you can use
pitch shifting to reduce the number of buffers you need.
> - If so how many buffers can I create? would it be ok to create around 1000
> (small) buffers?
>
Sure. That shouldn't be a problem, as long as you don't need to play
more than a few at once. Buffers (audio data in memory) aren't
explicitly limited, but sources are.
> - Are there any other ways of changing the frequency of a specific sound
> buffer or source+buffer?
>
No, you've pretty much covered the bases.
> - Maybe I should use another sound library?
>
You might have better luck with another library, but if not, it sounds
like OpenAL can do what you need (even though it might be a bit cumbersome).
In case you don't know, there is a function in ALUT that will generate
square waves for you:
alutCreateBufferWaveform(ALUT_WAVEFORM_SQUARE, frequency, phase,
duration).
--
--"J"
"I'm a castaway stranded in a desolate land,
I can see the footprints in the virtual sand."
--Neil Peart
More information about the Openal
mailing list