woodenbots
Member
Hello All,
I am working on a project using a Teensy 3.5 and I would like to be able to use the MusicWithoutDelay library in conjunction with a passive piezo buzzer. It seems that this library depends on the Tone.h library by Brett Hagman. To start with I'm attempting to load up and test the "Basic" example sketch for the MusicWithoutDelay library, but while compiling I'm confronted with the following error:
I'm assuming that the lines:
point to the heart of the problem. It appears that the Tone.h library has not been optimized for use with the Teensy platform.
My questions for y'all is would it be possible to easily optimize this library for use with the Teensy? Has this library already been optimized for Teensy and I just missed it in my internet searches? In the alternative, would it be possible to modify the MusicWithoutDelay library to operate independently of the Tone.h library? Or does anyone have any suggestions for a library like MusicWithoutDelay that has already been optimized for use with the Teensy.
Thank you for any assistance that you could provide and please let me know if I need to edit anything or if you need further information.
EDIT:
Here's the exact source code I'm attempting to compile from the MusicWithoutDelay's example folder:
I am working on a project using a Teensy 3.5 and I would like to be able to use the MusicWithoutDelay library in conjunction with a passive piezo buzzer. It seems that this library depends on the Tone.h library by Brett Hagman. To start with I'm attempting to load up and test the "Basic" example sketch for the MusicWithoutDelay library, but while compiling I'm confronted with the following error:
Code:
Arduino: 1.8.5 (Mac OS X), TD: 1.40, Board: "Teensy 3.5, Serial, 120 MHz, Faster, US English"
/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/wittyoctopus/Documents/Arduino/libraries -fqbn=teensy:avr:teensy35:usb=serial,speed=120,opt=o2std,keys=en-us -vid-pid=0X16C0_0X0483 -ide-version=10805 -build-path /var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178 -warnings=default -build-cache /var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_cache_567795 -verbose /Users/wittyoctopus/Documents/Arduino/libraries/MusicWithoutDelay/examples/Basic/Basic.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/wittyoctopus/Documents/Arduino/libraries -fqbn=teensy:avr:teensy35:usb=serial,speed=120,opt=o2std,keys=en-us -vid-pid=0X16C0_0X0483 -ide-version=10805 -build-path /var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178 -warnings=default -build-cache /var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_cache_567795 -verbose /Users/wittyoctopus/Documents/Arduino/libraries/MusicWithoutDelay/examples/Basic/Basic.ino
Using board 'teensy35' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr
Using core 'teensy3' from platform in folder: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr
Detecting libraries used...
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK64FX512__ -DTEENSYDUINO=140 -DARDUINO=10805 -DF_CPU=120000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178/sketch/Basic.ino.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK64FX512__ -DTEENSYDUINO=140 -DARDUINO=10805 -DF_CPU=120000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/wittyoctopus/Documents/Arduino/libraries/MusicWithoutDelay/src" "/var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178/sketch/Basic.ino.cpp" -o "/dev/null"
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK64FX512__ -DTEENSYDUINO=140 -DARDUINO=10805 -DF_CPU=120000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/wittyoctopus/Documents/Arduino/libraries/MusicWithoutDelay/src" "-I/Users/wittyoctopus/Documents/Arduino/libraries/Tone" "/var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178/sketch/Basic.ino.cpp" -o "/dev/null"
Using cached library dependencies for file: /Users/wittyoctopus/Documents/Arduino/libraries/MusicWithoutDelay/src/MusicWithoutDelay.cpp
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK64FX512__ -DTEENSYDUINO=140 -DARDUINO=10805 -DF_CPU=120000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/wittyoctopus/Documents/Arduino/libraries/MusicWithoutDelay/src" "-I/Users/wittyoctopus/Documents/Arduino/libraries/Tone" "/Users/wittyoctopus/Documents/Arduino/libraries/Tone/Tone.cpp" -o "/dev/null"
Generating function prototypes...
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK64FX512__ -DTEENSYDUINO=140 -DARDUINO=10805 -DF_CPU=120000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/wittyoctopus/Documents/Arduino/libraries/MusicWithoutDelay/src" "-I/Users/wittyoctopus/Documents/Arduino/libraries/Tone" "/var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178/sketch/Basic.ino.cpp" -o "/var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178/preproc/ctags_target_for_gcc_minus_e.cpp"
"/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178/preproc/ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK64FX512__ -DTEENSYDUINO=140 -DARDUINO=10805 -DF_CPU=120000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/wittyoctopus/Documents/Arduino/libraries/MusicWithoutDelay/src" "-I/Users/wittyoctopus/Documents/Arduino/libraries/Tone" "/var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178/sketch/Basic.ino.cpp" -o "/var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178/sketch/Basic.ino.cpp.o"
Basic:12: warning: ISO C++ forbids converting a string constant to 'char*'
char *song = ":d=4:c,d,e,f,g,a,b,c1"; //the C major scale. This format is known as RingTone Transfer Language or RTTL(It was used by Nokia's phone company).
^
Compiling libraries...
Compiling library "MusicWithoutDelay"
Using previously compiled file: /var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178/libraries/MusicWithoutDelay/MusicWithoutDelay.cpp.o
Compiling library "Tone"
"/Applications/Arduino.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -fno-exceptions -felide-constructors -std=gnu++14 -fno-rtti -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -D__MK64FX512__ -DTEENSYDUINO=140 -DARDUINO=10805 -DF_CPU=120000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "-I/Users/wittyoctopus/Documents/Arduino/libraries/MusicWithoutDelay/src" "-I/Users/wittyoctopus/Documents/Arduino/libraries/Tone" "/Users/wittyoctopus/Documents/Arduino/libraries/Tone/Tone.cpp" -o "/var/folders/t4/6n9gw0tn5hd0lc9l1jh2jl9m0000gn/T/arduino_build_532178/libraries/Tone/Tone.cpp.o"
/Users/wittyoctopus/Documents/Arduino/libraries/Tone/Tone.cpp:126:4: error: expected constructor, destructor, or type conversion before '(' token
ISR(TIMER0_COMPA_vect)
^
Using library MusicWithoutDelay at version 1.0.0 in folder: /Users/wittyoctopus/Documents/Arduino/libraries/MusicWithoutDelay
Using library Tone at version 1.0.0 in folder: /Users/wittyoctopus/Documents/Arduino/libraries/Tone
Error compiling for board Teensy 3.5.
I'm assuming that the lines:
Code:
/Users/wittyoctopus/Documents/Arduino/libraries/Tone/Tone.cpp:126:4: error: expected constructor, destructor, or type conversion before '(' token
ISR(TIMER0_COMPA_vect)
^
point to the heart of the problem. It appears that the Tone.h library has not been optimized for use with the Teensy platform.
My questions for y'all is would it be possible to easily optimize this library for use with the Teensy? Has this library already been optimized for Teensy and I just missed it in my internet searches? In the alternative, would it be possible to modify the MusicWithoutDelay library to operate independently of the Tone.h library? Or does anyone have any suggestions for a library like MusicWithoutDelay that has already been optimized for use with the Teensy.
Thank you for any assistance that you could provide and please let me know if I need to edit anything or if you need further information.
EDIT:
Here's the exact source code I'm attempting to compile from the MusicWithoutDelay's example folder:
Code:
//Type 's' in serial monitor, you should see something :D (This proves that my library doesn't use delay)
/*Example for the MusicWithoutDelay Library by Nathan Ramanathan. nathan6ramanathan@gmail.com
This simple sketch is the most basic thing my library does effectively.
It plays the C Major scale, with each note being a quarter note.
The song stops playing when the instrument is done playing forward and backward once.
Obviously, you can do other things while the song is being played.
For example, talk to Serial, read buttons, display images on an OLED screen, etc...
*/
//To learn more about this project go to https://github.com/nathanRamaNoodles/MusicWithoutDelay-LIbrary
#include <MusicWithoutDelay.h>
#include <Tone.h> //https://github.com/bhagman/Tone
char *song = ":d=4:c,d,e,f,g,a,b,c1"; //the C major scale. This format is known as RingTone Transfer Language or RTTL(It was used by Nokia's phone company).
MusicWithoutDelay instrument(song); //d=4 means that every note without a number in front of the letter is assumed to be a quarter note.
Tone myTone;
void setup() { //For details on the RTTL format, look at https://github.com/nathanRamaNoodles/MusicWithoutDelay-LIbrary documentation
// put your setup code here, to run once:
myTone.begin(11); //connect speaker with 200 ohm resistor to pin 11.
Serial.begin(9600);
unsigned long t = instrument.getTotalTime(); //spits out total time in milliseconds
Serial.print("Total Time: "); Serial.println(t / 1E3);
}
void loop() {
// put your main code here, to run repeatedly:
unsigned long cMillis = millis(); //I know millis() can be implemented in my library,
instrument.play(cMillis, myTone); //but its important to recognize that this library depends
if (instrument.isEnd()) { //on your main code not having delay(). Also, it increases stability, so your welcome :D
instrument.reverse(); //reverses song when end is reached
}
if (instrument.isStart()) {
instrument.pause(); //stops the song when beginning is reached while song was played backwards
}
if (Serial.available()) {
char str = Serial.read();
switch (str) {
case 's': //type 's' in Serial monitor.
//instrument.skipTo(instrument.getTotalTime() * (0.50)); //skip to halfway point
Serial.println("What's it to ya? I don't use delay, and you shouldn't either.\n Star this project on Github, and spread this good news to others.");
break;
}
}
}
Last edited: