franta-hg@1
|
1 |
/**
|
franta-hg@1
|
2 |
* SysEx message encoder for Roland MT-32
|
franta-hg@1
|
3 |
* Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
|
franta-hg@1
|
4 |
*
|
franta-hg@1
|
5 |
* This program is free software: you can redistribute it and/or modify
|
franta-hg@1
|
6 |
* it under the terms of the GNU General Public License as published by
|
franta-hg@1
|
7 |
* the Free Software Foundation, version 3 of the License.
|
franta-hg@1
|
8 |
*
|
franta-hg@1
|
9 |
* This program is distributed in the hope that it will be useful,
|
franta-hg@1
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
franta-hg@1
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
franta-hg@1
|
12 |
* GNU General Public License for more details.
|
franta-hg@1
|
13 |
*
|
franta-hg@1
|
14 |
* You should have received a copy of the GNU General Public License
|
franta-hg@1
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
franta-hg@1
|
16 |
*/
|
franta-hg@0
|
17 |
#include <iostream>
|
franta-hg@0
|
18 |
#include <iomanip>
|
franta-hg@0
|
19 |
|
franta-hg@0
|
20 |
/**
|
franta-hg@0
|
21 |
* Translates text from standard input to a hex-formatted System Exclusive (SysEx) message for Roland MT-32,
|
franta-hg@0
|
22 |
* which instructs the unit to show given text on the display.
|
franta-hg@0
|
23 |
*
|
franta-hg@0
|
24 |
* Roland MT-32 is capable to display 20 characters.
|
franta-hg@0
|
25 |
* Longer messages are silently truncated by the MT-32 unit (this software does not check the length).
|
franta-hg@0
|
26 |
*
|
franta-hg@0
|
27 |
* The SysEx message contains a checksum.
|
franta-hg@0
|
28 |
* If the checksum is wrong, the MT-32 unit shows the "Exc. Checksum error" message for few seconds
|
franta-hg@0
|
29 |
* and then returns back to the default screen.
|
franta-hg@0
|
30 |
*
|
franta-hg@0
|
31 |
* Usage:
|
franta-hg@0
|
32 |
* amidi --port="hw:2,0,0" --send-hex="$(echo -n ' Run GNU/Linux ' | ./mt-32-display )"
|
franta-hg@0
|
33 |
*
|
franta-hg@0
|
34 |
* @param argc
|
franta-hg@0
|
35 |
* @param argv
|
franta-hg@0
|
36 |
* @return
|
franta-hg@0
|
37 |
*/
|
franta-hg@0
|
38 |
int main(int argc, char**argv) {
|
franta-hg@0
|
39 |
std::cout << "f0 41 10 16 12 20 00 00 ";
|
franta-hg@0
|
40 |
std::cout << std::hex << std::setfill('0');
|
franta-hg@0
|
41 |
|
franta-hg@0
|
42 |
int sum = 0;
|
franta-hg@0
|
43 |
|
franta-hg@0
|
44 |
// 20 00 00 = display message
|
franta-hg@0
|
45 |
sum += 0x20;
|
franta-hg@0
|
46 |
sum += 0x00;
|
franta-hg@0
|
47 |
sum += 0x00;
|
franta-hg@0
|
48 |
|
franta-hg@0
|
49 |
for (char ch; std::cin.read(&ch, 1).good();) {
|
franta-hg@0
|
50 |
std::cout << std::setw(2) << ((int) ch) << " ";
|
franta-hg@0
|
51 |
sum += ch;
|
franta-hg@0
|
52 |
}
|
franta-hg@0
|
53 |
|
franta-hg@0
|
54 |
sum %= 128;
|
franta-hg@0
|
55 |
sum = 128 - sum;
|
franta-hg@0
|
56 |
std::cout << std::setw(2) << sum;
|
franta-hg@0
|
57 |
std::cout << " f7";
|
franta-hg@0
|
58 |
|
franta-hg@0
|
59 |
std::cout << std::endl;
|
franta-hg@0
|
60 |
return 0;
|
franta-hg@0
|
61 |
}
|