Go Down

Topic: Reactive Piano LED Strip (Read 328 times) previous topic - next topic

SchnoppDog

Hello Arduino Community,

Recently I saw some videos on youtube of pianists playing the piano with lightended (flashing) keys (for example Rousseau). Since I like playing the piano myself I wanted to do the same. I searched through the internet for any tutorial on how to do that. But in the end I didn't find any good/helpful instruction on how to do it. Since I am a rookie in arduino coding (never did anything with arduino) I don't know the code.

I did find some Information on which Hardware requirements I need.
  • An Arduino (Reccomendations from forums have been arduino uno)
  • LED Stripe Neopixel ws2812 (or any othter addressable LED Strip)
  • And of course Cables, Resistorsm, Breadboard etc.

Now I don't know if it would work anyways since in those instructions the (old) two round midi cables were used. I don't have those for my piano. I have an USB to Host port. Is it still possible to accomplish my goal?

It would be nice if you could provide me any Information on how to do this. Links, Forum Threads anything would help me since I really want to do this.

Thank you very much in Advance.
(PS: sry for the bad english)

Grumpy_Mike

Quote
I have an USB to Host port. Is it still possible to accomplish my goal?
That means your Arduino will need a USB host shield.

Also don't use Neopixel LEDs, the WS2812 type as the timing required to drive them interferes with reception of the MIDI messages. Use the so called Dot Star types instead.

Otherwise it is straightforward but you need to learn about coding. Start with the examples in the led library you decide to use, I think the Adafruit one is simplest to understand.

krullebolle

  • Is your USB out a midi signal?
  • Use an arduino with native USB capabilities, like this one.
  • Then use this library for reading the midi signal.
  • Then use this library, or the adafruit like mike says for adressing your dot star leds.



This is 2 minutes of googling. There are alot of examples in the libraries, I would suggest you buy an arduino DUE starter pack, so you can first learn to code and tinker a bit with it. And slowly learn yourself. Research is everything, there is no problem that hasnt been asked before. Everything is out on the internet with a little search effort.

slipstick

The project is perfectly possible, even fairly straightforward. But please tell us exactly what "piano" you have. It's always easier to help if we know what we're dealing with.

There are several Arduinos that can handle MIDI over USB without needing a separate USB Host which makes life simpler. I like the Pro Micro or Leonardo for MIDI but there are others.

Steve


Grumpy_Mike

#4
Oct 12, 2018, 10:08 am Last Edit: Oct 12, 2018, 10:21 am by Grumpy_Mike
Quote
This is 2 minutes of googling.
And crap googling at that. You are failing to understand the diferance between USB host and USB client.

Quote
There are several Arduinos that can handle MIDI over USB without needing a separate USB Host which makes life simpler. I like the Pro Micro or Leonardo for MIDI but there are others.
Sorry none of those processors can operate as a USB host only as a client.

Just look at the sockets involved. They are designed so that you have to plug a host into a client. The Arduino has the wrong sort of socket, it is not the same as a PC so you can't attach an Arduino to a cable that is expecting to be plugged into a PC.

slipstick

Apologies, I'm obviously going to have to understand USB topology a bit better.

I could have sworn I'd done MIDI instrument USB out to a Pro Micro to run LEDs and other stuff. Maybe I've only done it via a PC as host. More investigation needed.

Steve

SchnoppDog

First of all thank you for helping me this much. As you recommended I'm going to start coding with an Arduino starter pack to get into programming with it.

Quote from: krullebolle
Is your USB out a midi signal?
I guess it is. It says in the manual that I can switch with one key the two functions of "sending midi" and "receiving midi"

Quote from: slipstick
But please tell us exactly what "piano" you have.
It's a Yamaha P-45

DavidM81

I too would love to know how this is done. SchnoppDog, if you search Arduino and midi on YouTube there's a series of videos that might help but it doesn't show you how to use the midi out signals to correspond to led's. I'm a complete novice at this stuff but this has really sparked my interest in Arduino.

Grumpy_Mike

I could have sworn I'd done MIDI instrument USB out to a Pro Micro to run LEDs and other stuff.
As far as I know the Due is the only Arduino capable of acting like a USB host.

See:- https://www.arduino.cc/en/Reference/USBHost

Quote
but it doesn't show you how to use the midi out signals to correspond to led's.
It is the MIDI in that you want to correspond to a light. This project controls solenoids depending on the MIDI input. Just replace the solenoids with an LED and resistor. There is no need to have the solenoid driver either you can connect them direct to the pins.
http://www.thebox.myzen.co.uk/Hardware/Glockenspiel.html

