TCastleSound and mp3?

Are there plans in the roadmap for mp3 support… I search and it looked like maybe that was done some years ago? Maybe it is the encoding in my file that keeps it from loading? I was going to test a nice splashing sound to accompany my swimming pig. Since it was mp3 and wouldn’t work, I tested with the next most convenient wav… the werewolf-howl from one of the castle examples. OMG, that was a bad idea… my cats Freaked Out, spilling my drink all over the floor.

Audacity to the rescue. The file I am using is probably too big… but the splashing sounds really cool, especially with multiple animals swimming around you. I deleted the howling wav. No howling allowed here now. Is there a cost for having many of the TCastleSoundSource objects using the same wav? How would you handle something like a stream that makes sound if water is flowing… could you place a transform with a TCastleSoundSource as needed or would that be way too many? Maybe you can use the same source over and over?

We support OggVorbis and WAV files, not MP3, with our default sound backend (OpenAL, OpenAL | Manual | Castle Game Engine ). While supporting other formats is not out of the question, it is some additional burden (in case of OpenAL, we need to load sounds ourselves), and it didn’t seem critical for a long time, so I’m leaning toward not doing it.

Audacity or SOX can convert MP3 → OggVorbis perfectly.

( The FMOD sound backend ( FMOD | Manual | Castle Game Engine ) can be extended with additional sound formats without much issues, and support everything that FMOD supports. Though using FMOD means you are no longer open-source. Depending on your project, FMOD may be free or paid (see FMOD licensing, it is friendly to indies) – it is a proprietary, but powerful, library. )

To play a longer sound set TCastleSound.Stream to true. See Castle Game Engine: CastleSoundEngine: Class TCastleSound . See Sound | Manual | Castle Game Engine for an overview of most important properties.

The werewolf sound also caused a weird reaction from my cat long time ago :slight_smile: I added then --no-sound command-line option (you can also run from CGE editor with “Run → Run Parameters → No Sound” checked), and I test all my games on headphones, and we never talked about it again with my cat :slight_smile:

No. Underneath, we cache the resource for the same sound file. So practically, many TCastleSound with the same URL share common resources. Doesn’t matter how they are used (in multiple TCastleSoundSources or other ways).

Hm, not sure actually.

Multiple TCastleSoundSource along the line of the river (I will call it “river”, not “stream”, to avoid mixing up with the TCastleSound.Stream :slight_smile: ) would work, but would not necessarily sound good – you will have many sounds at once, if you place them too closely (disregarding performance).

My first approach would be one TCastleTransform with one TCastleSoundSource that is moved, from code, to always be at “the 3D point of the river that is closest to player’s position”. But here I think about typical FPS game, player walks in a forest, and the main point of spatial sound is to make sure “player is aware whether river is on left or right side”. From what I saw, you present more “overview” look at world… I honestly don’t know how to express river sound best.