Go Down

Topic: Arduino-based optocompressor (Read 2220 times) previous topic - next topic

efinque

Dec 29, 2018, 12:53 am Last Edit: Jun 19, 2019, 04:55 pm by efinque
Sup Arduino forum,

I thought I'd post this project here too for you to see (full thread on GroupDIY)

A build pic :



Finished unit :



Schematic :



And the code :

Code: [Select]
void setup() {
  Serial.begin(9600);
  pinMode (A0, INPUT);
  pinMode (A5, INPUT);
  pinMode (10, OUTPUT);
  pinMode (13, OUTPUT);
}

void loop() {
  int controlV = analogRead(A0);
  int threshold = analogRead(A5);
  int hold = 500;
  Serial.println(controlV);
  Serial.println(threshold);
 
 if (controlV > threshold) {
    digitalWrite (10, HIGH);
    digitalWrite (13, HIGH);
    delay(hold);
      }
    else
      digitalWrite(10, LOW);
      digitalWrite(13, LOW);
  }


The pictures may look sort of skewed but I hope you get the idea..

Any thoughts?

-ef

EDIT : I'd post a sound sample but my desktop PC suffers from thermal shutdowns so I can't really record anything for the time being

EDIT 2 : there's a typo in the schematic, the output vol pot could be after the LDR.. this current plan changes the load the control circuit resistor sees, whereas with the pot after the LDR it limits the output signal.. I guess it's a matter of taste, since it doesn't have active buffering for the output signal.

Grumpy_Mike

Quote
Any thoughts?
No resistors in the LEDs, a circuit designed to kill things.

efinque

No resistors in the LEDs, a circuit designed to kill things.
The digital outs give 5V.. I burnt more LEDs with a 5VDC PSU and a ballast resistor than with this.

Grumpy_Mike

I burnt more LEDs with a 5VDC PSU and a ballast resistor than with this.
Don't be stupid. If you did that then you did not have the right resistor value, it was way too low.

Quote
The digital outs give 5V.
Yes after over 50 years in the electronics business I know that. What you don't know is the importance of power supply impedance.

If you are not willing to accept good solid advice then why did you ask?

These sorts of crappy circuits are the bane of the internet.

wolframore

#4
Jan 03, 2019, 02:37 am Last Edit: Jan 03, 2019, 02:48 am by wolframore
The code doesn't look complete. Let's ignored the burnt LED do you have it working? Wonder how it sounds.  Also there's no gain stage. I have an LA2A. Same concept. Look it up. You should be able to find schematics. Think along the line. Currently all you have a threshold and gate but no make up gain.

I really don't see the need for the Arduino for this. It's all analog circuitry. It's been done before with tubes. Just replace the tubes with transistors.
Bad Boys Rate Our Young Girls But Violet Goes willingly - Get Some Now :) - ELI the ICE man

efinque

The code doesn't look complete. Let's ignored the burnt LED do you have it working?
Yes the last time I tested it.


Quote
Also there's no gain stage. I have an LA2A. Same concept. Look it up. You should be able to find schematics. Think along the line. Currently all you have a threshold and gate but no make up gain.
That's something I was thinking but I didn't have opamps.

Quote
I really don't see the need for the Arduino for this. It's all analog circuitry. It's been done before with tubes. Just replace the tubes with transistors.
I breadboarded a Schmitt trigger to light a LED but it didn't work for one reason or another. I think one option/mod would be to invert the optocoupler LED.

wolframore

#6
Jan 09, 2019, 02:23 am Last Edit: Jan 09, 2019, 02:30 am by wolframore
A Schmitt trigger is the wrong idea. The beautiful thing about a optocompressor is the smooth analog that comes with it. It's almost transparent. The original filament light took time to turn on and fade out which adds a smoothness to the compression. It slows and smooths the attack and release. 

I really have no idea what you have since I can only imagine how you have it functioning. It could work as a noise gate or a leveling device. All depends on how you program but I wouldn't think that it's a compressor without the make up gain.
Bad Boys Rate Our Young Girls But Violet Goes willingly - Get Some Now :) - ELI the ICE man

sevostille

#7
Jan 10, 2019, 09:56 pm Last Edit: Jan 10, 2019, 09:57 pm by sevostille
This has been done many times (mostly with PICs or solid state control logic), but it is far from easy. The right vactrol (and a periphery tuned to it) is vital for the sound, and so is ultra low latency on the control signal.

Besides, you absolutely must have proper buffering on the in- and output - the Arduinos are 0 to +5V (or 0 to +3.3V) devices, while audio is AC. Just feeding audio into A0 will have you miss the bottom half of the wave and overshoot the available sample rate by a magnitude - you'd have to use an anti-aliasing filter and shift the entire wave to the positive range, or (better yet) rectify for the envelope before you make it to the Arduino input. And you have to brace the input element in your circuit for at least 12Vpp, or it may go up in smoke when used behind a fuzzbox or other hot devices - a self-limiting buffer op amp or at least clipping diodes will be necessary (at any rate unless you absolutely want to be swamped with repairs under warranty).