SchnoppDog

#9
Oct 16, 2018, 08:50 am Last Edit: Oct 16, 2018, 08:51 am by SchnoppDog
Quote from: DavidM81
if you search Arduino and midi on YouTube there's a series of videos that might help but it doesn't show you how to use the midi out signals to correspond to led's
I know. I've already contacted some of them but they never replied since today. I know that it is something like magic "you won't tell someone how you did it". But they could have give atleast some hints like all of you did.

When I get payed next time I'm going to get me a starter kit, trying some codes and after that maybe do the project.

The thing is that I know how to connect the strip and code it for lighting but don't know how to interact with midi :/. Guess I'll have to figure it out in the future.

vibhu18

There's another approach, what about controlling the LEDs with the pitch of the sound.
You can do it like this. Get an electrolytic microphone. connect it with A0 pin of Arduino(any board). then use the library open music lab ,it consists of FHT library which perfectly samples the incoming signals and puts them into different frequency bins and then uses Fourier Hartley Transform to sample the signal into different frequency bands.

so you can program your  Arduino using this library in such a way that different colors glow at different frequency bands.

Next step is controlling LED strip from Arduino. For this, you can use IRL540(recommended) or IRF530 for better current amplification and switching. You can also use this module https://shop.controleverything.com/products/8-channel-8w-open-collector-fet-driver for the same purpose


Grumpy_Mike

#11
Oct 16, 2018, 11:51 am Last Edit: Oct 16, 2018, 11:54 am by Grumpy_Mike
Quote
but don't know how to interact with midi :/. Guess I'll have to figure it out in the future.
If you use the Neopixel ( WS2812 ) LEDs then you can't do it correctly because the timing needed to drive the strip stops the MIDI receive from working when there is a lot of MIDI activity. So figure that out now not in the future.

To do this you need to use the Dot Star (APA102) type of LED strip where the timing is not critical.

Interacting with MIDI is simple suppose you have a variable with the MIDI note number in it. Then simply set the LED in the strip whose number is simply this minus the lowest number you want to show on the strip:-

Code: [Select]

leds[note - lowestNumber] = CRGB::Red;

 
For note on and
Code: [Select]

leds[note - lowestNumber] = CRGB::Black;


for note off.

Grumpy_Mike

There's another approach, what about controlling the LEDs with the pitch of the sound.
You can do it like this. Get an electrolytic microphone. connect it with A0 pin of Arduino(any board). then use the library open music lab ,it consists of FHT library which perfectly samples the incoming signals and puts them into different frequency bins and then uses Fourier Hartley Transform to sample the signal into different frequency bands.
This will not work for real sounds as it lights up the LEDs for all the harmonics not just the fundamental note that the OP wants to high lite on his keyboard. You get a spectrum display not a note display.

vibhu18

This will not work for real sounds as it lights up the LEDs for all the harmonics not just the fundamental note that the OP wants to high lite on his keyboard. You get a spectrum display not a note display.
Brother, FFT is made for this purpose on to sample a sinusoidal frequency bound signal to respective frequency bands. he can check the frequency of different notes and then program the Arduino in such a way that the particular note comes in that particular band and then he can turn on the led light corresponding to that frequency band.
I have done this, I have categorized it for bass and treble where low-frequency bands for bass and higher for treble. then further again you can categorize them for the particular frequency. 

Grumpy_Mike

Quote
Brother, FFT is made for this purpose on to sample a sinusoidal frequency bound signal to respective frequency bands.
Yes but we are not dealing with pure sinusoidal signals here.

To be strictly accurate the FFT was designed to model the flow of heat through a bar. Splitting sounds up is only a recent use of the mathematical technique.

Quote
I have done this, I have categorized it for bass and treble where low-frequency bands for bass and higher for treble.
Yes I have done this as well, it is called a spectrum display. If you want to see a full example of this then please see chapters 15 and 16 of the book I wrote:- http://www.apress.com/9781484217207

Quote
then further again you can categorize them for the particular frequency.
No you can't. For any given real note you can not say what frequency is the fundamental, the strongest frequency changes thought the duration of the note. You can not isolate notes and send them back to the keys on the note which is what this thread is all about. Keeping things simple in the digital domain is the only way to do things reliably. Many people have tried to do this and they all have failed. This is why a sound to MIDI conversion never works at 100%.

If you want to make a contribution to this thread then please restrict yourself to the problem in hand.

Go Up