Environmental awareness

As long as anyone can remember our environment has been providing food, water and a space to live for all of us. However our behavior changed and nowadays the environment also is a very important energy supplier. With our project, called the EnvironmentalJukebox, we wanted to make people aware that our environment has capabilities we haven’t ever thought of. It can be used to be creative. Especially aspects referring weather can be used to control a machine we have created. Since music plays a big role in many people’s lives we thought it could be very interesting to connect music and environmental aspects. This is how our project emerged.

What is it?

The EnvironmentalJukebox is, as its name implies, some kind of jukebox. However it’s not a common one. Instead of letting the user choose a certain type of music or radio station, the EnvironmentalJukebox creates and changes music by itself based on four environmental parameters: wind, light, rain and temperature. This music consists of piano-chords and a drum-beat. Once one or more of the environmental parameters change, music changes accordingly. For example, if the speed of the wind increases, the speed of the music increases. If it begins to rain, music gets louder. Temperature is used to decide whether chords within a minor or major key should be played and the amount of light is crucial for the pitch of the tones. The more light is captured the higher is the pitch of the tones and chords.


How does it work?

In the EnvironmentalJukebox two sensors (one for light, one for temperature) and two motors are used to measure the four parameters mentioned before. See below for a short tutorial how to measure wind-speed and waterflow.

To change the music once one or more of the environmental parameters change, the output of the sensors and motors need to be read. Therefore we use d an Arduino Uno, the Processing programming language and SoundCipher, a sound-library for Processing. See the next paragraph to learn how to connect Arduino to Processing.

At the beginning of our Processing application we had to create all chords we wanted to use. This can by done by float-arrays containing four values, e.g.:

float[] fisdur = {6.0, 10.0, 13.0, 18.0};

Each value represents one key on a regular piano. Furthermore we created keys each of which contains six chords and two ArrayLists, one for minor keys and one for major keys. As mentioned above, temperature is used to decide whether to play minor or major keys. To guarantee diversion to a certain degree, chords within a key are chosen randomly. So if the temperature doesn’t change for some time different chords can be heard. However all of them are within a certain minor or major key depending on temperature. To transponse chords when more or less light is available we wrote a method which ensures that chords are transponsed only within octaves to avoid disharmony.

Methods to chose keys/chords randomly and to transponse chords.

Lessons learned:

How to connect Arduino to Processing?

The first issue we had to encounter was how to connect the Arduino board to a higher programming language – in our case: Processing.  Certainly the Arduino library has to go into the processing-folder but there is still a library mismatch, if the library files “librxtxSerial.jnilib” and “RXTXcomm.jar” are not copied from your Arduino-program-folder to the Java library of your operating system. Now the “Firmata” library has to be loaded onto the Arduino board. This is done by launching Arduino and selecting “Examples” > “Firmata” > “StandardFirmata”. But now you have to be really careful! When you load a normal Arudino sketch the “Firmata” is being erased and you would have to load it once again on your Arduino! After this has been done properly a serial connection to the Arduino can be set up in Processing by using the statements

import processing.serial.*;
import cc.arduino.*;

and creating a serial Arduino object for example as

Arduino arduino = new Arduino(this, Arduino.list()[4], 57600);

This object now can be addressed with most Arduino commands but unfortunately not with all, what brings us to our next issue.

Circuit Diagram (made with Fritzing)

How to measure wind?

Since we had to measure the speed of wind for our project the first idea was to simply grab the fan-speed of an old PC-fan that has not been connected to current but instead is just grounded with its sensor pin connected to one of the digital Arduino-pins. This works fine since there are many examples of Arduino-code for grabbing fan speed but sadly none of them worked for us in Processing, since not all needed Arduino commands are supported. So our solution was to mount the rotor of one fan to an electric motor and measure the speed by tracing the outgoing current. This can be done by connecting the plus-port of the motor to an Arduino’s analog input port. The value being read from the port (range goes from 0 to 1023) reflects the outgoing current of the motor.

Measuring the speed of wind was not so easy as it my sound at first.

How to measure water flow?

To measure the amount of rain the workflow is basically the same. Once the rotor was attached to the motor we had to use a pipe and a some kind of container to gather water on the top of the jukebox. For a working construction it’s crucial that the diameter of the pipe matches the width of the rotor. Furthermore the water has flow with a certain speed and the pipe needs to be perfectly aligned to the rotor to make it turn around. Unfortunately we didn’t test it thoroughly enough so this measurement didn’t work as we had expected.

Measurement of water flow can also be done by a rotor attached to a motor.

Parallel programming with processing?

Programming Processing is very similar to coding Arduino directly using the Arduino programming tool. There is a setup() method and also a permanently called method that is named draw() and not loop() like in Arduino. This is all in all no problem but when it comes to doing things real-time parallel it can get a little bit tricky. In our case we needed to play chords and a beat at the same time. But since only one of this can be done at one moment in the draw() method we had to find  a workaround. Our solution was to create different objects of our sound-library (SoundCipher) a SoundCipher-object and an SCScore-object and call them consecutive so (with a little tweaking) the sound seemed to be absolutely parallel. An other method could have been a callback-method that allows the program to jump back into the setup()-method, but this was a little to time intense for our purpose.

To give the impression of parallel execution the beats have to be played immediately before the chords.

Values and Potentials:

The Environmental Jukebox is a tool that creates random-music that always sounds very harmonic and adepts to the environmental influences. So it can be used as a tool of inspiration for musicians when they place it on some outdoor locations where they like to compose their tunes. Due to the fact that the Jukebox always sticks to a certain key and only changes it when the temperature drops below 20° it also works really nice as an accompanying instrument that can be joined by any thinkable solo instrument. Also the acoustic representation of the environment itself could make the Jukebox interesting for any environmentally aware companies or organizations that would like to have some smooth background-tunes at their place that are created by nature itself.

Next Steps:

Thus music almost offers endless possibilities, the options how to improve and enhance the Environmental Jukebox seem to be without much limit, too. Adding multiple channels and instruments, more sensors or even building a portable device, that not only reacts on environmental influences but also on the ones of his wearer, are just a few of the possibilities that could be done in the future. For more human interaction an interface with real instruments would certainly push the jukebox more in an interactive direction, that would give it more of the attitude of a real instrument, that could join in any musical arrangement. Even the combination of many devices to whole automated concerts that depend on environmental energies would be thinkable and would certainly be a lot of fun!