123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|416|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Off Topic -> AudioCompressing

Fri, 03 Sep 2010, 17:25
dna
Hey All.

I was using winrar and 7zip to compress some audio only too find that the compressed archive was not any smaller.

Is there a compression method that will reduce the size of a audio file?

-=-=-
DNA
Fri, 03 Sep 2010, 17:39
CodersRule
Audio/pictures are already compressed; hence the reason you use mp3s over wavs, or pngs over bmps.
If you want to compress the data more, save it in a different package; save wavs into something more compressed like an mp3 or an ogg.
Fri, 03 Sep 2010, 18:39
HoboBen
In addition to choosing formats such as mp3 or ogg, you can also reduce the sample rate. In the case of lossy compression such as mp3 you can also increase compression at the cost of sound quality.

-=-=-
blog | work | code | more code
Sat, 04 Sep 2010, 01:12
Afr0
I already made an example showing how to do that here.

Technically it doesn't actually compress anything, it only uncompresses. But to compress you only have to reverse the algorithm!

In fact, to get you started:

* Grab a wav file.
* Create a new file.
* In the new file, output 'XAI\0' for speech, or 'XAJ\0' for music.
* Take the size of the wav file minus the WAVEFORMATEX header and plop it into the new file as the uncompressed size.
* Write the WAVEFORMATEX header to the new file, except for the last field [cbSize].
Here's the WAVEFORMATEX header, for your convenience:



Once you've done that, all that's left to do is to compress the audio stream from the wav file and dump it into your new file. Then close.


-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Sat, 04 Sep 2010, 03:14
JL235
I use Audacity for converting audio from one format to another. I'd also recommend converting to Ogg rather then MP3 as in my experience it compresses WAAAAAAAAAAAAY more.
Sat, 04 Sep 2010, 05:31
Jayenkai
Indeed. Blitzmax uses Ogg happily on all three target systems, and I'm REALLY happy about that! I've been cramming allsorts into my games, lately.
But you'd have to be sure your language of choice does do Ogg.. I don't think BlitzClassic does it.
...

does it?!

-=-=-
''Load, Next List!''
Sat, 04 Sep 2010, 13:46
dna
Thanks for the info JL235. I never knew that OGG compressed more than mp3.
I'll try that.

-=-=-
DNA
Sat, 04 Sep 2010, 13:53
dna
Thanks for suggesting that code AFRO but it does not work inside of B2D


-=-=-
DNA
Sat, 04 Sep 2010, 14:31
Afr0
Uhm.... yes? Yes it does!
You just have to convert the values...

WORD = short
DWORD = int

I'm not sure if Blitz distinguishes between signed and unsigned, but it shouldn't really matter so long as you don't use negative values.
As for my C# code... the compression algorithm itself should be relatively easy to convert and reverse, as it's mostly math... not very language specific...

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!