Led visualizer для фортепиано

Raspberry Pi Blog

Unlock your inner Rousseau with this gorgeous Raspberry Pi Zero LED piano visualiser.

Pianist Rousseau

Fans of the popular YouTube pianist Rousseau would be forgiven for thinking the thumbnail above is of one of his videos. It’s actually of a Raspberry Pi build by Aleksander Evening, who posted this project on Reddit last week as an homage to Rousseau, who is one of his favourite YouTubers.

Building an LED piano visualiser

After connecting the LED strip to the Raspberry Pi Zero W, and setting up the Pi as a Bluetooth MIDI host, Aleksander was almost good to go. There was just one thing standing in his way…

He wanted to use the Synthesia software for visualisations, and, unmodified, this software doesn’t support the MIDI files Aleksander planned to incorporate. Luckily, he found the workaround:

As of today Synthesia doesn’t support MIDI via Bluetooth, it should be added in next update. There is official workaround: you have to replace dll file. You also have to enable light support in Synthesia. In Visualizer settings you have to change “input” to RPI Bluetooth. After that when learning new song next-to-play keys will be illuminated in corresponding colors, blue for left hand and green for right hand.

Homemade Rousseau

The final piece is a gorgeous mix of LEDs, sound, and animation — worthy of the project’s inspiration.

Find more information, including parts, links to the code, and build instructions, on Aleksander’s GitHub repo. And as always, if you build your own, or if you’ve created a Raspberry Pi project in honour of your favourite musician, artist, or YouTuber, we’d love to see it in the comments below.

Читайте также:  Password ludovico einaudi ноты

And now, a little something from Rousseau:

Источник

Led visualizer для фортепиано

Piano LED Visualizer

  • Piano with MIDI or USB output
  • MIDI to USB interface (if your piano doesn’t have USB output) Amazon US | Aliexpress (cheap midi interfaces might not work as intended, I recommend hardware from more known brands. I personally use iConnectivity mio Amazon US )
  • Raspberry Pi Zero WH Amazon US | Aliexpress | Aliexpress #2
  • MicroSD card (16GB is more than enough) Amazon US | Aliexpress
  • USB OTG Amazon US | Aliexpress
  • WS2812B LED Strip (at least 1.5m with 144 diodes/meter) Amazon US | Aliexpress
  • Power Supply (5V 6A is enough to light 172 LEDs @50% power) Amazon US | Aliexpress
  • DC 5.5×2.5mm socket with quick connection Amazon US | Aliexpress
  • Waveshare LCD TFT 1,44» 128x128px Amazon US | Aliexpress
  • Some wires

Not required but worth having, to make everything look neat:

  • Custom 3d printed case (I attached STL file with modified 3d model, there is additional space and holes for power socket and wires, here is original model)
  • Braid for cables Amazon US | Aliexpress
  • Heat shrink bands Amazon US | Aliexpress
  • Aluminium LED Profile with diffuser (highly recommend to search for the right one in local shops) pic#1pic#2Aliexpress(choose T0515 for 12mm 2 meters, credits to vzoltan for finding this)
  • Double side tape to stick everything on the piano
  • Windows 10 laptop/tablet with bluetooth to run Synthesia

Total cost (excluding piano and tablet) should be 75-100 USD Disclosure: All of the links above are affiliate links, which means that without additional costs for you, I will earn a commission if you make a purchase by clicking through it.

There are two ways, you can use preconfigured system image or install everything manually.

1. System image

  • Download latest zip file from releases.
  • Unzip the file.
  • Use program like Win32 Disk Imager or Etcher to save system image to your SD card (4GB is a minimum).

If you don’t need to connect your RPi to Wi-Fi you can eject SD card from your PC and put it in Raspberry Pi. After 3-8 minutes (depending on how fast your SD card is) you should see Visualizer menu on RPi screen.

If you want to make your RPi autoconnect to Wi-Fi you need to follow this guide (starting from step 3)

