Control Yamaha dig piano over midi/sysex

As I wrote some time ago I bought a Yamaha P-525 and have the intention to control it from Cantabile. As Yamaha has issues with its ordering system and I have to wait until the end of March I decided to start excercising with my P-140. Reading fora and manuals I figured out that the piano should send the midi information by two commands:

  • Panel/status Transmit
  • Initial setup Send

Starting with the first: it send a midi message that

  • does work if sent back
  • is completely not understandable for me why it works
    The command is e.g.
    x"F0 43 0 7C 0 32 43 4C 20 20 43 4C 50 27 30 35 31 31 0B 17 0 0 1 0A 0A 1 2 0A 0A 0 0D 36 0A 1 1 0A 0A 3 2 2 2 2 0 0 0A 0 2 40 3 3 78 0 0A 0 0 0 54"
    (tab = space)
    I recognize parts of the numbers reading the Data Format documents, but I cannot interprete it according to the formats of the system messages. Actually it does change the settings of the keyboard panel and is the only command that does that.

With other simple commands I can set effects as reverb etc., like:
0xF0 0x43 0x10 0x4C 0x02 0x01 0x00 0x03 0x10 0xF7
(when I wrote this I did not know the x"" notation)

I could not get the change voice command working until today, when I realized that the voice is only changed for the midi coming in from the PC and not for the keyboard internally (first long command does that,…)

I question I still have is around the voice changing with MSB, LSB and Program Change numbers, e.g. MSB = 0, LSB = 122 and P.C. =1.

The midi monitor shows as below, changing to 0,122,1

I hoped that this would correspond to
image
And that actually works, for the midi incoming form the PC.
I use midi.banked_program_change(1,15621) as this number is listed in the first image. Program_change(1,5) to change to program 5 on channel 1. Does anybody understand why the number 15621, 3D05H (5 probably for program 5)
The first picture mentions controller fine 122, is that somehow hidden is the 15621?

I realize that I’m not very knowledgeable in this field and probably ask the wrong questions. Hopefully someone can help me to understand this all better,
thanks, Joop

Unfortunately no reactions yet. I’ll start with the simple question. Hopefully the Sysex experts on the forum can find some time for this.

The combination

  • midi.banked_program_change(1,15621)-
  • Program_change(1,5)
    yields B0 00 00 B0 20 7A C0 05 C0 05, being
    B0 00 00 - MSB 0
    B0 20 7a - LSB 122
    C0 05 C0 05 - Program change 5 (but then twice,…?)

Question 1
How are the bank numbers calculated from midi.banked_program_change(1,15621)

Question 2
Raw data of the lines shown in the Midi Monitor picture show for Program Change:
C0 05 00 00
The line Program Change (Banked) does not give raw data, lines further give information on effects etc., not on program change.

With Copy all I find:
|849.384 1 Controller 0 - Bank Select (MSB) 0
|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|—|
|849.386 (+0.002) 1 Controller 32 - Bank Select (LSB) 122
| 1 Controller (Fine) 0 122
| 1 Program Change 5
| 1 Program Change (Banked) 122.5

giving information on the commands, but not the HEX coding.
So: How do I exactly get the HEX codes from the incoming midi messages, which I can send back to change the program on the piano. I got there with some guessing, but I would prefer a more exact way of working.
Any reactioon is much appreciated!

Hi Joop,

I use MIDI Tools to read incoming MIDI sys-ex to my PC. The tool set includes a sys-ex reader and writer. I used it when creating a rack for my RD2000 and it helped me. There is also MIDIOX that does the job too.

Dave

2 Likes

Thanks, I can try that!
It runs in parallel to Cantabile or is it the one or the other?

  • and any idea about the working of midi.banked_program_change(1,15621)?

It can run in parallel as a separate app but still see all the same ports that Cantabile sees in the Options.

It looks to me like it is an instance of the raw pg numbers with no bank or pg shown. Here’s what I think is how it works. I might be wrong so if others know more please chime in. :slight_smile:

Divide it by 128
15621/128 = 122.0390625
subract 122 = .0390625
multiply the remainder by 128
.0390625 * 128 = .5

Add the 2 results

122 + .5 = 122.5

Well found, looks logical! This is a normal way to handle midi values?
@brad could you shine your light on this?

Installed, looks really helpful!

The midi.banked_program_change function generates the MSB/LSB CC events and the program change event for a banked program number that’s been packed as binary number in the form

00MMMMMMMLLLLLLLPPPPPP
    msb    lsb    pg

which can be calculated as

(msb * 128 * 128) + (lsb * 128) + pg

or

(msb << 14) | (lsb << 7) | pg

eg: msb = 2, lsb = 3 and one-based pg = 5:

(2 * 128 * 128) + (3 * 128) + 4 = 33156

So:

midi.banked_program_change(33156)

Note this sends the bank CCs and the program change. You don’t need to follow it with another program change event.

If you have the bank msb/lsb and pg number separate numbers you can just send the CC and program change events directly.

This is the same as the above:

midi.cc(1, 0, 2)                     // 0 = bank select MSB 2
midi.cc(1, 32, 3)                    // 32 = bank select LSB 3
midi.program_change(1, 4)            // program change 4 (or 5 one-based)

Watch out for one vs zero-based program numbers. Cantabile supports both, but it only affects how program numbers are entered and displayed.

The bank numbers are always zero-based - ie: the first msb bank is 0, the first lsb bank is 0 and no conversion is necessary.

Program numbers can be one or zero-based and there’s an option in Tools → Options → General → Formatting that controls Cantabile’s behaviour.

When zero-based is selected the displayed/entered number in Cantabile is exactly the value used in the MIDI events.

When one-based is selected, the first program number is displayed as 1 - but it’s represented in MIDI as 0. So you need to subtract one when converting from display value to MIDI and add one when converting from MIDI to display.

The MIDI generator functions midi.banked_program_change and midi.program_change always work with zero-based program numbers.

Regarding this:

It’s correct but watch out for rounding errors. If you want to do this with integer math you can just unpack the bits

msb = (val >> 14) & 127
lsb = (val >> 7) & 127
pr = val & 127
2 Likes

Thanks, I’ll look into that, but not today anymore,

Is this kind of information somewhere in the guides?

Joop

Is there also an offset with the channel nummers, as midi.program_change(1,5) yields
C0 05?, channel0 instead of 1?