Advertisement
ripred

midifile_process.txt

Jul 10th, 2024 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.40 KB | None | 0 0
  1. * **************************************************************************************
  2. * Clone the Repository:
  3. * **************************************************************************************
  4.  
  5. ~ ripred$ cd Documents/Arduino
  6. Arduino ripred$ cd miditones
  7. -bash: cd: miditones: No such file or directory
  8.  
  9. Arduino ripred$ git clone https://github.com/LenShustek/miditones.git
  10. Cloning into 'miditones'...
  11. remote: Enumerating objects: 222, done.
  12. remote: Counting objects: 100% (36/36), done.
  13. remote: Compressing objects: 100% (27/27), done.
  14. remote: Total 222 (delta 12), reused 27 (delta 9), pack-reused 186
  15. Receiving objects: 100% (222/222), 862.23 KiB | 4.31 MiB/s, done.
  16. Resolving deltas: 100% (109/109), done.
  17.  
  18. Arduino ripred$ cd miditones
  19. miditones ripred$ ll
  20. total 632
  21. -rw-r--r-- 1 ripred staff 1.1K Jul 10 18:39 LICENSE.txt
  22. -rw-r--r-- 1 ripred staff 184B Jul 10 18:39 Makefile
  23. -rw-r--r-- 1 ripred staff 14K Jul 10 18:39 README.txt
  24. -rw-r--r-- 1 ripred staff 88K Jul 10 18:39 miditones.c
  25. -rw-r--r-- 1 ripred staff 33K Jul 10 18:39 miditones.exe
  26. -rwxr-xr-x 1 ripred staff 49K Jul 10 18:39 miditones_linux*
  27. -rw-r--r-- 1 ripred staff 25K Jul 10 18:39 miditones_scroll.c
  28. -rw-r--r-- 1 ripred staff 21K Jul 10 18:39 miditones_scroll.exe
  29. -rw-r--r-- 1 ripred staff 18K Jul 10 18:39 miditones_scroll_example.txt
  30. -rwxr-xr-x 1 ripred staff 43K Jul 10 18:39 miditones_scroll_linux*
  31.  
  32. * **************************************************************************************
  33. * Compile the miditones.c file to a binary executable:
  34. * **************************************************************************************
  35.  
  36. miditones ripred$ gcc -o miditones miditones.c
  37. miditones.c:760:37: warning: passing 'unsigned int *' to parameter of type 'int *' converts between pointers to integer types with different sign [-Wpointer-sign]
  38. else if (opt_int(arg, "c", &channel_mask, 1, 0xffff))
  39. ^~~~~~~~~~~~~
  40. miditones.c:686:57: note: passing argument to parameter 'pval' here
  41. bool opt_int(const char* arg, const char* keyword, int *pval, int min, int max) {
  42. ^
  43. miditones.c:943:12: warning: format specifies type 'unsigned long' but the argument has type 'int' [-Wformat]
  44. secs, np->time_usec % 1000000,
  45. ^~~~
  46. /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  47. __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
  48. ^~~~~~~~~~~
  49. miditones.c:943:18: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  50. secs, np->time_usec % 1000000,
  51. ^~~~~~~~~~~~~~~~~~~~~~~
  52. /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  53. __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
  54. ^~~~~~~~~~~
  55. miditones.c:983:12: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  56. output_usec / 1000, output_usec % 1000, queue_numitems, queue_oldest_ndx, queue_newest_ndx);
  57. ^~~~~~~~~~~~~~~~~~
  58. miditones.c:983:32: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  59. output_usec / 1000, output_usec % 1000, queue_numitems, queue_oldest_ndx, queue_newest_ndx);
  60. ^~~~~~~~~~~~~~~~~~
  61. miditones.c:994:73: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  62. fprintf(fid, "*** tone generator status at output time %lu.%03lu\n", output_usec / 1000, output_usec % 1000);
  63. ~~~ ^~~~~~~~~~~~~~~~~~
  64. %u
  65. miditones.c:994:93: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  66. fprintf(fid, "*** tone generator status at output time %lu.%03lu\n", output_usec / 1000, output_usec % 1000);
  67. ~~~~~ ^~~~~~~~~~~~~~~~~~
  68. %03u
  69. miditones.c:1105:33: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  70. output_usec / 1000, output_usec % 1000, describe(&q->note));
  71. ^~~~~~~~~~~~~~~~~~
  72. miditones.c:1105:53: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  73. output_usec / 1000, output_usec % 1000, describe(&q->note));
  74. ^~~~~~~~~~~~~~~~~~
  75. miditones.c:1114:94: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]
  76. if (loggen) fprintf(logfile, " *** this is a consecutive delay, of %d msec\n", delta_msec); }
  77. ~~ ^~~~~~~~~~
  78. %lu
  79. miditones.c:1126:78: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  80. if (loggen) fprintf(logfile, " <-pull from queue at %lu.%03lu msec\n", output_usec / 1000, output_usec % 1000);
  81. ~~~ ^~~~~~~~~~~~~~~~~~
  82. %u
  83. miditones.c:1126:98: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  84. if (loggen) fprintf(logfile, " <-pull from queue at %lu.%03lu msec\n", output_usec / 1000, output_usec % 1000);
  85. ~~~~~ ^~~~~~~~~~~~~~~~~~
  86. %03u
  87. miditones.c:1136:33: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  88. output_usec / 1000, output_usec % 1000, delta_msec,
  89. ^~~~~~~~~~~~~~~~~~
  90. miditones.c:1136:53: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  91. output_usec / 1000, output_usec % 1000, delta_msec,
  92. ^~~~~~~~~~~~~~~~~~
  93. miditones.c:1137:33: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  94. oldtime / 1000, oldtime % 1000, output_deficit_usec); }
  95. ^~~~~~~~~~~~~~
  96. miditones.c:1137:49: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  97. oldtime / 1000, oldtime % 1000, output_deficit_usec); }
  98. ^~~~~~~~~~~~~~
  99. miditones.c:1137:65: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  100. oldtime / 1000, oldtime % 1000, output_deficit_usec); }
  101. ^~~~~~~~~~~~~~~~~~~
  102. miditones.c:1139:35: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  103. output_usec / 1000, output_usec % 1000, oldtime-output_usec, output_deficit_usec);
  104. ^~~~~~~~~~~~~~~~~~
  105. miditones.c:1139:55: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  106. output_usec / 1000, output_usec % 1000, oldtime-output_usec, output_deficit_usec);
  107. ^~~~~~~~~~~~~~~~~~
  108. miditones.c:1139:75: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  109. output_usec / 1000, output_usec % 1000, oldtime-output_usec, output_deficit_usec);
  110. ^~~~~~~~~~~~~~~~~~~
  111. miditones.c:1139:96: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  112. output_usec / 1000, output_usec % 1000, oldtime-output_usec, output_deficit_usec);
  113. ^~~~~~~~~~~~~~~~~~~
  114. miditones.c:1223:30: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  115. horizon - np->time_usec);
  116. ^~~~~~~~~~~~~~~~~~~~~~~
  117. miditones.c:1256:94: warning: format specifies type 'long' but the argument has type 'timestamp' (aka 'unsigned int') [-Wformat]
  118. printf("debug queue %s note %02X at %6ld\n", cmd == CMD_PLAYNOTE ? "PLAY" : "STOP", note, time_usec);
  119. ~~~~ ^~~~~~~~~
  120. %6u
  121. miditones.c:1538:31: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  122. tracknum, timenow_usec / 1000, timenow_usec % 1000, timenow_ticks);
  123. ^~~~~~~~~~~~~~~~~~~
  124. miditones.c:1538:52: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  125. tracknum, timenow_usec / 1000, timenow_usec % 1000, timenow_ticks);
  126. ^~~~~~~~~~~~~~~~~~~
  127. miditones.c:1617:60: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  128. fprintf(logfile, "ending timenow_usec: %lu.%03lu\n", timenow_usec / 1000, timenow_usec % 1000);
  129. ~~~ ^~~~~~~~~~~~~~~~~~~
  130. %u
  131. miditones.c:1617:81: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  132. fprintf(logfile, "ending timenow_usec: %lu.%03lu\n", timenow_usec / 1000, timenow_usec % 1000);
  133. ~~~~~ ^~~~~~~~~~~~~~~~~~~
  134. %03u
  135. miditones.c:1618:60: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  136. fprintf(logfile, "ending output_usec: %lu.%03lu\n", output_usec / 1000, output_usec % 1000); }
  137. ~~~ ^~~~~~~~~~~~~~~~~~
  138. %u
  139. miditones.c:1618:80: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
  140. fprintf(logfile, "ending output_usec: %lu.%03lu\n", output_usec / 1000, output_usec % 1000); }
  141. ~~~~~ ^~~~~~~~~~~~~~~~~~
  142. %03u
  143. 29 warnings generated.
  144.  
  145. miditones ripred$ ll
  146. total 776
  147. -rw-r--r-- 1 ripred staff 1.1K Jul 10 18:39 LICENSE.txt
  148. -rw-r--r-- 1 ripred staff 184B Jul 10 18:39 Makefile
  149. -rw-r--r-- 1 ripred staff 14K Jul 10 18:39 README.txt
  150. -rwxr-xr-x 1 ripred staff 71K Jul 10 18:40 miditones*
  151. -rw-r--r-- 1 ripred staff 88K Jul 10 18:39 miditones.c
  152. -rw-r--r-- 1 ripred staff 33K Jul 10 18:39 miditones.exe
  153. -rwxr-xr-x 1 ripred staff 49K Jul 10 18:39 miditones_linux*
  154. -rw-r--r-- 1 ripred staff 25K Jul 10 18:39 miditones_scroll.c
  155. -rw-r--r-- 1 ripred staff 21K Jul 10 18:39 miditones_scroll.exe
  156. -rw-r--r-- 1 ripred staff 18K Jul 10 18:39 miditones_scroll_example.txt
  157. -rwxr-xr-x 1 ripred staff 43K Jul 10 18:39 miditones_scroll_linux*
  158.  
  159. * **************************************************************************************
  160. * Copy over our midi file into this folder:
  161. * **************************************************************************************
  162.  
  163. miditones ripred$ cp ../miditones_orig/jinglebells.mid .
  164. miditones ripred$ ll
  165. total 792
  166. -rw-r--r-- 1 ripred staff 1.1K Jul 10 18:39 LICENSE.txt
  167. -rw-r--r-- 1 ripred staff 184B Jul 10 18:39 Makefile
  168. -rw-r--r-- 1 ripred staff 14K Jul 10 18:39 README.txt
  169. -rw-r--r--@ 1 ripred staff 4.6K Jul 10 18:40 jinglebells.mid
  170. -rwxr-xr-x 1 ripred staff 71K Jul 10 18:40 miditones*
  171. -rw-r--r-- 1 ripred staff 88K Jul 10 18:39 miditones.c
  172. -rw-r--r-- 1 ripred staff 33K Jul 10 18:39 miditones.exe
  173. -rwxr-xr-x 1 ripred staff 49K Jul 10 18:39 miditones_linux*
  174. -rw-r--r-- 1 ripred staff 25K Jul 10 18:39 miditones_scroll.c
  175. -rw-r--r-- 1 ripred staff 21K Jul 10 18:39 miditones_scroll.exe
  176. -rw-r--r-- 1 ripred staff 18K Jul 10 18:39 miditones_scroll_example.txt
  177. -rwxr-xr-x 1 ripred staff 43K Jul 10 18:39 miditones_scroll_linux*
  178. miditones ripred$
  179.  
  180. * **************************************************************************************
  181. * run the miditones program on the jinglebells.mid file to create a jinglebells.c file:
  182. * **************************************************************************************
  183.  
  184. miditones ripred$
  185. miditones ripred$ ./miditones -t=2 -n=10 jinglebells.mid
  186. MIDITONES V2.4, (C) 2011-2021 Len Shustek
  187. Using 2 tone generators
  188. Processing 2 tracks.
  189. All 2 tone generators were used.
  190. 232 notes were skipped because there weren't enough tone generators.
  191. 62 consecutive delays could be eliminated
  192. 1139 bytes of score data were generated, representing 73.142 seconds of music with 3 tempo changes
  193. Done.
  194. miditones ripred$
  195. miditones ripred$
  196.  
  197. * **************************************************************************************
  198. * examine the contents of the jinglebells.c file:
  199. * **************************************************************************************
  200.  
  201. miditones ripred$
  202. miditones ripred$ cat jinglebells.c
  203. // Playtune bytestream for file "jinglebells.mid" created by MIDITONES V2.4 on Wed Jul 10 18:43:36 2024
  204. // command line: ./miditones -t=2 -n=10 jinglebells
  205. const unsigned char PROGMEM score [] = {
  206. // The Coventry Carol
  207. 0x90,62, 0x91,59, 1,29, 0x90,71, 1,30,
  208. 0x90,69, 1,30, 0x90,67, 1,29, 0x90,62,
  209. 0x91,59, 1,30, 1,30, 1,29, 0x90,62,
  210. 0,143, 0x90,62, 0,143, 0x90,62, 0x91,59,
  211.  
  212. <snipped> ...
  213.  
  214. 0,142, 0x90,72, 0x91,62, 1,30, 0x90,71,
  215. 1,30, 0x90,71, 0x91,62, 1,30, 0x90,71,
  216. 0,142, 0x90,71, 0,143, 0x90,74, 0x91,66,
  217. 1,30, 0x90,74, 1,30, 0x90,72, 0x91,62,
  218. 1,29, 0x90,69, 1,30, 0x90,67, 0x91,59,
  219. 1,30, 1,30, 2,59, 0x80, 0x81, 0xF0};
  220.  
  221. // This 1139 byte score contains 308 notes and uses 2 tone generators
  222. // 232 notes had to be skipped
  223. miditones ripred$
  224.  
  225. * **************************************************************************************
  226. * Create an example jinglebells.ino sketch using that table from the jinglebells.c file:
  227. * **************************************************************************************
  228. miditones ripred$
  229. miditones ripred$ cat jinglebells.ino
  230.  
  231. //*****************************************************************************
  232. //
  233. // Test of playtune library for Arduino NANO
  234. //
  235. // L. Shustek, 31 Jan 2011, initial release.
  236. // L. Shustek, 27 Feb 2011, new score data
  237. // L. Shustek, 6 April 2015; change for compatibility with Arduino IDE v1.6.x
  238. // T. Wasiluk, 28 May 2016; added debug & delay code, moved to examples subdirectory
  239. //
  240. //*****************************************************************************
  241.  
  242. #include <Playtune.h>
  243.  
  244. //------------------------------------------------
  245. // scores are put in program space memory
  246. //------------------------------------------------
  247.  
  248. // Playtune bytestream for file "jinglebells.mid" created by MIDITONES V2.4 on Wed Jul 10 18:43:36 2024
  249. // command line: ./miditones -t=2 -n=10 jinglebells
  250. const unsigned char PROGMEM score [] = {
  251. // The Coventry Carol
  252. 0x90,62, 0x91,59, 1,29, 0x90,71, 1,30,
  253. 0x90,69, 1,30, 0x90,67, 1,29, 0x90,62,
  254. 0x91,59, 1,30, 1,30, 1,29, 0x90,62,
  255. 0,143, 0x90,62, 0,143, 0x90,62, 0x91,59,
  256.  
  257. <snipped for brevity> ...
  258.  
  259. 0,142, 0x90,72, 0x91,62, 1,30, 0x90,71,
  260. 1,30, 0x90,71, 0x91,62, 1,30, 0x90,71,
  261. 0,142, 0x90,71, 0,143, 0x90,74, 0x91,66,
  262. 1,30, 0x90,74, 1,30, 0x90,72, 0x91,62,
  263. 1,29, 0x90,69, 1,30, 0x90,67, 0x91,59,
  264. 1,30, 1,30, 2,59, 0x80, 0x81, 0xF0};
  265.  
  266. // This 1139 byte score contains 308 notes and uses 2 tone generators
  267. // 232 notes had to be skipped
  268.  
  269. Playtune pt;
  270.  
  271. void setup() {
  272.  
  273. // Enable all 2 NANO timers for notes that are output on digital pins 10 and 11.
  274. // Those pins should be wired to 500-ohm resistors, the other ends of which should be connected together
  275. // to one terminal of an 8-ohm speaker. The other terminal of the speaker should be connected to ground.
  276. // No other hardware is needed!
  277.  
  278. pt.tune_initchan (10);
  279. pt.tune_initchan (11);
  280.  
  281. #define DBUG 0
  282. #if DBUG
  283. Serial.begin(9600);
  284. Serial.println("Debug");
  285. #endif
  286.  
  287. }
  288.  
  289. void loop() {
  290.  
  291. pt.tune_playscore (score); /* start playing */
  292. while (pt.tune_playing) ; /* wait here until playing stops */
  293. pt.tune_delay(1000); /* wait a second */
  294.  
  295. }
  296.  
  297.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement