mwetherill's picture

Audio not playing

I am trying to switch out our Audio library to utilize openTK

i am currently not getting any audio. What would be things for me to check to find the source of the failure?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mwetherill's picture

Additionally, I have noticed that my bufferIDs reset back to 0 instead of staying at their original number. Is this normal? I get a number like 74780888 then it goes to 0 when I try to play the sound.

mwetherill's picture

Still working, I am getting sound to play however its not consistent, some times it works some times it does not.

When it does play it takes 10 times longer to play. I am using the same ring test sound. I have verified all of the source information is the same between both projects.

The difference I see is that I am not playing directly after I buffer the sound. it is very strange. I also do not run the audio proceduraly, I have created my own my audio manager which contains the buffer ID, I have created my own SourceClass which loads the data, buffers it, plays it, disposes of it etc. I can't seem to get the code to work the same. The buffer ID is finally consistent part of the time. Any ideas?

mwetherill's picture

Everything is working, however the sounds just don't play right, some times they take 2-3 times as long to play, it sounds choppy with clicking noises, while other times it plays for just a split second.

Anyone able to help at all?

the Fiddler's picture

Which operating system and which version of OpenAL are you using?

(If you are on Linux you need at least libOpenAL.so.1 - libOpenAL.so.0 is extremely buggy and will not work correctly no matter what. All modern distros should be using the newer version).

mwetherill's picture

Using Version OpenAL1.1 in Windows 7 64bit.

mwetherill's picture

it seems more of a memory issue, but i don't understand why your playback demo works perfect while following and nearly copying the code, but implementing in a scalable oop manner causes it to fail.

Is there any initialization needed outside of the playback example?

mwetherill's picture

it seems more of a memory issue, but i don't understand why your playback demo works perfect while following and nearly copying the code, but implementing in a scalable oop manner causes it to fail.

Is there any initialization needed outside of the playback example?

mwetherill's picture

Ive tried a few things.

For the longest time. I have 2 classes, a source Audio class and a Main Audio class
The Main Audio Class, just contains the Audio Context. At runtime it initializes and creates the audio context.
It also loads up and returns the source class.

The Source Audio class is each Source.
It contains a buffer, and a source and can control settings ( I have all the settings disabled so it is just defaults)
I tell it to load the sound passing it the string of the file location.
I then proceed to create the Buffer, AL.GenBuffer();
I save the BufferID as an Integer.
I then use AL.GenSource() and store that in an int named sourceID.
I then Load up the audio Data out of the file.
I follow verbatim from the Playback example.
I create a FileStream and open the .WAV file (the_ring_that_fell.wav)
I then Use a binary reader to read the FileStream
I proceed to check the Signature verbatim from the example, then I store the Riff ChunkSize
I then Read the WAV format, then read and store the formatSignature
I then read the Format Signature, run the check.
Then I read through
FormatChunkSize - Int32, Audioformat-int16, channels-int16, SamplesPerSecond-int32, AverageBytesPerSecond - int32, BlockAlign-16, BitsPerSample-int16
I then read the data_signature,
then read the dataChunkSize,
then I return the entire data in a bytes array.

After that I buffer the Bytes Array into my buffer.
us AL.Source(sourceID,ALsourcei.buffer, bufferID)
then I play the source.

Its all choppy.

mwetherill's picture

So I figured out my issue

When I declared my audio context I had
AudioContext context = new AudioContext();
This was the issue
When I removed the = new AudioContext(); and placed it into my main class's constructor
so inside the initialization function I had
context= new AudioContext();
it stopped the stuttering and is now consistent
I still had a strange tick noise at the end, but it works!

I will keep looking into that strange tick noise at the end.

You might want to post this incase somebody else runs into it as it is a strange issue to run into and track down.