Skip to content

Instantly share code, notes, and snippets.

@mntone
Created October 27, 2013 04:24
Show Gist options
  • Save mntone/7177955 to your computer and use it in GitHub Desktop.
Save mntone/7177955 to your computer and use it in GitHub Desktop.
wave header
_declspec( align( 1 ) )
class wave_header
{
public:
wave_header( void ):
format_size( 16 ),
format_id( 1 ),
channel( 1 ),
sample_rate( 44100 ),
bits_per_samples( 16 ),
bitrate( sample_rate * channel * bits_per_samples / 8 ),
block_size( channel * bits_per_samples / 8 ),
data_size( 0 )
{
memcpy( riff, "RIFF", 4 );
memcpy( wave, "WAVE", 4 );
memcpy( format, "fmt ", 4 );
memcpy( data, "data", 4 );
}
private: char riff[4];
public: uint32_t total_size;
private:
char wave[4];
char format[4];
uint32_t format_size;
uint16_t format_id;
public:
uint16_t channel;
uint32_t sample_rate;
uint32_t bitrate;
uint16_t block_size;
uint16_t bits_per_samples;
private: char data[4];
public: uint32_t data_size;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment