Skip to content

Instantly share code, notes, and snippets.

@iSkore
Last active March 3, 2016 01:33
Show Gist options
  • Save iSkore/ae0dbe2877c22ca2e969 to your computer and use it in GitHub Desktop.
Save iSkore/ae0dbe2877c22ca2e969 to your computer and use it in GitHub Desktop.
C Program in c minor

Square Wave

^   squ x
	 |
	,|, 1 _________________                       _
	 |                     |                     |
	 |                     |                     |
	 |                     |                     |
"""".*""""""""""|""""""""""|."""""""""|""""""""".|"""">
	 |                     |                     |    x
	 |                     |                     |
	,|,                  sm|_____________________|
	 |  -1
	 |

Triangle Wave

^   tri x
	 |
	,|, 1     ,"‾",
	 |      _"     "_        
	 |    ,"         ",                             ,"
	 |,*^'             ‾-*,                      ,*^
"""".*""""""""""|""""""""""|."""""""""|""""""""".|"""">
	 |                       ‾*,            ,*‾             x
	 |                          "_        _"
	,|,                  sm        "* _ *"
	 |  -1                           
	 |

Sine Wave

	 ^   sin x
	 |
	,|, 1    _....._
	 |    ,="       "=.
	 |  ,"             ".                           ,"
	 |,"        ,        ".,                     ,,"
"""".*""""""""""|""""""""""|."""""""""|""""""""".|"""">
  ." |                       ".               ." __    x
,"   |                         "._         _,"   ||
	,|,                  sm       "-.....-"
	 |  -1
	 |

Sawtooth Wave

^   saw x
	 |
	,|, 1
	 |            _,- -^ ‾ |                     |
	 |      _,- ^          |                     |
	 |_,- ^                |                     |_,- ^
"""".*""""""""""|""""""""""|."""""""""|""""""",-^|"""">
	 |                     |            _,- ‾    |    x
	 |                     |      _,- ^          |
	,|,                  sm|_,- ^
	 |  -1
	 |

Command Line Interface

echo "g(i,x,t,o){return((3&x&(i*((3&i>>16?\"BY}6YB6%\":\"Qj}6jQ6%\")[t%8]+51)>>o))<<4);};main(i,n,s){for(i=0;;i++)putchar(g(i,1,n=i>>14,12)+g(i,s=i>>17,n^i>>13,10)+g(i,s/3,n+((i>>11)%3),10)+g(i,s/5,8+n-((i>>10)%3),9));}"|gcc -xc -&&./a.out|aplay

Broken Out - C

g( i, x, t, o ) {
	return( ( 3&x&( i * ( ( 3 & i >> 16 ? \"BY}6YB6%\" : \"Qj}6jQ6%\" ) [ t % 8 ] + 51 ) >> o ) ) << 4 );
};

main( i, n, s ) {
	for( i = 0;; i++ )
		putchar( g( i, 1, n = i >> 14, 12 ) +
				 g( i, s = i >> 17, n ^ i >> 13, 10 ) +
				 g( i, s / 3, n + ( ( i >> 11 ) % 3 ), 10 ) +
				 g( i, s / 5, 8 + n - ( ( i >> 10 ) % 3 ), 9 )
				);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment