static void VOC_GetNextDataBlock(SAMPLE_AUDIO_STREAM *pAudioStream) { VOC_BLOCK_HEADER VocBlockHeader; VOC_AUDIO_STREAM *pVocAudioStream = &VocAudioStream; /* read header */ Sample_ReadData(pAudioStream,(unsigned char *)&VocBlockHeader, sizeof(VOC_BLOCK_HEADER)); pVocAudioStream->CurrentBlockOffset = 0; if (VocBlockHeader.ID!=0) { unsigned long BlockSize; BlockSize = VOC_GetBlockSize(&VocBlockHeader); switch (VocBlockHeader.ID) { /* sample data */ case 9: { VOC_BLOCK9_HEADER Block9Header; Sample_ReadData(pAudioStream, (unsigned char *)&Block9Header, sizeof(VOC_BLOCK9_HEADER)); pVocAudioStream->CurrentBlockSize = BlockSize - sizeof(VOC_BLOCK9_HEADER); #ifdef CPC_LSB_FIRST pAudioStream->SampleFrequency = Block9Header.SampleFrequency; #else pAudioStream->SampleFrequency = SwapEndianWord(Block9Header.SampleFrequency); #endif pAudioStream->SampleBits = Block9Header.BitsPerSample; pAudioStream->SampleChannels = Block9Header.NoOfChannels; } break; case 1: { VOC_BLOCK1_HEADER Block1Header; Sample_ReadData(pAudioStream, (unsigned char *)&Block1Header, sizeof(VOC_BLOCK1_HEADER)); pVocAudioStream->CurrentBlockSize = BlockSize - sizeof(VOC_BLOCK1_HEADER); if (Block1Header.CompressionType==0) { pAudioStream->SampleBits = 8; pAudioStream->SampleChannels = 1; } pAudioStream->SampleFrequency = VOC_SampleRateToFrequency(Block1Header.SampleRate); } break; /* data block */ case 2: { pVocAudioStream->CurrentBlockSize = BlockSize; } break; /* silence block */ case 3: { pVocAudioStream->Flags |= VOC_AUDIO_STREAM_FLAGS_SILENCE_ACTIVE; } break; /* start repeat */ case 6: { int RepeatCount; VOC_BLOCK6_HEADER Block6Header; Sample_ReadData(pAudioStream, (unsigned char *)&Block6Header, sizeof(VOC_BLOCK6_HEADER)); #ifdef CPC_LSB_FIRST RepeatCount = Block6Header.RepeatCount; #else RepeatCount = SwapEndianWord(Block6Header.RepeatCount); #endif if (RepeatCount==0x0ffff) { pVocAudioStream->Flags |= VOC_AUDIO_STREAM_FLAGS_REPEAT_INFINITE; } else { pVocAudioStream->RepeatCount = RepeatCount-1; } /*(pVocAudioStream->RepeatPosition = Sample_GetPosition(); */ } break; /* end repeat */ case 7: { BOOL bRepeat = FALSE; if (pVocAudioStream->Flags & VOC_AUDIO_STREAM_FLAGS_REPEAT_INFINITE) { bRepeat = TRUE; } else { /* update repeat count */ pVocAudioStream->RepeatCount--; if (pVocAudioStream->RepeatCount!=0) { bRepeat = TRUE; } } if (bRepeat) { /* Sample_SetPosition(pVocAudioStream->RepeatPosition); */ } } break; default: { } break; } } }
/* setup header */ void YMOutput_GenerateHeaderData(unsigned char *pData, int nVersion, int nVBL) { nVersion = YMOutput_ValidateVersion(nVersion); if (nVersion == 3) { memcpy(pData, YM3_Ident_Text, strlen(YM3_Ident_Text)); } else { YM5_HEADER YM5_Header; memcpy(&YM5_Header.ID, YM5_Ident_Text, 4); memcpy(&YM5_Header.IDString, YM5_IdentString_Text, 8); YM5_Header.NumVBL = nVBL; YM5_Header.SongAttributes = YM5_SONG_ATTRIBUTE_DATA_INTERLEAVED; YM5_Header.NoOfDigiDrumSamples = 0; YM5_Header.YMFrequency = 1000000; YM5_Header.PlayerFrequency = 50; YM5_Header.VBLLoopIndex = 0; YM5_Header.SizeOfExtraData = 0; #ifdef CPC_LSB_FIRST YM5_Header.NumVBL = SwapEndianLong(YM5_Header.NumVBL); YM5_Header.SongAttributes = SwapEndianLong(YM5_Header.SongAttributes); YM5_Header.YMFrequency = SwapEndianLong(YM5_Header.YMFrequency); YM5_Header.VBLLoopIndex = SwapEndianLong(YM5_Header.VBLLoopIndex); YM5_Header.NoOfDigiDrumSamples = SwapEndianWord(YM5_Header.NoOfDigiDrumSamples); YM5_Header.PlayerFrequency = SwapEndianWord(YM5_Header.PlayerFrequency); YM5_Header.SizeOfExtraData = SwapEndianWord(YM5_Header.SizeOfExtraData); #endif memcpy(pData, &YM5_Header,sizeof(YM5_HEADER)); pData+=sizeof(YM5_HEADER); /* write name of song */ if (YM5_SongName!=NULL) { int nStringLen = strlen(YM5_SongName); memcpy(pData, YM5_SongName, nStringLen); pData+=nStringLen; } pData[0] = '\0'; pData++; /* write author name */ if (YM5_AuthorName!=NULL) { int nStringLen = strlen(YM5_AuthorName); memcpy(pData, YM5_AuthorName, nStringLen); pData+=nStringLen; } pData[0] = '\0'; pData++; if (YM5_Comments!=NULL) { int nStringLen = strlen(YM5_Comments); memcpy(pData, YM5_Comments, nStringLen); pData+=nStringLen; } pData[0] = '\0'; pData++; } }