here’s my code, due to my inexperience with c++ i didnt exactly understand what to do. i changed the name of my callback function to the function name but nothing changed. I’d really appreciate it if you would tell me where to change and modify my code.
Thanks a lot
#include
#include “juce.h”
//Include timer functions
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
using namespace std;
class ModeOne {
//Declare midi input device
MidiInput* piano;
public:
void startListening();
void handleIncomingMidiMessages(MidiMessage);
};
void ModeOne::startListening()
{
//Get the indexes of the midiInput devices
StringArray deviceIndex = StringArray::StringArray();
deviceIndex = MidiInput::getDevices();
cout << deviceIndex[0] +"\n";
cout << deviceIndex[1] +"\n";
cout << deviceIndex[2] +"\n";
cout << deviceIndex[3] +"\n";
//Declare for recieving midi messages from the midi input
MidiInputCallback* handleIncomingMidiMessage = 0;
//Open device
piano = MidiInput::openDevice(2, handleIncomingMidiMessage);
//Start listening for midi messages from the piano
piano ->start();
cout << "reached";
}
//And the callback function and do something with the incoming midi message
void handleIncomingMidiMessage(MidiInput* source,const MidiMessage& m){
//Declare midi message attributes
int byte1, byte2, byte3;
const double timeStamp = 0;
//Initialize variables
byte1 = 0;
byte2 = 0;
byte3 = 0;
MidiMessage keyPlayed = MidiMessage::MidiMessage (byte1, byte2, byte3, timeStamp);
keyPlayed = m;
cout << “Key Pressed”;
}
int main()
{
ModeOne ModeOneListener;
ModeOneListener.startListening();
}