Mixing and mastering

Hello! I am a 15 year old producer (generally within instrumental hip hop) and an avid programmer, and I just recently discovered Sonic Pi. I have played around with it some, and so far I completely love it and would very much like to produce my music entirely using it. However, there is one thing preventing me from doing this, and that is the lack of mixer channels for mixing and mastering. When using other DAWs, there is usually some kind of mixer view where you can see different channels and the volumes coming out of them, along with faders to make adjustments to the volumes and balance them, and a place to add effects. Now, naturally, it would go against the design philosophy of Sonic Pi to include all of these features in a visual interface. However, I would like to know what current approaches musicians in the community take to mixing and mastering their Sonic Pi tracks. I also would like to know if it would be possible to have some sort of interface in a future version of Sonic Pi that allowed you to see the volumes of different channels and assign instruments or live loops to the channels.

1 Like

You can have use the various effects to create something similar as a mixing table. It’s not as easy as using a DAW but it’s the charm of Sonic-Pi I guess. You need to control everything using code. There is some effects that allow you to control the volume level, the compression, to filter things, etc… Try to look at the effects section in the documentation and you’ll find a lot about that.

One other option is to route the sound out of Sonic-Pi and grab it in your favorite DAW. If you are using MIDI or OSC, you can also use Sonic-Pi to control your VST directly in your DAW. It’s usually a good alternative when you want to create a very specific sound.

1 Like

Hi there, and welcome to in-thread.
You can do a lot to control features in Sonic Pi using TouchOSC (available for Mac and Android). One project I did a couple of years ago is shown in this video

Another builds a recording/playback instrument, again using TouchOSC
and is described in this thread

1 Like

Hi there @sdsd19,

first of all, please let me welcome you to our community - it’s lovely to have you join us :slight_smile:

Secondly, you ask a really important question about Sonic Pi. Whilst it was originally designed to just aid the teaching of Computer Science in schools, it has since evolved some pretty sophisticated musical abilities that start to make it very interesting for music producers such as yourself.

However, there’s still a lot more work to be done (as you can see).

Do you have any ideas on how you might imagine Sonic Pi change to develop the kind of features that you describe whilst still keeping true to its original goal of being simple enough to work with young kids?

I’d be happy to read descriptions, looks at rough sketches, anything really. Basically I’m totally open to new ideas :slight_smile:

2 Likes

Hi @sdsd19,

it is possible to handle live_loops as tracks and direct their output to separate channels/external effect chains via sound_out. I suppose you could find a mixer application for Windows or MacOSX, I have an example to do this with Linux. Maybe this points into a direction which is helpfull for you…

3 Likes

This is exactly what I was looking for. Thank You!

Hello @samaaron ! Thank you for your reply. I actually have a bunch of ideas for things that would make Sonic Pi more producer friendly (at least in my opinion). If possible I would love to send them to you. If I do though, I think I should play around with Sonic Pi a bit more, in case any of my issues resolve themselves.

Hi there. Definitely do play around and definitely do share your ideas. Posting them on here would be a great place to have a discussion about them :slight_smile:

Could there be tracks that are automatically mixed to go to the master bus.

Anything that produces sound could have a ‘track:’ option. E.g.

sample :bd_haus track: 1

meaning that the bass drum sound is passed through track 1.

‘track’ would itself be a sound source. I.e. the following block would add some reverb to everything on track 2.

trk2verb = with_fx :reverb, mix: 0.3 do
track 2
end

saving a reference would allow it to be automated, and to remove it later.

How would sends work? I tried to make up something for ‘send’, but it got a bit messy.

I am assuming that it might be possible to have the number of tracks dynamic, so they are only created when they are referenced somewhere. Rather than having (say) 16 tracks.

There already is, in effect, a master track. But, if ‘track’ is a sound source, then perhaps ‘master’ could be as well.

with_fx :eq, low_shelf: 1.1 do
master
end

To me, the roughness and lack of polish / mastering is part of the charm of using Sonic Pi instead of a DAW. I feel more connected to the music when I’m working with the raw sound on-the-fly. Trying to do something refined in Sonic Pi seems a bit like forcing a square peg in a round hole. It could be an interesting challenge to build something out of it, for sure.

That being said, if you want the algorithmic composition but with proper mastering and refinement, you might be better off figuring out how to make Sonic Pi control things inside your DAW. I’m not sure how to do that, but I would be very surprised if no one else has tried to approach the problem before.

You could also look into the different OSC tools out there and use that to control the parameters of your synths instead of static numbers. I use TouchOSC on my smartphone to control it with when i practice. TouchOSC has a bunch of pre-made layouts, and the option to make your own too. Install the app on your iPad and you’re good to go. I did a write-up of my workflow here

3 Likes

Something I’ve done recently is to control the volumes for each loop using the get/set functions at the top of the code. You could do the same for mastering in terms of FX - I’ve added a little bit for that.
This is one possible way to do it anyway :slight_smile:

