What's the correct way to use spred function to send out midi ntoe?

Hello,
I am using Sonic Pi with an external synth, trying to make a Euclidean drum pattern. My code get an error as seen below. Can anyone help me fix it ? Thanks in advance !

use_bpm 118
live_loop :kick do
midi_note_on :c4, 100, if spread(3,8).tick, port: “elektron_model_cycles_1”, channel: 1
sleep 0.25
end

You’re almost there, you just have to make sure the if ... part is at the end of the line:

use_bpm 118
live_loop :kick do
  midi_note_on :c4, 100, port: "elektron_model_cycles_1", channel: 1 if spread(3,8).tick
  sleep 0.25
end

Also, you probably want to use midi instead of midi_note_on, otherwise you are just switching a midi note on continuously but never switching it off.

1 Like

Or you can use “on” instead of “if”. Then you don’t have to place it on the end of the line…

1 Like

Thank you ! It works!

1 Like

Thanks ! I’ll give it a try

1 Like