Exemplo n.º 1
0
//*****************************************************************************
//
// Parsing a file header to meet RIFF WAVE PCM file format, reading out the specifications and updating the file format object
//
//*****************************************************************************
void parseFileFmt(unsigned char* const headerAddr, WAV_FILEFMT* const filefmt){
		
		//Initialize file format object to default value.
		filefmt->Fmt_IsFile_RIFF = false;
		filefmt->Fmt_IsFile_WAVE = false;
		filefmt->Fmt_IsFile_PCM = false;
		filefmt->Fmt_File_Channel = 0;
		filefmt->Fmt_File_SampleRate = 0;
		filefmt->Fmt_File_ByteRate = 0;
		filefmt->Fmt_File_BitDepth = 0;
		filefmt->Fmt_File_DataChunkSize = 0;
		
		//Parse the file header to meet RIFF WAVE PCM file format, reading out the specifications and updating the file format object
		if(IsFileRIFF(headerAddr + Header_Offset_RIFF)==true){
			
			filefmt->Fmt_IsFile_RIFF = true;
			
			if(IsFileWave(headerAddr + Header_Offset_WAVE)==true){
				
				filefmt->Fmt_IsFile_WAVE = true;
				
				if(IsPCMFormat(headerAddr + Header_Offset_PCM)==true){
					
					filefmt->Fmt_IsFile_PCM = true;
					
					filefmt->Fmt_File_Channel = getChNumber(headerAddr + Header_Offset_Channel);
					filefmt->Fmt_File_SampleRate = getSampleRate(headerAddr + Header_Offset_SampleRate);
					filefmt->Fmt_File_ByteRate = getByteRate(headerAddr + Header_Offset_ByteRate);
					filefmt->Fmt_File_BitDepth = getBitPerSample(headerAddr + Header_Offset_BitDepth);
					filefmt->Fmt_File_DataChunkSize = getSampleDataSize(headerAddr + Header_Offset_DataChunkSize);
					
				}
				else{
					filefmt->Fmt_IsFile_PCM = false;
				}
				
			}
			else{
				filefmt->Fmt_IsFile_WAVE = false;
			}
			
		}
		else{
			filefmt->Fmt_IsFile_RIFF = false;
		}
		
}
Exemplo n.º 2
0
TSoundTrackFormat TSoundTrack::getFormat() const {
  return TSoundTrackFormat(getSampleRate(), getBitPerSample(),
                           getChannelCount(), isSampleSigned());
}