element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Music Time
  • Challenges & Projects
  • Project14
  • Music Time
  • More
  • Cancel
Music Time
P14 Music Time Blog Musical Box
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Music Time to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: redcharly
  • Date Created: 14 Apr 2023 9:46 PM Date Created
  • Views 995 views
  • Likes 8 likes
  • Comments 2 comments
  • raspberry
  • musictimech
  • music
  • psoc
Related
Recommended

Musical Box

redcharly
redcharly
14 Apr 2023

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.

image

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.

image

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.).

image

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..

image

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.

image

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.

image

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.

image

A rather boring job is to classify the music, i.e. associate a pair of coordinates to each song based on the criteria adopted.

image


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.

image

image

image

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.  

image

image

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

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.

  • Sign in to reply
  • dougw
    dougw over 2 years ago

    Nicely done.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • aspork42
    aspork42 over 2 years ago

    that is awesome - nice work!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube