You can use bit-shifting as an alternative way of creating "music". This principle enables you to squeeze as much processing power as possible out of the Arduino while creating novel and interesting effects. The challenge lies in composing through bitshifting. This is an example of how such composition could look like:
OCR0A = ((-t&4095)*(255&t*(t&t>>13))>>12)+(127&t*(234&t>>8&t>>3)>>(3&t>>14)); // by tejeez
I have made this box to explore the consequences of changing the different parameters in the pieces. This enables me to see how they effect the overall sound qualities and enables me to prototype new compositions. The different parameters are changed through the 4 potentiometers. One potentiometer to choose the current algoritm and the other potentiometers to change the parameters of it. Although the sounds can be considered crude, it is quite engaging to experiment and play with.
This project is based on Duane Banks code. He does a good job on crediting his sources, I want to embed them here for reference: The original tunes were produced by Viznut and by others in response to his original blog post here - The original Arduino port was completed by Arduino Forum user Stimmer. Duane Banks used the synth schematic found in this instructable plus a customized version of the timing functions found in the code. I adopted his code and modified the different algorithms so you can play around with their parameters and get a sense of how it affects the sounds.
Step 1: Components Needed
- Arduino board
- Prototyping shield.
- Pin headers.
- 4 10kOhm potentiometers.
- 2.2k Resistor.
- 100n Capacitor.
- 100u Capacitor.
- Jack connector.
- A pair of computer speakers.
If you want to make the enclosure you would need:
- 3mm black acrylic.
- A wooden box (I got mine from the container store in SF).
Step 2: Making the Circuit
Wiring it up is pretty much according to the diagram. If you would like to experiment with wiring the sound circuit up on a breadboard you can find pretty detailed pictures and instructions in this instructable.
The potmeters should be connected with 5v on one side and Ground on the other. The middle pin should be connected individually to each analog in on the Arduino.
Step 3: Uploading the Code
The 3 things that usually cause trouble:
- On windows you have to install the proper drivers (sometimes also on mac).
- Remember to select the right serial port in the gui.
- Remember to select the right board in the gui.
Below are the simplified steps to uploading the code to your Arduino board:
Step 4: Debug With Guino
I am using Guino to visualize the code. Guino is a new program to visualize data coming from the arduino board and it enables you to manipulate it on the fly.
You can find the the Instructable here on how to use it. It is really simple to get up and running and it enables you to control some of the internal values. Download the program from here and run the program (you have already installed the libraries in the previous steps).
Step 5: Making the Enclosure
You should do the following steps to makethe enclosure
- I used a laser cutter to cut the acrylic plate to put on top. You can download the diagram here.
- Mount the potentiometers inside the holes.
- Drill a square hole in the box where the usb port on the Arduino is located.
- Drill a hole in the enclosure for the jack connector.
- Mount the Arduino board with a gluegun or a little screw.
- Wire the sound output to the jack connector on the box. The left and right channel should be connected to the same wire.
Drilling a square hole
Drilling a square hole in a wooden box has proven to be a tricky task. I have yet to find the perfect solution for it. My solution in this case was to use a drill press, a tiny drill bit and a larger drill bit.
Start out by marking with a pen the approximate area where the hole should be. Then drill many, many tiny holes inside this area. Since it can be tricky to get the precise placement of the square hole I usually compare it to the arduino board to see what areas I am missing. When you have drilled enough holes for the wood to be porous then use the larger drill bit to remove all the loose bits.
I would love to hear if anybody have a better way to do this?