--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore Tue May 19 16:01:09 2020 +0200
@@ -0,0 +1,4 @@
+syntax: glob
+
+*~
+mt-32-display
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile Tue May 19 16:01:09 2020 +0200
@@ -0,0 +1,10 @@
+mt-32-display: mt-32-display.cpp
+ g++ -o mt-32-display mt-32-display.cpp
+
+clean:
+ rm -f mt-32-display
+
+run: mt-32-display
+ echo -n "ahoj" | ./mt-32-display
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mt-32-display.cpp Tue May 19 16:01:09 2020 +0200
@@ -0,0 +1,45 @@
+#include <iostream>
+#include <iomanip>
+
+/**
+ * Translates text from standard input to a hex-formatted System Exclusive (SysEx) message for Roland MT-32,
+ * which instructs the unit to show given text on the display.
+ *
+ * Roland MT-32 is capable to display 20 characters.
+ * Longer messages are silently truncated by the MT-32 unit (this software does not check the length).
+ *
+ * The SysEx message contains a checksum.
+ * If the checksum is wrong, the MT-32 unit shows the "Exc. Checksum error" message for few seconds
+ * and then returns back to the default screen.
+ *
+ * Usage:
+ * amidi --port="hw:2,0,0" --send-hex="$(echo -n ' Run GNU/Linux ' | ./mt-32-display )"
+ *
+ * @param argc
+ * @param argv
+ * @return
+ */
+int main(int argc, char**argv) {
+ std::cout << "f0 41 10 16 12 20 00 00 ";
+ std::cout << std::hex << std::setfill('0');
+
+ int sum = 0;
+
+ // 20 00 00 = display message
+ sum += 0x20;
+ sum += 0x00;
+ sum += 0x00;
+
+ for (char ch; std::cin.read(&ch, 1).good();) {
+ std::cout << std::setw(2) << ((int) ch) << " ";
+ sum += ch;
+ }
+
+ sum %= 128;
+ sum = 128 - sum;
+ std::cout << std::setw(2) << sum;
+ std::cout << " f7";
+
+ std::cout << std::endl;
+ return 0;
+}