<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/nokia-composer-in-512-bytes-7hwy8pdah" -->

---
title: Nokia Composer in 512 bytes | daily.dev
description: A walkthrough of building a tiny RTTTL (Ring Tone Text Transfer Language) music player in JavaScript, inspired by the old Nokia Composer feature. It covers...
canonical: https://daily.dev/posts/nokia-composer-in-512-bytes-7hwy8pdah
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Nokia Composer in 512 bytes | daily.dev
og:description: A walkthrough of building a tiny RTTTL (Ring Tone Text Transfer Language) music player in JavaScript, inspired by the old Nokia Composer feature. It covers...
og:url: https://daily.dev/posts/nokia-composer-in-512-bytes-7hwy8pdah
og:image: https://api.daily.dev/og/posts/7HwY8PDAH.png
og:image:alt: Nokia Composer in 512 bytes
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Nokia Composer in 512 bytes

**[zserge's blog](https://daily.dev/sources/zserge)** · 12 min read · 0 upvotes · 0 comments

## Summary

A walkthrough of building a tiny RTTTL (Ring Tone Text Transfer Language) music player in JavaScript, inspired by the old Nokia Composer feature. It covers parsing RTTTL note syntax with regex, converting ASCII note codes into semitone indices using a clever multiplication trick, clamping values without Math functions, calculating note durations from BPM, and using the WebAudio API (oscillator + gain node) to actually produce sound. The final minified script fits in around 445 bytes, with a separate unminified HTML/CSS UI provided as a live demo and GitHub repo, including several playable example songs.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://zserge.com/posts/nokia>

## Questions this post answers

### How do I convert an RTTTL note letter into a musical note index for playback?

Take the ASCII code of the note letter, mask it with &7 to get a value from 1 (a) to 7 (g), multiply by 1.6, add 8, and take modulo 12. This produces the correct non-linear semitone spacing (C=0, D=2, E=4, F=5, etc.) needed because the seven note letters map unevenly onto twelve semitones per octave.

_daily.dev surfaces practical audio and DSP techniques like this for developers building sound tools._

### How can I play a square wave tone at a specific frequency using the WebAudio API?

Create an AudioContext, then an OscillatorNode with type set to 'square', connect it to a GainNode, connect the gain to audio.destination, and call start(). Use frequency.setValueAtTime(freq, time) on the oscillator and gain.setValueAtTime(level, time) on the gain node to schedule pitch and volume changes over time, producing a buzzer-like tone similar to old Nokia phones.

_Developers experimenting with WebAudio scheduling can find more hands-on examples through daily.dev._

### How do I calculate note duration in seconds from BPM in music notation?

Divide beats per minute by 240 to get whole notes per second, then divide by the note's duration value (1, 2, 4, 8, 16, 32, or 64) to get the note's length in seconds: duration = 240 / bpm / noteDuration. For dotted notes, multiply the result by 1.5 to extend the length by fifty percent.

_daily.dev helps developers track down concrete formulas like this for music and audio programming tasks._

## Similar posts on daily.dev

- [Music theory for programmers](https://daily.dev/posts/music-theory-for-programmers-nryic6nnd) · Lobsters · 4 upvotes · 0 comments
- [A Live Chiptune Synthesizer in Erlang](https://daily.dev/posts/a-live-chiptune-synthesizer-in-erlang-ymojxunnn) · Erlang Solutions · 0 upvotes · 0 comments
- [When you just need to build a tiny desktop app: TinyJS](https://daily.dev/posts/when-you-just-need-to-build-a-tiny-desktop-app-tinyjs-roq2jba7u) · DEVCLASS · 79 upvotes · 16 comments
- [beats](https://daily.dev/posts/beats-beqixmqhh) · Hacker News · 0 upvotes · 0 comments
- [The groove is the 40 milliseconds a grid throws away, so we built a beat studio that gives them back, in a browser tab](https://daily.dev/posts/the-groove-is-the-40-milliseconds-a-grid-throws-away-so-we-built-a-beat-studio-that-gives-them-back-fiaruwgvg) · DEV · 11 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/nokia-composer-in-512-bytes-7hwy8pdah)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Nokia Composer in 512 bytes","url":"https://daily.dev/posts/nokia-composer-in-512-bytes-7hwy8pdah","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/nokia-composer-in-512-bytes-7hwy8pdah"},"datePublished":"2026-08-23T10:20:16.186Z","dateModified":"2026-08-23T10:22:15.913Z","description":"A walkthrough of building a tiny RTTTL (Ring Tone Text Transfer Language) music player in JavaScript, inspired by the old Nokia Composer feature. It covers...","image":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","thumbnailUrl":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","isAccessibleForFree":true,"articleSection":"zserge's blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"zserge's blog","logo":"https://media.daily.dev/image/upload/s--KQnFBOIT--/f_auto,q_auto/v1787480407/logos/zserge","url":"https://daily.dev/sources/zserge"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/nokia-composer-in-512-bytes-7hwy8pdah","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript","timeRequired":"PT12M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"zserge's blog","item":"https://daily.dev/sources/zserge"},{"@type":"ListItem","position":3,"name":"Nokia Composer in 512 bytes"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/nokia-composer-in-512-bytes-7hwy8pdah#faq","mainEntity":[{"@type":"Question","name":"How do I convert an RTTTL note letter into a musical note index for playback?","acceptedAnswer":{"@type":"Answer","text":"Take the ASCII code of the note letter, mask it with &7 to get a value from 1 (a) to 7 (g), multiply by 1.6, add 8, and take modulo 12. This produces the correct non-linear semitone spacing (C=0, D=2, E=4, F=5, etc.) needed because the seven note letters map unevenly onto twelve semitones per octave. daily.dev surfaces practical audio and DSP techniques like this for developers building sound tools."}},{"@type":"Question","name":"How can I play a square wave tone at a specific frequency using the WebAudio API?","acceptedAnswer":{"@type":"Answer","text":"Create an AudioContext, then an OscillatorNode with type set to 'square', connect it to a GainNode, connect the gain to audio.destination, and call start(). Use frequency.setValueAtTime(freq, time) on the oscillator and gain.setValueAtTime(level, time) on the gain node to schedule pitch and volume changes over time, producing a buzzer-like tone similar to old Nokia phones. Developers experimenting with WebAudio scheduling can find more hands-on examples through daily.dev."}},{"@type":"Question","name":"How do I calculate note duration in seconds from BPM in music notation?","acceptedAnswer":{"@type":"Answer","text":"Divide beats per minute by 240 to get whole notes per second, then divide by the note's duration value (1, 2, 4, 8, 16, 32, or 64) to get the note's length in seconds: duration = 240 / bpm / noteDuration. For dotted notes, multiply the result by 1.5 to extend the length by fifty percent. daily.dev helps developers track down concrete formulas like this for music and audio programming tasks."}}]}
```

