tools/packsound/source/packsound.cpp
/***************************************

	Convert a Space Ace file to a WAV file

***************************************/
Convert a Space Ace file to a WAV file
Convert a Space Ace file to a WAV file
static Word EncapsulateToWAV(OutputMemoryStream *pOutput,const Word8 *pInput,WordPtr uInputLength)
{
	if (uInputLength<4) {
		return 10;
	}
	const Word8 *pWork = pInput+4;
	WordPtr uCounter = uInputLength-4;
	int iSampleRate = LittleEndian::Load(&reinterpret_cast<const SpaceAceAudioFile_t *>(pInput)->m_uDOCRate);
	iSampleRate = static_cast<int>((static_cast<float>(iSampleRate)/512.0f)*SCAN_RATE);
	if (uCounter) {
		do {
			if (pWork[uCounter-1]==0x88) {
				break;
			}
		} while (--uCounter);
	}
	pOutput->Append("RIFF");
	pOutput->Append(static_cast<Word32>((uCounter*2)+44));
	pOutput->Append("WAVEfmt ");
	pOutput->Append(static_cast<Word32>(16));				
	pOutput->Append(static_cast<Word16>(1));				
	pOutput->Append(static_cast<Word16>(1));				
	pOutput->Append(static_cast<Word32>(iSampleRate));		
	pOutput->Append(static_cast<Word32>(iSampleRate));		
	pOutput->Append(static_cast<Word16>(1));				
	pOutput->Append(static_cast<Word16>(8));				
	pOutput->Append("data");
	pOutput->Append(static_cast<Word32>(uCounter*2));
	do {
		pOutput->Append(g_Lookup[(pWork[0]>>4)&0xF]);
		pOutput->Append(g_Lookup[pWork[0]&0xF]);
		++pWork;
	} while (--uCounter);
	return 0;
}
static Word EncapsulateToWAV ( OutputMemoryStream * pOutput , const Word8 * pInput , WordPtr uInputLength ) { if ( uInputLength < 4 ) { return 10 ; } const Word8 * pWork = pInput + 4 ; WordPtr uCounter = uInputLength - 4 ; int iSampleRate = LittleEndian :: Load ( & reinterpret_cast < const SpaceAceAudioFile_t * > ( pInput ) -> m_uDOCRate ) ; iSampleRate = static_cast < int > ( ( static_cast < float > ( iSampleRate ) / 512.0f ) * SCAN_RATE ) ; if ( uCounter ) { do { if ( pWork [ uCounter - 1 ] == 0x88 ) { break ; } } while ( -- uCounter ) ; } pOutput -> Append ( " " ) ; pOutput -> Append ( static_cast < Word32 > ( ( uCounter * 2 ) + 44 ) ) ; pOutput -> Append ( " " ) ; pOutput -> Append ( static_cast < Word32 > ( 16 ) ) ; pOutput -> Append ( static_cast < Word16 > ( 1 ) ) ; pOutput -> Append ( static_cast < Word16 > ( 1 ) ) ; pOutput -> Append ( static_cast < Word32 > ( iSampleRate ) ) ; pOutput -> Append ( static_cast < Word32 > ( iSampleRate ) ) ; pOutput -> Append ( static_cast < Word16 > ( 1 ) ) ; pOutput -> Append ( static_cast < Word16 > ( 8 ) ) ; pOutput -> Append ( " " ) ; pOutput -> Append ( static_cast < Word32 > ( uCounter * 2 ) ) ; do { pOutput -> Append ( g_Lookup [ ( pWork [ 0 ] >> 4 ) & 0xF ] ) ; pOutput -> Append ( g_Lookup [ pWork [ 0 ] & 0xF ] ) ; ++ pWork ; } while ( -- uCounter ) ; return 0 ; }
Convert a Space Ace file to a WAV file
Convert a Space Ace file to a WAV file
// Too small? // Convert from a IIgs step rate to a samples per second rate // Trim excess data if needed // Chunk size (Minimum) // Format code (PCM) // Mono // Samples per second // Bytes per second (Same as samples) // Byte aligned // Bits per sample // No diff