External Synth Setup Example

Hello everyone

As part of my live setup I’ve made a couple of functions that I use to control my hardware synths. I figured they could serve as an example and starting point for others to work from.

# An important part of this code is the midi ports that
# you set for each synth. This depends entirely on your
# midi setup. I use a 4-port midi interface, and I make
# sure to connect my synths the same way every time.


# The Volca Drum has six different "sound slots" it can play
# The sound isn't determined by the note, but which channel the
# note is sent to.
define :volca do |sound|
  channel = 0
  case sound
  when 1 then channel = 1
  when 2 then channel = 2
  when 3 then channel = 3
  when 4 then channel = 4
  when 5 then channel = 5
  when 6 then channel = 6
  end
  midi :c1, channel: channel, port: "midiout3_(midi4x4)_3"
end

# the Roland SE-02 is a monosynth, which makes it super easy to work with
# this function is purely to make my code easier to understand by the audience.
define :se02 do |note, sustain|
  midi note, port: "midiout2_(midi4x4)_2", sustain: sustain
end


# the Roland System-1M is a polysynth with up to four voices, which means
# it needs a way to handle multiple notes at a time.
define :system1m do |note, sustain|
  case note
  when Symbol
    midi note, port: "midi4x4_1", sustain: sustain
  when Numeric
    midi note, port: "midi4x4_1", sustain: sustain
  else
    note.each do |n|
      midi n, port: "midi4x4_1", sustain: sustain
    end
  end
end

# This fuction is used to send control signals to the synth
# which controls the different parameters, such as cutoff.
# It's not particularly clean, but it gets the job done.
# The parameters and numbers depend on the midi implementation
# of that particular synth, so give the manual a look.
define :ctrl do |synth, param, value|
  se02_parameters = {
    "glide" => 5,
    "xmod_filter" => 16,
    "xmod_osc" => 17,
    "xmod_pulse" => 18,
    "noise_mix" => 41,
    "osc1_mix" => 48,
    "osc2_mix" => 49,
    "osc3_mix" => 50,
    "feedback" => 51,
    "lfo_rate" => 102,
    "lfo_osc" => 103,
    "lfo_filter" => 105,
    "delay_time" => 82,
    "delay_amount" => 91,
    "delay_regen" => 83,
    "cutoff" => 74
  }
  
  system1m_parameters = {
    "mod_wheel" => 1,
    "cutoff" => 3,
    "glide" => 5,
    "resonance" => 9,
    "bitcruster_amount" => 12,
    "delay_time" => 13,
    "osc1_mix" => 16,
    "osc2_mix" => 17,
    "sub_mix" => 18,
    "noise_mix" => 19,
    "pitch_envelope" => 22,
    "pitch_attack" => 23,
    "pitch_decay" => 24,
    "lfo_pitch" => 26,
    "lfo_fade_time" => 27,
    "lfo_filter" => 28,
    "lfo_rate" => 29,
    "osc1_color" => 50,
    "osc1_xmod" => 52,
    "osc2_color" => 55,
    "osc2_tune" => 56,
    "hpf_cutoff" => 79,
    "reverb_amount" => 91,
    "delay_amount" => 94
  }
  
  case synth
  when "se02" then
    if se02_parameters.has_key?(param)
      midi_cc se02_parameters[param], val_f: value, port: "midiout2_(midi4x4)_2"
    else
      print "no such parameter"
    end
  when "system1m" then
    if system1m_parameters.has_key?(param)
      midi_cc system1m_parameters[param], val_f: value, port: "midi4x4_1"
    else
      print "no such parameter"
    end
  else
    print "no such synth"
  end
  
end

# A handy little panic button
midi_all_notes_off
1 Like

hi @chris.krakou

Big thanks for sharing this piece of code ! I think i will look at it to play with an elektron sample :slight_smile:

Edit :

  • maybe it would worth to have more code to see how you use this.
  • why your code is not colorized ?

Cheers

Wait, Ruby has a case statement? I wish I’d known that earlier…