Side-chained compression?

Heya All :smiley:

First post - I recently saw Sam do a talk in Melbourne & performing live - I was blown away and I’ve finally gotten around to messing with the software- it’s been so much fun so far! :tada:

I come from an Audio Engineering background and have messed with other music / audio mixing tools like Ableton, ProTools/Reaper etc, and I guess it’s a blessing and a curse - I keep reaching for tools I already know and thinking from an “audio” perspective rather than from a “coding” one.

So, this one might seem obvious, but I’ll ask: Is there a way to side-chain the input to a compressor?

I’m looking for this kind of effect: https://youtu.be/b9o91rqw0LE?t=123

To clarify- in a lot of compressors there’s an option to set where the compressor defines it’s input. A really good example of this in dance music is to set a compressor with a really slow release on a main Synth line, but have it take it’s input from the kick drum, so on every Kick beat, the compressor is triggered, and ducks the volume of the Synth - and then slowly the synth recovers volume. It gives it that neat “Pumping” sound, and I’m looking to achieve that in code.

I’ve thought around this a little - and I’m struggling to see how I’d implement this kind of thing inside SonicPi. It appears the compressors have no assignable input, so I’m wondering if there’s a way to do this through code. Could I assign the volume of the kick to a variable, and have that adjust a compressor somehow? Or create this effect manually by controlling the synth’s amplitude somehow?

Anyone had any experience with this?

Thanks in advance! :raised_hands:

1 Like

Hi @oheydrew,

I am pretty sure that there is no such thing as ‘sidechain compression’ currently in Sonic Pi. But you may direct e. g. a certain live loop (or thread) to a certain output and route this into an external compressor using with_fx :sound_out (see this example setup for Linux).

1 Like

Thanks @Martin! That’s fine, I expected as such. I guess I could achieve somewhat of the effect I’m after by manually ducking the volume of the loop I want on the beats I’d like (the kick beat, I’d imagine). It’s not exactly the same, but it might be a workaround. I’ll have a play! :loud_sound:

Sorry, side chaining isn’t supported at this stage. Mainly because I hadn’t figured out an approach to incorporating it which meshed with the current design and was simple enough to teach to a 10 year old child.

I’ve got some rough sketches now, so we should hopefully see some possibility of this in a future release though :slight_smile:

4 Likes

That’s great news @samaaron :slight_smile: Thanks for jumping in and clarifying!

I’d be interested to hear your thoughts on the possible implementations, if there’s an issue thread for it or anything like that, I’d love to see it. If I can help in a code-way or anything let me know. But I wouldn’t stress too much about it- I was just getting excited and reaching for tools I don’t really need :wink:

2 Likes

Hi there,

I fiddled a bit around to get something close to a sidechain compressor:

use_bpm 60
set_control_delta! 0.01

s = 1

with_fx :level, amp: s do |t|
  live_loop :bassline do
    sample :bass_trance_c, start: 0.1, amp: 1
    sleep sample_duration :bass_trance_c, start: 0.1
  end
  
  live_loop :kick do
    sleep 0.45
    s = 0.6
    control t, amp: s, amp_slide: 0.01
    sleep 0.05
    sample :drum_heavy_kick, amp: 2
    sleep 0.25
    s = 1
    control t, amp: s, amp_slide: 0.01
    sleep 0.25
  end
end

It is actually quite timing sensitive :slight_smile: But maybe a good starting point for some experimentation.

Cu.

Hi minced_mind,

Please explain… I thought there had to be something to control?

like: t = play 66, amp: 2 , or something. I dont see that in your code?

So I twiddled a bit, and got this, which explains to me what was going on.
Am I wrong?

Eli…

use_bpm 60
set_control_delta! 0.01

s = 1

with_fx :level, amp: s do |t|
  live_loop :bassline do
    t = sample :bass_trance_c, start: 0.1, amp: 1
    sleep sample_duration :bass_trance_c, start: 0.1
  end
  
  live_loop :kick do
    sleep 0.45
    s = 0.6
    control t, amp: s, amp_slide: 0.01
    sleep 0.05
    sample :drum_heavy_kick, amp: 2
    sleep 0.25
    s = 1
    control t, amp: s, amp_slide: 0.01
    sleep 0.25
  end
end

Although I actually quite like this too.

use_bpm 60
set_control_delta! 0.01

s = 1


live_loop :kick do
  sleep 0.45
  t = sample :bass_trance_c, start: 0.1, amp: 1
  s = 0.1
  control t, amp: s, amp_slide: 0.01
  sleep 0.05
  sample :drum_heavy_kick, amp: 2
  sleep 0.25
  s = 1
  control t, amp: s, amp_slide: 0.0001
  sleep 0.25
end

Mmm, @Eli - in your first example you’re defining two things as “t”, the :level FX unit, and then later on over-writing it with the :bass_trance_c sample - so things get a little confusing.

Indeed, I prefer your second option, and I messed around similarly to do something similar. It’s possible to create whatever you like manually like this, but it’s fiddly and doesn’t scale super well, so I was reaching for a compressor.

Still, very cool! Nice idea controlling the level of a :level FX unit @minced_mind - That’s a really good point. I suppose one could manually control the threshold component of a compressor FX module, too? :thinking:

1 Like

I see… I missed the t in the fx… must
get me some new glasses.

Thanks for the explanation.

Eli…

Dont mind me… I’m just thrashing around in the dark as
usual… I mean, there is a compressor fx, why not just.
use that?

To be honest, I manually tune the levels in my songs, so
this method of not over-loading(?) a song isnt really of
much use to me.

use_bpm 60
set_control_delta! 0.01

s = 1

with_fx :compressor, threshold: s do |t|
  live_loop :bassline do
    sample :bass_trance_c, start: 0.1, amp: 1
    sleep sample_duration :bass_trance_c, start: 0.1
  end
  
  live_loop :kick do
    sleep 0.45
    s = 0.1
    control t, threshold: s, threshold_slide: 0.01
    sleep 0.05
    sample :drum_heavy_kick, amp: 2
    sleep 0.25
    s = 1
    control t, threshold: s, threshold_slide: 0.01
    sleep 0.25
  end
end

Hello all,

well, you can use a compressor, too. The problem here is, you are compressing the kick, too.
The compressor is just a fast volume fader, so I used the level FX to fade the volume and use a higher amp for the kick to neutralize the effect on the kick, so that only the bassline is compressed :slight_smile:
I tried different approaches but they all had their downsides, like controling the amp of the bassline directly, but this doesn’t work well and is a pita when you have a more complex bassline than this really easy example. You can experiment a bit with the sleeps around the kick and the “s”-value to finetune the pumping. It’s more or less a hack and doesn’t perfectly simulate a sidechain compressor, but you can get pretty neat similar efects :slight_smile:

Cu.