Musical Box
Introduction
This project was created to participate in a contest and we have modified it and enriched it with features. Even now we are working to add new features in the little free time we can find.
I love music and it accompanies me in all the important moments of my life. This project uses a Cypress Semiconductor CY8CKIT-041-41XX PSoC® 4100S Pioneer Kit and a Raspberry Pi 4 to build a simple Music Machine. The operating principle is simple: let's imagine, for example, distributing the musical genres we prefer on an x,y plane, then positioning the songs according to the genre. Just click on the trackpad and the song will start with the coordinates closest to those of the clicked position. Once the song is finished, the song closest to the clicked position among those remaining is played.
Obviously, the user can decide whether to change the genre (by clicking on a new area of the trackpad) or move to the next song. It will also be possible to vary the volume using the trackpad.
For example, we could associate the x-axis with speed ( low x corresponds to "slow" music, love songs, while high x values represent "fast" songs, for example Rock songs. The Y axis could instead represent a quality index, for example, low values of y could represent pop music, while higher values represent Jazz. The work of classifying the songs is very important and, based on how it is done, we will obtain different results.
An interesting classification for long stays in the car could be, for example, this, staring at the bottom left for love songs, for example, Elton John, at the bottom right for rock songs (Queen, Eagles, etc.), at the top right for fast rock songs (Deep Purple, Metallica), top left Jazz pieces (Miles Davis, John Coltrane, etc.).
The project
The project was created using only two devices.
We used the CY8CKIT-041-41XX PSoC® 4100S Pioneer Kit to build the user interface. The device is really interesting and we have only used the trackpad for now. Its modular construction allows you to use it even in an external case, it is in fact made as two distinct sections, that of the sensors and the control unit which are connected via a flat cable. It is very simple to use the components of this device in a complex project..
The task performed by this module is only to collect the commands provided by the user, for example, the position on the "music map", or the simple operations that we can perform, such as adjusting the volume or changing the track. The code was created starting from the examples provided by Cypress which allows you to use the trackpad with the "click", "swipe" and "rotation" functions.
Edge Swipe Right, Click, Edge Swipe Left, Rotate Clockwise, Rotate Counterclockwise, Touchpad Area
The second device used was a Raspberry Pi 4 which is used to make the mp3 file player. We'll use simple Python code to handle the playback of the audio tracks. In particular, the pygame library that manages mp3 files with extreme simplicity and reliability has been of great help. The connection between the two devices was made with a simple serial connection.
Song classification
All the songs to be used must be contained in a folder whose position must be declared in the Python code.
Each song will have a prefix consisting of two numbers between 0 and 99 that represent the Cartesian (x and y) coordinates of the song in the trackpad plane. The trackpad has a sensitive area represented by a matrix of 100x100 points and the association between the song and its "position", i.e. its x and y coordinates, must be made by the user according to one's preferences, through a "musical map ". I have thought of a few but the choice depends on everyone's musical tastes and, based on their musical preferences, everyone will be able to create their own "musical map", where to place the songs.
A rather boring job is to classify the music, i.e. associate a pair of coordinates to each song based on the criteria adopted.
It could be very interesting to automatically classify the songs using an Artificial Intelligence system, such as Edge Impulse which, from the spectral components of the song, can extract the x and y coordinates for correct placement of the song in the x, and y plane of our musical map.
The code
We had to program the CY8CKIT-041-41XX PSoC® 4100S Pioneer Kit and the Raspberry Pi 4. To program the trackpad we used PSoC Creator while we used Python to create the Musical Box on the Raspberry.
Conclusion
It was so much fun making this project. I hope I haven't bored you too much and thanks to Genesis for the blog title.