Go Down

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

OzGrant

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 {
  public:
    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);
  mySerial.begin(31250);
  midi.begin(0);
}

void loop()

   midi.poll();
}

]

nickvd

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);

OzGrant

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.

OzGrant

G'day,
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.

OzGrant

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