Go Down

Topic: MIDI react LED using Arduino. (but im really stuck) (Read 1 time) previous topic - next topic

ozguney

You have to select the correct USB mode from the Tools menu.

Also, your program will crash/behave unpredictably if pitch is less than 20 or greater than 107.
Do you mean this?

My piano pitch scale is 21 to 108. Its 88 key piano. I cannot send MIDI mesagge out of that scale.

PieterP

#46
Jul 17, 2018, 02:10 pm Last Edit: Jul 17, 2018, 02:11 pm by PieterP
Yes.

Your logic is still flawed. The LEDs are zero-based, so you have to subtract 21, not 20. Even if your piano doesn't send out notes outside of that range, you still have to account for it. What happens if you use MIDI software, for example? Or if you transpose your piano? It takes one extra line of code. You can use the Arduino constrain macro.

ozguney

Yes.

Your logic is still flawed. The LEDs are zero-based, so you have to subtract 21, not 20. Even if your piano doesn't send out notes outside of that range, you still have to account for it. What happens if you use MIDI software, for example? Or if you transpose your piano? It takes one extra line of code. You can use the Arduino constrain macro.
Thanks for suggestion. I'll consider your suggestion.


Still I can't use Teensy's own MIDI library. My Teensy is not responding. Almost I have tried all things to do. I get stuck again. Teensy can not see my Piano. I think I need some help

Grumpy_Mike

Quote
Teensy can not see my Piano
Why should it?

A piano needs to be connected to a USB host if it is a USB connector. If it is a 5 Pin DIN connector it can.

What connection have you got?

ozguney

#49
Jul 17, 2018, 07:22 pm Last Edit: Jul 17, 2018, 07:22 pm by ozguney
Why should it?

A piano needs to be connected to a USB host if it is a USB connector. If it is a 5 Pin DIN connector it can.

What connection have you got?
USB connection. Pieter said "You didn't have to use HairlessMIDI" and I thought the Teensy can see MIDI signal over USB.

Grumpy_Mike

You misunderstood what he said. He said you didn't need hairless for the PC to see the Teensy as a USB device.

He said nothing about a Teensy acting as a USB host.


ozguney

https://www.pjrc.com/teensy/td_midi.html

This is for what? PC to Teensy or Teensy to PC?

Grumpy_Mike

Even bigger sigh - that link doesn't work.

Quote
This is for what? PC to Teensy or Teensy to PC?
Yes.

You don't get it do you. A Teensy can send MIDI to a PC, and receive MIDI from a PC.

But it can not act like a PC for a MIDI device that is expecting to see a PC.
If you would answer
Quote
What connection have you got?
It would be good, but if it is a USB cable then you need the Teensy to act as a host. Then you can't have that Teensy act as a client to the PC.

So where are you plugging the keyboard into. If it is the PC then you need to route that MIDI to your Teensy, this will not happen automatically.

ozguney

Yes.

Your logic is still flawed. The LEDs are zero-based, so you have to subtract 21, not 20. Even if your piano doesn't send out notes outside of that range, you still have to account for it. What happens if you use MIDI software, for example? Or if you transpose your piano? It takes one extra line of code. You can use the Arduino constrain macro.
I still can't send MIDI signal to Teensy over PC. I try Serial.begin, USB Type : MIDI & usbMIDI codes, MIDI.h library. How can I send MIDI signal to Teensy? over HairlessMIDI or Teensy can take MIDI signal on PC? How can I route them to Teensy. Because Mike says its not happen automatically.

PieterP

1. You have a piano with a MIDI interface using a USB connection, right?
2. It doesn't have 5-pin MIDI connectors, correct?
3. You want to connect the Teensy directly to the piano to display the playing notes.
4. Up 'till now, you used the computer in between, but it would be nice to just leave the computer out entirely.

Correct, or not?

ozguney

1. You have a piano with a MIDI interface using a USB connection, right?
2. It doesn't have 5-pin MIDI connectors, correct?
3. You want to connect the Teensy directly to the piano to display the playing notes.
4. Up 'till now, you used the computer in between, but it would be nice to just leave the computer out entirely.

Correct, or not?
1. Correct this is my piano.
2. Correct, I'm using this.
3. Correct, over PC connection. Because I'll record my piano pieces too so then I need piano connect.
4. If I leave computer I can not record my pieces, covers etc. So I need piano connection to my PC. If there is a way to split MIDI to the 2 same signal(1 for Teensy via 5 pin MIDI connector and 1 for directly PC for recording my MIDIs) It will be OK for me. But I surely need record my MIDIs to PC.

Grumpy_Mike

#57
Jul 19, 2018, 11:01 am Last Edit: Jul 19, 2018, 11:09 am by Grumpy_Mike
That keyboard has a connection to a "USB host" according to that link. That means it is not very easy to connect it directly to an Arduino of any type. You need some sort of host shield, or host to serial converter.

This is the lowest cost one I have come across:-
http://www.hobbytronics.co.uk/usb-host-midi

PieterP

Alright. You'll need to route the MIDI output from your piano to the MIDI input of the Teensy. This has to be done on your computer in software. On Linux, I use QJackCtl, I haven't tried any Windows equivalents.
Some DAWs may support it, or you can use a software tool.

ozguney

That keyboard has a connection to a "USB host" according to that link. That means it is not very easy to connect it directly to an Arduino of any type. You need some sort of host shield, or host to serial converter.

This is the lowest cost one I have come across:-
http://www.hobbytronics.co.uk/usb-host-midi
The HairlessMIDI converts USB's MIDI signal to Serial.



Alright. You'll need to route the MIDI output from your piano to the MIDI input of the Teensy. This has to be done on your computer in software. On Linux, I use QJackCtl, I haven't tried any Windows equivalents.
Some DAWs may support it, or you can use a software tool.
When I was using Arduino I was loosing some datas but I was sending Piano's MIDI signal to Arduino perfectly. But I cant even run this code on Teensy

Code: [Select]
void OnNoteOn(byte channel, byte note, byte velocity) {
  digitalWrite(LED_BUILTIN, HIGH); // Any Note-On turns on LED
}

void OnNoteOff(byte channel, byte note, byte velocity) {
  digitalWrite(LED_BUILTIN, LOW);  // Any Note-Off turns off LED
}

void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
  usbMIDI.setHandleNoteOff(OnNoteOff);
  usbMIDI.setHandleNoteOn(OnNoteOn) ;
  digitalWrite(LED_BUILTIN, HIGH);
  delay(400);                 // Blink LED once at startup
  digitalWrite(LED_BUILTIN, LOW);
}

void loop() {
  usbMIDI.read();
}


I was sending Midi signal over Serial port but its not giving any reaction. (I tried any USB Type Serial, Serial-MIDI, Serial-MIDI4x, Serial-MIDI16x) but my Teensy's Led not responding. Also MIDI.h library doesnt work.

Go Up