As part of an upcoming project, I need to compress some audio a bit.
Now there's plenty of analogue compressor schematics on the web, but a lot require obsolete FETs or odd ball lamps, shining on an LDR (the optical compressor). I fancied a different approach.
Here's the plan, audio comes in to the "top" of a digital pot (also known as an R-DAC), the pot is controlled by the arduino. The wiper of the pot is connected to out audio output. That way, we can use the arduino to effectively wind our pot up and down to control the level of the audio.
The wiper of the pot also feeds a rectifier, and the resultant level sampled by one of the Arduino's analogue ports, and that value is processed to provide the control signal to the pot.
A schematic is scratched out...
Audio comes in on J1, C3 is a DC blocking cap as the audio is biassed to half of the 5v supply by R1 & R2. The audio then feed the top of our digital pot, U2, on pin 5. Pin 7 of our pot is the bottom of our pot, and is connected to GND. Audio emerges from the wiper of out pot on pin 6, there's another coupling cap, C9, and the audio is then biassed to half our 12V rail by R14 & R16. It feeds a buffer amp, U1B and is output via R15 & C11, and is referenced to gnd by R17.The audio also feed U1A, which has a gain of about 14, and boosts the audio up to a sensible 10 volts pk-pk or so. This is coupled via C8 to our rectifier (D1 and a small filter cap of 10nF. This then drives the ADC of the arduino on pin A0. I haven't really shown the power supply, but it's just a single 12V supply, the 5V being derived from the arduino's on board regulator.
The software, can be found on my github page, as usual https://github.com/andydoswell/audio-compressor
There are some variables to play with, being Target, Avg, Attack and Decay. Play around with the values and get a feel for it.
One other thing I played with, was feeding U1A from the incoming audio, rather than the devices own output. It was possible to get the software to lose control and end up with no audio coming out, but it could be tamed.. I think this type is called a "feed forward" compressor, and again, worth some experimentation.
Here it is lashed on a bit of breadboard. It performed surprisingly well, and quiet too.
No comments:
Post a Comment