[dad864]: riffhdr.cpp  Maximize  Restore  History

Download this file

41 lines (35 with data), 1.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "stdafx.h"
// Writes the RIFF header into a stream
#include <stdio.h>
#include "riffhdr.h"
RIFF_HEADER riff = {
{'R', 'I', 'F', 'F'},
0,
{'W', 'A', 'V', 'E', 'f', 'm', 't', ' '},
16, 1, 2,
22050, 22050*4,
4, 16,
{'d', 'a', 't', 'a'}
};
void write_riff_header (void *memory, long samples, int channels, int samplerate) {
riff.raw_data_len = samples * sizeof(short);
riff.total_len_m8 = riff.raw_data_len + sizeof(RIFF_HEADER) - 8;
riff.nChannels=(unsigned short) channels;
riff.nSamplesPerSec=samplerate;
riff.nAvgBytesPerSec=channels*sizeof(short)*samplerate;
memcpy(memory, &riff, sizeof(RIFF_HEADER) );
}
WAVC_HEADER wavc={
{'W','A','V','C'},
{'V','1','.','0'},
0,0,28,
2,16,22050,0x9ffdu
};
void write_wavc_header (FILE *fpoi, long samples, int channels, int compressed, int samplerate) {
wavc.uncompressed=samples*sizeof(short);
wavc.compressed=compressed;
wavc.channels=(short) channels;
wavc.samplespersec=(short) samplerate;
rewind(fpoi);
fwrite(&wavc, 1, sizeof(WAVC_HEADER) ,fpoi );
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks