MIDI control problem

Hi, I am a student who is beginning to learn Sonic Pi.
I have a question about that I used sample MIDI controlling code in tutorial.

This is my program.


When I play Triads many times, Sonic Pi can catch all notes but the live_loop sometimes only synth one or two notes.
image

Could someone tell me how to solve it?

Hi and welcome
(This has been edited…The first post got muddled up)

Looking at your code and the cue log, it looks like you are using a keyboard that uses separate note_on and note_off triggers.
The way Sonic Pi generates notes is that you have to specify a start time and a duration in order to play a note. With a keyboard sonic pi doesn’t know how long the note is going to be when you press the key down. There are two possible solutions.
The easiest way is to assume a length for the note. This is supplied by means of the sustain: parameter. If you don’t supply one it is assumed to be 1 beat, which at the default bpm of 60 lasts for 1 second, then dies away. This may explain why your netes seem to be lost if you play too many close together. You could try more staccato notes using
synth :piano, note: note, amp: 1, release: 0.2 for example which would play notes which died away over 0.2 beats
The harder solution is to start each note playing with an arbitrary long time (say 5 seconds) and use the note_off symbol to kill the note when the key is released. (On many keyeboards note_off is signified by using note_on with a velocity parameter of 0).
I have developed programs to use this second method, and it works well playing aSonic Pi synth with an external keyboard. I wrote an article here which shows how it works. If you select the link to the revised-simpler-polyphonic-gated-synth-using-sonic-pi-3 and use the second version of the program which is designed for keyboards that have separate note_on and note_off signals that should work for you. (the program is called simplepolysynth2.rb

3 Likes

Thank you, Your suggestion is useful.