daniel-birket / audible-adventure

An accessible Adventure-like game & engine with a hybrid text & audio user interface.
GNU General Public License v3.0
3 stars 0 forks source link

What about sound formats? #3

Open daniel-birket opened 2 years ago

daniel-birket commented 2 years ago

@lawrenceper , the SDL2 audio mixer library (which pygame also uses) is a multi-channel stereo player capable of many sound formats. It can play this formats:

I read that MIDI synthesis is CPU intensive relative to a simpler format like WAV. Obviously MIDI is a lot smaller, but you would be at the mercy of the playback library for sound quality compare to what you could tweak with audio tools. I don't know much about audio formats beyond WAV is simple but bulky and MP3 is compressed. Size doesn't seem to be a huge factor these days but I still like efficiency. Note that the library seems able to handle multiple formats at once.

It also has one long-playing 'stream' channel intended for long audio, like music, not short samples. It is also able to loop samples, so if you have 5 seconds of swamp frogs croaking, you can loop them as needed. There is also volume control, including fade-in-fade-out. I imagine sequences like:

Scene descriptions might be synthesized from text.

Anyway, I'd like your thoughts on what format would be good to use store channels of audio for playback during the game, including:

lawrenceper commented 2 years ago

Hi,

I think that WAV files would be better for audio loops than compressed audio like MP3. MP3s are great especially for speech because of the smaller size. I have messed around with MP3 files in Audacity, and there seems to be an audio gap when looping an MP3 file vs a WAV file.

To truly use open source tech, we could use OGG and FLAC file formats. OGG is a file format that is compressed (lossy) like MP3, and FLAC is compressed but is still lossless. Think of FLAC like a ZIP file with a WAV file inside it.

I could do some experimenting in Audacity with both file formats to see if there is a noticeable gap between the loop. To my ears, the OGG format did not sound that grate, but we could use a higher bitrate when exporting in Audacity. From what I remember, the FLAC encoder has options for compression as well.

A FLAC file might be better suited for ambient sound than OGG, especially if we're using 5 second clipps. The OGG format will work better with speech )E.G. acting/dialogue).

Hope this helps.