Sonic Pi has lots of possibilities to play sequences of notes,
chords,and chords progressions, but…
I was experimenting pass midi notes to Reason and,
with one note,worked fine.
When i tried to pass a list;nothing happened :
# Midi in/Out (midi through DAW)
# Set Bpm (Tempo)
use_bpm 120
use_debug false
# Sends midi clock at current bpm
live_loop:clock do
midi_clock_beat
sleep 1
end
# Midi Out
live_loop :midich do
(midi_notes :d3, :d4, :d5).tick
use_midi_defaults channel: 2,port: "pure_data_in"
end
# Send midi control messages
midi_cc 42,65, channel: 2 # cc = 65 to Malstrom
There’s some other way to pass notes,and chords to
# Midi in/Out (midi through DAW)
# Set Bpm (Tempo)
use_bpm 120
use_debug false
# Sends midi clock at current bpm
live_loop:clock do
midi_clock_beat
sleep 1
end
# Midi Chord
define :midi_chord do |notes, *args|
notes.each do |note|
midi note, *args
end
end
live_loop :midich do
midi_chord chord(:c4,:major),channel: 2,
port:"pure_data_in", sustain: 2
sleep 4
end
I’d not be able to define a function like this,so i took from
In fact, i see no advantage,since this method only
play one chord;no rings or progressions.
So, i stick with the old one;here’s an improvement:
# Notes Through vst
# Note Durations
w = 4
h = 2
q = 1
e = 0.5
s = 0.25
# Set Bpm (Tempo)
use_bpm 120
use_debug false
# Sends midi clock at current bpm
live_loop:clock do
midi_clock_beat
sleep 1
end
# Midi Out
live_loop :Ch1 do
midi [:C3,:Eb3].ring.tick(:note),
channel: 1,port:"pure_data_in",
attack: 0.01, sustain: 0.3, release: 0.1
sleep (ring q,e,s,h).tick(:dur)
end
Naming Ticks are equivalent to play_pattern_timed (in this case)
See chapter 9.4
Am using this to pass information through Minihost Modular Beta
You’ve done it again. I did not realize that I could use sustain: with midi. I’ve been doing all my note on/off the hard way, tracking the last played value. However, are you able to make use of attack: and release: ? Is that sending standard CCs for those?
@kniknoo, the midi function isn’t a direct representation of anything in the standard MIDI specification. Instead, it’s two calls: first a call to midi_note_on followed by a pause and then a call to midi_note_off. The midi function handles this implicit concurrency and strict timing for you
So the following can be seen to be equivalent:
midi :e1, release: 0.2
at do
midi_note_on :e1
sleep 0.2
midi_note_off :e1
end
Apologies, but I’m not 100% sure what you mean here. Triggering a bunch of notes at the same time is done by writing each note trigger code on a separate line with no interleaving calls to sleep or sync. A chord progression implies that you’re spreading out the note triggers over time which would require either a sleep or sync to advance time:
(chord :e3, :minor).each do |n|
midi n, release: 0.1
end
sleep 1
(chord :a2, :major).each do |n|
midi n, release: 0.1
end
sleep 1
(chord :f2, :major).each do |n|
midi n, release: 0.1
end
there was a discussion on Github about that some time ago. The result was the following function (which is exactly what @samaaron says made convenient as a function). You could keep that at the top of your buffer (I keep it in the init file of Sonic Pi at ~/.sonic-pi/init.rb):
# https://github.com/samaaron/sonic-pi/issues/1691
# Use: midi_chord chord(:c4,:major), sustain:0.2
define :midi_chord do |notes, *args|
notes.each do |note|
midi note, *args
end
end
In fact i blended the two questions together,
and fortunately you answered both.
Be sure that you solved one of main issues for
Sonic Pi users.
Thank you very much, once again.
Here is the answer to what you asked me,
with an improvement of our friends :
Passing Notes Through vst
define :midi_chord do |notes, *args|
notes.each do |note|
midi note, *args
end
end
# Note Durations
w = 4
h = 2
q = 1
e = 0.5
s = 0.25
# Set Bpm (Tempo)
use_bpm 120
use_debug false
# Sends midi clock at current bpm
live_loop:clock do
midi_clock_beat
sleep s
end
live_loop :midich1 do
use_midi_defaults channel: 1,release: 0.2,port:"pure_data_in"
midi :e3
sleep q
midi :g3
sleep q
midi :b3
sleep q
end
Send midi control messages
midi_cc n channel: x # n = see MIDI Implementation Chart
# of your DAW or vst(documrntation folder of your app).
For future reference, I’ve just added some information on how to format your posts using Markdown to the pinned community post. You might be interested in reading the section on formatting code blocks