This code below is a shell script that will produce immense amounts of Nostalgia for NB's older crowd. The script uses a.out to play audio in 8bits at a 8000MHz in mono.
Warning: You will need a bash/shell environment for this bash/shell script to work. A GNU/Linux disto (Debian, Gentoo, Arch, Slack etc), or a BSD will work (I don't know much about BSD to be honest, so I will explain everything from a GNU/Linux perspective).
Step One: Open a shell terminal
It should by default place you in your home folder, /home/username/ and it's up to you if you want to create another folder or create the script directly in your home folder. For this example, I will plot it directly into the home folder.
Step Two: Inserting the code
From here, you will use nano (unless of course you're more experienced, then you would have just copied the code and gone off and done your own thing).
nano music.sh
This will open a non-graphical text editor. Don't get scared, all you're going to do is copy and paste the code (you will have to right click inside the terminal window and choose paste from the pop up menu).
At this point, you will hit ctrl+o, that will write the changes you made to music.sh. After which you will use ctrl+x to exit nano.
Step Three: Starting the script.
You should be back in your home directory, use chmod +x to make the shell script executable.
Then all you have to do is run the script
./music.sh
Warning: To stop this script, use ctrl+c. Else, if you close the terminal window and find yourself unable to halt it, use ps -ef and look for ./a. out and aplay. To the left will be the PID (process ID) you will need to kill it.
Use the kill command to kill the PID, example from my image: kill 8217 && kill 8218
Enjoy!
Warning: You will need a bash/shell environment for this bash/shell script to work. A GNU/Linux disto (Debian, Gentoo, Arch, Slack etc), or a BSD will work (I don't know much about BSD to be honest, so I will explain everything from a GNU/Linux perspective).
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
You must be registered for see images
It should by default place you in your home folder, /home/username/ and it's up to you if you want to create another folder or create the script directly in your home folder. For this example, I will plot it directly into the home folder.
Step Two: Inserting the code
From here, you will use nano (unless of course you're more experienced, then you would have just copied the code and gone off and done your own thing).
nano music.sh
This will open a non-graphical text editor. Don't get scared, all you're going to do is copy and paste the code (you will have to right click inside the terminal window and choose paste from the pop up menu).
You must be registered for see images
At this point, you will hit ctrl+o, that will write the changes you made to music.sh. After which you will use ctrl+x to exit nano.
Step Three: Starting the script.
You should be back in your home directory, use chmod +x to make the shell script executable.
Then all you have to do is run the script
./music.sh
You must be registered for see images
Warning: To stop this script, use ctrl+c. Else, if you close the terminal window and find yourself unable to halt it, use ps -ef and look for ./a. out and aplay. To the left will be the PID (process ID) you will need to kill it.
You must be registered for see images
Use the kill command to kill the PID, example from my image: kill 8217 && kill 8218
Enjoy!
Last edited: