大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> 程序开发 -> 生成一个波文件

生成一个波文件

时间: 2021-07-31 作者:daque

type  tpcmwaveheader = record    rid : array[0..3] of char; { 'riff' identifier }    rlen : longint;    wid : array[0..3] of char; { 'wave' identifier }    fid : array[0..3] of char; { 'fmt ' identifier }    flen : longint; { fixed, must be 16 }    wformattag : word; { fixed, must be 1 }    nchannels : word; { mono=1, stereo=2 }    nsamplespersec : longint; { samplerate in hertz }    navgbytespersec : longint;    nblockalign : word;    nbitspersample : word; { resolution, e.g. 8 or 16 }    did : array[0..3]of char; { 'data' identifier }    dlen : longint; { number of following data bytes }  end;    procedure writepcmwavefile(filename : string; resolution, channels, samplerate, samples : integer; data : pointer);  var h : tpcmwaveheader;    f : file;    databytes : integer;  begin    databytes:=samples;    databytes:=databytes*channels; { double if stereo }    databytes:=databytes*(resolution div 8); { double if 16 bit }        fillchar(h,sizeof(tpcmwaveheader),#0);    with h do    begin    rid[0]:='r';    rid[1]:='i';    rid[2]:='f';    rid[3]:='f'; { 1st identifier }    rlen:=databytes+36;    wid[0]:='w';    wid[1]:='a';    wid[2]:='v';    wid[3]:='e'; { 2nd identifier }    fid[0]:='f';    fid[1]:='m';    fid[2]:='t';    fid[3]:=chr($20); { 3rdidentifier ends with a space character }    flen:=$10; { fixed, must be 16 }    wformattag:=1; { fixed, must be 1 }    nchannels:=channels; { channels }    nsamplespersec:=samplerate; { sample rate in hertz }    navgbytespersec:=samplerate*channels*trunc(resolution div 8);    nblockalign:=channels*(resolution div 8); { byte order, see below }    nbitspersample:=resolution;    did[0]:='d';    did[1]:='a';    did[2]:='t';    did[3]:='a'; { data identifier }    dlen:=databytes; { number of following data bytes }    end;    assignfile(f,filename);    rewrite(f,1);    blockwrite(f,h,sizeof(h));    blockwrite(f,pbytearray(data),databytes);    closefile(f);  { the rest of the file is the wave data. order is low-high for left channel,    low-high for right channel, and so on.    for mono or 8 bit files make the respective changes. }  end;

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.