Home › Forums › General › Panels, Components, Macros › Yamaha Master Tune
- This topic has 10 replies, 2 voices, and was last updated 5 years, 10 months ago by eggi.
-
AuthorPosts
-
May 3, 2018 at 8:21 pm #83764
Hi, I’m new here, and totally new to sysex, and this is my first post, so apologies if this is the wrong forum section.
I have tried to find the solution for several days, and I have tried reading the documentation, but I just can’t get this to work.
I have two Yamaha modules which does the master tune setting the same way via sysex.
Tha data range for XG Master Tune is 0d-2047d (0000h-07FFh=WXYZh) with 0.1 cent/step. The value for the standard tuning (default) is 1024d (0400h), 0d (0000h) will cause a tuning of -102.4 Cent and 2047d (07FFh) will cause a tuning of +102.3 Cent. The hexadecimal value WXYZh must be transmitted as so called ‘Nibblized MIDI data’ with four ‘Nibbles’ in the form 0Wh,0Xh,0Yh,0Zh.
F0 43 10 4C 00 00 00 00 04 00 00 F7 (This is master tune set to 0 (default) on the XG module)
This I have tried to emulate in the sysex formula editor as:
F0 43 10 4C 00 00 00 ls ms ls ms F7
I have set up a modulator with -102.4 as minimum value and 102.3 as maximum. Also there is a modulatorValue + 64 setting which gives me 000.4 on the master tune on the module when the rotary is set at 0.
I see that the way this is supposed to work is that the byte values need to go from 00 to 0F independently, now they do, but in pairs. I just can’t figure out how to do this. Could anyone guide me in the right direction?
May 4, 2018 at 9:39 pm #83773the vars ls and ms only let you split a number into two nibbles not four. I don’t know of a Ctrlr built-in feature who will split a value into 4 nibbles. You will have to code that with a Lua script. It is not very difficult but you will need minimal programming skills.
- This reply was modified 5 years, 10 months ago by Possemo.
May 4, 2018 at 9:53 pm #83776Thanks Possemo, that helps a lot. Now I can stop trying making it work with regular controls, and focus on solving the task with Lua scripting.
May 5, 2018 at 12:58 am #83777I would do that with built-in bit operations. Something like this:
myNewMethod = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source) BigVal=BigInteger(value) lowest=BigVal:getBitRangeAsInt(0,4) -- (0,4) explained: ("start-bit", "number of bits") low=BigVal:getBitRangeAsInt(3,4) mid=BigVal:getBitRangeAsInt(7,4) high=BigVal:getBitRangeAsInt(11,4) panel:sendMidiMessageNow("F0 43 10 4C 00 00 00"..high..mid..low..lowest.."F7") end
then attach this method to a slider (with correct value range) on the property “Called when the modulator value changes”. My bitranges are just random values, you need to insert to right values.
- This reply was modified 5 years, 10 months ago by Possemo.
May 14, 2018 at 10:14 pm #83947Hello again Possemo.
I’ve been fiddling around with the code you sent me, but after further reading the documentation on the XG Format Master Tune it of seems a bit clearer to me.
The way it works is:
Starting with lowest possible value:
F0 43 10 4C 00 00 00 00 00 00 00 F7
The last byte goes from 00 to 0F –
F0 43 10 4C 00 00 00 00 00 00 0F F7
Then the second last byte changes to 01, and increases by one every time the last byte reaches 0F. This goes on in a similar way for the next two bytes until the highest value is reached.
The highest value is F0 43 10 4C 00 00 00 00 07 0F 0F F7.
The first problem I see when I see the output in the MIDI Monitor is that with the current code below the values are not even sent as hexadecimal. Is there a function I can use to do that?
masterTune = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source) BigVal=BigInteger(value) lowest=BigVal:getBitRangeAsInt(0,1) low=BigVal:getBitRangeAsInt(4,1) mid=BigVal:getBitRangeAsInt(8,1) high=BigVal:getBitRangeAsInt(12,1) data = CtrlrMidiMessage("F0 43 10 4C 00 00 00 "..high..mid..low..lowest.." F7") panel:sendMidiMessageNow(data) end
Also the output I get is only 10 bytes long f.ex: f0 43 10 4c 00 00 00 03 31 f7
I suspect this is because the values are all wrong. I don’t really understand getBitRangeAsInt (big surprise there… )
I found this site – but it seems a bit over the top for what I’m trying to do.
I’m properly stuck, any help would be greatly appreaciated. 🙂
May 14, 2018 at 11:29 pm #83949I said that my values are not the right ones – I just put some values. I hoped that I can put you on track with a quick half-coocked sketch.
You are right – it did send decimal values not hex. And the values were wrong. Attached panel with a slider that is doing what you want. To give a short explanation:
the value range of the parameter (as you described) is 0 to 2047 decimal. This is split into 4 nibbles but in fact you would only need 3 4-bit nibbles to do that. Therefore the highest nibble will be always zero. To understand bitranges use the built-in calculator in Ctrlr. You will see that:
16 values (from 0 to 15) will need 4 bits (2 raised to the exponent of 4)
Add another 4 bits and you get 256 values (0 to 255) – 2 raised to the exponent of 8.
Plus another 4 bits = 4096 values (0 to 4095) = 2 raised to the exponent of 12.Attachments:
You must be logged in to view attached files.May 15, 2018 at 12:05 am #83951Thanks a lot!
I had actually put those values in another version, but I didn’t use that way of writing the hex values, I just typed them directly, would that make a difference? Trying to learn. 🙂
May 15, 2018 at 8:10 am #83953What do you mean by “typing directly” – do you mean my first method without {} brackets?. As you see the difference is that with my first method variables will be sent in decimal which is wrong. I would use the {} brackets like in my example panel. You can use the first method but then you have to make hexstrings out of the variables first.
May 15, 2018 at 6:38 pm #83957Hello again!
By “typing directly” I meant typing “F0 43 10 4C 00 00 00 “..high..mid..low..lowest..” F7″ as opposed to {0xF0, 0x43, 0x10, 0x4C, 0x00, 0x00, 0x00, highest, high, low, lowest, 0xF7}. Also, I was wondering if typing 0xF0 means something different from F0 in this context, or just another syntax.
My understanding is that in the first example I concatenated a string, which CtrlMidiMessage interpreted as such, whereas by typing the values as an array of values, they are converted to individual hexadecimal values by CtrlrMidiMessage.
- This reply was modified 5 years, 10 months ago by eggi.
May 15, 2018 at 8:15 pm #83960yea I would say your conclusion is right. I am no expert and I learned all I know by reading about Lua and studying other panels. That’s why I am often using the abbreviation “AFAIK”.
AFAIK 0x.. means that the following characters will be interpreted as hex numbers. So in the version with {} brackets (which describes an array, or in Lua terminology a table) you are dealing with hex numbers. The other version uses a concatenated string, as you say. So in this version you are using hex strings. In the end the result is the same – that is – if you converted the variables into hex strings first. You can use string.format for this:
string.format(“%.2x”, myVariable)
Google “Lua string.format” to see all the many variations you can do with string.format
May 16, 2018 at 5:57 pm #83974Thanks a lot, Possemo!
I learned a lot with your help. Thanks for the tip with string.format.
-
AuthorPosts
- The forum ‘Panels, Components, Macros’ is closed to new topics and replies.