Code Monkey home page Code Monkey logo

piano-led-visualizer's Introduction

Piano LED Visualizer

contributions welcome

Everything Is AWESOME

What you need:

Not required but worth to have 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 right one in local shops) pic#1 pic#2
  • Double side tape to mount everything on 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, meaning, at no additional cost to you, I will earn a commission if you click through and make a purchase.

Software preparations

Install Raspbian on you Raspberry Pi. This step requires to connect monitor, keyboard and/or mouse to your RPi. If you can't do it I suggest you to follow this guide: Raspberry Pi Setup Without a Monitor, Keyboard or a Mouse

Automatic midi connection and setting Raspberry Pi as Bluetooth MIDI host

Here is instruction Just do following parts and skip the others:

  • configuring automatic midi connection (this is required even if you don't need Bluetooth feature)
  • midi bluetooth setup

If you have problems with connecting your PC to RPI try to add

DisablePlugins = pnat

to /etc/bluetooth/main.conf file. You will have to restart RPI after making this change.

If you still have problems with connecting your Windows tablet/pc try to install Blueman, graphical bluetooth manager

sudo apt-get install blueman

If you don't need BT connection you can skip "midi bluetooth setup" part, but you need to install few libraries anyway.

sudo apt-get install libjack0 
sudo apt-get install libjack-dev 
sudo apt-get install libasound2-dev

Learning to play with Synthesia

Official instruction:

First, make sure the "Midi.UseWinRtMidi" option is enabled:

  1. Hold your Shift key while launching Synthesia (to open the configuration window).
  2. Find the "Midi.UseWinRTMidi" entry in the Setting drop-down box.
  3. Add a check mark to the "Value" box.

BT support on different devices:

  • BLE MIDI on macOS: completely automatic and supported
  • BLE MIDI on iOS: completely automatic and supported
  • BLE MIDI on Win10: enable the "Midi.UseWinRTMidi" advanced option to try and use Microsoft's complete mess of a UWP driver.
  • BLE MIDI on Android: if your device supports the "Android M MIDI" feature, just connect to the MIDI device using these instructions and it should "work" fine, with all of Android's awful latency and dropped events

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

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

Using cable instead of Bluetooth

If you can't get stable bluetooth connection there are alternative ways that requires the purchase of additional equipment. The optimal solution I found is this device. It allows you to connect your RPi with any equipment that supports midi through USB. It can also be useful if you want less delay and fewer missed notes. Here is some short comparison.

Connecting LED Strip to Raspberry Pi and enabling SPI

There is no point to reinvent the wheel again, here is a nice tutorial

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.

You also need to enable SPI

Putting everything together

After connecting all cables as described above everything should fit nicely to case. 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

Running Visualizer

Download or clone this repository into your RPI.

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

Using PIP install all libraries listed in requirements.txt file Run visualizer.py with command

sudo -E python visualizer.py

You can auto run Visualizer on RPi boot, just follow this tutorial: How To Autorun A Python Script On Raspberry Pi Boot

If you are using WaveShare 1.3inch 240x240 LED Hat instead of 1.44inch 128x128, add this argument:

sudo -E python visualizer.py --display 1in3

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 decide 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:

<control_number>66</control_number> 
<next_step>126</next_step>

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.

  <control_number>66</control_number> 
  <next_step>-1</next_step>

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

Image Image enter image description here Image Image Image Image Image

piano-led-visualizer's People

Contributors

onlaj avatar ericdallo avatar rickstaa avatar namdaoduy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.