資源簡介
利用C語言生成wave音頻文件,內容為簡單的正弦波函數。
代碼片段和文件信息
//?sin.cpp?:?Defines?the?entry?point?for?the?console?application.
#include?
#include?
#include?
#include?
#include?
#define?PI?3.1425926
int?main()
{
????char?*sine_buf??=(char?*)?malloc(100000?*?sizeof(char));
????int?i;
????struct?bb
????{
????????char RiffID[4]; //?‘R‘‘I‘‘F‘‘F‘ “RIFF“標志
????????int RiffSize; //?文件長度(WAVE文件的大小?不含前8個字節)
????????char RiffFormat[4]; //?‘W‘‘A‘‘V‘‘E‘ “WAVE“標志
????????char FmtID[4]; //?‘f‘‘m‘‘t‘‘?‘?“fmt?“標志
????????int FmtSize; //過渡字節(不定)16?for?PCM.?This?is?the?size?of?the?rest?of?the?Subchunk?which?follows?this?number.
????????unsigned?short FormatTag; //格式類別?當FormatTag=1,用的就是非壓縮格式。
????????unsigned?short Channels; //通道數(單聲道為1?雙聲道為2)
????????int SamplesPerS
- 上一篇:c++數獨小游戲
- 下一篇:c++實現刪除文件夾與文件的小工具
評論
共有 條評論