# Tone Function Missing?

**URL:** <https://community.particle.io/t/tone-function-missing/1116>\
**Category:** Getting Started\
**Created:** [December 31, 2013, 3:59pm UTC](https://community.particle.io/t/tone-function-missing/1116 "2013-12-31T15:59:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dom](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dom/32/142_2.png) [@Dom](https://community.particle.io/u/Dom)\
**Post date:** [December 31, 2013, 3:59pm UTC](https://community.particle.io/t/tone-function-missing/1116/1 "2013-12-31T15:59:40Z")

</div>

Hi

I’m a newbie… At least in the world of Arduino… So stick with me. I was going through some Arduino examples on the web and attempting to get them running on the Spark Core. One of them was playing sounds (agreed not necessarily essential but fun). The examples use the Tone() and noTone(). When I attempt to compile this on the web IDE I get

```
../be706443cd7acffa8ea2a9abe8d964e99b36e48df442641d6018afaa0bd2/the_user_app.cpp:16:30: error: 'tone' was not declared in this scope
../be706443cd7acffa8ea2a9abe8d964e99b36e48df442641d6018afaa0bd2/the_user_app.cpp:19:20: error: 'noTone' was not declared in this scope

```

Is this a missing library/function that hasn’t been ported or just something stupid I’m doing.

Thanks…

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [December 31, 2013, 4:10pm UTC](https://community.particle.io/t/tone-function-missing/1116/2 "2013-12-31T16:10:55Z")

</div>

Yup! You got it… I checked here [http://docs.spark.io/#/firmware](http://docs.spark.io/#/firmware) and there’s no **Fun** section. It’s all business… heh heh. I wouldn’t mind having tone() and noTone() functionality as well. It would probably come at the cost of losing a PWM output or two whenever you use tone() but that’s understandable.

If you use the delayMicroseconds() and [direct port manipulation](https://community.spark.io/t/bit-bang-digital-outputs-example/1096) you might be able to roll your own for now though.

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [December 31, 2013, 4:47pm UTC](https://community.particle.io/t/tone-function-missing/1116/3 "2013-12-31T16:47:13Z")

</div>

This might help if you want to play along… heh heh

```
CONSTANT	Freq (Hz)	Period (us)	Period/2 (us)
NOTE_B2 123 8130 4065
NOTE_C3 131 7634 3817
NOTE_CS3	139 7194 3597
NOTE_D3 147 6803 3401
NOTE_DS3	156 6410 3205
NOTE_E3 165 6061 3030
NOTE_F3 175 5714 2857
NOTE_FS3	185 5405 2703
NOTE_G3 196 5102 2551
NOTE_GS3	208 4808 2404
NOTE_A3 220 4545 2273
NOTE_AS3	233 4292 2146
NOTE_B3 247 4049 2024
NOTE_C4 262 3817 1908
NOTE_CS4	277 3610 1805
NOTE_D4 294 3401 1701
NOTE_DS4	311 3215 1608
NOTE_E4 330 3030 1515
NOTE_F4 349 2865 1433
NOTE_FS4	370 2703 1351
NOTE_G4 392 2551 1276
NOTE_GS4	415 2410 1205
NOTE_A4 440 2273 1136
NOTE_AS4	466 2146 1073
NOTE_B4 494 2024 1012
NOTE_C5 523 1912 956
NOTE_CS5	554 1805 903
NOTE_D5 587 1704 852
NOTE_DS5	622 1608 804
NOTE_E5 659 1517 759
NOTE_F5 698 1433 716
NOTE_FS5	740 1351 676
NOTE_G5 784 1276 638
NOTE_GS5	831 1203 602
NOTE_A5 880 1136 568
NOTE_AS5	932 1073 536
NOTE_B5 988 1012 506
NOTE_C6 1047 955 478
NOTE_CS6	1109 902 451
NOTE_D6 1175 851 426
NOTE_DS6	1245 803 402
NOTE_E6 1319 758 379
NOTE_F6 1397 716 358
NOTE_FS6	1480 676 338
NOTE_G6 1568 638 319
NOTE_GS6	1661 602 301
NOTE_A6 1760 568 284
NOTE_AS6	1865 536 268
NOTE_B6 1976 506 253
NOTE_C7 2093 478 239
NOTE_CS7	2217 451 226
NOTE_D7 2349 426 213
NOTE_DS7	2489 402 201
NOTE_E7 2637 379 190
NOTE_F7 2794 358 179
NOTE_FS7	2960 338 169
NOTE_G7 3136 319 159
NOTE_GS7	3322 301 151
NOTE_A7 3520 284 142
NOTE_AS7	3729 268 134
NOTE_B7 3951 253 127
NOTE_C8 4186 239 119
NOTE_CS8	4435 225 113
NOTE_D8 4699 213 106
NOTE_DS8	4978 201 100

```

![](https://sea2.discourse-cdn.com/flex026/uploads/particle/141/fa1a31ff7fcfce89.png)

And code defines:

```
#define NOTE_B2 4065
#define NOTE_C3 3817
#define NOTE_CS3	3597
#define NOTE_D3 3401
#define NOTE_DS3	3205
#define NOTE_E3 3030
#define NOTE_F3 2857
#define NOTE_FS3	2703
#define NOTE_G3 2551
#define NOTE_GS3	2404
#define NOTE_A3 2273
#define NOTE_AS3	2146
#define NOTE_B3 2024
#define NOTE_C4 1908
#define NOTE_CS4	1805
#define NOTE_D4 1701
#define NOTE_DS4	1608
#define NOTE_E4 1515
#define NOTE_F4 1433
#define NOTE_FS4	1351
#define NOTE_G4 1276
#define NOTE_GS4	1205
#define NOTE_A4 1136
#define NOTE_AS4	1073
#define NOTE_B4 1012
#define NOTE_C5 956
#define NOTE_CS5	903
#define NOTE_D5 852
#define NOTE_DS5	804
#define NOTE_E5 759
#define NOTE_F5 716
#define NOTE_FS5	676
#define NOTE_G5 638
#define NOTE_GS5	602
#define NOTE_A5 568
#define NOTE_AS5	536
#define NOTE_B5 506
#define NOTE_C6 478
#define NOTE_CS6	451
#define NOTE_D6 426
#define NOTE_DS6	402
#define NOTE_E6 379
#define NOTE_F6 358
#define NOTE_FS6	338
#define NOTE_G6 319
#define NOTE_GS6	301
#define NOTE_A6 284
#define NOTE_AS6	268
#define NOTE_B6 253
#define NOTE_C7 239
#define NOTE_CS7	226
#define NOTE_D7 213
#define NOTE_DS7	201
#define NOTE_E7 190
#define NOTE_F7 179
#define NOTE_FS7	169
#define NOTE_G7 159
#define NOTE_GS7	151
#define NOTE_A7 142
#define NOTE_AS7	134
#define NOTE_B7 127
#define NOTE_C8 119
#define NOTE_CS8	113
#define NOTE_D8 106
#define NOTE_DS8	100
```

---

<div class="post-metadata">

**Author:** ![zachary](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/zachary/32/20717_2.png) [@zachary](https://community.particle.io/u/zachary)\
**Post date:** [December 31, 2013, 5:25pm UTC](https://community.particle.io/t/tone-function-missing/1116/4 "2013-12-31T17:25:20Z")

</div>

Added tone() and noTone() to the backlog. Thanks guys! As always, pull requests are welcome!

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [January 1, 2014, 8:32am UTC](https://community.particle.io/t/tone-function-missing/1116/5 "2014-01-01T08:32:31Z")

</div>

@Dom I couldn’t help myself… had to make this today:

> **[A Remote RTTTL (RingTone Text Transfer Language) Song Player](https://community.particle.io/t/a-remote-rtttl-ringtone-text-transfer-language-song-player/1149?redirected=true)**
>
> Check out the readme.md on github for all the details and source code: Youtube video in action: Pics:

**Fun Category** [Check!]

---

<div class="post-metadata">

**Author:** ![Dom](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dom/32/142_2.png) [@Dom](https://community.particle.io/u/Dom)\
**Post date:** [January 1, 2014, 9:28am UTC](https://community.particle.io/t/tone-function-missing/1116/6 "2014-01-01T09:28:12Z")

</div>

@BDub I’ll give it a go tonight.

Thanks

---

<div class="post-metadata">

**Author:** ![Dom](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dom/32/142_2.png) [@Dom](https://community.particle.io/u/Dom)\
**Post date:** [January 1, 2014, 8:23pm UTC](https://community.particle.io/t/tone-function-missing/1116/7 "2014-01-01T20:23:05Z")

</div>

Works Great… Rick Rolling away… 😄

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [January 1, 2014, 10:45pm UTC](https://community.particle.io/t/tone-function-missing/1116/8 "2014-01-01T22:45:48Z")

</div>

@Dom Haha nice 🙂 …

---

<div class="post-metadata">

**Author:** ![crow610](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@crow610](https://community.particle.io/u/crow610)\
**Post date:** [January 5, 2014, 9:37am UTC](https://community.particle.io/t/tone-function-missing/1116/9 "2014-01-05T09:37:41Z")

</div>

I JUST RICK ROLL’D MYSELF!!!  
HAHAHAHA

you rock!

---

<div class="post-metadata">

**Author:** ![satishgn](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/satishgn/32/20740_2.png) [@satishgn](https://community.particle.io/u/satishgn)\
**Post date:** [April 21, 2014, 3:42pm UTC](https://community.particle.io/t/tone-function-missing/1116/10 "2014-04-21T15:42:39Z")

</div>

Anyone interested can give this a try:  
[https://github.com/spark/core-firmware/blob/master/src/spark\_wiring\_tone.cpp](https://github.com/spark/core-firmware/blob/master/src/spark_wiring_tone.cpp)

The implementation is based on Timer interrupts using Output Compare Toggle Mode of TIM peripherals. 10 timer mapped pins of the Core can be used to generate tones.

---

<div class="post-metadata">

**Author:** ![dougal](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dougal/32/20713_2.png) [@dougal](https://community.particle.io/u/dougal)\
**Post date:** [April 21, 2014, 9:07pm UTC](https://community.particle.io/t/tone-function-missing/1116/11 "2014-04-21T21:07:05Z")

</div>

Heh, awesome. Back in the days of candybar and flip phones, I spent a lot of time transcribing music into RTTTL so that my wife and I could have custom ringtones without having to buy them at ridiculously inflated prices from our carrier. 😄 I might even still have my notes in the garage from when I did the Star Trek theme, Indiana Jones, and the Emperor’s March from Star Wars.

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [April 21, 2014, 9:33pm UTC](https://community.particle.io/t/tone-function-missing/1116/12 "2014-04-21T21:33:08Z")

</div>

Cool, post 'em up over here if you can dig them out 😄 [https://community.spark.io/t/a-remote-rtttl-ringtone-text-transfer-language-song-player/1149](https://community.spark.io/t/a-remote-rtttl-ringtone-text-transfer-language-song-player/1149)
