Ask HN: Is this idea for audio compression technically feasible?
I have a great idea for an audio compression algorithm, but does exist already? And if not, is it technically feasible?
My idea is that you take repeating identical sounds/frequencies (kick/snare/hi-hat/bass etc.) and encode them as the "same" as the first occurence in the song. That way you would save a lot of data/space, especially with electronic music where many of the sounds actually are 100% identical along the song.
But would this work in practice? Or would it be too complex to find out what is truly identical and what is just similar, but not similar enough to be marked as "same"?
I would love to hear what HN has to say about this. Thanks!
13 comments
[ 1.5 ms ] story [ 32.5 ms ] threadFor lossy audio compression algorithms like mp3 and ogg, they use psychoacustic techniques, removing information the human ear can't hear, like very high or very low frequencies (that's why they're lossy). MP3 does something like slicing the signal in small fragments, applying some mathematical functions to them, like the Modified Discrete Cosine Transform (similar to Fourier Transform or FFT), then removing some components of it.
The technique you're describing would pretty much be equivalent of using samples and sequence them, which would be akin to reinventing the .mod format (.mod, .s3m, .xm etc)
To use samples though, you need the individual samples. To identify and extract the samples from the song would be much more difficult, unless maybe each instrument was in its own track or channel.
So, I think compression like that might work in software they use to write / develop a track; if the software can determine that 2 notes or beats are identical, it could code the file with less data in it, but I think of music to be similar to water. It's fluid, with each note / beat / voice effecting the notes / beats around it. Ever listen to a track with the voice removed? Or with the drums removed? It sounds very different then when the track untouched. Point being, I don't think this would work for a final mp3 or lossless compression.
(or I may be completely wrong)
[0]http://labs.echonest.com/Uploader/index.html
To simplify things: You start with a sequence of notes stored as MIDI, which are played through synthesizers and sampled instruments, which generate the sounds. Then you layer effects on top of that, such as reverb, filters, and compression.
Distributing this "source code" probably wouldn't make music files any smaller, since you would also need to distribute all of the sample packs and effects plugins. A single reverb or compression plugin will take up tens of megabytes. Acoustic instruments are usually sampled at very high quality. A grand piano library can be gigabytes of samples, which includes all kinds of variations for velocity, acoustic response, etc.
In addition to that, anything you record with a microphone can't be compressed in this way, such as vocals, or any acoustic instruments. So if you have vocals throughout the whole song, then the entire length of this audio track will have to compressed at the original bitrate anyway. So if you have a 3 minute song that uses lots of samples, but also has 3 minutes of vocals, then the vocals are your bottleneck. Whatever you do to split up your track into samples, your minimum filesize will be 3 minutes of compressed audio.
So as soon as you have anything that can't be reduced into repeating samples + filters, you won't be able to do better than MP3 or FLAC (for lossless compression).
If your song contains very little recorded audio, and is purely MIDI + synthesizers, then this technique could save a lot of space.
What you describe may be called a conversion to a tracker format.
What I'm wondering about if it's feasible having an algorithm that searches for repeated instances of any sound (don't limit yourself to thinking MOD or samples) across a file and then marks these as "same" in order to save space.
Any programmers who could tell me that?