Note: replace “ with » when editing wpa_supplicant.conf file.

2. Manual installation

Learning to play with Synthesia

We need to make a connection between your PC/MAC/Android. There are at least 3 ways of doing that:

1. Sevilla’s Soft MIDI USB-USB device This is, in my opinion, the best way to make connection between RPi and PC. It works with any device that support MIDI over USB, offers the lowest latency and no lost packets. The only downside is that it cost €39.00 (

48 USD) + shipping. You connect your Piano and PC to USB HUB connected to RPi and that’s it, everything just works. Link to store

2. RTP MIDI (MIDI by ethernet) For this method you need to use some software on your Synthesia’s device and both devices must be connected to the same local network.

Default port is 5004.

  • Connect RTP MIDI server with your piano, type: aconnect -i -l You should see something like:

Look for your piano name and RTP midi ports, in my case it’s mio MIDI 1 and rtpmidi raspberrypi .

  • Connect them accordingly with:

aconnect 20:0 128:1

aconnect 128:1 20:0

In case of any problems those commands might be helpful:

sudo systemctl restart rtpmidid restarting RTP midi service

aconnect —removeall removing all connections between ports

3. Bluetooth This method is not recommended due to problems with establishing the first connection, especially on devices other than those with Windows 10. If you still want to try, follow this link for instructions.

You have to enable light support in Synthesia by setting «Key Light» option to «Finger-based channel». In Visualizer settings you have to change «input» to either RPI Bluetooth (for bluetooth connection), rtpmidi raspberrypi (for RTP connections) or MIDI USB-USB (for cable connection). After that when learning new song next-to-play keys will be illuminated in corresponding colors, blue for left hand and green for right hand.

If you are getting mixed colors, meaning that leds are lighting up with your predefined and next-to-play colors at the same time, you can use «Skipped notes» option in Visualizer to disable one of them.

Learning to play MIDI files

The Visualizer supports learning to play MIDI files without the need of Synthesia or additional external devices.

For practicing, the following 3 modes can be used:

  • Melody: The song will wait for you to hit the correct notes. Take your time and try to avoid mistakes. Holding notes to their full duration is also important, otherwise you might develop muscle memory with the mistakes included.
  • Rhythm: Adjust the speed using Set tempo option until you can play without mistakes. Play as fast as you can comfortably. Work your way up to 100% speed. Practice the Melody first to make this step easier.
  • Listen: In this mode the song will play in listen only mode at the Set tempo speed.

Different combinations of practicing modes be realized using the Hands and Mute Hand options. To practice only a section of the song, adjust the Start point and the End point values.

Recommended way of practicing is by following the song music sheet (see below how to print the music sheet from a midi file), while the Visualizer indicates the notes to press on the piano.

Handling MIDI files

  • Generating music sheet: To generate a printable music sheet from a MIDI file use the Midi Sheet Music app. The app already contains a library of MIDI files that can be played.
  • Editing MIDI files: To visualize and edit MIDI files use the MidiEditor. Only type 1 of midi files have been tested. Other types of midi files might need to be adjusted in order to work with the Visualizer.
  • Uploading MIDI files: Two ways are proposed here to upload MIDI files to Raspberry Pi Zero
    • From PC: WinSCP
    • From Smartphone: RaspController

In case of upload errors, use Putty to change the access permissions for the Songs folder:

Connecting LED Strip to Raspberry Pi and enabling SPI

There is no point to reinvent the wheel again, here is a nice tutorial (do only the hardware part)

If you are wondering how to connect wires to RPI if screen hat is taking all pins here is a picture of how I did it. There should be a gap between RPI and screen so you can solder your wires or just wrap cables around the pins and separate them with heat shrink bands.

After connecting all cables as described above everything should fit nicely to case. Scroll down to see some photos of the setup I made If you don’t have a 3d printer (like me) try to find some company or private person who will print it for you. I paid 12USD for my print. RPICaseModel.stl

