Pages: 1 [2]   Go Down
Author Topic: MIDI Serial Port  (Read 4313 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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();
}

]
Logged

Southern Ontario
Offline Offline
Sr. Member
****
Karma: 2
Posts: 279
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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:
NewSoftSerial mySerial(10, 11);
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: 1 [2]   Go Up
Jump to: