Digital Record Player Using Arduino and Processing

by sophihuseby in Circuits > Arduino

318 Views, 1 Favorites, 0 Comments

Digital Record Player Using Arduino and Processing

IMG_1055.jpeg

Creators: Sophia Huseby, Ian Rowland, Eric Wang.

Introducing digital record player:

Our digital record player plays the instrumental arrangement of 4 songs (Canon in D, Industry Baby, Sweet Caroline, He’s a Pirate) in quintet form. The user can add or remove discs to control which instrument and their respective contrapuntal lines gets played. For these four songs, the record plays in a loop of 16 seconds of their starting musical sentence. The fifth song(I keep my beloved in a box) is continuous and is not affected by discs.

How did we come up with this idea and why did we choose this:

In our brainstorming session, one of our group members thought it might be interesting to do a digital record player. Another one of our group members, building on top of that idea, suggested that for the interactive portion, we could add and subtract voice lines. All of us love music and fell in love with that idea immediately.

How we made this project:

In our planning stage, we decided that Sophia will be mostly responsible for the box and other component manufacturing and design, Ian will be mostly responsible for electronics soldering, wiring and Arduino side coding, Eric will be mostly responsible for music writing/transcribing and processing side coding. With clearly divided responsibilities we each set off to our own research and work. Each of us had our successes in our assigned responsibilities, but we still helped each other out whenever anyone needed.

Difficulties we encountered along the way:

Manufacturing: most of the manufacturing difficulties we encountered were logistical, as there are many different parts that needed different tools like a laser cutter and 3D printers, drills etc. Finding the appointments during the semester can be tricky. Some of the files at one point were corrupted and our progress was set back by that.

Electronics: The main difficulty I encountered was soldering the individual neopixels to each other. I had to spend a lot of time on each one, measuring out each wire and assuring there were no shorts. Not shorting the LEDs was extra difficult because although neopixels are very small, each one requires 6 different solder joints, none of which can touch. Later on, it was difficult for me to stay organized while trying to wire and solder all of the pieces together. There were more wires than I expected and I had to stay engaged to assure that everything was being wired correctly.

Programming: programming on the processing end has been smooth in terms of technical difficulties, however, we did have three different iterations of the code as we were improving our program. Coming up with ideas and testing them can be a lengthy process

1. 1 st iteration: can only play the additional line at the starting period which occurs every 16 seconds. Programmer used the delay function for 16 seconds for the file to finish playing.

2. 2 nd iteration: plays music on pretty much exactly the time the disk was inserted. How it works is music starts when detecting a change, programmer use cue function and millis function to pin point music location and play it. But there is significant delay with all the code process time and inputs delays etc. to the point where the downbeats dont match and was somewhat painful to listen to

3. 3 rd iteration: it is the combination of the two previous iterations, it loops every 1 second and play files at the cue of the second marks. Theres the clicking sound of the file start and the legato is not smooth. But this version is the best as it has only a little bit of delay, it greatly increases intractability compare to the first iteration and mitigates the weakness of the second iteration.


watch our demo video: https://www.youtube.com/watch?v=OkzDUMnndfo&t=107s

get our code: https://github.com/sophiahuseby/digitalrecords

get our music files: https://drive.google.com/drive/folders/1gIXOxL6kdPx-Kk8TefT-3e1ma5DUYFJ-

Supplies

container:

  • plywood
  • black acrylic
  • white acrylic
  • 3d printer + filament
  • acrylic paint
  • spray paint - hammered texture
  • wood glue
  • satin fabric
  • black felt
  • hot glue

hardware:

  • solder
  • soldering iron
  • solid core wire
  • stranded core wire
  • jumper wires
  • photoresistors (6x)
  • 10k resistors (6x)
  • adafruit neopixels
  • continuous 360º servos (5x)
  • power supply
  • arduino mega board
  • extension cord
  • protoboards
  • wire cutters
  • wire strippers

Planning & Drafting

Screen Shot 2023-05-06 at 11.25.56 PM.png
Screen Shot 2023-05-06 at 11.26.04 PM.png
Screen Shot 2023-05-06 at 11.26.10 PM.png
Screen Shot 2023-05-06 at 10.51.56 PM.png

In our initial brainstorm, we learned that we would all be interested in creating something that dealt with sound/music. 

To assure that our project's wiring and coding would later work, we created a simple button circuit that tested whether the user can push a button/buttons and a specific voice part of a song would play. After wiring 5 buttons, we used Arduino to communicate button presses with Processing, which would play specific sound files depending on which button/buttons were being pressed.

Laser Cutting & Assembling Box