Q — Can I use Raspberry Pi 1/2/3/4 instead of Zero?

  • In theory, yes. In practice many users reported problems with huge delay between key presses and lights reacting to it on Raspberrys other than Zero.

Q — What about Raspberry Pi Zero without Wi-Fi and bluetooth?

  • If you are going only for the visuals and do not plan to use it with Synthesia you can save some bucks and buy cheaper, non-WH version of Zero.

Q — Can I use other screens or no screen at all?

  • Currently the only other supported screen is Waveshare LCD TFT 1,3″. As for no screen, you need it for changing LED settings. If you don’t mind changing it manually by editing settings file you can go without screen.

Q — Does the color of LED strip PCB matter?

Q — Can I use other led strip?

  • Only WS281X led strips are supported

Q — Do I need power supply for LED strip?

  • RPi alone should be fine powering up to 10 LEDs at the same time, although I do not recommend it.

Q — Do I need soldering skills to make it?

  • Users reported that LED strips bought on Amazon are shipped in one meter strips, in that case you would need to solder them. I bought mine on Aliexpress and it was 2 meters long strip in one piece. As for connecting wires to RPi, I just wrapped them around pins and tightened it with heat shrink bands.

Q — How do I access recorded files?

  • If you connected your RPi to Wi-Fi you can use SFTP to transfer files. In any FTP program like Filezilla connect to your RPi local address (for example: sftp://192.168.1.10 ) and navigate to /home/Piano-LED-Visualizer/Songs.

Q — How do I update visualizer?

A — From the Visualiser menu Other Settings > Update visualizer > Confirm . After the update, a reboot is required. Warning: The update will revert all customizations to the default values!

B — Connect to your console using SSH and type:

cd /home/Piano-LED-Visualizer and then

git pull origin master

If for some reasons it does not work try to remove whole project and clone it again.

sudo rm -rf Piano-LED-Visualizer

sudo git clone https://github.com/onlaj/Piano-LED-Visualizer

Using the sequences

In the visualizer menu you can find setting called «Sequences». It allows you to change led properties while playing using third key on Waveshare hat or your piano pedals. You can edit or create new sequences by editing «sequences.xml» file. The «control_number» defines which pedal is used to go to the next step.

Control number Pedal name
64 Damper Pedal (Sustain/Hold) On/Off
65 Portamento On/Off
66 Sostenuto On/Off
67 Soft Pedal On/Off

The «next_step» value decides if next step is activated when you press or release the pedal. For example if you want to change settings after fully pressing Sostenuto pedal you should write it like:

127 is the maximum value when pedal is fully pressed, so you are saying to script to change settings when value is bigger than 126. This is how it should look when you want to change settings when fully releasing pedal.

(-) before the number means that next step will be activated when pedal value is below 1.

You can also use sequences as a way to save your presets under custom names.

Источник

Led visualizer для фортепиано

Piano LED Visualizer

  • Piano with MIDI or USB output
  • MIDI to USB interface (if your piano doesn’t have USB output) Amazon US | Aliexpress (cheap midi interfaces might not work as intended, I recommend hardware from more known brands. I personally use iConnectivity mio Amazon US )
  • Raspberry Pi Zero WH Amazon US | Aliexpress | Aliexpress #2
  • MicroSD card (16GB is more than enough) Amazon US | Aliexpress
  • USB OTG Amazon US | Aliexpress
  • WS2812B LED Strip (at least 1.5m with 144 diodes/meter) Amazon US | Aliexpress
  • Power Supply (5V 6A is enough to light 172 LEDs @50% power) Amazon US | Aliexpress
  • DC 5.5×2.5mm socket with quick connection Amazon US | Aliexpress
  • Waveshare LCD TFT 1,44» 128x128px Amazon US | Aliexpress
  • Some wires

Not required but worth having, to make everything look neat:

  • Custom 3d printed case (I attached STL file with modified 3d model, there is additional space and holes for power socket and wires, here is original model)
  • Braid for cables Amazon US | Aliexpress
  • Heat shrink bands Amazon US | Aliexpress
  • Aluminium LED Profile with diffuser (highly recommend to search for the right one in local shops) pic#1pic#2Aliexpress(choose T0515 for 12mm 2 meters, credits to vzoltan for finding this)
  • Double side tape to stick everything on the piano
  • Windows 10 laptop/tablet with bluetooth to run Synthesia

Total cost (excluding piano and tablet) should be 75-100 USD Disclosure: All of the links above are affiliate links, which means that without additional costs for you, I will earn a commission if you make a purchase by clicking through it.

There are two ways, you can use preconfigured system image or install everything manually.

1. System image

  • Download latest zip file from releases.
  • Unzip the file.
  • Use program like Win32 Disk Imager or Etcher to save system image to your SD card (4GB is a minimum).

If you don’t need to connect your RPi to Wi-Fi you can eject SD card from your PC and put it in Raspberry Pi. After 3-8 minutes (depending on how fast your SD card is) you should see Visualizer menu on RPi screen.

If you want to make your RPi autoconnect to Wi-Fi you need to follow this guide (starting from step 3)

Note: replace “ with » when editing wpa_supplicant.conf file.

2. Manual installation

Learning to play with Synthesia

We need to make a connection between your PC/MAC/Android. There are at least 3 ways of doing that:

1. Sevilla’s Soft MIDI USB-USB device This is, in my opinion, the best way to make connection between RPi and PC. It works with any device that support MIDI over USB, offers the lowest latency and no lost packets. The only downside is that it cost €39.00 (

48 USD) + shipping. You connect your Piano and PC to USB HUB connected to RPi and that’s it, everything just works. Link to store

2. RTP MIDI (MIDI by ethernet) For this method you need to use some software on your Synthesia’s device and both devices must be connected to the same local network.

Default port is 5004.

  • Connect RTP MIDI server with your piano, type: aconnect -i -l You should see something like:

Look for your piano name and RTP midi ports, in my case it’s mio MIDI 1 and rtpmidi raspberrypi .

  • Connect them accordingly with:

aconnect 20:0 128:1

aconnect 128:1 20:0

In case of any problems those commands might be helpful:

sudo systemctl restart rtpmidid restarting RTP midi service

aconnect —removeall removing all connections between ports

3. Bluetooth This method is not recommended due to problems with establishing the first connection, especially on devices other than those with Windows 10. If you still want to try, follow this link for instructions.

You have to enable light support in Synthesia by setting «Key Light» option to «Finger-based channel». In Visualizer settings you have to change «input» to either RPI Bluetooth (for bluetooth connection), rtpmidi raspberrypi (for RTP connections) or MIDI USB-USB (for cable connection). After that when learning new song next-to-play keys will be illuminated in corresponding colors, blue for left hand and green for right hand.

If you are getting mixed colors, meaning that leds are lighting up with your predefined and next-to-play colors at the same time, you can use «Skipped notes» option in Visualizer to disable one of them.

Learning to play MIDI files

The Visualizer supports learning to play MIDI files without the need of Synthesia or additional external devices.

For practicing, the following 3 modes can be used:

  • Melody: The song will wait for you to hit the correct notes. Take your time and try to avoid mistakes. Holding notes to their full duration is also important, otherwise you might develop muscle memory with the mistakes included.
  • Rhythm: Adjust the speed using Set tempo option until you can play without mistakes. Play as fast as you can comfortably. Work your way up to 100% speed. Practice the Melody first to make this step easier.
  • Listen: In this mode the song will play in listen only mode at the Set tempo speed.

Different combinations of practicing modes be realized using the Hands and Mute Hand options. To practice only a section of the song, adjust the Start point and the End point values.

Recommended way of practicing is by following the song music sheet (see below how to print the music sheet from a midi file), while the Visualizer indicates the notes to press on the piano.

Handling MIDI files

  • Generating music sheet: To generate a printable music sheet from a MIDI file use the Midi Sheet Music app. The app already contains a library of MIDI files that can be played.
  • Editing MIDI files: To visualize and edit MIDI files use the MidiEditor. Only type 1 of midi files have been tested. Other types of midi files might need to be adjusted in order to work with the Visualizer.
  • Uploading MIDI files: Two ways are proposed here to upload MIDI files to Raspberry Pi Zero
    • From PC: WinSCP
    • From Smartphone: RaspController

In case of upload errors, use Putty to change the access permissions for the Songs folder:

Connecting LED Strip to Raspberry Pi and enabling SPI

There is no point to reinvent the wheel again, here is a nice tutorial (do only the hardware part)

If you are wondering how to connect wires to RPI if screen hat is taking all pins here is a picture of how I did it. There should be a gap between RPI and screen so you can solder your wires or just wrap cables around the pins and separate them with heat shrink bands.

After connecting all cables as described above everything should fit nicely to case. Scroll down to see some photos of the setup I made If you don’t have a 3d printer (like me) try to find some company or private person who will print it for you. I paid 12USD for my print. RPICaseModel.stl

Q — Can I use Raspberry Pi 1/2/3/4 instead of Zero?

  • In theory, yes. In practice many users reported problems with huge delay between key presses and lights reacting to it on Raspberrys other than Zero.

Q — What about Raspberry Pi Zero without Wi-Fi and bluetooth?

  • If you are going only for the visuals and do not plan to use it with Synthesia you can save some bucks and buy cheaper, non-WH version of Zero.

Q — Can I use other screens or no screen at all?

  • Currently the only other supported screen is Waveshare LCD TFT 1,3″. As for no screen, you need it for changing LED settings. If you don’t mind changing it manually by editing settings file you can go without screen.

Q — Does the color of LED strip PCB matter?

Q — Can I use other led strip?

  • Only WS281X led strips are supported

Q — Do I need power supply for LED strip?

  • RPi alone should be fine powering up to 10 LEDs at the same time, although I do not recommend it.

Q — Do I need soldering skills to make it?

  • Users reported that LED strips bought on Amazon are shipped in one meter strips, in that case you would need to solder them. I bought mine on Aliexpress and it was 2 meters long strip in one piece. As for connecting wires to RPi, I just wrapped them around pins and tightened it with heat shrink bands.

Q — How do I access recorded files?

  • If you connected your RPi to Wi-Fi you can use SFTP to transfer files. In any FTP program like Filezilla connect to your RPi local address (for example: sftp://192.168.1.10 ) and navigate to /home/Piano-LED-Visualizer/Songs.

Q — How do I update visualizer?

A — From the Visualiser menu Other Settings > Update visualizer > Confirm . After the update, a reboot is required. Warning: The update will revert all customizations to the default values!

B — Connect to your console using SSH and type:

cd /home/Piano-LED-Visualizer and then

git pull origin master

If for some reasons it does not work try to remove whole project and clone it again.

sudo rm -rf Piano-LED-Visualizer

sudo git clone https://github.com/onlaj/Piano-LED-Visualizer

Using the sequences

In the visualizer menu you can find setting called «Sequences». It allows you to change led properties while playing using third key on Waveshare hat or your piano pedals. You can edit or create new sequences by editing «sequences.xml» file. The «control_number» defines which pedal is used to go to the next step.

Control number Pedal name
64 Damper Pedal (Sustain/Hold) On/Off
65 Portamento On/Off
66 Sostenuto On/Off
67 Soft Pedal On/Off

The «next_step» value decides if next step is activated when you press or release the pedal. For example if you want to change settings after fully pressing Sostenuto pedal you should write it like:

127 is the maximum value when pedal is fully pressed, so you are saying to script to change settings when value is bigger than 126. This is how it should look when you want to change settings when fully releasing pedal.

(-) before the number means that next step will be activated when pedal value is below 1.

You can also use sequences as a way to save your presets under custom names.

Источник

Оцените статью