void LoadMIDIEventList(const char *pFilename) { printf("--- MIDISYS ENGINE: LoadMIDIEventList(\"%s\")\n", pFilename); MIDI_FILE *mf = midiFileOpen(pFilename); char str[128]; int ev; int timeline_index = 0; int track_index = 0; MIDI_MSG msg; if (mf) { int i, iNum; unsigned int j; midiReadInitMessage(&msg); iNum = midiReadGetNumTracks(mf); for(i=0;i<iNum;i++) { #ifdef SUPERVERBOSE printf("# Track %d\n", i); #endif while(midiReadGetNextMessage(mf, i, &msg)) { #ifdef SUPERVERBOSE printf(" %.6ld ", msg.dwAbsPos); #endif if (msg.bImpliedMsg) { ev = msg.iImpliedMsg; } else { ev = msg.iType; } memcpy(&timeline[track_index][timeline_index], &msg, sizeof(MIDI_MSG)); if (ev == msgMetaEvent && msg.MsgData.MetaEvent.iType == metaTrackName) { strncpy(timeline_trackname[track_index], msg.MsgData.MetaEvent.Data.Text.pData, 8); timeline_trackname[track_index][8] == '\0'; printf("track #%d, name = \"%s\"\n", track_index, timeline_trackname[track_index]); } #ifdef SUPERVERBOSE DebugPrintEvent(ev,msg); #endif timeline_index++; } printf("track length: %d\n", timeline_index); timeline_tracklength[track_index] = timeline_index; track_index++; timeline_index = 0; } timeline_trackcount = track_index; midiReadFreeMessage(&msg); midiFileClose(mf); } //timeline_length = timeline_index+1; printf("--- MIDISYS ENGINE: LoadMIDIEventList() success\n"); }
static void HandleQueues() { int ilRc = RC_SUCCESS; /* Return code */ int ilBreakOut = FALSE; do { ilRc = que(QUE_GETBIG,0,mod_id,PRIORITY_3,igItemLen,(char *)&prgItem); /* depending on the size of the received item */ /* a realloc could be made by the que function */ /* so do never forget to set event pointer !!! */ prgEvent = (EVENT *) prgItem->text; if( ilRc == RC_SUCCESS ) { /* Acknowledge the item */ ilRc = que(QUE_ACK,0,mod_id,0,0,NULL); if( ilRc != RC_SUCCESS ) { /* handle que_ack error */ HandleQueErr(ilRc); } /* fi */ switch( prgEvent->command ) { case HSB_STANDBY : ctrl_sta = prgEvent->command; break; case HSB_COMING_UP : ctrl_sta = prgEvent->command; break; case HSB_ACTIVE : ctrl_sta = prgEvent->command; ilBreakOut = TRUE; break; case HSB_ACT_TO_SBY : ctrl_sta = prgEvent->command; break; case HSB_DOWN : /* whole system shutdown - do not further use que(), send_message() or timsch() ! */ ctrl_sta = prgEvent->command; Terminate(1); break; case HSB_STANDALONE : ctrl_sta = prgEvent->command; ResetDBCounter(); ilBreakOut = TRUE; break; case REMOTE_DB : /* ctrl_sta is checked inside */ HandleRemoteDB(prgEvent); break; case SHUTDOWN : Terminate(1); break; case RESET : ilRc = Reset(); break; case EVENT_DATA : dbg(TRACE,"HandleQueues: wrong hsb status <%d>",ctrl_sta); DebugPrintItem(TRACE,prgItem); DebugPrintEvent(TRACE,prgEvent); break; case TRACE_ON : dbg_handle_debug(prgEvent->command); break; case TRACE_OFF : dbg_handle_debug(prgEvent->command); break; default : dbg(TRACE,"HandleQueues: unknown event"); DebugPrintItem(TRACE,prgItem); DebugPrintEvent(TRACE,prgEvent); break; } /* end switch */ } else { /* Handle queuing errors */ HandleQueErr(ilRc); } /* end else */ } while (ilBreakOut == FALSE); ilRc = Init_Process(); if(ilRc != RC_SUCCESS) { dbg(TRACE,"InitDemhdl: init failed!"); } } /* end of HandleQueues */