Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaxori/rtttl-player
The player converts a music string in "Ring Tone Text Transfer Language" code into pitch and duration.
https://github.com/kaxori/rtttl-player
esp32 toit
Last synced: about 2 months ago
JSON representation
The player converts a music string in "Ring Tone Text Transfer Language" code into pitch and duration.
- Host: GitHub
- URL: https://github.com/kaxori/rtttl-player
- Owner: kaxori
- License: mit
- Created: 2024-04-28T20:48:00.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-04-28T21:39:33.000Z (5 months ago)
- Last Synced: 2024-04-29T22:10:18.099Z (5 months ago)
- Topics: esp32, toit
- Language: Toit
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RTTTL-PLAYER
The player converts a music string in "Ring Tone Text Transfer Language" code into pitch and duration.Inspired by the idea of reusing the piezo detectors contained in discarded smoke detectors,
the desire to play melodies arose.The rtttl-player converts the RTTTL melody string into a Tone list. Regular expressions (=> dartino_regexp pkg) is used to analyse the music string.
A user defined tone player (lamdba function) is intented to control your own device.
# Installation
```bash
jag pkg install github.com/kaxori/rtttl-player
```# Usage
```toit
import rtttl-player show *
import gpio show Pin
import gpio.pwm show PwmGPIO_BUZZER ::= 16
BUZZER ::= Pin GPIO_BUZZERplay-host pitch duration:
print "pitch: $(%5d pitch), duration: $duration ms"play-buzzer freq length:
if freq > 0: // play tone
melody_pwm := Pwm --frequency=freq
melody_channel := melody_pwm.start BUZZER
melody_channel.set_duty_factor 0.5
sleep --ms=length
melody_pwm.close
else: // pause
sleep --ms=lengthmain:
SMOKE ::= "smoke:o=5,d=4,b=130:c,d#,f.,c,d#,8f#,f,p,c,d#,f.,d#,c,2p,8p,c,d#,f.,c,d#,8f#,f,p,c,d#,f.,d#,c"
rtttl := rtttl-player (:: | pitch duration | play-buzzer pitch duration )
rtttl.play SMOKE
```# References
Wiki RTTTL: https://de.wikipedia.org/wiki/Ring_Tones_Text_Transfer_Language
RTTTL Format Specifications: http://merwin.bespin.org/t4a/specs/nokia_rtttl.txt
To play RTTTL online: https://adamonsoon.github.io/rtttl-play/
Collection of melodies: https://1j01.github.io/rtttl.js/
Toit regexp package: https://pkg.toit.io/package/github.com%2Ferikcorry%[email protected]
Online RegExp tester: https://regex101.com/