I’m trying to scale data in simple wav file.
I’m using this structure to store wave meta information.
struct meta
{
char chunk_id[4];
int chunk_size;
char format[4];
char subchunk1_id[4];
int subchunk1_size;
short int audio_format;
short int num_channels;
int sample_rate;
int byte_rate;
short int block_align;
short int bits_per_sample;
short int extra_param_size;
char subchunk2_id[4];
int subchunk2_size;
};
I’m adding samples based on simple linear interpolation, but in order to process resulting file I need to change file meta information in some way.
What do I need to change in this structure to make wav file N times longer?
If you’ve read the spec on wav files, you’ll see there is a short header before each chunk of data containing a chunk ID and a chunk size. I would assume that you would need to change the chunk size to accommodate the new information.
You should also be aware than if you are interpolating new information between existing samples in the file, you’ll need to adjust the sample rate so that you can play the audio without a frequency shift.