Screen Shot 2023-05-06 at 10.55.07 PM.png
Screen Shot 2023-05-06 at 10.55.15 PM.png
Screen Shot 2023-05-06 at 10.55.22 PM.png
Screen Shot 2023-05-06 at 10.59.30 PM.png

First step of the project was to create the box that was used as a holder for the record player. We designed the box to have two different compartments, one for the interface and one for the circuits. In order for this box to be created, many hours were spent in the ATLAS BTU lab as well as BLDG 61 at the Boulder Public Library. We thought that aesthetics were very important for this project, and settled on a retro/vintage theme for our record player. We decided that we wanted our box to seem like an old travel suitcase, and the inside to be white and retro.

Fabricating the box:

  • purchase plywood that you would like to use for the box
  • laser cut it using MakerCase (two boxes, but one is altered with a rectangular hole in bottom for the acrylic sheet to sit on)
  • use wood glue to glue the pieces together
  • paint however you'd like
  • use satin fabric in color of your choice (for this project we used white) for the lining
  • paint details onto the box

Fabricating Parts

Screen Shot 2023-05-06 at 10.50.41 PM.png
Screen Shot 2023-05-06 at 10.51.17 PM.png
Screen Shot 2023-05-06 at 10.51.28 PM.png
Screen Shot 2023-05-06 at 10.51.36 PM.png
Screen Shot 2023-05-06 at 11.01.30 PM.png
Screen Shot 2023-05-06 at 11.01.37 PM.png

Next, we had to 3D print a custom servo mount in order to incorporate photoresistors poking up from the acrylic sheet, which was made in SketchUp and then 3D printed in ATLAS's BTU lab. Additionally, we laser cut the records out of black acrylic and then engraved the ridges into them. The labels were made out of sticker paper and then cut out and fit to each record so that they all sat nicely on the records.

To create the acrylic sheet that seperated the hardware from the interface:

  1. Laser cut it to the correct size to sit in your box
  2. Measure out your records and then decide where the mounts should go
  3. Draw holes where the wires and photoresistors should be entering in and out of
  4. Drill holes into the acrylic where the draw holes once were

To create the 3D print servo part:

  1. Measured the servos with calipers to ensure that we had the correct measurements
  2. 3D modeled the part in Sketchup with a hole for the servo to sit, a hole for the servo wires so that they did not crimp, and a hole for the photoresistor to sit
  3. Then we sent the file to the 3D printer and printed out five parts
  4. Sanded the parts and then painted the rim so that the user knew which record went to which mount.

Musical Compositions

