Last active
October 21, 2025 10:07
-
-
Save pschatzmann/0ad6189f42771ac66562d43b41b655d6 to your computer and use it in GitHub Desktop.
Revisions
-
pschatzmann revised this gist
Oct 21, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,7 +42,7 @@ void setup(void) { Serial.println("started..."); } // Arduino loop - play rtttl tune void loop() { rtttl.setTransposeOctaves(-2); rtttl.begin(info); -
pschatzmann revised this gist
Oct 21, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ The examples usually use a __very high pitch__, so I added the functionality to ## Example Arduino Sketch Here is a simple example that uses an AI Thinker AudioKit as output device and the Saxophone provided by STK. The pitch of the example is too high, so we transpose it down by 2 octaves! ```C++ #include "AudioTools.h" -
pschatzmann created this gist
Oct 21, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ Yesterday I was ask to extend my [Arduino AudioTools library](https://github.com/pschatzmann/arduino-audio-tools) to support __RTTTL__. To be honest, I had no clue what this is, so I had to look it up: RTTTL stands for __Ring Tone Text Transfer Language__ and was developed by Nokia to transfer ringtones to cellphones. It basically descibes the notes and durations in simple text form. My library supports [different sound generators](https://pschatzmann.github.io/arduino-audio-tools/group__generator.html) and also provides the [frequencies of all notes](https://pschatzmann.github.io/arduino-audio-tools/classaudio__tools_1_1_musical_notes.html): so all I needed was to provide a parser for RTTTL and link it up with the existing functionality. The new class is called [RTTTOutput](https://pschatzmann.github.io/arduino-audio-tools/classaudio__tools_1_1_r_t_t_t_l_output.html) and you just provide the __generator__ and __output device__ in the constructor and then you can play the audio by printing the RTTTS string. Apart from the simple sound generators, we can use the STKGenerator class which provides access to [all instruments](https://pschatzmann.github.io/arduino-stk/html/classstk_1_1Instrmnt.html) provided by the STK framework. You can find a big collections of ringtones on the internet. Here is the link to one [extensive example collection](https://microblocks.fun/mbtest/NokringTunes.txt). The examples usually use a __very high pitch__, so I added the functionality to transpose the played notes by +-n octaves. ## Example Arduino Sketch Here is a simple example that uses an AI Thinker AudioKit as output device and the Saxophone provided by STK. ```C++ #include "AudioTools.h" #include "AudioTools/AudioLibs/AudioBoardStream.h" #include "AudioTools/AudioLibs/AudioSTK.h" // install https://github.com/pschatzmann/Arduino-STK AudioInfo info(44100, 2, 16); Saxofony instrument(440); // the stk clarinet instrument STKGenerator<Instrmnt, int16_t> generator(instrument); // subclass of SoundGenerator AudioBoardStream out(AudioKitEs8388V1); RTTTLOutput<int16_t> rtttl(generator, out); // Arduino Setup void setup(void) { // Open Serial Serial.begin(115200); AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info); // start I2S Serial.println("starting I2S..."); auto config = out.defaultConfig(TX_MODE); config.copyFrom(info); out.begin(config); // Setup generator generator.begin(info); Serial.println("started..."); } // Arduino loop - copy sound to out void loop() { rtttl.setTransposeOctaves(-2); rtttl.begin(info); rtttl.print("ZoVrolij:d=4,o=5,b=125:8g,8c6,8c6,8c6,8c6,8g,8g,8p,8g,8a,8a,8p,8a,8e,8e,8p,8e,8f,8d,8f,8d,8a,8g,8p,8g,8c,8d,8e,8g,c6,8p,8g,8c6,8c6,8c6,8c6,8g,8g,8p,8g,8a,8a,8p,8a,8e,8e,8p,8e,8f,8d,8f,8d,8a,8g,8p,8g,8c,8d,8e,8g,c6,8p,8c6,8c#6,8c#6,8c#6,8c#6,8g#,8g#,8p,8g#,8a#,8a#,8a#,8a#,8f,8f,8p,8f,8d#,8f,8f#,8d#,8a#,8g#,8p,8g#,8c#,8d#,8f,8g#,c#6,8p,8g#,8c#6,8c#6,8c#6,8c#6,8g#,8g#"); delay(3000); } ```