# [.net] Proper Audioformat for background music?

This topic is 3550 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I need an audio format, which needs less space (like mp3, ..) and which is easily convertable to .wav in memory for use in c# (DirectSound, OpenAl, ..). .wav would take too much space .mp3 needs licenses .ogg is nice, but there is no really usable converter for itt Any ideas?

##### Share on other sites
.ogg

just get/write a converter. I had to do it for a project once, it wasnt that bad.

heres a place to start if you decide to write a converter:
http://en.wikipedia.org/wiki/Ogg

##### Share on other sites
I tried writing a OGG Stream Decoder now using the InterOp lib from http://www.codeplex.com/OggVorbisInterop

My decoder works fine for the first 115 kbytes, but then all following calls to Vorbis.Synthesis end in a AccessViolationException - Can't see what i'm doing wrong.

When reading 2x16 kbytes, the third call (to fill the buffers up again) causes the access violation
When reading 2x1024 kbytes, the first fill up call in the first buffer ends in a access violation after 115 kb

Code:
http://www.wilcob.com/Wilco/Pastecode/23898/showpaste.aspx

Output:
[Sound] Play() [IsStreamed=True][Decoder] Resetting...[Decoder] Parsing header..[Sound] FillInitial()[Decoder] - Decoding (read=16384)[Decoder] - Decoding (read=16384)[Sound] UpdateStream() [processed=0][Sound] UpdateStream() [processed=0][Sound] UpdateStream() [processed=0][Sound] UpdateStream() [processed=1][Decoder] - Decoding (error, read=0)[Decoder] System.AccessViolationException: Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.   bei Xiph.Interop.Vorbis.Vorbis.vorbis_synthesis(vorbis_block& vb, ogg_packet& op)   bei Xiph.Interop.Vorbis.Vorbis.Synthesis(VorbisBlock vb, OggPacket op)

When reading 2x 65kb, it works fine for the first buffer (65536), but crashes when filling the second one (@ 528000 bytes always) and any further call

##### Share on other sites
There's an Ogg converter available through the Mono project, called csvorbis, which is completely native C#. You'll need to check it out from their anonymous SVN though, I couldn't find a zip anywhere.

There's an included decoder sample but it was coded rather strangely. It wasn't too hard to convert it into a simple reader class though. I'm using it in my own game engine at the moment, but I haven't gotten around to setting it up for streaming so it takes a few seconds when loading a large file.

Email me and I'd be happy to send you the zipped files and my OpenAL converter class.

AlphaGremlin