Algorithmic composition or automated composition basically refers to the process of using some formal process to make music with minimal human intervention.
3. I found a project that essentially does this using potentiometers and buttons but I wanted to recreate using sensors (Humidity, Temperature, LDR Module) instead.
Circuito.IO & TinkerCad
To create and test the design
Arduino IDE
To Write the code
DHT11 Humidity and Temperature Sensor
Arduino Uno
LDR (Mini Photocell)
3x 220 Ohm Resistor
Breadboard
Jumper Wires
3 Red LEDs
White Cardboard
Hot Glue
Cutter
I began by looking for inspiration ideas, then selected the LCDs as a second output and the LDR module as a second input.
in Circuit.io, I built the circuit to ensure that all of the wiring and other details were correct.
Following the tutorial on the Counter Complex Blogspot, I chose the one-line algorithm that would be used by the gadget.
Then, using the code from the inspiration projects, I began coding in the Arduino IDE.
The algorithm utilizes 3 environmental parameters
(Temperature, Humidity, Light intensity) obtained from DHT11 and an LDR
it integrates them into the one-line algorithm, which would in turn through shaping & pulse width modulation generate an algorithmic piece of music.
The 3 LEDs are connected to a Data Direction Register and act as a visualizer for the music.
I started by checking the ports on the Arduino's microcontroller and made sure I'm choosing the right, as well as the data directions, and since I was connecting the speaker on the pin number 10 I modified the code to use the shift register TCCR1B.
I set the visualizers (LEDs) directly on the directional data register.
Then I included the library that would catch the parameters for the algorithm, in this case, the humidity and temperature sensor, defined the parameters, and mapped them to a (0,2) and (-2,2) ranges
the function putb() updates the waveform
Defining the parameters and mapping them
setting up the visualizer
The one-line algorithm here is the one I used for the code, the "t" here is the time parameter, and applying bitwise operations to it changes it continuously.
The line I used here came with pure experimentation (was premade by another user and I tweaked it until liked the way it sounded)
But for example:
Bitwise AND limits the pitch set to a specific scale, which, in our case is dictated by the sensors' readings.
the + sign signifies the separation of each part from the other for example, the bass from drums.
A deeper deconstruction of the one-line algorithms can be found here
I arranged all of the components on the breadboard and started connecting them one by one.
Using Arduino Code and the Avometer, I tested the components and connections.
I began compiling my code, then re-uploaded it to the Arduino board and tested the circuit with the lights on and off to see whether the parameter by the LDR will actually affect the composition
I used the Walkamon Lo-fi prototype I initially made for my final project, then I mounted the LEDs and the LDR module using male-female jumpers.
The concepts of object Oriented Programming and Computational Skills Mr. Ahmed Khaled presented in the extra session helped me alot understanding much more pieces of code online and helped me design and structure my code.
2- Defining Universal Variables, because they were defined in separate methods and functions hence most of the code was buggy.