1

I would like to send a MIDI SysEx message like this to my Roland JX8P Synth.

F0 41 36 06 21 20 01 22 1B F7

This message would alter the VCF cutoff frequency of the synth. 1B is a variable hexadecimal value, swinging from 00 to 7F, relative to cutoff frequency.

In the MIDI library I've found the documentation for sending a SysEx message.

sendSysEx (int length, const byte *const array, bool ArrayContainsBoundaries=false)

From what I can tell bool ArrayContainsBoundaries specifies whether or not you want the library to include the F0 and F7 message start/stop tags (I don't so I'll set it to true). Int length denotes the message length in bytes(my message is 10 bytes, so this will be 10).

What I'm confused about is the array. Instead of storing all the values in the array can I just specify them like this?

 MIDI.sendSysEx(10,0xF0 0x41 0x36 0x06 0x21 0x20 0x01 0x22 0x1B 0xF7,true);

Also, is adding the prefix 0x the correct way to specify the bytes here?

4

1 に答える 1

3

基本的な答えは「いいえ」です。

sendSysEx()関数は、2 つまたは 3 つのパラメーターを取得しようとしています。

  • 長さ
  • データの配列
  • 配列に境界が含まれているかどうかのフラグ。これはオプションです。省略した場合、パラメータは false として扱われます

次のように配列データを渡そうとすることによって:

MIDI.sendSysEx(10,0xF0 0x41 0x36 0x06 0x21 0x20 0x01 0x22 0x1B 0xF7,true);

次の 2 つのいずれかを行っています。

  • 上記のように、これは単なる構文エラーです。コンパイラは、何も区切られていない数値リテラルのリストを解析する方法を知りません。
  • 項目をコンマで区切った場合、コンパイラは「ああ、彼は 12 個のパラメーターを渡しています。12 個の整数パラメーターを受け取る関数を探しましょう...ああ、持っていません。申し訳ありません。」と言います。それはあなたのno matching function for call toエラーを与えます。

したがって、関数を呼び出す 1 つの方法は次のようになります。

byte data[] = { 0xF0, 0x41, 0x36, 0x06, 0x21, 0x20, 0x01, 0x22, 0x1B, 0xF7 };
sendSysEx(10, data, true);

C++11 では、関数呼び出しでリストを初期化することで目的に近づけることができsendSysEx(10,{0xF0, 0x41, 0x36, 0x06, 0x21, 0x20, 0x01, 0x22, 0x1B, 0xF7}, true);ます。そのような初期化子リストはints ではなくbytes のリストであり、整数リテラルが 8 ビットであると想定するようにコンパイラに具体的に指示しない限り、これもコンパイラ エラーを引き起こします。

于 2013-03-30T15:31:11.003 に答える