UP | HOME

Demystifying the Bells
50 $COLON is too expensive

Table of Contents

What are these horrid sounds? Who would do this? How does one become a “Super Idol”? If you find yourself asking such questions, then allow me to extend the boundaries of your understanding.

piano.png

History

On <2023-06-22 Thu>, uwu_to_owo robotized a set of 8 bells in his basement using a NodeMCU, an Arduino UNO waifu board, and a set of relays and solenoids. During the stream, chatters were allowed to control the bells with a syntax similar to ABC or Helmholtz pitch notation. As of the time of writing, these bells can be heard when he gets a new follower, or when a viewer donates 100 Bits. It seemed like doing something similar in Elisp would be a good exercise, and somehow it evolved into what it is now.

Notation

An obvious shortcoming of the original script was that it emulated a set of bells that could only represent a single octave of the C major scale. The syntax was simple, with forward slashes representing rests and letters representing notes. These rules have since been arbitrarily extended to allow for greater flexibility and musical expression while still retaining backwards compatability with the original bells.

Rests

  • Forward slashes (/) represent a rest.
A/B/C///A/B/C///A

Semitones

  • Semitones are represented as notes suffixed with an octothorpe (#), denoting a sharp.
  • It’s worth noting that a lowercase “b” is interpreted as a “B” note in the fifth octave (1 above the default), rather than qualifying a flat.
  • Unicode ♯ and ♭ are ignored.
AG#F#/C#/G#/F#

Octaves

  • Octaves were originally expressed with uppercase letters (the lower octave) or lowercase letters (the upper, higher-pitched octave).
  • Now, optionally, suffixing a note with a digit will override this; it borrows from the convention used in scientific pitch notation.
  • When specifying an octave this way, keep in mind that this notation puts middle C at C4.
E3G#3B3G#3B3D#B3D#F#D#B3G#3A3CECEDF#AcBAE

Extending notes

  • This notation assumes that a note will be an eighth note by default. The duration of a note can be extended by a fixed amount by appending one or more tildes (~) to the end of the note.
A~Bc~de~/e~/e~dc~BA~

Chords

  • Chords are groupings of notes within square brackets ([]).
  • The duration of the chord is equal to its longest constituent note.
  • In other words, you can extend a note within the chord to lengthen the entire thing.
[CEG~~~]G[A3CE~][F3A3C~~~]

Tracks

  • Additional “tracks” can be played in parallel by using a pipe character (|).
  • Everything prior to the first pipe is the lead melody, and will be played with the default instrument.
BDf#BDf#Bf#Ac#eAc#eAe|B3/B3/B3/B3/A3/A3/A3/A3

Beats Per Minute

  • Any number at the beginning of the input will be interpreted as the tempo. The default BPM is 75.
110ed#c#BA#G#F#ED#C#B3A#3G#3~~~

Examples

  • Super Idol

  ddd#dcA#G/cA#G/A#/c/c/dcA#cd/GGG/A#/G/ddd#dcA#dc/dG/A#A#A/AAd/d/A#/
  • Littleroot Town

  60CFGA//GAGAA#/c/dA/Ac#d/e/d/AGFEFAd/DEF///cA#A#AF///dAAGF/////EDE//FG~|
  ///F2C3A3C3F2C3A3C3A2G3CG3A2G3C#G3D3F3DF3C#3F3C#F3C3F3CF3B2F3B3F3A#2F3
  A#3F3A#2F3A#3F3G2F3A#3F3G2F3A#3F3C3G3A#3G3C3G3A#3G3C3E3A#3E3C
  • Terraria Day

  150g~//f#~B~//B~c~e~d~G~//G~//G~d~g~a~////b~////A3DG~[DGB~]////[EGc~]////
  g~~/g~//f#~B~//B~c~e~d~G~//G~////////d~G~//////[C#A~][Ec#~][Ae~][GB][Ac#][Bd~]|
  G2~G3~G3~G2~G3~G3~G2~G3~G2~G3~G3~G2~G3~G3~G2~G3~G2~G3~G3~G2~G3~G3~G2~G3~
  G2~G3~G3~G2~G3~G3~G2~G3~G2~G3~G3~G2~G3~G3~G2~G3~G2~G3~G3~G2~G3~G3~G2~G3~
  G2~G3~G3~G2~G3~G3~G2~G3~G2~G3~G3~G2~

Demo

WARNING: May be loud

API

  • You can redeem the bells with the name of a song instead of a string of notes.
  • A list of available premade song names can be found here: https://api.colonq.computer/api/songs
  • To get the notes of a song, send a request to https://api.colonq.computer/api/song/hash, where the hash is an MD5 digest of the song’s lowercased title.

    title="Littleroot Town"
    hash=$(echo -n "${title}" | tr [:upper:] [:lower:] | md5sum | cut -d' ' -f1)
    curl https://api.colonq.computer/api/song/"${hash}"
    

FAQ

How do I make it do the thing?

See Notation.

How can I test this?

Check out the demo.

Since muzak.el is an Emacs Lisp script, you can evaluate it with GNU Emacs.

Once the script has been evaluated, you can play notes from your own scripts (or IELM) like so:

;; This will play the C major scale, with a rest between each note.
(muzak/play "100C/D/E/F/G/A/B/c")

This script depends on `ffplay’, `ffmpeg’ and `mpv’.

Where can I find more examples?

Songs I’ve made or collected can be found in `muzak//song-table’ in the Elisp script.

More community contributions can be found here.

How does it work?

The pitch of a note is determined by the frequency of vibrations that produce it. By mapping textual input to the frequencies of musical notes, we can produce music in a structured way. The script defers to FFMPEG and MPV to produce sounds.

The latest public version of the script can be found here or on clonk’s Github.

If you’re more comfortable with reading JavaScript, you can check the demo.

Why not use ABC, GUIDO, or some other text notation?

Historical reasons, mainly, and for ease of use with input from Twitch.

Why “muzak”?

Muzak is elevator music.

Huh?

2x.webp

Author: Bezelea (bezelea@pubnix)

Date:

Made with [[https://www.gnu.org/software/emacs/][GNU Emacs]]