earliest MIDI input! (no note input tho)
This commit is contained in:
parent
13a8873050
commit
5360cd73f4
15 changed files with 525 additions and 27 deletions
|
|
@ -2653,10 +2653,24 @@ std::vector<String>& DivEngine::getAudioDevices() {
|
|||
return audioDevs;
|
||||
}
|
||||
|
||||
std::vector<String>& DivEngine::getMidiIns() {
|
||||
return midiIns;
|
||||
}
|
||||
|
||||
std::vector<String>& DivEngine::getMidiOuts() {
|
||||
return midiOuts;
|
||||
}
|
||||
|
||||
void DivEngine::rescanAudioDevices() {
|
||||
audioDevs.clear();
|
||||
if (output!=NULL) {
|
||||
audioDevs=output->listAudioDevices();
|
||||
if (output->midiIn!=NULL) {
|
||||
midiIns=output->midiIn->listDevices();
|
||||
}
|
||||
if (output->midiOut!=NULL) {
|
||||
midiOuts=output->midiOut->listDevices();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2786,11 +2800,35 @@ bool DivEngine::initAudioBackend() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (output->initMidi(false)) {
|
||||
midiIns=output->midiIn->listDevices();
|
||||
midiOuts=output->midiOut->listDevices();
|
||||
} else {
|
||||
logW("error while initializing MIDI!\n");
|
||||
}
|
||||
if (output->midiIn) {
|
||||
String inName=getConfString("midiInDevice","");
|
||||
if (!inName.empty()) {
|
||||
// try opening device
|
||||
logI("opening MIDI input.\n");
|
||||
if (!output->midiIn->openDevice(inName)) {
|
||||
logW("could not open MIDI input device!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DivEngine::deinitAudioBackend() {
|
||||
if (output!=NULL) {
|
||||
if (output->midiIn) {
|
||||
if (output->midiIn->isDeviceOpen()) {
|
||||
logI("closing MIDI input.\n");
|
||||
output->midiIn->closeDevice();
|
||||
}
|
||||
}
|
||||
output->quitMidi();
|
||||
output->quit();
|
||||
delete output;
|
||||
output=NULL;
|
||||
|
|
|
|||
|
|
@ -214,6 +214,8 @@ class DivEngine {
|
|||
String lastError;
|
||||
String warnings;
|
||||
std::vector<String> audioDevs;
|
||||
std::vector<String> midiIns;
|
||||
std::vector<String> midiOuts;
|
||||
std::vector<DivCommand> cmdStream;
|
||||
|
||||
struct SamplePreview {
|
||||
|
|
@ -570,6 +572,12 @@ class DivEngine {
|
|||
// get available audio devices
|
||||
std::vector<String>& getAudioDevices();
|
||||
|
||||
// get available MIDI inputs
|
||||
std::vector<String>& getMidiIns();
|
||||
|
||||
// get available MIDI inputs
|
||||
std::vector<String>& getMidiOuts();
|
||||
|
||||
// rescan audio devices
|
||||
void rescanAudioDevices();
|
||||
|
||||
|
|
|
|||
|
|
@ -1537,7 +1537,32 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
isBusy.lock();
|
||||
}
|
||||
got.bufsize=size;
|
||||
|
||||
// process MIDI events (TODO: everything)
|
||||
if (output->midiIn) while (!output->midiIn->queue.empty()) {
|
||||
TAMidiMessage& msg=output->midiIn->queue.front();
|
||||
int chan=msg.type&15;
|
||||
switch (msg.type&0xf0) {
|
||||
case TA_MIDI_NOTE_OFF: {
|
||||
if (chan<0 || chan>=chans) break;
|
||||
pendingNotes.push(DivNoteEvent(msg.type&15,-1,-1,-1,false));
|
||||
break;
|
||||
}
|
||||
case TA_MIDI_NOTE_ON: {
|
||||
if (chan<0 || chan>=chans) break;
|
||||
pendingNotes.push(DivNoteEvent(msg.type&15,-1,(int)msg.data[0]-12,msg.data[1],true));
|
||||
break;
|
||||
}
|
||||
case TA_MIDI_PROGRAM: {
|
||||
// TODO: change instrument event thingy
|
||||
break;
|
||||
}
|
||||
}
|
||||
logD("%.2x\n",msg.type);
|
||||
output->midiIn->queue.pop();
|
||||
}
|
||||
|
||||
// process audio
|
||||
if (out!=NULL && ((sPreview.sample>=0 && sPreview.sample<(int)song.sample.size()) || (sPreview.wave>=0 && sPreview.wave<(int)song.wave.size()))) {
|
||||
unsigned int samp_bbOff=0;
|
||||
unsigned int prevAvail=blip_samples_avail(samp_bb);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue