MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); midi = new MistyMidi(); loadPortNames(); connect(ui->intputList, SIGNAL(currentTextChanged(QString)), midi, SLOT(input_changed(QString))); connect(midi, SIGNAL(send_message(QString)), this, SLOT(updatelog(QString))); ui->actionE_xit->setShortcut(QKeySequence::Quit); ui->synthList->setRowCount(1); ui->synthList->setItem(0, 0, new QTableWidgetItem("Piano", QTableWidgetItem::Type)); SynthSelector *combo = new SynthSelector(ui->synthList, outputs); ui->synthList->setCellWidget(0, 1, combo); QDir mididir ("MIDI"); if(mididir.exists()) { mididir.setFilter(QDir::Files | QDir::NoSymLinks); mididir.setNameFilters(QStringList("*.mid")); QFileInfoList files = mididir.entryInfoList(); for(int i=0; i<files.size(); i++) { ui->accompanimentList->addItem(files.at(i).fileName()); } } else { ui->accompanimentList->addItem(QString("Midi Directory %1 Not Found").arg(mididir.absolutePath())); } }
void drawlog(Logger* lg){ WINDOW *w = lg->win; delwin(w); int l,c; l = (getmaxy(stdscr)-lg->height)/2; int maxx=getmaxx(stdscr); c = (maxx-lg->width)/2; lg->win = newwin(lg->height,lg->width,l,c); w = lg->win; updatelog(lg); }
void MainWindow::onAccompanimentSelection() { int tracks = 0; int events = 0; QMessageBox qmb; MidiFile *midifile = new MidiFile(); connect(midifile, SIGNAL(sendmessage(QString)), this, SLOT(updatelog(QString))); int errornum = midifile->LoadFile(ui->accompanimentList->currentItem()->text()); /* while (tracks < midifile->numTracks()) { ui->msgarea->append(midifile->getTrackName(tracks)); while(events < midifile->numEvents(tracks)) { ui->msgarea->append(midifile->getTrackEventText(tracks, events)); events++; } tracks++; } */ if(errornum==MidiFile_OK) { testmidi = new TestMidiOutput(midi->getMistyOutputs(), midifile); connect(testmidi, SIGNAL(send_message(QString)), this, SLOT(updatelog(QString))); testmidi->start(); } else ui->msgarea->append(QString("Unable to load Midi file: %1").arg(midifile->getError(errornum))); }
static int update_state(int dir, int hc, int uc, int fc,unsigned char *buf, int len) { int i,ret=0; dsyslog(LOG_INFO,"update_state: dir=%d, hc=0x%x, uc=0x%x, fc=0x%x\n",dir,hc,uc,fc); hc &= 0x0f; sem_getvalue(&state.lock,&i); dsyslog(LOG_INFO,"semaphore value: %d\n",i); sem_wait(&state.lock); dsyslog(LOG_INFO,"Got the state lock\n"); // if we get a preset dim high/low, we can store the level only if: // the previous housecode was stored // the previous message received was not a function (had to be unit) // a valid unit is stored if ((fc == X10_CMD_PRESETDIMHIGH || fc == X10_CMD_PRESETDIMLOW) && (state.fcsent[state.hc] != 1) && (state.lastuc != -1)) { updatestatus(state.hc,state.lastuc,fc,fc == X10_CMD_PRESETDIMLOW ? preset_low[hc] : preset_high[hc]); } if (hc != state.hc) { // restart if new housecode received state.hc = hc; state.lastuc = -1; state.fc = -1; } if (uc >= 0 && uc < MAX_UNITS) { if (state.fcsent[state.hc]) { clear_uc(state.hc); state.fcsent[state.hc] = 0; } state.uc[state.hc][uc] = 1; state.lastuc = uc; } if (fakereceive == 1 || dir == 0) updatelog(dir,hc,uc,fc); // something just changed so now update the queue head to wake everyone up if (fc >= 0) { // we have a completed command // we may never have received a unit code so it may still be -1 // if (fc != X10_CMD_STATUS) state.fcsent[state.hc] = 1; state.fc = fc; switch (fc) { case X10_CMD_ALLLIGHTSOFF: // we don't know which ones are lights case X10_CMD_ALLUNITSOFF: for (i = 0; i < MAX_HOUSECODES; i++) { updatestatus(state.hc,i,fc,0); } break; case X10_CMD_ALLLIGHTSON: for (i = 0; i < MAX_HOUSECODES; i++) { updatestatus(state.hc,i,fc,100); } break; case X10_CMD_ON: for (i = 0; i < MAX_UNITS; i++) if (state.uc[state.hc][i]) { updatestatus(state.hc,i,fc,100); } break; case X10_CMD_OFF: for (i = 0; i < MAX_UNITS; i++) if (state.uc[hc][i]) { updatestatus(state.hc,i,fc,0); } break; case X10_CMD_DIM: for (i = 0; i < MAX_UNITS; i++) if (state.uc[hc][i]) { int value = state.status[state.hc][i]; value -= 6; if (value < 0) value = 0; updatestatus(state.hc,i,fc,value); } break; case X10_CMD_BRIGHT: for (i = 0; i < MAX_UNITS; i++) if (state.uc[hc][i]) { int value = state.status[state.hc][i]; value += 6; if (value > 100) value = 100; updatestatus(state.hc,i,fc,value); } break; case X10_CMD_STATUS: dsyslog(LOG_INFO,"status request to housecode %c",'A'+state.hc); break; case X10_CMD_STATUSOFF: dsyslog(LOG_INFO,"status of %c%d is OFF",'A'+state.hc,state.lastuc+1); if (state.hc < MAX_HOUSECODES && state.lastuc < MAX_UNITS) { updatestatus(state.hc,state.lastuc,fc,0); } break; case X10_CMD_STATUSON: dsyslog(LOG_INFO,"status of %c%d is ON",'A'+state.hc,state.lastuc+1); if (state.hc < MAX_HOUSECODES && state.lastuc < MAX_UNITS) { updatestatus(state.hc,state.lastuc,fc,100); } break; case X10_CMD_HAILREQUEST: dsyslog(LOG_INFO,"hail request to housecode %c",'A'+state.hc); break; case X10_CMD_HAILACKNOWLEDGE: dsyslog(LOG_INFO,"hail ACK to housecode %c",'A'+state.hc); break; case X10_CMD_EXTENDEDCODE: // extended code dsyslog(LOG_INFO,"extended code to housecode %c",'A'+state.hc); if (len > 0){ ret = -1; } break; case X10_CMD_EXTENDEDDATAA: // extended data (analog) dsyslog(LOG_INFO,"extended data (analog) to housecode %c", 'A' + state.hc); if (len > 0){ ret = -1; } break; case X10_CMD_PRESETDIMHIGH: // already handled dsyslog(LOG_INFO,"preset dim low %c%d",'A'+state.hc,state.lastuc); break; case X10_CMD_PRESETDIMLOW: // already handled dsyslog(LOG_INFO,"preset dim low %c%d",'A'+state.hc,state.lastuc); break; default: ret = -1; break; } // end of switch statement } // end of if (fc >= 0) dsyslog(LOG_INFO,"Released the state lock\n"); sem_post(&state.lock); return ret; }
void sigint(int sig_num){ printf("Exiting...\n"); updatelog(); exit(0); }