本文整理汇总了C++中EMUFILE::read_32LE方法的典型用法代码示例。如果您正苦于以下问题:C++ EMUFILE::read_32LE方法的具体用法?C++ EMUFILE::read_32LE怎么用?C++ EMUFILE::read_32LE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EMUFILE
的用法示例。
在下文中一共展示了EMUFILE::read_32LE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: formatChunk
static bool formatChunk(EMUFILE &inf)
{
// seek to just after the RIFF header
inf.fseek(12,SEEK_SET);
// search for a format chunk
for (;;)
{
char chunk_id[4];
u32 chunk_length;
inf.fread(chunk_id, 4);
if (!inf.read_32LE(chunk_length)) return false;
// if we found a format chunk, excellent!
if (memcmp(chunk_id, "fmt ", 4) == 0 && chunk_length >= 16)
{
// read format chunk
u16 format_tag;
u16 channel_count;
u32 samples_per_second;
//u32 bytes_per_second = read32_le(chunk + 8);
//u16 block_align = read16_le(chunk + 12);
u16 bits_per_sample;
if (inf.read_16LE(format_tag) != 1) return false;
if (inf.read_16LE(channel_count) != 1) return false;
if (inf.read_32LE(samples_per_second) != 1) return false;
inf.fseek(6,SEEK_CUR);
if (inf.read_16LE(bits_per_sample) != 1) return false;
chunk_length -= 16;
// format_tag must be 1 (WAVE_FORMAT_PCM)
// we only support mono 8bit
if (format_tag != 1 ||
channel_count != 1 ||
bits_per_sample != 8)
{
MessageBox(0,"not a valid RIFF WAVE file; must be 8bit mono pcm",0,0);
return false;
}
return true;
}
inf.fseek(chunk_length,SEEK_CUR);
}
return false;
}
示例2: dataChunk
static bool dataChunk(EMUFILE &inf)
{
bool found = false;
// seek to just after the RIFF header
inf.fseek(12,SEEK_SET);
// search for a format chunk
for (;;)
{
char chunk_id[4];
u32 chunk_length;
if (inf.eof()) return found;
if (inf.fread(chunk_id, 4) != 4) return found;
if (!inf.read_32LE(chunk_length)) return found;
// if we found a data chunk, excellent!
if (memcmp(chunk_id, "data", 4) == 0)
{
found = true;
u8 *temp = new u8[chunk_length];
if (inf.fread(temp,chunk_length) != chunk_length)
{
delete[] temp;
return false;
}
newWavData.fwrite(temp,chunk_length);
delete[] temp;
chunk_length = 0;
}
inf.fseek(chunk_length,SEEK_CUR);
}
return found;
}