Code Self Study Forum

Étude in C minor

        int
       main()
      {float f
    ;char c;int
  d,o;while(scanf(
 "%d%c%d ",&d,&c,&o)
>0){c&=31;for(f=!(c>>4)*55,c=(c*8/5+8)%12+o*
                     12-24;c--;f*=1.0595);
                        for(d=16e3/d;d--;
                           putchar(d*f
                            *.032))
                              ;}}

From the post:

I don’t really draw well, so I used formatted C code instead. That was supposed to be a triangular sound wave written in C. In fact, this very C code plays two-octave melodies written in text notation from stdin.

It’s only 160 bytes, fits into a modern-day tweet, and the reason it’s there is to show how simple it is to create minimal music with code in any programming language, not just the special languages like CSound, ChucK, or SonicPi.