wavfile.h

来自「一个symbian 冒险游戏代码」· C头文件 代码 · 共 74 行

H
74
字号
#ifndef _WAVFILE_H
#define _WAVFILE_H


#include "stdint.h"
#include "SoundFormat.h"
#include <lang/String.h>
#include <lang/Object.h>


namespace io {
	class InputStream;}


/** 
 * Class for sound file loading and saving. 
 * @author Jani Kajala (jani.kajala@helsinki.fi)
 */
class WavFile :
	public lang::Object
{
public:
	/** 
	 * Reads sound file header.
	 * @exception IOException
	 */
	explicit WavFile( const lang::String& name );

	///
	~WavFile();

	/** 
	 * Reads specified number of bytes of sound data from the file. 
	 * @exception IOException
	 */
	void	read( void* data, int bytes );

	/** Returns number of bytes sound data in the sound file. */
	int		size() const;

	/** Returns sound file format. */
	const SoundFormat&	format() const;

private:
	struct RIFFChunk
	{
		char		id[4];
		uint32_t	size; // size of data to follow
	};

	struct WaveFormatHeader
	{ 
		uint16_t	formatTag;
		uint16_t	channels;
		uint32_t	samplesPerSec;
		uint32_t	avgBytesPerSec;
		uint16_t	blockAlign;
	}; 

	P(io::InputStream)		m_in;
	SoundFormat				m_format;
	int						m_begin;
	int						m_end;
	int						m_size;

	static void findChunk( io::InputStream* in, int& size, int end, const char* id, RIFFChunk* chunk );

	WavFile( const WavFile& );
	WavFile& operator=( const WavFile& );
};


#endif // _WAVFILE_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?