Lines Matching refs:pSMFData
56 static EAS_RESULT SMF_ParseMetaEvent (S_EAS_DATA *pEASData, S_SMF_DATA *pSMFData, S_SMF_STREAM *pSMFStream);
57 static EAS_RESULT SMF_ParseSysEx (S_EAS_DATA *pEASData, S_SMF_DATA *pSMFData, S_SMF_STREAM *pSMFStream, EAS_U8 f0, EAS_INT parserMode);
58 static EAS_RESULT SMF_ParseEvent (S_EAS_DATA *pEASData, S_SMF_DATA *pSMFData, S_SMF_STREAM *pSMFStream, EAS_INT parserMode);
60 static void SMF_UpdateTime (S_SMF_DATA *pSMFData, EAS_U32 ticks);
106 S_SMF_DATA* pSMFData;
136 pSMFData = EAS_CMEnumData(EAS_CM_SMF_DATA);
139 pSMFData = EAS_HWMalloc(pEASData->hwInstData, sizeof(S_SMF_DATA));
140 EAS_HWMemSet((void *)pSMFData,0, sizeof(S_SMF_DATA));
142 if (!pSMFData)
146 pSMFData->fileHandle = fileHandle;
147 pSMFData->fileOffset = offset;
148 pSMFData->pSynth = NULL;
149 pSMFData->time = 0;
150 pSMFData->state = EAS_STATE_OPEN;
151 *ppHandle = pSMFData;
176 S_SMF_DATA* pSMFData;
180 pSMFData = (S_SMF_DATA *) pInstData;
181 if (pSMFData->state != EAS_STATE_OPEN)
185 if ((result = VMInitMIDI(pEASData, &pSMFData->pSynth)) != EAS_SUCCESS)
192 if ((result = SMF_ParseHeader(pEASData->hwInstData, pSMFData)) != EAS_SUCCESS)
196 pSMFData->state = EAS_STATE_READY;
221 S_SMF_DATA *pSMFData;
223 pSMFData = (S_SMF_DATA*) pInstData;
227 if (pSMFData->state == EAS_STATE_STOPPED)
232 if (pSMFData->nextStream == NULL)
241 if (pSMFData->flags & SMF_FLAGS_CHASE_MODE)
248 *pTime = pSMFData->time >> 8;
250 *pTime = pSMFData->time >> 8;
273 S_SMF_DATA* pSMFData;
280 pSMFData = (S_SMF_DATA*) pInstData;
281 if (pSMFData->state >= EAS_STATE_OPEN)
284 if (!pSMFData->nextStream) {
290 ticks = pSMFData->nextStream->ticks;
293 pSMFData->state = EAS_STATE_ERROR;
297 if (pSMFData->nextStream->midiStream.jetData & MIDI_FLAGS_JET_MUTE)
302 if ((result = SMF_ParseEvent(pEASData, pSMFData, pSMFData->nextStream, parserMode)) != EAS_SUCCESS)
309 pSMFData->nextStream->ticks = SMF_END_OF_TRACK;
313 else if (pSMFData->nextStream->ticks != SMF_END_OF_TRACK)
315 if ((result = SMF_GetDeltaTime(pEASData->hwInstData, pSMFData->nextStream)) != EAS_SUCCESS)
322 pSMFData->nextStream->ticks = SMF_END_OF_TRACK;
326 else if (pSMFData->nextStream->ticks == ticks)
328 pSMFData->state = EAS_STATE_PLAY;
335 pSMFData->nextStream = NULL;
336 for (i = 0; i < pSMFData->numStreams; i++)
338 if (pSMFData->streams[i].ticks < temp)
340 temp = pSMFData->streams[i].ticks;
341 pSMFData->nextStream = &pSMFData->streams[i];
346 if (pSMFData->nextStream)
348 pSMFData->state = EAS_STATE_PLAY;
351 SMF_UpdateTime(pSMFData, pSMFData->nextStream->ticks - ticks);
355 pSMFData->state = EAS_STATE_STOPPING;
356 VMReleaseAllVoices(pEASData->pVoiceMgr, pSMFData->pSynth);
383 S_SMF_DATA* pSMFData;
386 pSMFData = (S_SMF_DATA*) pInstData;
389 if (pSMFData->state == EAS_STATE_STOPPING)
391 if (VMActiveVoices(pSMFData->pSynth) == 0)
392 pSMFData->state = EAS_STATE_STOPPED;
395 if (pSMFData->state == EAS_STATE_PAUSING)
397 if (VMActiveVoices(pSMFData->pSynth) == 0)
398 pSMFData->state = EAS_STATE_PAUSED;
402 *pState = pSMFData->state;
425 S_SMF_DATA* pSMFData;
429 pSMFData = (S_SMF_DATA*) pInstData;
432 for (i = 0; i < pSMFData->numStreams; i++)
434 if (pSMFData->streams[i].fileHandle != NULL)
436 if ((result = EAS_HWCloseFile(pEASData->hwInstData, pSMFData->streams[i].fileHandle)) != EAS_SUCCESS)
440 if (pSMFData->fileHandle != NULL)
441 if ((result = EAS_HWCloseFile(pEASData->hwInstData, pSMFData->fileHandle)) != EAS_SUCCESS)
445 if (pSMFData->pSynth != NULL)
446 VMMIDIShutdown(pEASData, pSMFData->pSynth);
451 if (pSMFData->streams)
452 EAS_HWFree(pEASData->hwInstData, pSMFData->streams);
455 EAS_HWFree(pEASData->hwInstData, pSMFData);
480 S_SMF_DATA* pSMFData;
485 pSMFData = (S_SMF_DATA*) pInstData;
488 pSMFData->time = 0;
491 VMReset(pEASData->pVoiceMgr, pSMFData->pSynth, EAS_TRUE);
495 pSMFData->nextStream = NULL;
496 for (i = 0; i < pSMFData->numStreams; i++)
500 if ((result = EAS_HWFileSeek(pEASData->hwInstData, pSMFData->streams[i].fileHandle, pSMFData->streams[i].startFilePos)) != EAS_SUCCESS)
504 pSMFData->streams[i].ticks = 0;
507 EAS_InitMIDIStream(&pSMFData->streams[i].midiStream);
510 if ((result = SMF_GetDeltaTime(pEASData->hwInstData,&pSMFData->streams[i])) != EAS_SUCCESS)
512 if (pSMFData->streams[i].ticks < ticks)
514 ticks = pSMFData->streams[i].ticks;
515 pSMFData->nextStream = &pSMFData->streams[i];
520 pSMFData->state = EAS_STATE_READY;
543 S_SMF_DATA *pSMFData;
546 pSMFData = (S_SMF_DATA*) pInstData;
547 if (pSMFData->state == EAS_STATE_STOPPED)
551 VMMuteAllVoices(pEASData->pVoiceMgr, pSMFData
552 pSMFData->state = EAS_STATE_PAUSING;
576 S_SMF_DATA *pSMFData;
579 pSMFData = (S_SMF_DATA*) pInstData;
580 if (pSMFData->state == EAS_STATE_STOPPED)
584 pSMFData->state = EAS_STATE_PLAY;
608 S_SMF_DATA *pSMFData;
610 pSMFData = (S_SMF_DATA*) pInstData;
616 EAS_HWMemCpy(&pSMFData->metadata, (void*) value, sizeof(S_METADATA_CB));
626 for (i = 0; i < pSMFData->numStreams; i++)
627 pSMFData->streams[i].midiStream.jetData =
628 (pSMFData->streams[i].midiStream.jetData &
631 pSMFData->flags |= SMF_FLAGS_JET_STREAM;
640 for (i = 0; i < pSMFData->numStreams; i++)
643 pSMFData->streams[i].midiStream.jetData |= MIDI_FLAGS_JET_MUTE;
645 pSMFData->streams[i].midiStream.jetData &= ~MIDI_FLAGS_JET_MUTE;
653 if (value < pSMFData->numStreams)
654 pSMFData->streams[value].midiStream.jetData |= MIDI_FLAGS_JET_MUTE;
661 if (value < pSMFData->numStreams)
662 pSMFData->streams[value].midiStream.jetData &= ~MIDI_FLAGS_JET_MUTE;
695 S_SMF_DATA *pSMFData;
697 pSMFData = (S_SMF_DATA*) pInstData;
702 if (pSMFData->numStreams == 1)
711 if (pSMFData->pSynth)
712 VMGetPolyphony(pEASData->pVoiceMgr, pSMFData->pSynth, pValue);
718 if (pSMFData->pSynth)
719 VMGetPriority(pEASData->pVoiceMgr, pSMFData->pSynth, pValue);
724 *pValue = pSMFData->transposition;
729 *pValue = (EAS_I32) pSMFData->pSynth;
817 static EAS_RESULT SMF_ParseMetaEvent (S_EAS_DATA *pEASData, S_SMF_DATA *pSMFData, S_SMF_STREAM *pSMFStream)
857 pSMFData->tickConv = (EAS_U16) (((temp * 1024) / pSMFData->ppqn + 500) / 1000);
858 pSMFData->flags |= SMF_FLAGS_HAS_TEMPO;
864 pSMFData->flags |= SMF_FLAGS_HAS_TIME_SIG;
868 else if (pSMFData->metadata.callback)
887 readLen = pSMFData->metadata.bufferSize - 1;
890 if ((result = EAS_HWReadFile(pEASData->hwInstData, pSMFStream->fileHandle, pSMFData->metadata.buffer, readLen, &readLen)) != EAS_SUCCESS)
892 pSMFData->metadata.buffer[readLen] = 0;
893 pSMFData->metadata.callback(metaType, pSMFData->metadata.buffer, pSMFData->metadata.pUserData);
921 static EAS_RESULT SMF_ParseSysEx (S_EAS_DATA *pEASData, S_SMF_DATA *pSMFData, S_SMF_STREAM *pSMFStream, EAS_U8 f0, EAS_INT parserMode)
934 if ((result = EAS_ParseMIDIStream(pEASData, pSMFData->pSynth, &pSMFStream->midiStream, f0, parserMode)) != EAS_SUCCESS)
943 if ((result = EAS_ParseMIDIStream(pEASData, pSMFData->pSynth, &pSMFStream->midiStream, c, parserMode)) != EAS_SUCCESS)
948 pSMFData->flags |= SMF_FLAGS_HAS_GM_ON;
970 static EAS_RESULT SMF_ParseEvent (S_EAS_DATA *pEASData, S_SMF_DATA *pSMFData, S_SMF_STREAM *pSMFStream, EAS_INT parserMode)
982 if ((result = SMF_ParseMetaEvent(pEASData, pSMFData, pSMFStream)) != EAS_SUCCESS)
989 if ((result = SMF_ParseSysEx(pEASData, pSMFData, pSMFStream, c, parserMode)) != EAS_SUCCESS)
996 if ((result = EAS_ParseMIDIStream(pEASData, pSMFData->pSynth, &pSMFStream->midiStream, c, parserMode)) != EAS_SUCCESS)
1004 if ((result = EAS_ParseMIDIStream(pEASData, pSMFData->pSynth, &pSMFStream->midiStream, c, parserMode)) != EAS_SUCCESS)
1011 if (pSMFData->time == 0)
1013 if (pSMFData->flags & SMF_FLAGS_CHASE_MODE)
1016 pSMFData->flags &= ~SMF_FLAGS_CHASE_MODE;
1018 else if ((pSMFData->flags & SMF_FLAGS_SETUP_BAR) == SMF_FLAGS_SETUP_BAR)
1019 pSMFData->flags = (pSMFData->flags & ~SMF_FLAGS_SETUP_BAR) | SMF_FLAGS_CHASE_MODE;
1034 * pSMFData - pointer to parser instance data
1047 EAS_RESULT SMF_ParseHeader (EAS_HW_DATA_HANDLE hwInstData, S_SMF_DATA *pSMFData)
1058 if ((result = EAS_HWFileSeek(hwInstData, pSMFData->fileHandle, pSMFData->fileOffset + SMF_OFS_HEADER_SIZE)) != EAS_SUCCESS)
1060 if ((result = EAS_HWGetDWord(hwInstData, pSMFData->fileHandle, &chunkSize, EAS_TRUE)) != EAS_SUCCESS)
1064 if ((result = EAS_HWFileSeek(hwInstData, pSMFData->fileHandle, pSMFData->fileOffset + SMF_OFS_NUM_TRACKS)) != EAS_SUCCESS)
1066 if ((result = EAS_HWGetWord(hwInstData, pSMFData->fileHandle, &pSMFData->numStreams, EAS_TRUE)) != EAS_SUCCESS)
1070 if (pSMFData->numStreams > MAX_SMF_STREAMS)
1072 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "SMF file contains %u tracks, playing %d tracks\n", pSMFData->numStreams, MAX_SMF_STREAMS); */ }
1073 pSMFData->numStreams = MAX_SMF_STREAMS;
1074 } else if (pSMFData->numStreams == 0)
1081 if ((result = EAS_HWGetWord(hwInstData, pSMFData->fileHandle, &division, EAS_TRUE)) != EAS_SUCCESS)
1085 pSMFData->ppqn = 192;
1089 pSMFData->ppqn = (division & 0x7fff);
1090 pSMFData->tickConv = (EAS_U16) (((SMF_DEFAULT_TIMEBASE * 1024) / pSMFData->ppqn + 500) / 1000);
1093 if (pSMFData->streams == NULL)
1095 pSMFData->streams = EAS_HWMalloc(hwInstData,sizeof(S_SMF_STREAM) * pSMFData->numStreams);
1096 if (pSMFData->streams == NULL)
1100 EAS_HWMemSet((void *)(pSMFData->streams), 0, sizeof(S_SMF_STREAM) * pSMFData->numStreams);
1104 chunkStart = (EAS_U32) pSMFData->fileOffset;
1106 pSMFData->nextStream = NULL;
1107 for (i = 0; i < pSMFData->numStreams; i++)
1123 if ((result = EAS_HWFileSeek(hwInstData, pSMFData->fileHandle, (EAS_I32) chunkStart)) != EAS_SUCCESS)
1127 if ((result = EAS_HWGetDWord(hwInstData, pSMFData->fileHandle, &temp, EAS_TRUE)) != EAS_SUCCESS)
1131 if ((result = EAS_HWGetDWord(hwInstData, pSMFData->fileHandle, &chunkSize, EAS_TRUE)) != EAS_SUCCESS)
1142 pSMFData->streams[i].ticks = 0;
1143 pSMFData->streams[i].fileHandle = pSMFData->fileHandle;
1146 pSMFData->fileHandle = NULL;
1149 pSMFData->streams[i].startFilePos = (EAS_I32) chunkStart + SMF_CHUNK_INFO_SIZE;
1152 EAS_InitMIDIStream(&pSMFData->streams[i].midiStream);
1155 if ((result = SMF_GetDeltaTime(hwInstData, &pSMFData->streams[i])) != EAS_SUCCESS)
1158 if (pSMFData->streams[i].ticks < ticks)
1160 ticks = pSMFData->streams[i].ticks;
1161 pSMFData->nextStream = &pSMFData->streams[i];
1165 if (i < (pSMFData->numStreams - 1))
1167 if ((result = EAS_HWDupHandle(hwInstData, pSMFData->streams[i].fileHandle, &pSMFData->fileHandle)) != EAS_SUCCESS)
1173 if (pSMFData->nextStream)
1174 SMF_UpdateTime(pSMFData, pSMFData->nextStream->ticks);
1201 static void SMF_UpdateTime (S_SMF_DATA *pSMFData, EAS_U32 ticks)
1205 if (pSMFData->flags & SMF_FLAGS_CHASE_MODE)
1208 temp1 = (ticks >> 10) * pSMFData->tickConv;
1209 temp2 = (ticks & 0x3ff) * pSMFData->tickConv;
1210 pSMFData->time += (EAS_I32)((temp1 << 8) + (temp2 >> 2));