Go Down

Topic: MIDI Serial Port (Read 7868 times) previous topic - next topic


Code: [Select]
Well after many hrs have return to the forum so some clever person can tell me what I've done wrong.
The Led does not flash whne a midi signal is rx'ed.
The sketch is[code#include "Midi.h"
#include "NewSoftSerial.h"

NewSoftSerial mySerial(10, 11);
class MyMidi : public Midi {
    MyMidi(HardwareSerial &mySerial) : Midi(mySerial) {}
  void handleNoteOn(unsigned int channel, unsigned int note, unsigned int velocity)
    digitalWrite(13, HIGH);

  void handleNoteOff(unsigned int channel, unsigned int note, unsigned int velocity)
    digitalWrite(13, LOW);

// Create an instance of the MyMidi class.
MyMidi midi(Serial);

void setup()
  pinMode(13, OUTPUT);

void loop()




Code: [Select]
MyMidi midi(Serial);

You're still passing the hardware serial to the midi lib... you need to pass the nss object that you created earlier..

Code: [Select]
NewSoftSerial mySerial(10, 11);


Had declared NewSoftSerial mySerial(10, 11); after the includes.
But as you pointed out was still using MyMidi midi(Serial);

So changed that to MyMidi midi(mySerial);  then got a "no matching function error"
Tried MyMidi midi(HardwareSerial); then got non class type when midi.begin(0) compiled.

I just do not know enough about what I am doing.
The example sketch had MyMidi(HardwareSerial &s) : Midi(s) {}
Not even  sure if my change to  MyMidi(HardwareSerial &mySerial) : Midi(mySerial) {} is OK
So am lost in code.


It seems my problem is not knowing how to use the Class statement.
Have started a thread in "Programmimg questions" as that is the root of my problem with the MIDI.
Tks for your help up to this stage.


It seems the MIDI 2.5 library does allow a different  tx/rx port to be used see http://blog.makezine.com/archive/2009/01/midi-programming-library-for-arduin.html
Has anyone done it.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131