Who knows something about sound files?

I have a game-specific reason that it would be a really nice touch to include a 15 second sound file, but I’m not wild about doubling the size of my TADS image file. I know little about sound: what are the options for achieving the smallest file size via format, compression, audio editing, and anything else I don’t know about? I truly don’t care if the clip sounds like it’s coming from a 1985 Mac Plus, as long as it’s still intelligible and nice and compact. The existing file is in WAV…
Or alternatively, can anyone tell me what the smallest reasonable amount of bytes is that would be necessary for 15 sec of sound, with quality being a low priority. Thanks!

I’ve done a little experimenting with sound files in TADS. My source files were high-quality MP3. I used a Linux utility called SoundConverter to convert them to Ogg Vorbis audio using the “Very Low” quality setting. This worked out to a 44100 Hz sample / 64 kbps bitrate stereo file. The audio sounds fine, and is about one-fifth the file size of the original.

If I had used a more sophisticated audio program, I could have tweaked it down even further, but I’m comfortable with the final file size. Plus, because it’s music, I didn’t want to sacrifice stereo tracks. If they were sound effects or a short clips, you could convert to mono and achieve even better savings.

If you’re looking for a free solution and don’t have Linux, I know VLC can convert audio as well.

3 Likes

I haven’t really played around with it yet, so I’ll look into some of the things you said. Do you have any clue what a minimal byte size would be for 15 sec of basic audio?

2 Likes

It really depends on the source file itself and how low you’re willing to go in terms of quality.

A better approach in my mind is to come up with a target size and see if various conversions can meet that size.

Also—and this is just my opinion—in this day and age excessive file size is on a different scale than it was thirty years ago. If a 15s audio file was adding even 1mb to my final TADS game file, I personally wouldn’t sweat it (assuming it was the only audio file being added).

3 Likes

I have included BGM in games, and with my experimentation it’s an easy choice to immediately cut the bitrate of music in half in Audacity from 44.1kHz to 22(whatever) with every little noticeable degradation unless you’re a sensitive audiophile. This immediately halves the file size and lowers with bandwidth rate and pre-caching if playing online.

Depending on what the sound is, you could even cut the bitrate lower than that, but you’ll start to notice at some point. Open it in Audacity and play with how far you can lower the bitrate and still be satisfied, then export that to see how big the file is.

2 Likes

This is a 3:33 minute high quality music file. It’s 8.7 MB at 44.1kHz.
I know I could halve the sample rate (bitrate) and it would likely be 4.2 MB or thereabouts. So a 15 second file will depend - is it in stereo? What’s the sample rate?
You’ll need to pull it into an editing program like Audacity to discover the answers to your questions!

image

2 Likes

As a music producer and hobbyist audio engineer, I can confirm what’s been said so far, lol.

Ogg Vorbis and MP3 both offer lossy audio compression, but Ogg Vorbis gets you both smaller sound files but also with the use of open source software, as MP3 is technically patented.

But yeah, as said before, you can crunch the bit depth down to 8 bit (instead of 24 or 32 bit), and the rate to 64 kbps. You can go as low as 160-192 kbps before the average listener perks up and says “heyyyy THAT sounds weird!”

Around 128 kbps it starts getting real crunchy.

And around 64 kbps, you’re approaching the sound quality of old-school Doom sound samples. You could probably go lower than that, even, but the software I use doesn’t give me the option, lol.

If you’re not making a song, you can make it be mono and cut the size in half (stereo effects for a non-music sound effect are often a bit jarring).

Also, when exporting to your chosen audio format, you may have the opportunity to choose your compression algorithm (I had a few choices when exporting to MP3 one time). Just choose each of them one by one, and see how they compare. They will vary in both size and quality quite a bit. Also make sure your chosen audio format and compression algorithm is something that plays in whatever TADS runner that you’re using.

EDIT: Oh yeah! Almost forgot: Only confirm your compressed file by testing it IN THE GAME. There are a lot of situations where your computer cannot play a sound file, but the game you’re putting it in CAN play it! This happens a lot with Ogg Vorbis on Windows!

3 Likes

Thanks everybody for the knowledgeable info! I will be playing around with Audacity when I get a chance…

1 Like

If quality is not a consideration (or 1980s sound is a plus in your context), MIDI is an option for instrumental sound in HTML TADS.

3 Likes

@jnelson , @HanonO , @inventor200 , thanks! I reduced 11MB of sound to 1.5MB in Audacity by converting stereo to mono, reducing Hz, and exporting the existing file to a lighter weight format. Perfect! Curiously, the sounds wouldn’t play in QTads when I exported to ogg, so I used a 16-bit WAV.

3 Likes

Hmm, OGG playback works for me in QTads 3.3.0 on Windows.

Just to be sure: Are you setting a layer in the SOUND tag? For WAV, it’s not strictly necessary, but for OGG, it’s necessary, otherwise neither the official interpreter nor QTads will play it.

So, while

<SOUND SRC='mywavefile.wav'>

will work, this will not:

<SOUND SRC='myoggfile.ogg'>

The following, setting the layer explicitly, works for me on Windows, at least. (If QTads on Mac doesn’t play it, RealNC might be interested in a bug report.)

<SOUND SRC='myoggfile.ogg' LAYER=FOREGROUND>

Documentation reference: HTML TADS Sounds and Music

The LAYER attribute specifies the layer containing the sound. The value of the LAYER attribute must be FOREGROUND, BGAMBIENT, AMBIENT, or BACKGROUND.
[…]
An Ogg Vorbis resource (.OGG) can play in any layer; a layer must be explicitly specified with the SOUND tag.

Using the OGG format, you will gain so much space by the compression that you’ll be able to keep stereo and a high sampling rate etc., in contrast to the uncompressed WAV format. So if it works, I’d recommend OGG.

5 Likes

I recommend, keep the sample rate at 44.1k for ogg. This wont actually change the file size much when compressed. Some playback systems won’t rate convert. Might be the reason.

2 Likes

Very interesting, I had no idea about the layers. I’ll experiment with that…

1 Like