[Gambas-user] OpenAL (gb.openal) example code

Benoît Minisini gambas at ...1...
Wed Oct 21 22:26:15 CEST 2015


Le 15/09/2015 07:49, Kevin Fishburne a écrit :
>
> When I've gotten most everything I need figured out I'll write a
> tutorial to accompany the example code. This hopefully will be sooner
> than later.
>
> Currently using Alure.BufferDataFromFile to load sound files into OpenAL
> buffers I'm unable to get the buffer properties using the Al.GetBufferi
> function. I don't know if this is because I'm using Alure versus the
> regular Al method, but this code should work and doesn't (see attached
> project):
>
>    ' Load audio data from .wav file into audio buffer.
>    Print "Load buffer data from wav file:" & Gb.CrLf & "  ";
>    Print Alure.BufferDataFromFile("./test.ogg", AudioBuffer[0])
>
>    ' Display audio data properties.
>    Print "Audio frequency in Hz:" & Gb.CrLf & "  ";
>    Print Al.GetBufferi(AudioBuffer[0], Al.FREQUENCY)
>    Print "Audio buffer bit depth:" & Gb.CrLf & "  ";
>    Print Al.GetBufferi(AudioBuffer[0], Al.BITS)
>    Print "Audio channels:" & Gb.CrLf & "  ";
>    Print Al.GetBufferi(AudioBuffer[0], Al.CHANNELS)
>    Print "Audio data size in bytes:" & Gb.CrLf & "  ";
>    Print Al.GetBufferi(AudioBuffer[0], Al.SIZE)
>
> It returns zeros instead of the proper values. In particular I need the
> Size property returned, as this can be used to calculate an offset from
> which to start playing a sample once attached to a source. This is
> necessary because multiple sources created and played simultaneously
> using the same buffer will result in the waveforms being combined at the
> same sample point, which creates a metallic, flange-like effect. If I
> can find a buffer's size I can offset the position at which a source
> begins to play randomly between zero and the buffer's size like this:
>
> Al.Sourcei(Ship[ShipIndex].AudioSourceVelocity[0], Al.BYTE_OFFSET,
> Rnd(0, Al.GetBufferi(AudioBufferVelocity[0], Al.SIZE)))
>
> For now I'm going to have to use something like Rnd(0, 100000) for the
> offset and simply hope it doesn't exceed the buffer's size, which
> silently returns an error and plays the source at zero (no offset).
>

Is is better with revision #7428?

-- 
Benoît Minisini




More information about the User mailing list