| View previous topic :: View next topic |
| Author |
Message |
LiamOS n00b


Joined: 06 Jun 2012 Posts: 56 Location: Kerry/Dublin, Ireland
|
Posted: Fri Nov 30, 2012 4:33 pm Post subject: Command line techno |
|
|
Not sure if this has been posted yet:
| Code: | | echo "main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i>>8))^(i&i>>13|i>>6));}" | gcc -x c - && ./a.out | aplay |
One of the most fun commands I've ever run. _________________ CFLAGS=" -O999999" |
|
| Back to top |
|
 |
smartass Tux's lil' helper

Joined: 04 Jul 2011 Posts: 142 Location: right behind you ... (you did turn around, didn't you?)
|
Posted: Sat Dec 01, 2012 10:20 am Post subject: |
|
|
Beautiful!
An amazing trip through electronic music and genres
But that's just the beginning:
Now try running another in another terminal.
And why just one, try two, three, turn them off and on.... long live the binary DJ
| Code: |
#!/bin/bash
#binary techno program by LiamOS and smartass
echo "main(i){for(i=0;;i++)putchar(((i*(i>>8|i>>9)&46&i>>8))^(i&i>>13|i>>6));}" | gcc -x c -o binary_techno_source -
echo "All hail the binary DJ!"
read -p "How many turntables do you want: " turntables
active_turntables=0
declare -a turntables_pids
for ((i=0;i < $turntables;i++)); do
turntables_pids[$i]=0
done
while :; do
echo -n "Active turntables: "
for ((i=0;i < $turntables;i++)); do
if [ ${turntables_pids[$i]} -ne 0 ] ; then
echo -n "$(($i + 1)) "
fi
done
echo " (${active_turntables} in total)"
read -p "Turntable number to toggle on/off or 0 to quit: " request
if [ $request -gt $turntables ] ; then
echo "Invalid turntable number, you have only ${turntables} turntables"
continue
elif [ $request -eq 0 ] ; then
break
fi
index=$(($request - 1))
if [ ${turntables_pids[$index]} -eq 0 ] ; then
./binary_techno_source | aplay &>/dev/null & turntables_pids[$index]=$!
let active_turntables++
else
kill ${turntables_pids[$index]} &>/dev/null
let active_turntables--
turntables_pids[$index]=0
fi
done
for ((i=0;i < $turntables;i++)); do
pid=${turntables_pids[$i]}
if [ $pid -ne 0 ] ; then
kill $pid &>/dev/null
fi
done
rm -f binary_techno_source
|
Thank you so much LiamOS, you made my day
EDIT:
save as binary_techno
| Code: | | while :; do echo $(($RANDOM % 5 + 1)); sleep 10s; done | binary_techno | = unlimited electronic music!
Random never sounded so cool  |
|
| Back to top |
|
 |
ichbinsisyphos Guru


Joined: 08 Dec 2006 Posts: 547
|
Posted: Sat Dec 01, 2012 10:46 am Post subject: |
|
|
| That's awesome. Where is it from? The only trace I can find is an entry in some "xkcdb"-database, probably a archived post from the xkcd forums? |
|
| Back to top |
|
 |
LiamOS n00b


Joined: 06 Jun 2012 Posts: 56 Location: Kerry/Dublin, Ireland
|
Posted: Sat Dec 01, 2012 2:21 pm Post subject: |
|
|
A mate of mine posted it up on facebook. I've no idea where he found it.
Also, that's an absolutely fantastic script! Thanks, smartass. _________________ CFLAGS=" -O999999" |
|
| Back to top |
|
 |
jacktrick n00b

Joined: 01 Dec 2012 Posts: 0 Location: Dublin, Ireland
|
Posted: Sat Dec 01, 2012 2:52 pm Post subject: |
|
|
I'm LiamOS's mate. I'm subscribed to the xkcdb.com database rss feed (think bash.org, but for the #xkcd IRC channel) and that's where I saw it.
Source: http://www.xkcdb.com/?9067
So the original author (as far as I know) is rkm, who's a pretty funny guy.
smartass: that's pretty awesome, I've updated my boop.sh accordingly.  |
|
| Back to top |
|
 |
smartass Tux's lil' helper

Joined: 04 Jul 2011 Posts: 142 Location: right behind you ... (you did turn around, didn't you?)
|
Posted: Sat Dec 01, 2012 4:45 pm Post subject: |
|
|
Glad you liked it
Yeah, the only reference I found was on xkcdb. So thx for introducing me to Bucket by the way
I was wondering, whether to
- include the RANDOM part in the script itself
- suspend (SIGSTOP) processes instead of killing (SIGTERM) them (or offer both options)
I you think it's worth it, I might invest more time into it
It's pretty interesting how from time to time I can trigger quite catchy loops  |
|
| Back to top |
|
 |
sporkbox n00b

Joined: 11 Sep 2012 Posts: 19 Location: United States
|
Posted: Sat Dec 01, 2012 9:45 pm Post subject: |
|
|
Mind Status == Blown
How do I learn how to make musical loops with code? This shit is amazing. |
|
| Back to top |
|
 |
LiamOS n00b


Joined: 06 Jun 2012 Posts: 56 Location: Kerry/Dublin, Ireland
|
Posted: Mon Dec 03, 2012 4:48 am Post subject: |
|
|
| sporkbox wrote: | Mind Status == Blown
How do I learn how to make musical loops with code? This shit is amazing. |
The looping comes from the C program being run.
Nicely formatted, the program would read:
| Code: |
main(i) {
for (i=0 ; ; i++)
putchar( ((i*(i>>8|i>>9)&46&i>>8))^(i&i>>13|i>>6) );
}
|
This isn't a massive improvement, but this is a very low-level aspect of C. The operations here are mostly bitshifting, which is a fascinating thing in itself. _________________ CFLAGS=" -O999999" |
|
| Back to top |
|
 |
sikpuppy n00b


Joined: 12 Jun 2012 Posts: 23 Location: Central Coast, NSW
|
Posted: Mon Dec 03, 2012 5:09 am Post subject: |
|
|
Neat. It reminds me of RIchard D James (AKA Aphex Twin) who set up an old Sinclair ZX81 and changed the background hue on his TV rapidly. This caused interference to the audio circuit which, when he altered the speed of colour change, he could produce noise which approximated actual notes. The ZX81 didn't have any sound output nominally. He won some sort of prize as a schoolboy for this feat.
| Quote: | Richard claims to have produced sound on a Sinclair ZX81 (a machine with no sound hardware) at the age of 11:
When I was 11, I won 50 pounds in a competition for writing this program that made sound on a ZX81. You couldn't make sound on a ZX81, but I played around with machine code and found some codes that retuned the TV signal so that it made this really weird noise when you turned the volume up. |
|
|
| Back to top |
|
 |
LoTeK Apprentice


Joined: 26 Jul 2012 Posts: 230
|
Posted: Wed Dec 05, 2012 12:06 am Post subject: |
|
|
just epic !!!! thank you, plz post more if you have more..!!!!  |
|
| Back to top |
|
 |
|