0
|
1 |
#include <iostream>
|
|
2 |
#include <iomanip>
|
|
3 |
|
|
4 |
/**
|
|
5 |
* Translates text from standard input to a hex-formatted System Exclusive (SysEx) message for Roland MT-32,
|
|
6 |
* which instructs the unit to show given text on the display.
|
|
7 |
*
|
|
8 |
* Roland MT-32 is capable to display 20 characters.
|
|
9 |
* Longer messages are silently truncated by the MT-32 unit (this software does not check the length).
|
|
10 |
*
|
|
11 |
* The SysEx message contains a checksum.
|
|
12 |
* If the checksum is wrong, the MT-32 unit shows the "Exc. Checksum error" message for few seconds
|
|
13 |
* and then returns back to the default screen.
|
|
14 |
*
|
|
15 |
* Usage:
|
|
16 |
* amidi --port="hw:2,0,0" --send-hex="$(echo -n ' Run GNU/Linux ' | ./mt-32-display )"
|
|
17 |
*
|
|
18 |
* @param argc
|
|
19 |
* @param argv
|
|
20 |
* @return
|
|
21 |
*/
|
|
22 |
int main(int argc, char**argv) {
|
|
23 |
std::cout << "f0 41 10 16 12 20 00 00 ";
|
|
24 |
std::cout << std::hex << std::setfill('0');
|
|
25 |
|
|
26 |
int sum = 0;
|
|
27 |
|
|
28 |
// 20 00 00 = display message
|
|
29 |
sum += 0x20;
|
|
30 |
sum += 0x00;
|
|
31 |
sum += 0x00;
|
|
32 |
|
|
33 |
for (char ch; std::cin.read(&ch, 1).good();) {
|
|
34 |
std::cout << std::setw(2) << ((int) ch) << " ";
|
|
35 |
sum += ch;
|
|
36 |
}
|
|
37 |
|
|
38 |
sum %= 128;
|
|
39 |
sum = 128 - sum;
|
|
40 |
std::cout << std::setw(2) << sum;
|
|
41 |
std::cout << " f7";
|
|
42 |
|
|
43 |
std::cout << std::endl;
|
|
44 |
return 0;
|
|
45 |
}
|