Main Menu

search

You are here

Midi: Sonic-pi

[last updated: 2019-11-28]
raspberry Pi home page
Midi home page
Midi: links
-----

  • Sonic-pi is a program included in the rPi distro (menu > Programming > Sonic-pi). It has music editing features and seems to be geared mostly to live performance.
    However it can control my Concertmate Midi keyboard, though almost all the documentation and tutorials as I said are related to live performance, so there's a lot of digging needed to figure out how to manipulate the keyboard. But I persevere...
  • When you click "run" in upper left, whatever code is in the window will execute one time.
    However if you have a do-loop, it effectively runs until you stop it.
  • Turning notes on and off:
    • Minimal command to turn on a note:
      midi_note_on :e3 [volume] ... not sure range of volume parameter, est 0 - 100 decimal or so...
      :e3 is "e" note, 3rd octave
      It is equivalent to specify it as 52 (52nd key on a standard keyboard)
        ie: midi_note_on 52 [volume]
      • :es3 will play "e3 sharp" (equivalent to note #53), and
        :eb3 will play "e3 flat" (equivalent to note #51)
      • It isn't required to use whole numbers to specify a note.
        midi_note_on 52.35 ... is valid too.
    • When you've turned on a note, it will stay on until you turn it off.
      You can turn it off with either:
        midi_note_off [noteID] ... or
        midi_note_on [noteID] 0 ... which specifies zero volume
    • To specify how long you want the note to stay on before turning off,
      insert 'sleep' command between the on command and the off command:
      • midi_note_on 52 50
        sleep 0.5
        midi_note_off 52
      • (I think) Units of sleep parameter are "whole beats" (however and wherever they're specified...)
  • Programming Structures:
    • do/end loop:
    • defining & using variables:
    • defining & calling functions:
      • defining a function:
        define :foo do
          play 50
          sleep 1
          play 55
          sleep 2

        end

      • defining a function with a passed parameter:
        define :foo2 do |keyN, durN|
          midi_note_on keyN 50
          sleep durN
          midi_note_off keyN

        end

      • executing/calling a function:
        foo ... or
        foo2 50, 0.2

      ---------------------------

    • My Concertmate 1100 has ... keys:
      • The lowest key on the keyboard is #36, :C2
        However the keyboard will play even the lowest note possible in Midi format,
        that being: midi_note_on 0,
      • The highest key on the keyboard is #..., :c?
        However the keyboard will play midi notes up to ...
    • ... could not get anything to happen with midi_cc, even giving it up to 3 parameters (comma-sep),
      though it did not give me any errors...

    .

    .

    .

    eof