本文整理汇总了C++中IODevice::read_uint16方法的典型用法代码示例。如果您正苦于以下问题:C++ IODevice::read_uint16方法的具体用法?C++ IODevice::read_uint16怎么用?C++ IODevice::read_uint16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IODevice
的用法示例。
在下文中一共展示了IODevice::read_uint16方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void SoundProvider_Wave_Impl::load(IODevice &source)
{
source.set_little_endian_mode();
char chunk_id[4];
source.read(chunk_id, 4);
if (memcmp(chunk_id, "RIFF", 4))
throw Exception("Expected RIFF header!");
uint32_t chunk_size = source.read_uint32();
char format_id[4];
source.read(format_id, 4);
if (memcmp(format_id, "WAVE", 4))
throw Exception("Expected WAVE header!");
uint32_t subchunk_pos = source.get_position();
uint32_t subchunk1_size = find_subchunk("fmt ", source, subchunk_pos, chunk_size);
uint16_t audio_format = source.read_uint16();
num_channels = source.read_uint16();
frequency = source.read_uint32();
uint32_t byte_rate = source.read_uint32();
uint16_t block_align = source.read_uint16();
uint16_t bits_per_sample = source.read_uint16();
if (bits_per_sample == 16)
format = sf_16bit_signed;
else if (bits_per_sample == 8)
format = sf_8bit_unsigned;
else
throw Exception("Unsupported wave sample format");
uint32_t subchunk2_size = find_subchunk("data", source, subchunk_pos, chunk_size);
data = new char[subchunk2_size];
source.read(data, subchunk2_size);
num_samples = subchunk2_size / block_align;
}