Coder Social home page Coder Social logo

esp32_rtttl's Introduction

Play RTTTL (Nokia Ringtones)

Plays an RTTTL string via a piezo speaker using PWM.

LED will blink on/off with each note.

  1. Set target : idf.py set-target esp32s2
  2. Choose GPIO pins: idf.py menuconfig ...see RTTTL Configuration
  3. Build demo : idf.py build
  4. Flash to ESP32 : idf.py -p /dev/ttyUSB0 -b 115200 flash

Here are 10,825 example RTTTL tunes also available on archive.org

RTTTL Format Specification

RTTTL (RingTone Text Transfer Language) is the primary format used to distribute 
ringtones for Nokia phones. 

An RTTTL file is a text file, containing three colon-separated sections:
	# ringtone name
	# control section
	# comma separated sequence of tone commands
Arbitrary use of whitespace is valid.

Format
	[name]:[control[,control[,control]]]:tone[,tone[,...]]

	name    : ASCII ringtone name, max 10 characters

	control : tag=val
		tag : b = BPM*                  .. see below*      default = 63
		      d = default tone Duration .. {1,2,4,8,16,32} default = 4
		      o = default tone Octave   .. {4,5,6,7}       default = 6
			  
		* A "beat" is (generally) a "quarter note" 
		  Valid BPMs are { 25,  28,  31,  35,  40,  45,  50,  56,  63,
		                   70,  80,  90, 100, 112, 125, 140, 160, 180,
		                  200, 225, 250, 285, 320, 355, 400, 450, 500,
		                  565, 635, 715, 800, 900}

	tone     : [dur]note[oct][dot]
		dur  = note duration {1,2,4,8,16,32} .. 4=one-beat, 8=half-beat, etc.
		note = note name {a,a#,b,c,c#,d,d#,e,f,f#,g,g#,p} .. p = pause/rest
		oct  = octave {4,5,6,7} .. A4 = 440Hz*
		dot  = increase duration by 50%

		* Total note range (of Nokia 61xx) is {a4..b7} (39 notes)

	Example: 
		Simpsons : d=4,o=5,b=160 : 32p,c.6,e6,f#6,8a6,g.6,e6,c6,8a,8f#,8f#,8f#,2g

Wiring

The default code uses the onboard LED to flash when notes are played.

The only thing you need to do is add a Piezo Buzzer:

ESP32/GPIO:2 --[red]--> 220ohm resistor ----> Piezo Buzzer --[black]--> Gnd

...I'm not convinced the resistor is necessary, but probably safer that way.

Notes

I'm new to the ESP IDF, so I don't really know what most of the files are that I inherited from using the 'blink' example as a starting point ...All the real work is in main/rtttl.c

esp32_rtttl's People

Contributors

csbluechip avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.