DVDdoug

#8
Jan 11, 2019, 12:53 am Last Edit: Jan 11, 2019, 12:59 am by DVDdoug
I fully understanding building something like this for fun.     But, for less than $200 USD you can buy a stereo compressor that's got the traditional threshold, ratio, attack, release, and make-up gain controls.    You couldn't build it for that.    And, it's going to be fully debugged and tested for noise, distortion, and frequency response.  Sometimes there are more controls/options and often a compressor can be set-up as a limiter (which is a kind of fast-compression).

As far as I know, these basic-compressors are analog.   I don't know if they are optical or not (I assume not).   But, it doesn't matter what's inside as long as it does what a compressor is supposed to do.

If you "go digital" you can do all kinds of things with DSP (digital signal processing) including simulating the operation of your favorite vintage optical (or other) compressor.   And, you can do things in digital that aren't possible with analog.

If you don't need real-time processing you can do it in software.  Audacity (free) comes with a compressor effect or there are other free & non-free plug-ins that work with Audacity or DAW software.    Again, if you don't need real-time processing you can do things with an audio file that are impossible in real-time like "look-ahead" processing.   Look-ahead is great for limiting because a real-time limiter has to kick-in (and distort the waveform) before you hit the limit.   With look-ahead, you can leave the signal unmolested unless you go over the limit, and when you do go over the limit it can cut the level without changing the shape of the waveform.   



==========================================
Way back in the analog days I built an expander (the opposite of a compressor) with an NE570 chip.   It "worked" and it was "fun" but it was way too aggressive (2:1 linear expansion over the full dynamic range) and I was too inexperienced to improve it.     

sevostille

#9
Jan 11, 2019, 04:02 pm Last Edit: Jan 11, 2019, 07:15 pm by sevostille
If you "go digital" you can do all kinds of things with DSP (digital signal processing) including simulating the operation of your favorite vintage optical (or other) compressor.   And, you can do things in digital that aren't possible with analog.
There are many analog compressors with a digital control path, from the popular RNC1773 to the (very high end) Hoef DM or Cranesong Titan. And they do things you cannot do in digital (most notably, tame a signal BEFORE it is digitised). So the concept is feasible and has been explored.

But I agree that it is unlikely that a such minimal approach as above will result in something better sounding than the very affordable and pretty excellent RNC - if the original poster wants to discover the benefits of buffers, envelope followers and circuit protection iteratively, his experiment will be very much more expensive before it will even begin to work for more than a few hours...

wolframore

It's cool in concept that an LED and LDR with arduino can outperform an actual opto-compressor but in reality it's not that simple. 

I also like to compress a bit going to track for various reasons (good signal to noise being one).  It's also a good tool in live performance so the levels are matched and easier to mix with a strong signal.  You can also use it as a cool tool to duck based on other signals.  Compressors are very important tools for engineering sound.

10 (1024 steps) bit ADC is little disconcerting if you're converting it to digital, compared to processing that works in 16 (65,536) - 24 (16,777,216) bit it's night and day.  Many signal processors with 32 bit processing had hard time processing good reverbs back in the day.  Not sure what the Arduino would add to the mix.

Might be cool might not... again I have no idea what the device does but it's not really a compressor.
Bad Boys Rate Our Young Girls But Violet Goes willingly - Get Some Now :) - ELI the ICE man

sevostille

#11
Jan 12, 2019, 05:02 pm Last Edit: Jan 12, 2019, 05:34 pm by sevostille
10 (1024 steps) bit ADC is little disconcerting if you're converting it to digital,
For a control path that would do, analog limiters only have a one bit control path (over/under threshold), and even most analog compressors make do with three or four envelope switching points (which could be transported in two bits). A far more critical issue is that the maximum sample rate on the UNO is only 9.6kS/s - and that is the maximum, real time software will steal from that.

Both can be worked around if you extract the envelope prior to digitising, as the envelope needs much less resolution in either domain - even fast compressors can't have reaction times that reach into the audio domain, or they act as a filter or distortion, and ten times 20Hz, i.e. 5ms (200S/s), should be  enough to pipe a envelope into the compressor. 

But if you want to sample audio directly, and digitally extract its envelope in real time (perhaps even applying a filter), you need much more than a classic Arduino -  a external audio grade ADC and a 32bit board (Zero or the like), perhaps even a MRK Vidor (with DSP code outside the Arduino domain doing the hard work) would be necessary.

wolframore

I think the real issue is why digitize when it works perfectly in analog?
Bad Boys Rate Our Young Girls But Violet Goes willingly - Get Some Now :) - ELI the ICE man

efinque

Thanks for the input guys.

Stuff that I'm possibly looking to add is an output buffer/opamp (ie. make-up gain) and a knob for the peak hold.

It's purely an experimental project and designed to be used with a computer but works equally well as stand-alone (the peak hold could be automated via serial and if I added a control for that it would require a bypass I think)

Go Up