Realtime/dynamic mp3 compression (used as an effect)?

Feb 27, 2012 at 1:28am

Realtime/dynamic mp3 compression (used as an effect)?

Has anyone come across a realtime mp3 encoder/decoder in Max?
More specifically where you can control the bit rate in dynamic fashion (ie, with a number box).

The idea is to use the loss of resolution as a sort of ‘digital tone knob’ of sorts.

My understanding of how mp3 analysis/encoding is not great, but I know it’s an FFT-based process, so I’m wondering if it’s possible to do something like that in Max, in realtime.
Or at the very least try to emulate the ‘sound’ of what’s happening.

I found this pseudo-code that sort of summarises what’s happening:

algorithm MP3 {
/*Input: An audio signal in the time domain
Output: The same audio signal, compressed
/*
Process the audio signal in frames
For each frame {
Use the Fourier transform to transform the time domain data to the frequency domain, sending
the results to the psychoacoustical analyzer {
Based on masking tones and masked frequencies, determine the signal-to-masking noise
ratios (SMR) in areas across the frequency spectrum
Analyze the presence and interactions of transients
}
Divide the frame into 32 frequency bands
For each frequency band {
Use the modified discrete cosine transform (MDCT) to divide each of the 32 frequency bands
into 18 subbands, for a total of 576 frequency subbands
Sort the subbands into 22 groups, called scale factor bands, and based on the SMR, determine
a scaling factor for each scale factor band
Use nonuniform quantization combined with scaling factors to quantize
Encode side information
Use Huffman encoding on the resulting 576 quantized MDCT coefficients
Put the encoded data into a properly formatted frame in the bit stream
}
}

#61997
Feb 27, 2012 at 6:30pm

Also curious if anyone has done ‘data moshing’ type processing on audio, keeping frequencies static until new ones take over (similar to the i/p frame stuff in datamoshing).

#223900
Apr 3, 2012 at 12:21am

Hate to bump a somewhat old post, but does anyone have any ideas about this? I’d like to try and emulate something like http://mashable.com/2010/06/03/youtube-i-am-sitting/ – IE, really, really nasty audio codec compression. Doesn’t seem to be much literature on the subject, that I can find.

#223901
Apr 3, 2012 at 12:32am

I’ve actually got something super handy going, though it uses a custom external by Alex Harker, with some additional code by a good friend of mine.

I tweaked it a bit so you can select an arbitrary range that wraps around the spectrum (it makes sense if you look at it). I’ve also got a stereo 1-band version, and a stereo multi-band version kicking around.

Attachments:
  1. mp3ify.zip
#223902
Apr 3, 2012 at 2:22am

Wow, I was just looking for that! Thanks Rodrigo!

#223903
Apr 3, 2012 at 4:37am

I was messing around with pfft~ a bit today, trying to get something like what I wanted. I think this works! At the very least, it’s… interesting. And sorta gross.

Bitcrush/sample rate reduce the phase/amplitude of a signal seperately from each other, as well as rounding the amplitude (but not the phase), and multiplying the phase (but not the amplitude). Try putting the phase at -1, it’s amusing. :D

It’s all pretty simple patching but it amuses me no less.

Attachments:
  1. youtubery.zip
#223904
Apr 3, 2012 at 9:14am

That sounds pretty slick too.

I’ve got mine incorporated with the ‘lofi’ module of my patch, along with regular sample/bit reduction type stuff. It plays real nice with that stuff.

#223905

You must be logged in to reply to this topic.