mirror of https://github.com/dcoredump/dexed.git
parent
3c5417f3e9
commit
bcb05fa1e9
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,109 @@ |
||||
/*
|
||||
============================================================================== |
||||
|
||||
MidiMgr.cpp |
||||
Created: 24 Jun 2014 2:43:55am |
||||
Author: Pascal Gauthier |
||||
|
||||
============================================================================== |
||||
*/ |
||||
|
||||
#include "SysexComm.h" |
||||
|
||||
SysexComm::SysexComm() { |
||||
sysexChl = 1; |
||||
listener = NULL; // this will get injected later
|
||||
|
||||
inputName = ""; |
||||
outputName = ""; |
||||
|
||||
input = NULL; |
||||
output = NULL; |
||||
} |
||||
|
||||
SysexComm::~SysexComm() { |
||||
if ( input != NULL ) { |
||||
input->stop(); |
||||
delete input; |
||||
} |
||||
|
||||
if ( output != NULL ) |
||||
delete output; |
||||
} |
||||
|
||||
String SysexComm::getInput() { |
||||
return inputName; |
||||
} |
||||
|
||||
void SysexComm::setInput(String target) { |
||||
if ( input != NULL ) { |
||||
input->stop(); |
||||
delete input; |
||||
input = NULL; |
||||
} |
||||
|
||||
if ( listener == NULL ) |
||||
return; |
||||
|
||||
StringArray devices = MidiInput::getDevices(); |
||||
int idx = devices.indexOf(target); |
||||
|
||||
if ( idx == -1 ) { |
||||
// device not found
|
||||
inputName = ""; |
||||
return; |
||||
} |
||||
|
||||
input = MidiInput::openDevice(idx, listener); |
||||
if ( input != NULL ) { |
||||
inputName = target; |
||||
input->start(); |
||||
} |
||||
} |
||||
|
||||
String SysexComm::getOutput() { |
||||
return outputName; |
||||
} |
||||
|
||||
void SysexComm::setOutput(String target) { |
||||
if ( output != NULL ) { |
||||
delete output; |
||||
output = NULL; |
||||
} |
||||
|
||||
StringArray devices = MidiOutput::getDevices(); |
||||
int idx = devices.indexOf(target); |
||||
|
||||
if ( idx == -1 ) { |
||||
// device not found
|
||||
return; |
||||
} |
||||
|
||||
output = MidiOutput::openDevice(idx); |
||||
if ( output != NULL ) { |
||||
outputName = target; |
||||
} |
||||
} |
||||
|
||||
bool SysexComm::isInputActive() { |
||||
return input != NULL; |
||||
} |
||||
|
||||
bool SysexComm::isOutputActive() { |
||||
return output != NULL; |
||||
} |
||||
|
||||
int SysexComm::getChl() { |
||||
return sysexChl; |
||||
} |
||||
|
||||
void SysexComm::setChl(int chl) { |
||||
sysexChl = chl; |
||||
} |
||||
|
||||
void SysexComm::send(const juce::MidiMessage &message) { |
||||
if ( output == NULL ) |
||||
return; |
||||
|
||||
output->sendMessageNow(message); |
||||
} |
@ -0,0 +1,44 @@ |
||||
/*
|
||||
============================================================================== |
||||
|
||||
MidiMgr.h |
||||
Created: 24 Jun 2014 2:43:55am |
||||
Author: Pascal Gauthier |
||||
|
||||
============================================================================== |
||||
*/ |
||||
|
||||
#ifndef SYSEXCOMM_H_INCLUDED |
||||
#define SYSEXCOMM_H_INCLUDED |
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h" |
||||
|
||||
class SysexComm { |
||||
MidiInput *input; |
||||
MidiOutput *output; |
||||
String inputName; |
||||
String outputName; |
||||
int sysexChl; |
||||
public : |
||||
MidiInputCallback *listener; |
||||
|
||||
SysexComm(); |
||||
~SysexComm(); |
||||
|
||||
void setInput(String name); |
||||
void setOutput(String name); |
||||
void setChl(int chl); |
||||
|
||||
String getInput(); |
||||
String getOutput(); |
||||
int getChl(); |
||||
|
||||
bool isInputActive(); |
||||
bool isOutputActive(); |
||||
|
||||
void send(const MidiMessage& message); |
||||
}; |
||||
|
||||
|
||||
|
||||
#endif // SYSEXCOMM_H_INCLUDED
|
Loading…
Reference in new issue