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

Kevin Fishburne kevinfishburne at ...1887...
Tue Oct 20 07:40:55 CEST 2015


On 09/15/2015 01:49 AM, Kevin Fishburne wrote:
>
> 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).

Having not gotten a response I'll try again. There's now a second 
critical use case where I need to retrieve the properties of an OpenAL 
buffer. According to multiple Internet posts such as this one:

http://stackoverflow.com/questions/7978912/how-to-get-length-duration-of-a-source-with-single-buffer-in-openal

I'm using the correct method with the possible exception of relying upon 
Alure to load the buffer (which you'd think would be irrelevant since a 
buffer is a buffer is a buffer and all). Please see the OpenAL example 
in the GAMBAS software farm to test the failing code. I'm using Mint 
17.2 amd64 and GAMBAS from the stable PPA. There (as usual) is a 
possibility I'm just doing something really stupid, or there could be a 
legitimate problem with the OpenAL implementation in Alure or GAMBAS.

On an unrelated note, I finally watched Benoît's interview. A few 
things... First Benoît's English was good enough that I could understand 
about 80%+ of what he was saying. Second, the two guys doing the 
interview didn't seem to know their assholes from their elbows, 
especially the older Mac guy. Benoît, you were outstanding and your 
passion for both GAMBAS and BASIC really shone through; nice work and it 
was awesome seeing and hearing you talk about your (and our) passion. 
Also around the 23:00 mark you gave me a shout-out by name. I nearly 
shit myself. :)

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271





More information about the User mailing list