Skip to content

Commit

Permalink
Midi: use device name instead of (ignored) port number. Closed #32
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliomoro committed Jul 16, 2016
1 parent 751dc11 commit 7e1b136
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions core/Midi.cpp
Expand Up @@ -169,9 +169,9 @@ void Midi::writeOutputLoop(){
}
}
}
int Midi::readFrom(int port){
int Midi::readFrom(const char* port){
objAddrs[kMidiInput].push_back(this);
inputPort = open("/dev/midi1", O_RDONLY | O_NONBLOCK | O_NOCTTY);
inputPort = open(port, O_RDONLY | O_NONBLOCK | O_NOCTTY);
if(inputPort < 0){
return -1;
} else {
Expand All @@ -181,9 +181,9 @@ int Midi::readFrom(int port){
}
}

int Midi::writeTo(int port){
int Midi::writeTo(const char* port){
objAddrs[kMidiOutput].push_back(this);
outputPort = open("/dev/midi1", O_WRONLY, 0);
outputPort = open(port, O_WRONLY, 0);
if(outputPort < 0){
return -1;
} else {
Expand Down
4 changes: 2 additions & 2 deletions core/default_libpd_render.cpp
Expand Up @@ -152,8 +152,8 @@ bool setup(BelaContext *context, void *userData)
}
}

midi.readFrom(0);
midi.writeTo(0);
midi.readFrom("/dev/midi1");
midi.writeTo("/dev/midi1");
#ifdef PARSE_MIDI
midi.enableParser(true);
#else
Expand Down
4 changes: 2 additions & 2 deletions examples/08-PureData/customRender/heavy/render.cpp
Expand Up @@ -266,8 +266,8 @@ bool setup(BelaContext *context, void *userData) {
hv_setSendHook(gHeavyContext, sendHook);

// TODO: change these hardcoded port values and actually change them in the Midi class
midi.readFrom(0);
midi.writeTo(0);
midi.readFrom("/dev/midi1");
midi.writeTo("/dev/midi1");
midi.enableParser(true);

if(gScopeChannelsInUse > 0){
Expand Down
4 changes: 2 additions & 2 deletions examples/08-PureData/customRender/render.cpp
Expand Up @@ -214,8 +214,8 @@ bool setup(BelaContext *context, void *userData)
}
}

midi.readFrom(0);
midi.writeTo(0);
midi.readFrom("/dev/midi1");
midi.writeTo("/dev/midi1");
#ifdef PARSE_MIDI
midi.enableParser(true);
#else
Expand Down
4 changes: 2 additions & 2 deletions include/Midi.h
Expand Up @@ -267,14 +267,14 @@ class Midi {
* @param port Midi port to open
* @return 1 on success, -1 on failure
*/
int readFrom(int port);
int readFrom(const char* port);

/**
* Open the specified output Midi port and prepares to write to it.
* @param port Midi port to open
* @return 1 on success, -1 on failure
*/
int writeTo(int port);
int writeTo(const char* port);

/**
* Get received midi bytes, one at a time.
Expand Down
5 changes: 2 additions & 3 deletions scripts/hvresources/render.cpp
Expand Up @@ -211,9 +211,8 @@ bool setup(BelaContext *context, void *userData) {
// Set heavy send hook
hv_setSendHook(gHeavyContext, sendHook);

// TODO: change these hardcoded port values and actually change them in the Midi class
midi.readFrom(0);
midi.writeTo(0);
midi.readFrom("/dev/midi1");
midi.writeTo("/dev/midi1");
midi.enableParser(true);

if(gScopeChannelsInUse > 0){
Expand Down

0 comments on commit 7e1b136

Please sign in to comment.