Lines Matching refs:pData
110 static void PutBackChar (S_IMELODY_DATA *pData)
112 if (pData->index)
113 pData->index--;
114 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "PutBackChar '%c'\n", pData->buffer[pData->index]); */ }
117 EAS_INLINE void PutBackChar (S_IMELODY_DATA *pData) { if (pData->index) pData->index--; }
133 static EAS_BOOL IMY_PlayNote (S_EAS_DATA *pEASData, S_IMELODY_DATA *pData, EAS_I8 note, EAS_INT parserMode);
134 static EAS_BOOL IMY_PlayRest (S_EAS_DATA *pEASData, S_IMELODY_DATA *pData);
135 static EAS_BOOL IMY_GetDuration (EAS_HW_DATA_HANDLE hwInstData, S_IMELODY_DATA *pData, EAS_I32 *pDuration);
136 static EAS_BOOL IMY_GetLEDState (S_EAS_DATA *pEASData, S_IMELODY_DATA *pData);
137 static EAS_BOOL IMY_GetVibeState (S_EAS_DATA *pEASData, S_IMELODY_DATA *pData);
138 static EAS_BOOL IMY_GetBackState (S_EAS_DATA *pEASData, S_IMELODY_DATA *pData);
139 static EAS_BOOL IMY_GetVolume (EAS_HW_DATA_HANDLE hwInstData, S_IMELODY_DATA *pData, EAS_BOOL inHeader);
140 static EAS_BOOL IMY_GetNumber (EAS_HW_DATA_HANDLE hwInstData, S_IMELODY_DATA *pData, EAS_INT *temp, EAS_BOOL inHeader);
141 static EAS_RESULT IMY_ParseHeader (S_EAS_DATA *pEASData, S_IMELODY_DATA* pData);
142 static EAS_I8 IMY_GetNextChar (EAS_HW_DATA_HANDLE hwInstData, S_IMELODY_DATA *pData, EAS_BOOL inHeader);
190 S_IMELODY_DATA* pData;
209 pData = EAS_CMEnumData(EAS_CM_IMELODY_DATA);
211 pData = EAS_HWMalloc(pEASData->hwInstData, sizeof(S_IMELODY_DATA));
212 if (!pData)
214 EAS_HWMemSet(pData, 0, sizeof(S_IMELODY_DATA));
217 pData->fileHandle = fileHandle;
218 pData->fileOffset = offset;
219 pData->state = EAS_STATE_ERROR;
220 pData->state = EAS_STATE_OPEN;
223 *ppHandle = pData;
249 S_IMELODY_DATA* pData;
257 pData = (S_IMELODY_DATA*) pInstData;
258 if (pData->state != EAS_STATE_OPEN)
262 if ((result = VMInitMIDI(pEASData, &pData->pSynth)) != EAS_SUCCESS)
269 if ((result = IMY_ParseHeader(pEASData, pData)) != EAS_SUCCESS)
276 pData ->state = EAS_STATE_READY;
301 S_IMELODY_DATA *pData;
303 pData = (S_IMELODY_DATA*) pInstData;
307 *pTime = pData->time >> 8;
330 S_IMELODY_DATA* pData;
336 pData = (S_IMELODY_DATA*) pInstData;
337 if (pData->state >= EAS_STATE_OPEN)
340 if (pData->state == EAS_STATE_READY) {
341 pData->state = EAS_STATE_PLAY;
345 if (pData->time == 0)
352 VMProgramChange(pEASData->pVoiceMgr, pData->pSynth, IMELODY_CHANNEL, IMELODY_PROGRAM);
355 VMControlChange(pEASData->pVoiceMgr, pData->pSynth, IMELODY_CHANNEL, 7, 127);
359 if (pData->note)
363 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "Stopping note %d\n", pData->note); */ }
366 VMStopNote(pEASData->pVoiceMgr, pData->pSynth, IMELODY_CHANNEL, pData->note, 0);
367 pData->note = 0;
370 if (pData->restTicks)
372 pData->time += pData->restTicks;
373 pData->restTicks = 0;
384 c = IMY_GetNextChar(pEASData->hwInstData, pData, EAS_FALSE);
395 if (pData->repeatOffset < 0)
397 pData->repeatOffset = pData->startLine + (EAS_I32) pData->index;
400 pData->repeatTime = pData->time;
403 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "Repeat offset = %d\n", pData->repeatOffset); */ }
414 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "End repeat section, repeat offset = %d\n", pData->repeatOffset); */ }
417 if (pData->repeatTime == pData->time) {
418 pData->repeatCount = -1;
419 pData->repeatOffset = -1;
420 } else if (pData->repeatCount >= 0) {
423 if (pData->repeatCount > 0)
425 if (--pData->repeatCount == 0)
427 pData->repeatCount = -1;
436 if ((parserMode == eParserModePlay) || (pData->repeatCount != 0))
443 if ((result = EAS_HWFileSeek(pEASData->hwInstData, pData->fileHandle, pData->repeatOffset)) != EAS_SUCCESS)
445 IMY_ReadLine(pEASData->hwInstData, pData->fileHandle, pData->buffer, &pData->startLine);
446 pData->index = 0;
449 if (pData->repeatCount == -1)
450 pData->repeatOffset = -1;
457 if (!IMY_GetNumber(pEASData->hwInstData, pData, &temp, EAS_FALSE))
459 else if (pData->repeatOffset > 0)
463 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "Repeat count = %dt", pData->repeatCount); */ }
465 if (pData->repeatCount < 0)
466 pData->repeatCount = (EAS_I16) temp;
472 if (!IMY_GetVolume(pEASData->hwInstData, pData, EAS_FALSE))
478 pData->noteModifier = -1;
483 pData->noteModifier = +1;
488 c = IMY_GetNextChar(pEASData->hwInstData, pData, EAS_FALSE);
490 pData->octave = (EAS_U8) ((c - '0' + 1) * 12);
497 if (!IMY_GetLEDState(pEASData, pData))
503 if (!IMY_GetVibeState(pEASData, pData))
509 pData, EAS_FALSE) == 'a')
511 if (!IMY_GetBackState(pEASData, pData))
516 PutBackChar(pData);
517 if (IMY_PlayNote(pEASData, pData, c, parserMode))
526 if (IMY_PlayRest(pEASData, pData))
544 if (IMY_PlayNote(pEASData, pData, c, parserMode))
558 pData->state = EAS_STATE_STOPPING;
559 VMReleaseAllVoices(pEASData->pVoiceMgr, pData->pSynth);
584 S_IMELODY_DATA* pData;
587 pData = (S_IMELODY_DATA*) pInstData;
590 if (pData->state == EAS_STATE_STOPPING)
592 if (VMActiveVoices(pData->pSynth) == 0)
594 pData->state = EAS_STATE_STOPPED;
601 if (pData->state == EAS_STATE_PAUSING)
603 if (VMActiveVoices(pData->pSynth) == 0)
608 pData->state = EAS_STATE_PAUSED;
613 *pState = pData->state;
636 S_IMELODY_DATA* pData;
643 pData = (S_IMELODY_DATA*) pInstData;
646 if ((result = EAS_HWCloseFile(pEASData->hwInstData, pData->fileHandle)) != EAS_SUCCESS)
650 if (pData->pSynth != NULL)
651 VMMIDIShutdown(pEASData, pData->pSynth);
655 EAS_HWFree(pEASData->hwInstData, pData);
679 S_IMELODY_DATA* pData;
685 pData = (S_IMELODY_DATA*) pInstData;
688 VMReset(pEASData->pVoiceMgr, pData->pSynth, EAS_TRUE);
691 pData->time = 0;
692 pData->note = 0;
695 pData->state = EAS_STATE_ERROR;
696 if ((result = EAS_HWFileSeek(pEASData->hwInstData, pData->fileHandle, pData->fileOffset)) != EAS_SUCCESS)
698 if ((result = IMY_ParseHeader (pEASData, pData)) != EAS_SUCCESS)
705 pData->state = EAS_STATE_READY;
728 S_IMELODY_DATA *pData;
735 pData = (S_IMELODY_DATA*) pInstData;
736 if (pData->state == EAS_STATE_STOPPED)
740 VMMuteAllVoices(pEASData->pVoiceMgr, pData->pSynth);
741 pData->state = EAS_STATE_PAUSING;
765 S_IMELODY_DATA *pData;
772 pData = (S_IMELODY_DATA*) pInstData;
773 if (pData->state == EAS_STATE_STOPPED)
777 pData->state = EAS_STATE_PLAY;
802 S_IMELODY_DATA *pData;
804 pData = (S_IMELODY_DATA*) pInstData;
810 EAS_HWMemCpy(&pData->metadata, (void*) value, sizeof(S_METADATA_CB));
840 S_IMELODY_DATA *pData;
842 pData = (S_IMELODY_DATA*) pInstData;
852 *pValue = (EAS_I32) pData->pSynth;
882 static EAS_BOOL IMY_PlayNote (S_EAS_DATA *pEASData, S_IMELODY_DATA *pData, EAS_I8 note, EAS_INT parserMode)
893 if (!IMY_GetDuration(pEASData->hwInstData, pData, &duration))
897 pData->note = (EAS_U8) (pData->octave + noteTable[note - 'a'] + pData->noteModifier);
898 velocity = (EAS_U8) (pData->volume ? pData->volume * IMELODY_VEL_MUL + IMELODY_VEL_OFS : 0);
902 VMStartNote(pEASData->pVoiceMgr, pData->pSynth, IMELODY_CHANNEL, pData->note, velocity);
905 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "IMY_PlayNote: Start note %d, duration %d\n", pData->note, duration); */ }
909 switch (pData->style)
913 pData->restTicks = duration >> 4;
916 pData->restTicks = 0;
920 pData->restTicks = duration >> 1;
923 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "IMY_PlayNote: Note style out of range: %d\n", pData->style); */ }
925 pData->restTicks = duration >> 4;
930 pData->time += duration - pData->restTicks;
933 pData->noteModifier = 0;
954 static EAS_BOOL IMY_PlayRest (S_EAS_DATA *pEASData, S_IMELODY_DATA *pData)
963 if (!IMY_GetDuration(pEASData->hwInstData, pData, &duration))
971 pData->time += duration;
992 static EAS_BOOL IMY_GetDuration (EAS_HW_DATA_HANDLE hwInstData, S_IMELODY_DATA *pData, EAS_I32 *pDuration)
999 c = IMY_GetNextChar(hwInstData, pData, EAS_FALSE);
1011 duration = pData->tick * (1 << ('5' - c));
1014 c = IMY_GetNextChar(hwInstData, pData, EAS_FALSE);
1027 PutBackChar(pData);
1050 static EAS_BOOL IMY_GetLEDState (S_EAS_DATA *pEASData, S_IMELODY_DATA *pData)
1061 c = IMY_GetNextChar(pEASData->hwInstData, pData, EAS_FALSE);
1115 static EAS_BOOL IMY_GetVibeState (S_EAS_DATA *pEASData, S_IMELODY_DATA *pData)
1126 c = IMY_GetNextChar(pEASData->hwInstData, pData, EAS_FALSE);
1180 static EAS_BOOL IMY_GetBackState (S_EAS_DATA *pEASData, S_IMELODY_DATA *pData)
1191 c = IMY_GetNextChar(pEASData->hwInstData, pData, EAS_FALSE);
1245 static EAS_BOOL IMY_GetVolume (EAS_HW_DATA_HANDLE hwInstData, S_IMELODY_DATA *pData, EAS_BOOL inHeader)
1254 c = IMY_GetNextChar(hwInstData, pData, inHeader);
1257 if (pData->volume < 15)
1258 pData->volume++;
1263 if (pData->volume > 0)
1264 pData->volume--;
1272 c = IMY_GetNextChar(hwInstData, pData, inHeader);
1276 PutBackChar(pData);
1282 pData->volume = (EAS_U8) temp;
1303 static EAS_BOOL IMY_GetNumber (EAS_HW_DATA_HANDLE hwInstData, S_IMELODY_DATA *pData, EAS_INT *temp, EAS_BOOL inHeader)
1316 c = IMY_GetNextChar(hwInstData, pData, inHeader);
1325 PutBackChar(pData);
1352 static EAS_BOOL IMY_GetVersion (S_IMELODY_DATA *pData, EAS_INT *pVersion)
1361 c = pData->buffer[pData->index++];
1401 static void IMY_MetaData (S_IMELODY_DATA *pData, E_EAS_METADATA_TYPE metaType, EAS_I8 *buffer)
1406 if (!pData->metadata.callback)
1411 if (len >pData->metadata.bufferSize)
1412 len = pData->metadata.bufferSize;
1413 strncpy((char*) pData->metadata.buffer, (char*) buffer, (size_t) len);
1414 pData->metadata.buffer[len] = 0;
1417 pData->metadata.callback(metaType, pData->metadata.buffer, pData->metadata.pUserData);
1438 static EAS_RESULT IMY_ParseHeader (S_EAS_DATA *pEASData, S_IMELODY_DATA* pData)
1450 pData->time = 0;
1451 pData->tick = DEFAULT_TICK_CONV;
1452 pData->note = 0;
1453 pData->noteModifier = 0;
1454 pData ->restTicks = 0;
1455 pData->volume = 7;
1456 pData->octave = 60;
1457 pData->repeatOffset = -1;
1458 pData->repeatCount = -1;
1459 pData->style = 0;
1462 pData->index = 1;
1468 if (pData->index != 0)
1470 if ((result = IMY_ReadLine(pEASData->hwInstData, pData->fileHandle, pData->buffer, &pData->startLine)) != EAS_SUCCESS)
1478 token = IMY_ParseLine(pData->buffer, &pData->index);
1487 if (!IMY_GetVersion(pData, &temp))
1489 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "Invalid FORMAT field '%s'\n", pData->buffer); */ }
1500 if (!IMY_GetVersion(pData, &temp))
1502 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "Invalid VERSION field '%s'\n", pData->buffer); */ }
1513 IMY_MetaData(pData, EAS_METADATA_TITLE, pData->buffer + pData->index);
1517 IMY_MetaData(pData, EAS_METADATA_AUTHOR, pData->buffer + pData->index);
1522 IMY_GetNumber(pEASData->hwInstData, pData, &temp, EAS_TRUE);
1524 pData->tick = TICK_CONVERT / temp;
1529 c = IMY_GetNextChar(pEASData->hwInstData, pData, EAS_TRUE);
1531 c = IMY_GetNextChar(pEASData->hwInstData, pData, EAS_TRUE);
1533 pData->style = (EAS_U8) (c - '0');
1536 PutBackChar(pData);
1537 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "Error in style command: %s\n", pData->buffer); */ }
1543 c = IMY_GetNextChar(pEASData->hwInstData, pData, EAS_TRUE);
1546 PutBackChar(pData);
1549 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "Error in volume command: %s\n", pData->buffer); */ }
1553 IMY_GetVolume(pEASData->hwInstData, pData, EAS_TRUE);
1568 pData->index = 1;
1569 { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "Ignoring unrecognized token in iMelody file: %s\n", pData->buffer); */ }
1591 static EAS_I8 IMY_GetNextChar (EAS_HW_DATA_HANDLE hwInstData, S_IMELODY_DATA *pData, EAS_BOOL inHeader)
1599 c = pData->buffer[pData->index++];
1608 pData->index = 0;
1609 pData->buffer[0] = 0;
1610 if (IMY_ReadLine(hwInstData, pData->fileHandle, pData->buffer, &pData->startLine) != EAS_SUCCESS)
1619 if (IMY_ParseLine(pData->buffer, &index) == TOKEN_END)
1624 pData->buffer[0] = 0;