Example - Loading Audio Buffer #114
-
NOTE: Please use the Soundstream class now to load samples. This workaround is no longer needed and has some issues with certain sample types such as Windows PCM Extended. I've cracked the loading, using the NAudio library to parse the Waveformat header. AS such, the code is below for future reference. I use the WaveFileReader class to read in the header, plus the audio data. I then populate your Waveheader with the data, and then stream the rest of the buffer into a byte array, then create the audiobuffer. The WaveFileReader Length takes into account the size of the header and deducts from the Audiobuffer, ensuring its only playing the buffer. Sound now working in game.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I wish I had seen this before I wrote a parser. For anyone dealing in wave files, here is some quick code to load a PCM wave file.
|
Beta Was this translation helpful? Give feedback.
-
With Soundstream now available, this thread should be closed. Maybe a sample created and added to the repo. |
Beta Was this translation helpful? Give feedback.
I wish I had seen this before I wrote a parser. For anyone dealing in wave files, here is some quick code to load a PCM wave file.