How the functional processing code is constructed:

  1. Import processing library that allows you to play sound files. Refer to link as resource, example codes may be available in other online sources. (https://processing.org/reference/libraries/sound/index.html)
  2. Declare all the files and variables you will need in setup or outside, to parse Arduino data, use the template provided by class (https://docs.google.com/document/d/1NKBYIz1ZHwSnPQUp7VU03KiZmviw_fJmTD1YTkaJ8c/edit)
  3. In the draw function, read each Arduino value: the light sensor output and the potentiometer output. To keep time: delay loop to run every second (1000), use a counter that add 1 each loop to keep time, and resets itself after it reaches 16(or you could keep time by using modulus function).
  4. Also in the draw function use if statements on potentiometer value reading, the mapped values will determine which song to play, then in each song, check light sensor output to determine which voice parts to play(Arduino side outputs 1 for disc presence and 0 for absence).
  5. disc 5 is soprano, disc 4 is soprano 2 and so on and so forth. If light sensor reading is 1, music plays at the cue time (in seconds, the counter value keeps track of that) else it stops the file so it does not keep playing even when it was activated.
  6. in the end of the draw function, reset all the disc value to 0, so that the system will be aware if disc is taken off and the files will stop playing if the disc is no longer on the box (if the disc still is on the box the value will still be 1 as the disc value is read every at the start of every call of draw function).
  7. Small exception on the third song, where it is continuous (it plays for 6 minutes ish). I just used a loop that stops program from going further in the draw function so that the music keeps playing without interference. But when the new reading of the potentiometer says another song’s value, it will break the loop, continue the draw function and stops the music so that other music may play.


How to get the music:

  1. Use Muse Score or any software that allows for music export in to some form of sound file, I used wav.
  2. Since the code above for normal contrapuntal music runs 16s cycles, make sure that all the music excerpts you use are planned to be exactly 16 seconds long so that when the next cycle runs it does not feel like the previous music is cut off.
  3. Music loops better if the chords form a continuous circuit, for example, Canon uses the Romanesca sequence that loops back to the tonic every 8 chords, I made it play 2 seconds per chord to make it exactly 16 seconds and it loops back perfectly to the start every 16 seconds. Many other songs like He’s a Pirate also has a functional circuit in the first sentence(i-VI-V-i-VI-III-bVII-i). make it play 2 seconds per chord and the music loops well.
  4. Design each instrument and their line, I used the quintet format. One could use any form of ensemble formats. Although to keep it interesting, contrapuntal lines on each voicing is recommended.
  5. Export music one instrument at a time, put the file in the same folder as the code. Call the file using the code

Soldering

Screen Shot 2023-05-06 at 10.53.44 PM.png
CircuitDiagram.png
Screen Shot 2023-05-06 at 10.54.29 PM.png
Screen Shot 2023-05-06 at 10.55.30 PM.png
Screen Shot 2023-05-06 at 10.59.05 PM.png
Screen Shot 2023-05-06 at 11.02.53 PM.png
Screen Shot 2023-05-06 at 11.03.00 PM.png
Screen Shot 2023-05-06 at 11.03.08 PM.png
Screen Shot 2023-05-06 at 11.03.15 PM.png
Screen Shot 2023-05-06 at 11.03.45 PM.png
Screen Shot 2023-05-06 at 11.03.51 PM.png
Screen Shot 2023-05-06 at 11.03.59 PM.png

When you have a complete object/box that can hold your project, it is time to wire it all together.

  1. Set up a protoboard and solder your Arduino ground and power supply ground onto it. Next set up a protoboard for the Arduino 5V power and a different one for the power supply power.
  2. Using protoboards, wire each photoresistor, connecting to the Arduino power proto board, the ground (through 10k resistors), and lastly to an Arduino analog pin.
  3. Next is the potentiometer, solder the ground pin to the ground board, the power to the Arduino power board, and the input pin to another analog pin on the Arduino.
  4. The last thing that is powered fully by the Arduino Mega is the short, 3 LED strip. Wire the ground to ground, power to Arduino power, and the input to a digital Arduino pin.
  5. For the long LED strip, solder the power pin to the power proto board of the power supply, the ground to ground, and the input to a different digital pin.
  6. The last wiring of this project is the servos, which also need just 3 simple connections. Firstly, the power chord to the power supply proto board, the ground to ground, and the input to a PWM digital pin.


Arduino Code

How the Arduino code is constructed:

  1. Before the functions:
  2. Click on the “Library Manager” and install the Adafruit NeoPixel library by Adafruit and the Servo library by Michael Margolis, Arduino to control the RGBW LED lights and the servos.
  3. At the top of the Arduino sketch, include the adafruit and servo libraries and then initialize the LED strips as two different sets of adafruit neopixels.
  4. Define the digital Arduino pins that the two different LED strips are plugged into and define the number of neopixels in each strip.
  5. Initialize the analog pin where the potentiometer is connected to, and the 6 analog pins for each photoresistor, making sure to have a specific name for each one to be organized.
  6. Lastly before the setup function, create 5 different servo objects, being sure to name accordingly as well.
  7. In the setup function:
  8. Set up each analog pin for the photoresistors as an input and attach each servo object to a different digital pin.
  9. Lastly in setup(), begin the two LED strips, adjust the brightness to your liking, and start the serial monitor.
  10. In the loop function:
  11. Read the value from each photoresistor and set them to different, well-named variables. Do the same process for the potentiometer. 
  12. Now that you have everything set up, it’s time to make it all run. 
  13. Create an if-statement for the one photoresistor that is outside of the cylinders to check whether the lid is closed. If the lid is not open, turn off the long LED strip and make sure nothing is running.
  14. Use an else statement that is essentially if the lid is open, then run the code which I will explain below.
  15. Firstly in the else statement, turn on the long, 19 LED strip with colors of your liking.
  16. Next, use 5 different if-else statements for each voice part, declaring that if the photoresistor for that specific voice part is covered, then spin the servo and print in the serial monitor that the disc is equal to 1 (Disc 1 is bass, disc 2 is tenor, etc.). For example, if the bass photoresistor is covered, you will do “Serial.print(“disc1:1;”), which you will later use in Processing to connect the two coding programs.
  17. If that specific photoresistor is not covered, then stop the servo and print that the disc equals 0.
  18. Follow these steps for the photoresistors of all 5 voice parts but add in code to turn on the 3 front LEDs when the middle photoresistor is covered.
  19. Lastly, print the potentiometer value to the serial monitor, defining it clearly so you can later use it in Processing.

Demo

IMG_1055.jpeg
IMG_1056.jpeg
IMG_1057.jpeg
IMG_1058.jpeg
IMG_1059.jpeg
IMG_1060.jpeg
Screen Shot 2023-05-06 at 10.53.38 PM.png

At the end, when we finished our project, we showed it in class as well as ATLAS's 2023 spring expo. We had a great time and learned a lot, and were very excited about our finished product. We hope that if you'd like to recreate our project, this guide will help you do so!