{"id":388851,"date":"2024-06-29T08:13:02","date_gmt":"2024-06-29T08:13:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=388851"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T08:13:02","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=388851","title":{"rendered":"<span>\u041d\u0435\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u043f\u043e\u0442\u0443\u0433\u0438 \u0438\u043b\u0438 \u043a\u0430\u043a \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u043d\u0430 midi-\u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0435 \u0432 \u0441\u0442\u0438\u043b\u0435 linux-way<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/cd8\/473\/fb6\/cd8473fb6d8d4766e47f1ce807bf9c42.jpeg\" width=\"916\" height=\"228\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cd8\/473\/fb6\/cd8473fb6d8d4766e47f1ce807bf9c42.jpeg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043c\u0435\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>M-AUDIO KeyStation 61<\/p>\n<\/li>\n<li>\n<p>Ubuntu 20.04.3 LTS x86_64<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u0435\u043d\u0438\u0435 \u0432 Java<\/p>\n<\/li>\n<li>\n<p>\u0412\u0435\u0447\u043d\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0437\u0430\u043c\u0443\u0442\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0438\u043c\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0435 \u043c\u0435\u043b\u043e\u0434\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 KeyStation c <abbr title=\"Linux MultiMedia Studio\">LMMS<\/abbr><em> <\/em>\u0438\u043b\u0438 \u043b\u044e\u0431\u044b\u043c \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u0438\u043d\u0442\u0435\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u0437\u0432\u0443\u043a \u0441\u043e\u0444\u0442\u043e\u043c<em> <\/em>\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 <em>Windows<\/em>, \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u0442\u0430\u043c \u0432\u0441\u0451 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0444\u0430\u043d\u0430\u0442\u043e\u043c <em>Linux<\/em>, \u0442\u043e \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443 \u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0432\u0435\u0440\u0442\u0435\u0442\u044c\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u043f\u0440\u0438\u0434\u0435\u043b\u0430\u0445 <em>OpenSource \/ Freeware<\/em> \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 <em>Windows-way<\/em> \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e \u043c\u0435\u043d\u044f.<\/p>\n<h4>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h4>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c midi-\u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u043e\u0434\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u041f\u043e\u0442\u043e\u043c \u043f\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0440\u0435\u0432\u043d\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b \u043f\u0430\u043a\u0435\u0442\u044b <em>Ubuntu-Studio<\/em>, \u043d\u043e \u043c\u043e\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0441 \u0430\u0443\u0434\u0438\u043e\u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 <em>Jack<\/em> \u043d\u0435 \u0441\u043b\u043e\u0436\u0438\u043b\u0438\u0441\u044c. \u041d\u043e \u0432 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0432\u0441\u0451 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u043b \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u044b <em>lsusb<\/em> \u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <em>\/dev<\/em> \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0439 \u043c\u0438\u0434\u0438-\u0434\u0435\u0432\u0430\u0439\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043b\u0441\u044f \u043a\u0430\u043a <em>dmmidi1<\/em> (<em> <\/em>\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043b \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0432\u0442\u044b\u043a\u0430-\u0432\u044b\u0442\u044b\u043a\u0430 USB \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0432 \u0445\u0430\u0431 ). \u0418\u0437 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u0441\u0442\u0432\u0430 \u044f \u043e\u0442\u043a\u0440\u044b\u043b \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\u0438\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>cat<\/em>, \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0441 \u0434\u0435\u0432\u0430\u0439\u0441\u043e\u043c, \u0432 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\u0438\u043a\u0435 \u043f\u0440\u043e\u043b\u0435\u0442\u0430\u044e\u0442 \u0431\u0430\u0439\u0442\u0438\u043a\u0438. \u0422\u0443\u0442 \u0443 \u043c\u0435\u043d\u044f \u0438 \u043f\u0440\u043e\u0441\u043a\u043e\u0447\u0438\u043b\u0430 \u043c\u044b\u0441\u043b\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0441 &#171;\u0440\u043e\u0434\u043d\u044b\u043c\u0438&#187; \u0430\u0443\u0434\u0438\u043e \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c\u0438 \u043b\u0438\u043d\u0443\u0445\u0430, \u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u043e\u0439 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u0414\u0430 \u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u043b\u0435\u0442\u0430\u044e\u0449\u0438\u043c\u0438 \u0442\u0430\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043d\u0430\u043a\u0438\u0434\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u0434 \u0447\u0442\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 &#8212;<\/p>\n<pre><code class=\"java\">try {   var fis = new FileInputStream(\"\/dev\/\" + MIDI_DEVICE_NAME);    int data = 0;   int counter = 0;    boolean playOn;    while(data != -1) {     data = fis.read();     System.out.printf(\"--- %d --- %s --- \", ++counter, (char) data);     System.out.println(data);   }    fis.close(); } catch (IOException io){   System.out.println(io.getLocalizedMessage()); }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u0435\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043f\u043e \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0435 &#8212;<\/p>\n<ol>\n<li>\n<p>\u04211 \u04452 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0441\u0438\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u0435,<\/p>\n<\/li>\n<li>\n<p>\u04211 \u04451 c\u0438\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u043b\u0433\u043e\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>D1 \u04451 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>E1 x1 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u0435<\/p>\n<\/li>\n<\/ol>\n<p>\u0413\u0434\u0435 \u043f\u0435\u0440\u0432\u0430\u044f \u0431\u0443\u043a\u0432\u0430 \u044d\u0442\u043e \u043d\u043e\u0442\u0430, \u0430 \u0440\u044f\u0434\u043e\u043c \u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0446\u0438\u0444\u0440\u0430 \u044d\u0442\u043e \u043e\u043a\u0442\u0430\u0432\u0430 (<em> <\/em>\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0435) (<em> <\/em>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0435 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c, \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 ( \u0445\u043e\u0442\u044c \u043a\u0430\u043a \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c \u044d\u0442\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 )<\/p>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u0432 <em>\u0430\u0443\u0442\u043f\u0443\u0442\u0435<\/em> \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 &#8212; <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043b\u043e\u0433<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"1c\">Counter  Char   Byte  --- 1 --- $ --- 36 --- 2 --- j --- 106 --- 3 --- \u0092 --- 146 --- 4 --- $ --- 36 --- 5 ---   --- 0  --- 6 --- \u0092 --- 146 --- 7 --- $ --- 36 --- 8 --- g --- 103 --- 9 --- \u0092 --- 146 --- 10 --- $ --- 36 --- 11 ---   --- 0  --- 12 --- \u0092 --- 146 --- 13 --- $ --- 36 --- 14 --- L --- 76 --- 15 --- \u0092 --- 146 --- 16 --- $ --- 36 --- 17 ---   --- 0  --- 18 --- \u0092 --- 146 --- 19 --- &amp; --- 38 --- 20 --- Z --- 90 --- 21 --- \u0092 --- 146 --- 22 --- &amp; --- 38 --- 23 ---   --- 0  --- 24 --- \u0092 --- 146 --- 25 --- ( --- 40 --- 26 --- b --- 98 --- 27 --- \u0092 --- 146 --- 28 --- ( --- 40 --- 29 ---   --- 0<\/code><\/pre>\n<\/div>\n<\/details>\n<p>( \u041b\u043e\u0433\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u043b \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0447\u0442\u0435\u043d\u0438\u044f )<\/p>\n<p>\u0417\u043d\u0430\u044f \u043a\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u0438 \u043a\u0430\u043a \u043d\u0430\u0436\u0438\u043c\u0430\u043b\u0438\u0441\u044c, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0447\u0442\u043e &#8212; \u0437\u0430 \u043e\u0434\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0435<em> <\/em>(\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u0438\u0434\u0443 \u043f\u043e\u043b\u043d\u043e\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0451\u043d\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 &#8212; \u043a\u043b\u0430\u0432\u0438\u0448\u0430 \u0437\u0430\u0436\u0430\u0442\u0430 \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0442\u043f\u0443\u0449\u0435\u043d\u0430 )<em> <\/em>\u043c\u044b \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e <em>6-\u0431\u0430\u0439\u0442<\/em> \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0438 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f. (\u0432 \u043b\u043e\u0433\u0435 \u044f \u0443\u0436\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u043b \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e 6 \u0441\u0442\u0440\u043e\u043a \u0434\u0430 \u0431\u044b \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0449\u0435 \u0447\u0438\u0442\u0430\u0442\u044c)<em> <\/em>&#8212; \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>112 <\/em>\u043a\u0430\u043a \u044f \u043f\u043e\u043d\u044f\u043b &#8212; \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u043c-\u0442\u043e \u0442\u0438\u043f\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u043a\u0430\u043d\u0430\u043b\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043d\u0435\u0433\u043e &#8212; \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0431\u0430\u0439\u0442\u043e\u043c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>36<\/em>, <em>38<\/em>, <em>40<\/em>, \u0447\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u0435\u0436\u0434\u0443 \u043d\u043e\u0442\u0430\u043c\u0438 <em>\u0421<\/em> \u0438 <em>D<\/em>, <em>D<\/em> \u0438 <em>E<\/em> \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u0438 \u043f\u043e\u043b\u0443\u0442\u043e\u043d\u0430 <em>\u0421#<\/em> \u0438 <em>D#<\/em> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e (<em> <\/em>\u0427\u0435\u0440\u043d\u044b\u0439 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0435 )<em> <\/em>&#8212; \u0422\u0440\u0435\u0442\u044c\u0438\u043c \u0436\u0435 \u0431\u0430\u0439\u0442\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0438\u043b\u0443 \u0443\u0434\u0430\u0440\u0430 \u043f\u043e \u043a\u043b\u0430\u0432\u0438\u0448\u0435, \u0438\u043d\u0430\u0447\u0435 \u0436\u0435 &#8212; \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u043e\u0442\u0443 \u043e\u0442 <em>1<\/em> \u0434\u043e <em>127<\/em>, \u0438 <em>0<\/em> \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0432\u0438\u0448\u0430 \u043e\u0442\u043f\u0443\u0449\u0435\u043d\u0430.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0431\u0430\u0439\u0442<\/p>\n<\/td>\n<td>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0431\u0430\u0439\u0442<\/p>\n<\/td>\n<td>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u0431\u0430\u0439\u0442<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>97-119 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u0430\u043d\u0430\u043b\u0430<\/p>\n<\/td>\n<td>\n<p>24-108 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u043e\u0442\u044b<\/p>\n<\/td>\n<td>\n<p>1-127 &#8212; \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c (velocity)<\/p>\n<p>0 &#8212; \u043a\u043e\u0433\u0434\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u043e\u0442\u043f\u0443\u0449\u0435\u043d\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0417\u043d\u0430\u044f \u0447\u0442\u043e \u0432 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0435 \u0441 Java \u0435\u0441\u0442\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 midi \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043c\u0430\u0433\u0438\u0438 &#171;<em>\u043f\u0440\u043e\u0433\u0440\u0443\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/em>&#171;. &#8212; <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package dev.xred.ServlessMidiSynth;  import java.io.*; import java.util.HashMap;  public class ServerLessMidiSynthesizer {      private static final String MIDI_DEVICE_NAME = \"dmmidi1\";      static HashMap&lt;Byte, Thread> playing = new HashMap&lt;>();      public static void main(String[] args) throws IOException {          SimpleLogger logger = new SimpleLogger(ServerLessMidiSynthesizer.class);          try(var fis = new FileInputStream(\"\/dev\/\" + MIDI_DEVICE_NAME); var buf = new BufferedInputStream(fis)){             byte[] in = buf.readNBytes(3);              while(loop) {                 NotePlayer notePlayer = null;                 Thread thread = null;                 logger.print((in[2] != 0 ? \"pull in \" : \"pull out\") + in[0] + \" \" + in[1] + \" \" + in[2]);              \/\/ C\u043c\u043e\u0442\u0440\u0438\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0438\u0433\u0440\u0430\u0442\u044c \u043d\u043e\u0442\u0443 \u0438\u043b\u0438 \u0436\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439                 if(in[2] != 0 ){                     \/\/ \u0418\u0433\u0440\u0430\u0435\u043c \u043d\u043e\u0442\u0443                     notePlayer = new NotePlayer(in[1], in[2]);                     thread = new Thread(notePlayer);                     thread.start();                     playing.put(in[1], thread);                 } else {                     \/\/\u041f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u043c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u043e\u0442\u044b                     thread = playing.get(in[1]);                      if(thread != null){                         thread.interrupt();                         thread.stop();                          playing.remove(in[1]);                     }                  }                 in = buf.readNBytes(3);             }          } catch (IOException io){             logger.print(io.getLocalizedMessage());         }     } }<\/code><\/pre>\n<pre><code class=\"java\">package dev.xred.ServlessMidiSynth;  import javax.sound.midi.*;  public class NotePlayer implements Runnable {      private int note;     private int velocity;      public boolean playOn;      public NotePlayer(int note, int velocity){         this.note = note;         this.velocity = velocity;     }      public int getNote() {         return note;     }      public int getVelocity() {         return velocity;     }      @Override     public void run()          var midiPlayer = MidiPlayer.getInstance();         var mc = midiPlayer.getMidiChannel();          velocity += 50;         mc.noteOn(note, velocity);        \/\/ \u0421\u0442\u043e\u0438\u0442 \u0442\u0443\u0442 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a, \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b -       \/\/ \u0432\u044b\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0434\u043b\u0438\u043d\u043d\u0443 \u0438\u0433\u0440\u0430\u0435\u043c\u043e\u0439 \u043d\u043e\u0442\u044b         while(!Thread.interrupted());          mc.noteOff(note);     } } <\/code><\/pre>\n<pre><code class=\"java\">package dev.xred.ServlessMidiSynth;  import javax.sound.midi.*;  public class MidiPlayer {      private int lastOutputed = 0;      private static MidiPlayer instance;      private MidiChannel[] mChannels;     private Instrument[] instr;   \/\/ \u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0439\u0434\u044f\u0441\u044c \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 instr     private int instrumentNum = 0;          private MidiPlayer(){         Synthesizer midiSynth = null;          try {             midiSynth = MidiSystem.getSynthesizer();             midiSynth.open();         } catch (MidiUnavailableException e) {             e.printStackTrace();         }          instr = midiSynth.getDefaultSoundbank().getInstruments();         mChannels = midiSynth.getChannels();                if(midiSynth.loadInstrument(instr[instrumentNum])) System.out.println(\"instrument - \" + instrumentNum + \"has been loaded\");;     }      public static MidiPlayer getInstance() {         if(instance == null)             instance = new MidiPlayer();          return instance;     }      public MidiChannel getMidiChannel(){       \/\/ \u041d\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043e\u0441\u0442\u044b\u043b\u044c - \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u043a\u0438\u0434\u0430\u0442\u044c \u0437\u0432\u0443\u043a \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432, \u0442.\u043a.       \/\/ \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0430\u0445(\u0438\u0433\u0440\u0435) \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u0430\u043d\u0430\u043b\u0430       \/\/ \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u0432\u044b\u043b\u0435\u0442\u0430\u043b\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435         if (lastOutputed > 3) lastOutputed = 0;         return mChannels[lastOutputed++];     }  } <\/code><\/pre>\n<\/div>\n<\/details>\n<p>FileInputStream \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0443\u044e \u0441\u0442\u0430\u0434\u0438\u044e, \u0438 \u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 BufferedStream. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a &#171;<em>\u0431\u0443\u0444\u0435\u0440\u043d\u043e\u043c\u0443 \u0447\u0438\u0442\u0430\u043b\u0435<\/em>&#187; \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e <em>3 \u0431\u0430\u0439\u0442\u0430<\/em> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u0442\u0430\u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b. \u0415\u0441\u043b\u0438 \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443, \u0442\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0447\u0435\u0433\u043e \u043d\u0430\u043c \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c. \u0412 \u043f\u043b\u0430\u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043d\u043e\u0442\u044b \u0441\u0434\u0435\u043b\u0430\u043b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <em>NotePlayer<\/em> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 <em>Runnable<\/em>, \u043a\u0443\u0434\u0430 \u0441\u043a\u0438\u0434\u044b\u0432\u0430\u044e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442.\u0435. <em>2<\/em> \u0438 <em>3<\/em> \u0431\u0430\u0439\u0442. \u0417\u0430\u043f\u0438\u0445\u0438\u0432\u0430\u044e \u0432\u0441\u0451 \u0432 \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a, \u0430 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043a \u0432 <em>HashMap <\/em>\u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0441\u043b\u0435\u0436\u0435\u043d\u0438\u044f \u0437\u0430 \u043d\u0438\u043c, \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441 \u0447\u0442\u0435\u043d\u0438\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u044e, \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438 \u043d\u043e\u0442\u0430, \u0438 \u0435\u0441\u043b\u0438 \u0434\u0430, \u043f\u0440\u0438 <em>\u043d\u0443\u043b\u0435<\/em> \u0432 <em>3-\u0435\u043c \u0431\u0430\u0439\u0442\u0435<\/em> \u0432\u044b\u0437\u044b\u0432\u0430\u044e <em>interupt()<\/em>.<\/p>\n<hr\/>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0432 &#171;\u043a\u043e\u043b\u0434\u043e\u0432\u0430\u0442\u044c&#187; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u043b\u0430\u0434\u0438\u0442\u044c\u0441\u044f \u0438\u0433\u0440\u043e\u0439 \u043d\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0435. <\/p>\n<p><a href=\"https:\/\/github.com\/RedFraction\/ServerLessMidiSynthesizer\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 Github-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a><\/p>\n<p>P.S. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ALSA \u0443\u0436\u0435 \u043f\u043e\u0437\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443 \u043a LMMS \u0438 Reaper, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u0440\u0430\u0437\u0443 \u0434\u043e\u0448\u043b\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/583624\/\"> https:\/\/habr.com\/ru\/articles\/583624\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043c\u0435\u0435\u043c:<\/p>\n<ul>\n<li>\n<p>M-AUDIO KeyStation 61<\/p>\n<\/li>\n<li>\n<p>Ubuntu 20.04.3 LTS x86_64<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u0435\u043d\u0438\u0435 \u0432 Java<\/p>\n<\/li>\n<li>\n<p>\u0412\u0435\u0447\u043d\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u0437\u0430\u043c\u0443\u0442\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435 \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0438\u043c\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0435 \u043c\u0435\u043b\u043e\u0434\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 KeyStation c <abbr title=\"Linux MultiMedia Studio\">LMMS<\/abbr><em> <\/em>\u0438\u043b\u0438 \u043b\u044e\u0431\u044b\u043c \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u0438\u043d\u0442\u0435\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u0437\u0432\u0443\u043a \u0441\u043e\u0444\u0442\u043e\u043c<em> <\/em>\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 <em>Windows<\/em>, \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442, \u0442\u0430\u043c \u0432\u0441\u0451 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0444\u0430\u043d\u0430\u0442\u043e\u043c <em>Linux<\/em>, \u0442\u043e \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443 \u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0432\u0435\u0440\u0442\u0435\u0442\u044c\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u043f\u0440\u0438\u0434\u0435\u043b\u0430\u0445 <em>OpenSource \/ Freeware<\/em> \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 <em>Windows-way<\/em> \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e \u043c\u0435\u043d\u044f.<\/p>\n<h4>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u044f<\/h4>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043f\u044b\u0442\u0430\u043b\u0441\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c midi-\u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u043e\u0434\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u041f\u043e\u0442\u043e\u043c \u043f\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0440\u0435\u0432\u043d\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b \u043f\u0430\u043a\u0435\u0442\u044b <em>Ubuntu-Studio<\/em>, \u043d\u043e \u043c\u043e\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0441 \u0430\u0443\u0434\u0438\u043e\u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 <em>Jack<\/em> \u043d\u0435 \u0441\u043b\u043e\u0436\u0438\u043b\u0438\u0441\u044c. \u041d\u043e \u0432 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445 \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0432\u0441\u0451 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u043b \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u044b <em>lsusb<\/em> \u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <em>\/dev<\/em> \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0439 \u043c\u0438\u0434\u0438-\u0434\u0435\u0432\u0430\u0439\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043b\u0441\u044f \u043a\u0430\u043a <em>dmmidi1<\/em> (<em> <\/em>\u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0447\u0442\u043e \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043b \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0432\u0442\u044b\u043a\u0430-\u0432\u044b\u0442\u044b\u043a\u0430 USB \u043f\u0440\u043e\u0432\u043e\u0434\u0430 \u0432 \u0445\u0430\u0431 ). \u0418\u0437 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u0441\u0442\u0432\u0430 \u044f \u043e\u0442\u043a\u0440\u044b\u043b \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\u0438\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>cat<\/em>, \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0441 \u0434\u0435\u0432\u0430\u0439\u0441\u043e\u043c, \u0432 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b\u0438\u043a\u0435 \u043f\u0440\u043e\u043b\u0435\u0442\u0430\u044e\u0442 \u0431\u0430\u0439\u0442\u0438\u043a\u0438. \u0422\u0443\u0442 \u0443 \u043c\u0435\u043d\u044f \u0438 \u043f\u0440\u043e\u0441\u043a\u043e\u0447\u0438\u043b\u0430 \u043c\u044b\u0441\u043b\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0441 &#171;\u0440\u043e\u0434\u043d\u044b\u043c\u0438&#187; \u0430\u0443\u0434\u0438\u043e \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c\u0438 \u043b\u0438\u043d\u0443\u0445\u0430, \u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u043e\u0439 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u0414\u0430 \u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u043b\u0435\u0442\u0430\u044e\u0449\u0438\u043c\u0438 \u0442\u0430\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043d\u0430\u043a\u0438\u0434\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u0434 \u0447\u0442\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 &#8212;<\/p>\n<pre><code class=\"java\">try {   var fis = new FileInputStream(\"\/dev\/\" + MIDI_DEVICE_NAME);    int data = 0;   int counter = 0;    boolean playOn;    while(data != -1) {     data = fis.read();     System.out.printf(\"--- %d --- %s --- \", ++counter, (char) data);     System.out.println(data);   }    fis.close(); } catch (IOException io){   System.out.println(io.getLocalizedMessage()); }<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u0435\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043f\u043e \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0435 &#8212;<\/p>\n<ol>\n<li>\n<p>\u04211 \u04452 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0441\u0438\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u0435,<\/p>\n<\/li>\n<li>\n<p>\u04211 \u04451 c\u0438\u043b\u044c\u043d\u043e\u0435 \u0434\u043e\u043b\u0433\u043e\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>D1 \u04451 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>E1 x1 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u0435<\/p>\n<\/li>\n<\/ol>\n<p>\u0413\u0434\u0435 \u043f\u0435\u0440\u0432\u0430\u044f \u0431\u0443\u043a\u0432\u0430 \u044d\u0442\u043e \u043d\u043e\u0442\u0430, \u0430 \u0440\u044f\u0434\u043e\u043c \u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0446\u0438\u0444\u0440\u0430 \u044d\u0442\u043e \u043e\u043a\u0442\u0430\u0432\u0430 (<em> <\/em>\u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0435) (<em> <\/em>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0435 \u0441\u0442\u043e\u0438\u0442 \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c, \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 ( \u0445\u043e\u0442\u044c \u043a\u0430\u043a \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c \u044d\u0442\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 )<\/p>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u0432 <em>\u0430\u0443\u0442\u043f\u0443\u0442\u0435<\/em> \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 &#8212; <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043b\u043e\u0433<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"1c\">Counter  Char   Byte  --- 1 --- $ --- 36 --- 2 --- j --- 106 --- 3 --- \u0092 --- 146 --- 4 --- $ --- 36 --- 5 ---   --- 0  --- 6 --- \u0092 --- 146 --- 7 --- $ --- 36 --- 8 --- g --- 103 --- 9 --- \u0092 --- 146 --- 10 --- $ --- 36 --- 11 ---   --- 0  --- 12 --- \u0092 --- 146 --- 13 --- $ --- 36 --- 14 --- L --- 76 --- 15 --- \u0092 --- 146 --- 16 --- $ --- 36 --- 17 ---   --- 0  --- 18 --- \u0092 --- 146 --- 19 --- &amp; --- 38 --- 20 --- Z --- 90 --- 21 --- \u0092 --- 146 --- 22 --- &amp; --- 38 --- 23 ---   --- 0  --- 24 --- \u0092 --- 146 --- 25 --- ( --- 40 --- 26 --- b --- 98 --- 27 --- \u0092 --- 146 --- 28 --- ( --- 40 --- 29 ---   --- 0<\/code><\/pre>\n<\/div>\n<\/details>\n<p>( \u041b\u043e\u0433\u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u043b \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0447\u0442\u0435\u043d\u0438\u044f )<\/p>\n<p>\u0417\u043d\u0430\u044f \u043a\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u0438 \u043a\u0430\u043a \u043d\u0430\u0436\u0438\u043c\u0430\u043b\u0438\u0441\u044c, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u0447\u0442\u043e &#8212; \u0437\u0430 \u043e\u0434\u043d\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0435<em> <\/em>(\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u0438\u0434\u0443 \u043f\u043e\u043b\u043d\u043e\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0451\u043d\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 &#8212; \u043a\u043b\u0430\u0432\u0438\u0448\u0430 \u0437\u0430\u0436\u0430\u0442\u0430 \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0442\u043f\u0443\u0449\u0435\u043d\u0430 )<em> <\/em>\u043c\u044b \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e <em>6-\u0431\u0430\u0439\u0442<\/em> \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0438 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f. (\u0432 \u043b\u043e\u0433\u0435 \u044f \u0443\u0436\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u043b \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e 6 \u0441\u0442\u0440\u043e\u043a \u0434\u0430 \u0431\u044b \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0449\u0435 \u0447\u0438\u0442\u0430\u0442\u044c)<em> <\/em>&#8212; \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>112 <\/em>\u043a\u0430\u043a \u044f \u043f\u043e\u043d\u044f\u043b &#8212; \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u043c-\u0442\u043e \u0442\u0438\u043f\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u043a\u0430\u043d\u0430\u043b\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043d\u0435\u0433\u043e &#8212; \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0431\u0430\u0439\u0442\u043e\u043c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>36<\/em>, <em>38<\/em>, <em>40<\/em>, \u0447\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u0435\u0436\u0434\u0443 \u043d\u043e\u0442\u0430\u043c\u0438 <em>\u0421<\/em> \u0438 <em>D<\/em>, <em>D<\/em> \u0438 <em>E<\/em> \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u0438 \u043f\u043e\u043b\u0443\u0442\u043e\u043d\u0430 <em>\u0421#<\/em> \u0438 <em>D#<\/em> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e (<em> <\/em>\u0427\u0435\u0440\u043d\u044b\u0439 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0435 )<em> <\/em>&#8212; \u0422\u0440\u0435\u0442\u044c\u0438\u043c \u0436\u0435 \u0431\u0430\u0439\u0442\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0438\u043b\u0443 \u0443\u0434\u0430\u0440\u0430 \u043f\u043e \u043a\u043b\u0430\u0432\u0438\u0448\u0435, \u0438\u043d\u0430\u0447\u0435 \u0436\u0435 &#8212; \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u043e\u0442\u0443 \u043e\u0442 <em>1<\/em> \u0434\u043e <em>127<\/em>, \u0438 <em>0<\/em> \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0432\u0438\u0448\u0430 \u043e\u0442\u043f\u0443\u0449\u0435\u043d\u0430.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0431\u0430\u0439\u0442<\/p>\n<\/td>\n<td>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0431\u0430\u0439\u0442<\/p>\n<\/td>\n<td>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u0431\u0430\u0439\u0442<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>97-119 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043a\u0430\u043d\u0430\u043b\u0430<\/p>\n<\/td>\n<td>\n<p>24-108 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u043e\u0442\u044b<\/p>\n<\/td>\n<td>\n<p>1-127 &#8212; \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u044c (velocity)<\/p>\n<p>0 &#8212; \u043a\u043e\u0433\u0434\u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u043e\u0442\u043f\u0443\u0449\u0435\u043d\u0430<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0417\u043d\u0430\u044f \u0447\u0442\u043e \u0432 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0435 \u0441 Java \u0435\u0441\u0442\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 midi \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043c\u0430\u0433\u0438\u0438 &#171;<em>\u043f\u0440\u043e\u0433\u0440\u0443\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/em>&#171;. &#8212; <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0439\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package dev.xred.ServlessMidiSynth;  import java.io.*; import java.util.HashMap;  public class ServerLessMidiSynthesizer {      private static final String MIDI_DEVICE_NAME = \"dmmidi1\";      static HashMap&lt;Byte, Thread> playing = new HashMap&lt;>();      public static void main(String[] args) throws IOException {          SimpleLogger logger = new SimpleLogger(ServerLessMidiSynthesizer.class);          try(var fis = new FileInputStream(\"\/dev\/\" + MIDI_DEVICE_NAME); var buf = new BufferedInputStream(fis)){             byte[] in = buf.readNBytes(3);              while(loop) {                 NotePlayer notePlayer = null;                 Thread thread = null;                 logger.print((in[2] != 0 ? \"pull in \" : \"pull out\") + in[0] + \" \" + in[1] + \" \" + in[2]);              \/\/ C\u043c\u043e\u0442\u0440\u0438\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043d\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0438\u0433\u0440\u0430\u0442\u044c \u043d\u043e\u0442\u0443 \u0438\u043b\u0438 \u0436\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439                 if(in[2] != 0 ){                     \/\/ \u0418\u0433\u0440\u0430\u0435\u043c \u043d\u043e\u0442\u0443                     notePlayer = new NotePlayer(in[1], in[2]);                     thread = new Thread(notePlayer);                     thread.start();                     playing.put(in[1], thread);                 } else {                     \/\/\u041f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u043c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u043e\u0442\u044b                     thread = playing.get(in[1]);                      if(thread != null){                         thread.interrupt();                         thread.stop();                          playing.remove(in[1]);                     }                  }                 in = buf.readNBytes(3);             }          } catch (IOException io){             logger.print(io.getLocalizedMessage());         }     } }<\/code><\/pre>\n<pre><code class=\"java\">package dev.xred.ServlessMidiSynth;  import javax.sound.midi.*;  public class NotePlayer implements Runnable {      private int note;     private int velocity;      public boolean playOn;      public NotePlayer(int note, int velocity){         this.note = note;         this.velocity = velocity;     }      public int getNote() {         return note;     }      public int getVelocity() {         return velocity;     }      @Override     public void run()          var midiPlayer = MidiPlayer.getInstance();         var mc = midiPlayer.getMidiChannel();          velocity += 50;         mc.noteOn(note, velocity);        \/\/ \u0421\u0442\u043e\u0438\u0442 \u0442\u0443\u0442 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a, \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b -       \/\/ \u0432\u044b\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0434\u043b\u0438\u043d\u043d\u0443 \u0438\u0433\u0440\u0430\u0435\u043c\u043e\u0439 \u043d\u043e\u0442\u044b         while(!Thread.interrupted());          mc.noteOff(note);     } } <\/code><\/pre>\n<pre><code class=\"java\">package dev.xred.ServlessMidiSynth;  import javax.sound.midi.*;  public class MidiPlayer {      private int lastOutputed = 0;      private static MidiPlayer instance;      private MidiChannel[] mChannels;     private Instrument[] instr;   \/\/ \u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0439\u0434\u044f\u0441\u044c \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 instr     private int instrumentNum = 0;          private MidiPlayer(){         Synthesizer midiSynth = null;          try {             midiSynth = MidiSystem.getSynthesizer();             midiSynth.open();         } catch (MidiUnavailableException e) {             e.printStackTrace();         }          instr = midiSynth.getDefaultSoundbank().getInstruments();         mChannels = midiSynth.getChannels();                if(midiSynth.loadInstrument(instr[instrumentNum])) System.out.println(\"instrument - \" + instrumentNum + \"has been loaded\");;     }      public static MidiPlayer getInstance() {         if(instance == null)             instance = new MidiPlayer();          return instance;     }      public MidiChannel getMidiChannel(){       \/\/ \u041d\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u043e\u0441\u0442\u044b\u043b\u044c - \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u043a\u0438\u0434\u0430\u0442\u044c \u0437\u0432\u0443\u043a \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043d\u0430\u043b\u043e\u0432, \u0442.\u043a.       \/\/ \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0430\u0445(\u0438\u0433\u0440\u0435) \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u0430\u043d\u0430\u043b\u0430       \/\/ \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u0432\u044b\u043b\u0435\u0442\u0430\u043b\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435         if (lastOutputed > 3) lastOutputed = 0;         return mChannels[lastOutputed++];     }  } <\/code><\/pre>\n<\/div>\n<\/details>\n<p>FileInputStream \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0443\u044e \u0441\u0442\u0430\u0434\u0438\u044e, \u0438 \u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 BufferedStream. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a &#171;<em>\u0431\u0443\u0444\u0435\u0440\u043d\u043e\u043c\u0443 \u0447\u0438\u0442\u0430\u043b\u0435<\/em>&#187; \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e <em>3 \u0431\u0430\u0439\u0442\u0430<\/em> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u0442\u0430\u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b. \u0415\u0441\u043b\u0438 \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443, \u0442\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u0447\u0435\u0433\u043e \u043d\u0430\u043c \u043f\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c. \u0412 \u043f\u043b\u0430\u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043d\u043e\u0442\u044b \u0441\u0434\u0435\u043b\u0430\u043b \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <em>NotePlayer<\/em> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 <em>Runnable<\/em>, \u043a\u0443\u0434\u0430 \u0441\u043a\u0438\u0434\u044b\u0432\u0430\u044e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442.\u0435. <em>2<\/em> \u0438 <em>3<\/em> \u0431\u0430\u0439\u0442. \u0417\u0430\u043f\u0438\u0445\u0438\u0432\u0430\u044e \u0432\u0441\u0451 \u0432 \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a, \u0430 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043a \u0432 <em>HashMap <\/em>\u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0441\u043b\u0435\u0436\u0435\u043d\u0438\u044f \u0437\u0430 \u043d\u0438\u043c, \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441 \u0447\u0442\u0435\u043d\u0438\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u044e, \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043b\u0438 \u043d\u043e\u0442\u0430, \u0438 \u0435\u0441\u043b\u0438 \u0434\u0430, \u043f\u0440\u0438 <em>\u043d\u0443\u043b\u0435<\/em> \u0432 <em>3-\u0435\u043c \u0431\u0430\u0439\u0442\u0435<\/em> \u0432\u044b\u0437\u044b\u0432\u0430\u044e <em>interupt()<\/em>.<\/p>\n<hr\/>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0432 &#171;\u043a\u043e\u043b\u0434\u043e\u0432\u0430\u0442\u044c&#187; \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u043b\u0430\u0434\u0438\u0442\u044c\u0441\u044f \u0438\u0433\u0440\u043e\u0439 \u043d\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0435. <\/p>\n<p><a href=\"https:\/\/github.com\/RedFraction\/ServerLessMidiSynthesizer\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 Github-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a><\/p>\n<p>P.S. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ALSA \u0443\u0436\u0435 \u043f\u043e\u0437\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443 \u043a LMMS \u0438 Reaper, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u0440\u0430\u0437\u0443 \u0434\u043e\u0448\u043b\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/583624\/\"> https:\/\/habr.com\/ru\/articles\/583624\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-388851","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/388851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=388851"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/388851\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=388851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=388851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=388851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}