Midi_cc to select bank and qsynth

Hi !

## on choisit la banque 8 pour le canal midi 1
## we select bank number 8 on the midi canal 1
midi_cc 0, 0, channel: 1 # canal midi
midi_cc 32, 8 # banque 8
sleep 1
## on choisit le programme 1 piano
## we send a midi program change to select the program number 1
midi_pc 1
## we play a note to test
midi_note_on :c2
sleep 1

num_prg = [24, 25, 26]
num_prg.length.times do
  # midi program_change pour changer le numéro de programme dans la banque sélectionnée
  midi_pc num_prg.tick # le numero de programme doit exister attention au trou (mind the gap)
  midi_note_on 60
  sleep 2
end
midi_all_notes_off

ok now run again and you should notice a problem : the program change is shift. Hope my explanations are clear enough… not sure.
Thanks for an help

I tried this, and found that inserting a very short sleep between the pc call and the note_on achieved the expected behaviour. It didn’t seem to be necessary for the midi_pxc changes when the bank remained at 8, You can adjust the overall times to give to compensate as I have done here,

For the benefit of any others trying this out, you can only do bank changes like this in Qsynth if you set the Midi Bank Select mode to mma in the setup dialog. Unfortunately this setting is NOT available on the only Mac BINARY available for Qsynth. ver 0.3.6 which is very old, so the protgram only works on RPi or Linux or Windows? (not tested)

## on choisit la banque 8 pour le canal midi 1
## we select bank number 8 on the midi canal 1
midi_cc 0, 0, channel: 1 # canal midi
midi_cc 32, 8 # banque 8
sleep 0.95 #reduce this sleep to compensate for the extra one after midi_pc
## on choisit le programme 1 piano
## we send a midi program change to select the program number 1
midi_pc 1
sleep 0.05 # insertintg a short sleep here seems to cure the problem
## we play a note to test
midi_note_on :c2
sleep 1

num_prg = [24, 25, 26]
num_prg.length.times do
  # midi program_change pour changer le numéro de programme dans la banque sélectionnée
  midi_pc num_prg.tick # le numero de programme doit exister attention au trou (mind the gap)
  midi_note_on 60
  sleep 2
end
midi_all_notes_off

In general I have found that small sleeps after bank changes or midi_pc changes are sometimes necessary to get reliable operation when using Qsynth.

well you’re right i should have given more details about my configuration. I test on Ubuntu 18.04.03. with spi 3.2dev. Your solution is not working for me but maybe i have to test more sleep values to discover the good one ???

i feel the changing program is taking too much time to be set and then the midi note is played before. So it’s a really mess…

For windows you can install a more recent version https://github.com/JoshuaPrzyborowski/Qsynth-Windows-Builds the exe are provided 0.5.5.

This morning, i did some tests with loopMidi, qsynth 0.5.5 and spi 3.1 under w10 and meet some problems… the mma mode seems not to work. i keep learning and trying to find solutions and give you some feedbacks. It’s time for garden right now :slight_smile:

Hi i’m back with good news under windows 10

this script is working for me


# Testing midi and qsynth - nlb with big help from Robin Newman - 09-12-2019
# spi version : v3.1
# os : windows 10
# qsynth : 0.5.5 https://github.com/JoshuaPrzyborowski/Qsynth-Windows-Builds
# soundFont : Arachno SoundFont - Version 1.0.sf2 https://www.polyphone-soundfonts.com/en/files/27-instrument-sets/255-arachno-soundfont
# port loop midi : loopMidi 1.0.15


puts version


use_midi_defaults port: "loopmidi", channel: "4"

play 60


# the mma bank select mode is choosen in Qsynth configuration

midi_cc 0, 0 #
midi_cc 32, 0 # banque 0
sleep 0.95 #reduce this sleep to compensate for the extra one after midi_pc
## on choisit le programme 1 piano
## we send a midi program change to select the program number 1
midi_pc 1
sleep 0.85 # inserting a short sleep here seems to cure the problem
## we play a note to test
midi_note_on :c2
sleep 4

num_prg = [24, 25, 26]
num_prg.length.times do
  # midi program_change pour changer le numéro de programme dans la banque sélectionnée
  midi_pc num_prg.tick # le numero de programme doit exister attention au trou (mind the gap)
  sleep 0.15
  midi_note_on 60
  sleep 2
end




# to select the bank number 128
midi_cc 0, 1 # 1 = 128
midi_cc 32, 0 # bank selection >>  1*128 + 0 = 128
sleep 0.15

## we send a midi program change to select the program number 8
midi_pc 8
sleep 0.15


midi_note_on :c2
sleep 1
midi_note_on :g3
sleep 1

midi_all_notes_off


hope it helps.