Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * **************************************************************************************
- * Clone the Repository:
- * **************************************************************************************
- ~ ripred$ cd Documents/Arduino
- Arduino ripred$ cd miditones
- -bash: cd: miditones: No such file or directory
- Arduino ripred$ git clone https://github.com/LenShustek/miditones.git
- Cloning into 'miditones'...
- remote: Enumerating objects: 222, done.
- remote: Counting objects: 100% (36/36), done.
- remote: Compressing objects: 100% (27/27), done.
- remote: Total 222 (delta 12), reused 27 (delta 9), pack-reused 186
- Receiving objects: 100% (222/222), 862.23 KiB | 4.31 MiB/s, done.
- Resolving deltas: 100% (109/109), done.
- Arduino ripred$ cd miditones
- miditones ripred$ ll
- total 632
- -rw-r--r-- 1 ripred staff 1.1K Jul 10 18:39 LICENSE.txt
- -rw-r--r-- 1 ripred staff 184B Jul 10 18:39 Makefile
- -rw-r--r-- 1 ripred staff 14K Jul 10 18:39 README.txt
- -rw-r--r-- 1 ripred staff 88K Jul 10 18:39 miditones.c
- -rw-r--r-- 1 ripred staff 33K Jul 10 18:39 miditones.exe
- -rwxr-xr-x 1 ripred staff 49K Jul 10 18:39 miditones_linux*
- -rw-r--r-- 1 ripred staff 25K Jul 10 18:39 miditones_scroll.c
- -rw-r--r-- 1 ripred staff 21K Jul 10 18:39 miditones_scroll.exe
- -rw-r--r-- 1 ripred staff 18K Jul 10 18:39 miditones_scroll_example.txt
- -rwxr-xr-x 1 ripred staff 43K Jul 10 18:39 miditones_scroll_linux*
- * **************************************************************************************
- * Compile the miditones.c file to a binary executable:
- * **************************************************************************************
- miditones ripred$ gcc -o miditones miditones.c
- miditones.c:760:37: warning: passing 'unsigned int *' to parameter of type 'int *' converts between pointers to integer types with different sign [-Wpointer-sign]
- else if (opt_int(arg, "c", &channel_mask, 1, 0xffff))
- ^~~~~~~~~~~~~
- miditones.c:686:57: note: passing argument to parameter 'pval' here
- bool opt_int(const char* arg, const char* keyword, int *pval, int min, int max) {
- ^
- miditones.c:943:12: warning: format specifies type 'unsigned long' but the argument has type 'int' [-Wformat]
- secs, np->time_usec % 1000000,
- ^~~~
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
- __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
- ^~~~~~~~~~~
- miditones.c:943:18: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- secs, np->time_usec % 1000000,
- ^~~~~~~~~~~~~~~~~~~~~~~
- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
- __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
- ^~~~~~~~~~~
- miditones.c:983:12: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- output_usec / 1000, output_usec % 1000, queue_numitems, queue_oldest_ndx, queue_newest_ndx);
- ^~~~~~~~~~~~~~~~~~
- miditones.c:983:32: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- output_usec / 1000, output_usec % 1000, queue_numitems, queue_oldest_ndx, queue_newest_ndx);
- ^~~~~~~~~~~~~~~~~~
- miditones.c:994:73: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- fprintf(fid, "*** tone generator status at output time %lu.%03lu\n", output_usec / 1000, output_usec % 1000);
- ~~~ ^~~~~~~~~~~~~~~~~~
- %u
- miditones.c:994:93: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- fprintf(fid, "*** tone generator status at output time %lu.%03lu\n", output_usec / 1000, output_usec % 1000);
- ~~~~~ ^~~~~~~~~~~~~~~~~~
- %03u
- miditones.c:1105:33: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- output_usec / 1000, output_usec % 1000, describe(&q->note));
- ^~~~~~~~~~~~~~~~~~
- miditones.c:1105:53: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- output_usec / 1000, output_usec % 1000, describe(&q->note));
- ^~~~~~~~~~~~~~~~~~
- miditones.c:1114:94: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]
- if (loggen) fprintf(logfile, " *** this is a consecutive delay, of %d msec\n", delta_msec); }
- ~~ ^~~~~~~~~~
- %lu
- miditones.c:1126:78: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- if (loggen) fprintf(logfile, " <-pull from queue at %lu.%03lu msec\n", output_usec / 1000, output_usec % 1000);
- ~~~ ^~~~~~~~~~~~~~~~~~
- %u
- miditones.c:1126:98: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- if (loggen) fprintf(logfile, " <-pull from queue at %lu.%03lu msec\n", output_usec / 1000, output_usec % 1000);
- ~~~~~ ^~~~~~~~~~~~~~~~~~
- %03u
- miditones.c:1136:33: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- output_usec / 1000, output_usec % 1000, delta_msec,
- ^~~~~~~~~~~~~~~~~~
- miditones.c:1136:53: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- output_usec / 1000, output_usec % 1000, delta_msec,
- ^~~~~~~~~~~~~~~~~~
- miditones.c:1137:33: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- oldtime / 1000, oldtime % 1000, output_deficit_usec); }
- ^~~~~~~~~~~~~~
- miditones.c:1137:49: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- oldtime / 1000, oldtime % 1000, output_deficit_usec); }
- ^~~~~~~~~~~~~~
- miditones.c:1137:65: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- oldtime / 1000, oldtime % 1000, output_deficit_usec); }
- ^~~~~~~~~~~~~~~~~~~
- miditones.c:1139:35: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- output_usec / 1000, output_usec % 1000, oldtime-output_usec, output_deficit_usec);
- ^~~~~~~~~~~~~~~~~~
- miditones.c:1139:55: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- output_usec / 1000, output_usec % 1000, oldtime-output_usec, output_deficit_usec);
- ^~~~~~~~~~~~~~~~~~
- miditones.c:1139:75: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- output_usec / 1000, output_usec % 1000, oldtime-output_usec, output_deficit_usec);
- ^~~~~~~~~~~~~~~~~~~
- miditones.c:1139:96: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- output_usec / 1000, output_usec % 1000, oldtime-output_usec, output_deficit_usec);
- ^~~~~~~~~~~~~~~~~~~
- miditones.c:1223:30: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- horizon - np->time_usec);
- ^~~~~~~~~~~~~~~~~~~~~~~
- miditones.c:1256:94: warning: format specifies type 'long' but the argument has type 'timestamp' (aka 'unsigned int') [-Wformat]
- printf("debug queue %s note %02X at %6ld\n", cmd == CMD_PLAYNOTE ? "PLAY" : "STOP", note, time_usec);
- ~~~~ ^~~~~~~~~
- %6u
- miditones.c:1538:31: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- tracknum, timenow_usec / 1000, timenow_usec % 1000, timenow_ticks);
- ^~~~~~~~~~~~~~~~~~~
- miditones.c:1538:52: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- tracknum, timenow_usec / 1000, timenow_usec % 1000, timenow_ticks);
- ^~~~~~~~~~~~~~~~~~~
- miditones.c:1617:60: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- fprintf(logfile, "ending timenow_usec: %lu.%03lu\n", timenow_usec / 1000, timenow_usec % 1000);
- ~~~ ^~~~~~~~~~~~~~~~~~~
- %u
- miditones.c:1617:81: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- fprintf(logfile, "ending timenow_usec: %lu.%03lu\n", timenow_usec / 1000, timenow_usec % 1000);
- ~~~~~ ^~~~~~~~~~~~~~~~~~~
- %03u
- miditones.c:1618:60: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- fprintf(logfile, "ending output_usec: %lu.%03lu\n", output_usec / 1000, output_usec % 1000); }
- ~~~ ^~~~~~~~~~~~~~~~~~
- %u
- miditones.c:1618:80: warning: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Wformat]
- fprintf(logfile, "ending output_usec: %lu.%03lu\n", output_usec / 1000, output_usec % 1000); }
- ~~~~~ ^~~~~~~~~~~~~~~~~~
- %03u
- 29 warnings generated.
- miditones ripred$ ll
- total 776
- -rw-r--r-- 1 ripred staff 1.1K Jul 10 18:39 LICENSE.txt
- -rw-r--r-- 1 ripred staff 184B Jul 10 18:39 Makefile
- -rw-r--r-- 1 ripred staff 14K Jul 10 18:39 README.txt
- -rwxr-xr-x 1 ripred staff 71K Jul 10 18:40 miditones*
- -rw-r--r-- 1 ripred staff 88K Jul 10 18:39 miditones.c
- -rw-r--r-- 1 ripred staff 33K Jul 10 18:39 miditones.exe
- -rwxr-xr-x 1 ripred staff 49K Jul 10 18:39 miditones_linux*
- -rw-r--r-- 1 ripred staff 25K Jul 10 18:39 miditones_scroll.c
- -rw-r--r-- 1 ripred staff 21K Jul 10 18:39 miditones_scroll.exe
- -rw-r--r-- 1 ripred staff 18K Jul 10 18:39 miditones_scroll_example.txt
- -rwxr-xr-x 1 ripred staff 43K Jul 10 18:39 miditones_scroll_linux*
- * **************************************************************************************
- * Copy over our midi file into this folder:
- * **************************************************************************************
- miditones ripred$ cp ../miditones_orig/jinglebells.mid .
- miditones ripred$ ll
- total 792
- -rw-r--r-- 1 ripred staff 1.1K Jul 10 18:39 LICENSE.txt
- -rw-r--r-- 1 ripred staff 184B Jul 10 18:39 Makefile
- -rw-r--r-- 1 ripred staff 14K Jul 10 18:39 README.txt
- -rw-r--r--@ 1 ripred staff 4.6K Jul 10 18:40 jinglebells.mid
- -rwxr-xr-x 1 ripred staff 71K Jul 10 18:40 miditones*
- -rw-r--r-- 1 ripred staff 88K Jul 10 18:39 miditones.c
- -rw-r--r-- 1 ripred staff 33K Jul 10 18:39 miditones.exe
- -rwxr-xr-x 1 ripred staff 49K Jul 10 18:39 miditones_linux*
- -rw-r--r-- 1 ripred staff 25K Jul 10 18:39 miditones_scroll.c
- -rw-r--r-- 1 ripred staff 21K Jul 10 18:39 miditones_scroll.exe
- -rw-r--r-- 1 ripred staff 18K Jul 10 18:39 miditones_scroll_example.txt
- -rwxr-xr-x 1 ripred staff 43K Jul 10 18:39 miditones_scroll_linux*
- miditones ripred$
- * **************************************************************************************
- * run the miditones program on the jinglebells.mid file to create a jinglebells.c file:
- * **************************************************************************************
- miditones ripred$
- miditones ripred$ ./miditones -t=2 -n=10 jinglebells.mid
- MIDITONES V2.4, (C) 2011-2021 Len Shustek
- Using 2 tone generators
- Processing 2 tracks.
- All 2 tone generators were used.
- 232 notes were skipped because there weren't enough tone generators.
- 62 consecutive delays could be eliminated
- 1139 bytes of score data were generated, representing 73.142 seconds of music with 3 tempo changes
- Done.
- miditones ripred$
- miditones ripred$
- * **************************************************************************************
- * examine the contents of the jinglebells.c file:
- * **************************************************************************************
- miditones ripred$
- miditones ripred$ cat jinglebells.c
- // Playtune bytestream for file "jinglebells.mid" created by MIDITONES V2.4 on Wed Jul 10 18:43:36 2024
- // command line: ./miditones -t=2 -n=10 jinglebells
- const unsigned char PROGMEM score [] = {
- // The Coventry Carol
- 0x90,62, 0x91,59, 1,29, 0x90,71, 1,30,
- 0x90,69, 1,30, 0x90,67, 1,29, 0x90,62,
- 0x91,59, 1,30, 1,30, 1,29, 0x90,62,
- 0,143, 0x90,62, 0,143, 0x90,62, 0x91,59,
- <snipped> ...
- 0,142, 0x90,72, 0x91,62, 1,30, 0x90,71,
- 1,30, 0x90,71, 0x91,62, 1,30, 0x90,71,
- 0,142, 0x90,71, 0,143, 0x90,74, 0x91,66,
- 1,30, 0x90,74, 1,30, 0x90,72, 0x91,62,
- 1,29, 0x90,69, 1,30, 0x90,67, 0x91,59,
- 1,30, 1,30, 2,59, 0x80, 0x81, 0xF0};
- // This 1139 byte score contains 308 notes and uses 2 tone generators
- // 232 notes had to be skipped
- miditones ripred$
- * **************************************************************************************
- * Create an example jinglebells.ino sketch using that table from the jinglebells.c file:
- * **************************************************************************************
- miditones ripred$
- miditones ripred$ cat jinglebells.ino
- //*****************************************************************************
- //
- // Test of playtune library for Arduino NANO
- //
- // L. Shustek, 31 Jan 2011, initial release.
- // L. Shustek, 27 Feb 2011, new score data
- // L. Shustek, 6 April 2015; change for compatibility with Arduino IDE v1.6.x
- // T. Wasiluk, 28 May 2016; added debug & delay code, moved to examples subdirectory
- //
- //*****************************************************************************
- #include <Playtune.h>
- //------------------------------------------------
- // scores are put in program space memory
- //------------------------------------------------
- // Playtune bytestream for file "jinglebells.mid" created by MIDITONES V2.4 on Wed Jul 10 18:43:36 2024
- // command line: ./miditones -t=2 -n=10 jinglebells
- const unsigned char PROGMEM score [] = {
- // The Coventry Carol
- 0x90,62, 0x91,59, 1,29, 0x90,71, 1,30,
- 0x90,69, 1,30, 0x90,67, 1,29, 0x90,62,
- 0x91,59, 1,30, 1,30, 1,29, 0x90,62,
- 0,143, 0x90,62, 0,143, 0x90,62, 0x91,59,
- <snipped for brevity> ...
- 0,142, 0x90,72, 0x91,62, 1,30, 0x90,71,
- 1,30, 0x90,71, 0x91,62, 1,30, 0x90,71,
- 0,142, 0x90,71, 0,143, 0x90,74, 0x91,66,
- 1,30, 0x90,74, 1,30, 0x90,72, 0x91,62,
- 1,29, 0x90,69, 1,30, 0x90,67, 0x91,59,
- 1,30, 1,30, 2,59, 0x80, 0x81, 0xF0};
- // This 1139 byte score contains 308 notes and uses 2 tone generators
- // 232 notes had to be skipped
- Playtune pt;
- void setup() {
- // Enable all 2 NANO timers for notes that are output on digital pins 10 and 11.
- // Those pins should be wired to 500-ohm resistors, the other ends of which should be connected together
- // to one terminal of an 8-ohm speaker. The other terminal of the speaker should be connected to ground.
- // No other hardware is needed!
- pt.tune_initchan (10);
- pt.tune_initchan (11);
- #define DBUG 0
- #if DBUG
- Serial.begin(9600);
- Serial.println("Debug");
- #endif
- }
- void loop() {
- pt.tune_playscore (score); /* start playing */
- while (pt.tune_playing) ; /* wait here until playing stops */
- pt.tune_delay(1000); /* wait a second */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement