Try sonic pi


#1

sonic pi https://sonic-pi.net/
" Sonic Pi is a code-based music creation and performance tool."

It is fascinating. (and free)

you can add instrument1 as midi input

live_loop :midi_piano do
  use_real_time
  note, velocity = sync "/midi/instrument1/0/*/note_on"
  synth :piano, note: note, amp: velocity / 127.0
end

#2

now, I can set a chord into one key, while not affect others.

live_loop :midi_piano do
  use_real_time
  note, velocity = sync "/midi/instrument1/0/*/note_on"
  puts note
  if (note==48) # midi note 48, something like c2, or c3, if trigger this
    play chord(48, :major) # then play a chord
  else
    synth :piano , note: note, amp: velocity / 127.0
  end
end

#3

Very cool! You’d probably also enjoy StreamByter (Mac/iOS), which comes as both a standalone app and as the scripting language in the object-based graphical MIDI wrangler MidiFire. But it doesn’t yet run on Raspberry Pi…


#4

You can map a button to a chord with this program.
copy/ paste it into sonic-pi IDE (download from https://sonic-pi.net/ )

artiphon_address= "/midi/instrument1/*/*/note_on"
artiphon_synth= :dsaw
remap_keys=[40,41,42,43,44]
remap_chords=[chord(:c4,:major), \
              chord(:d4,:major), \
              chord(:e4,:major), \
              chord(:f4,:major), \
              chord(:g4,:major)]

# if you want to remap keys to chords
# turn remap to true
remap=true

define :artiphon do |synth_name, event_address|
  use_real_time
  note, velocity = sync event_address
  # remap the key
  if remap
    i=0
    remap_keys.length.times do
      note=remap_chords[i] if note==remap_keys[i]
      i += 1
    end
  end
  synth synth_name, \
    note: note, \
    release: 1.5,\
    amp: velocity/127.0
end

with_fx :reverb do
  live_loop :midi_play do
    artiphon artiphon_synth,artiphon_address
  end
end

#5

I put my code in:

Now, I can remap guitar notes into chords / loops / samples. It’s much easier to play the guitar like this. In order to avoid practicing the guitar, I actually start to learn ruby. What do they call this? Risk Hedging? :slight_smile:

There are many improvements to be made. I still don’t know how to make a loop play again and again, until I play the next loop. Now it will be interrupted by another chord.