# Settings
use_bpm 168
use_random_seed 1001

#Functions
define :getPitchFromNote do |note, sampleBaseNote, fineTune|
  return note - sampleBaseNote + fineTune
end

# Mix - I'm setting the values here and then applying them to the sounds in each loop
set :choirMash_MixVol, 0.13
set :beat1_MixVol, 9.5
set :beat2_MixVol, 1.5
set :bass1_MixVol, 0.5

# Master FX
set :distortion_Insert, 0.9 ; set :distortion_MixVol, 0.01

# Loops
with_fx :distortion, distort: get[:distortion_Insert], mix: get[:distortion_MixVol] do
  live_loop :choirMash do
    notes = (ring :A3, :Cs4, :E4, :Ab4,  :F3, :A3, :C4, :E4)
    phaseLine = (line 8, 1, steps: 128, inclusive: true).mirror
    amp = get[:choirMash_MixVol]
    
    32.times do ; tick
      with_fx :ixi_techno, phase: phaseLine.look do
        sample :ambi_choir, rpitch: (getPitchFromNote notes[0], :a3, 0), amp: amp, start: 0.2, finish: 0.5
        sample :ambi_choir, rpitch: (getPitchFromNote notes[1], :a3, 0), amp: amp, start: 0.2, finish: 0.5
        sample :ambi_choir, rpitch: (getPitchFromNote notes[2], :a3, 0), amp: amp, start: 0.2, finish: 0.5
        sample :ambi_choir, rpitch: (getPitchFromNote notes[3], :a4, 0), amp: amp, start: 0.2, finish: 0.5
        sleep 0.25
      end
    end
    
    32.times do ; tick
      with_fx :ixi_techno, phase: phaseLine.look do
        sample :ambi_choir, rpitch: (getPitchFromNote notes[4], :a3, 0), amp: amp, start: 0.2, finish: 0.5
        sample :ambi_choir, rpitch: (getPitchFromNote notes[5], :a3, 0), amp: amp, start: 0.2, finish: 0.5
        sample :ambi_choir, rpitch: (getPitchFromNote notes[6], :a3, 0), amp: amp, start: 0.2, finish: 0.5
        sample :ambi_choir, rpitch: (getPitchFromNote notes[7], :a4, 0), amp: amp, start: 0.2, finish: 0.5
        sleep 0.25
      end
    end
  end
  
  with_fx :eq, low_note: 60, low: -0.5 do
    live_loop :beat1 do
      mainSlices = (ring 4,3,2,3, 3,8,2,3, 4,3,10,3, 3,4,2,4)
      endSlices = (line 0, 15, steps: 16, inclusive: true).shuffle
      amp = get[:beat1_MixVol]
      
      48.times do
        sample :loop_compus, amp: rrand(amp, amp + 0.5), slice: mainSlices.tick, beat_stretch: 16
        sample :loop_perc2, amp: (amp / 8), slice: look
        sample :loop_perc1, amp: (amp / 8), slice: look, pan: -0.2
        sleep 0.5
      end
      
      16.times do
        sample :loop_compus, amp: rrand(amp, amp+0.5), slice: endSlices.tick, beat_stretch: 16
        sample :loop_perc2, amp: (amp / 8), slice: look
        sample :loop_perc1, amp: (amp / 8), slice: look, pan: -0.2
        sleep 0.5
      end
    end
  end
  
  with_fx :eq, low_note: 60, low: -0.5 do
    live_loop :beat2 do
      sleep 64
      fixedSlices = (ring 4,3,2,3, 3,8,2,3, 4,3,10,3, 3,4,2,4)
      amp = get[:beat2_MixVol]
      
      128.times do
        sample :loop_amen, amp: rrand(amp, amp + 0.2), slice: fixedSlices.tick, beat_stretch: 6, pan: 0.2
        sleep 0.25
      end
    end
  end
  
  with_fx :wobble, phase: 0.25, wave: 1, smooth: 1 do
    live_loop :bass1 do; tick
      notes = (ring :A1,:B1,:F1,:G1, :A1,:B1,:F1,:G1, :A1,:B1,:F1,:G1, :A2,:B2,:F2,:G2)
      amp = get[:bass1_MixVol]
      
      with_synth :tri do
        play notes.look, sustain: 4, release: 0.5, amp: amp
      end
      sleep 4
    end
  end
end
1 Like

Thank you! This looks like a great way to do it without external software.

Looks like you’ve already got the answers you need regarding mixing in SPi. I just wanted to add that if you are wanting to perform in depth mixing and mastering for digital releases you could just export your wav files and do them in the DAW of your preference. I personally always take my performances in SPi and pull them into Logic Pro X once I’m ready. I mix, master, rearrange and often add accompanying instruments, better buildups, etc…