Most tweetable 1-liner

Yusuke Endoh

Judges' comments:

To build:

make endoh3

To run:



Trying this out will depend on how your system can play sounds. The author’s remarks include some options for different operating systems.

The simplest way is to create a .wav file and have your system play that.

echo 'CDEFGABc' | ./endoh3 | ruby wavify.rb > cde.wav

There are also some other musical samples, and

Selected Judges Remarks:

This program can tweet out a tune and is small enough to tweet.

Author’s comments:


This is a sound synthesizer for a subset of ABC music notation.


gcc -o prog prog.c
echo "CDEFGABc" | ./prog > /dev/dsp

If /dev/dsp is not available on your system, use an OSS sound wrapper such as padsp or aoss:

echo "CDEFGABc" | ./prog | padsp tee /dev/dsp > /dev/null

If you are using Mac OS X, try sox:

echo "CDEFGABc" | ./prog | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio

If they do not work, use the attached script to convert the output into a wave file format:

echo "CDEFGABc" | ./prog | ruby wavify.rb > cde.wav

and play cde.wav.

You can enjoy some music scores that I attached:

cat | ./prog > /dev/dsp
cat | ./prog > /dev/dsp


The following sequence of questions may be helpful to understand the program.


The following features are supported:

The following features are not supported:

Known Bugs

You can not write a note length immediately followed by a note E, such as C2E2. Can you know why? You can work it around by inserting a whitespace: C2 E2.


I tested it on:


I believe that all the scores that I attached are out-of-copyright.

I did write a score of the Happy Birthday song too. (It does not matter because the song is out-of-copyright in my country.) But I do not attach it to protect you from W****r.

For the same reason, do not play a score that contains only z1092. You know, it is “the famous song”.

Spoiler (rot13)

Urer vf n zntvpny rkcerffvba juvpu V sbhaq ol oehgr-sbepr:

(p % 32 + 5) * 9 / 5 % 13 + a / 32 * 12 - 22

Vagrerfgvatyl, vg pbairegf na NFPVV ahzore bs NOP abgrf gb gur pbeerfcbaqvat gbar ahzore.

'P' (NFPVV  67) =>  3
'Q' (NFPVV  68) =>  5
'R' (NFPVV  69) =>  7
'S' (NFPVV  70) =>  9
'T' (NFPVV  71) => 10
'N' (NFPVV  65) => 12
'O' (NFPVV  66) => 14
'p' (NFPVV  99) => 15
'q' (NFPVV 100) => 17
'r' (NFPVV 101) => 19
's' (NFPVV 102) => 20
't' (NFPVV 103) => 22
'n' (NFPVV  97) => 24
'o' (NFPVV  98) => 26

Ol gur jnl, lbh pna jevgr n unys-gbar ol gur sbyybjvat punenpgref.

'X' =>  4 (= P#)
'Y' =>  6 (= Q#)
'H' =>  8 (= S#)
'I' => 11 (= T#)
'C' => 13 (= N#)

Abgr gung gur gbar ahzoref fvzcyl rahzrengr gur frzv-gbar fgrcf. Fb jr pna pnyphyngr gur serdhrapl rnfvyl: cbj(2, a / 12.0). Gura, ubj pna jr pnyphyngr cbj jvgubhg zngu.u? cbj(2, 1.0 / 12.0) vf nccebkvzngrq ol 89/84.. (V sbhaq guvf nccebkvzngvba ol hfvat Fgrea-Oebpbg gerr.) Jr pna tnva gur serdhrapl ol zhygvcylvat gur inyhr a gvzrf.

Svanyyl, gur sbyybjvat pbqr trarengrf n fnj jnir:

sbe(p = 0; p < yra; p++) chgpune(n = a * Q);

jurer Q vf n serdhrapl naq n vf n inevnoyr jubfr glcr vf pune. Ol nffvtavat sybng gb pune inevnoyr, gur vzcyvpvg glcr pbairegvba vf cresbezrq sebz sybng gb pune (zbqhyb 256). (Fgevpgyl fcrnxvat, guvf orunivbe vf haqrsvarq nppbeqvat gb va P99; lbh pna ercynpr vg jvgu (ybat)(a*Q) vs lbh ner crqnagvp.)

Nyy gung jnf yrsg jnf gb pbzovar naq pbaqrafr gur pbzcbaragf. Gur xrl vf fdhnfuvat gurz vagb whfg bar sbe-ybbc.

Creative Commons License

© Copyright 1984-2015, Leo Broukhis, Simon Cooper, Landon Curt Noll - All rights reserved
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.