不用控件
解决方案 »
- 关于TShell的问题,来者有分
- 求ADOExpress for Delphi 5 Update Pack 1&2的注册码
- 请教一个不难的问题 !!!!我想散分!!顶也有分的!!!
- 在d6中调用外部程序的问题
- 程序打包时出错(急)
- 特难问题:TThread的Synchronize能否执行一个函数,因为我需要返回值
- 用回连键代替Tag键的问题!
- 这到底是什么问题,真恼火!!!
- 有哪为朋友装了DELPHI5企业版的升级包,可以告诉我你用的注册号吗?我用DELPHI碟上的注册号装不上去。
- 如何解决WPTools v6.29安装时出现的错误
- delphi6的安装问题
- 兄弟们新问题想了好长时间没想通!!!!!!!!!!!!!!!!!!!!!!! 高手高手高高手啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TPCMWaveHeader = record
rID: array[0..3] of char; // 'RIFF' 标志
rLen: longint; // 文件长度
wID: array[0..3] of char; // 'WAVE' 标志
fId: array[0..3] of char; // 'fmt '标志 以空格结束(fID[3]:=Chr($20);)
fLen: longint; // 过度字节(不定)
wFormatTag: word; // 格式字节(过度字节为PCM形式的声音数据)
nChannels: word; // 通道数 单声道=1, 双声道=2 }
nSamplesPerSec: longint; // 采样频率 (每秒样本数),表示每个通道的播放速度
nAvgBytesPerSec: longint;
// 波形音频数据传送速度(值:通道数X每秒数据位数X每
// 样本的数据位数/8。播放软件利用根据此值估计缓
// 冲区的大小)
nBlockAlign: word;
// 数据块的调整数(按字节计算),值为通道数*没样本的数据位值/8。
// 播放软件需要一次处理多个该值大小的字节数据,以便
// 将其值用于缓冲区的调整。
nBitsPerSample: word;
// 每样本数据位数,表示每个声道中各个样本的数据位
// 数。如果有多个声道,对每个声道而言,样本大
// 小都一样 8 or 16
dId: array[0..3] of char; // 'data' 标志
dLen: longint; // 语音数据长度
end; TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
filename: string;
pcm: TPCMWaveHeader;
Data: array[0..80 * 10240] of Byte;
procedure PrintPcm;
procedure PrintData;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.PrintPcm;
begin
// memo1.lines.add('FileName:' + Filename);
memo1.lines.add('RIFF:' + pcm.rID);
memo1.lines.add('RLEN:' + inttostr(pcm.rLen));
memo1.lines.add('WAVE:' + pcm.wID);
memo1.lines.add('fmt:' + pcm.fId);
memo1.lines.add('Fixed:' + inttostr(pcm.fLen));
memo1.lines.add('wFormatTag:' + inttostr(pcm.wFormatTag));
memo1.lines.add('nChannels:' + inttostr(pcm.nChannels));
memo1.lines.add('nSamplesPerSec:' + inttostr(pcm.nSamplesPerSec));
memo1.lines.add('nAvgBytesPerSec:' + inttostr(pcm.nAvgBytesPerSec));
memo1.lines.add('nBlockAlign:' + inttostr(pcm.nBlockAlign));
memo1.lines.add('nBitsPerSample:' + inttostr(pcm.nBitsPerSample));
memo1.lines.add('dLen:' + inttostr(pcm.dLen));
end;procedure TForm1.PrintData;
var
i : Integer;
begin
for i := 0 to pcm.dLen - 1 do
begin
//memo1.lines.add(inttostr(Data[i]));
Canvas.LineTo(i, Data[i])
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
filename := 'C:\test.wav';
end;procedure TForm1.Button1Click(Sender: TObject);
var
iFileHandle : Integer;
iFileLength : Integer;
iBytesRead : Integer;
Buffer : PChar;
i, Size : Integer;
begin
iFileHandle := FileOpen(filename, fmOpenRead);
iFileLength := FileSeek(iFileHandle, 0, 2) - FileSeek(iFileHandle, 0, 0);
GetMem(Buffer, iFileLength + 1);
iBytesRead := FileRead(iFileHandle, Buffer^, iFileLength); //把文件读到buffer
FileClose(iFileHandle);
Move((Buffer)^, pcm, sizeof(pcm));
Move((Buffer)^, Data, pcm.dLen);
printpcm; //显示头信息
printData; //画波形图
FreeMem(Buffer);
end;end.
Delphi syntax:function FileOpen(const FileName: string; Mode: LongWord): Integer;C++ syntax:extern PACKAGE int __fastcall FileOpen(const AnsiString FileName, unsigned Mode);DescriptionUse FileOpen to open a file and obtain a file handle. The access mode value is constructed by or-ing one of the fmOpen constants with one of the fmShare constants defined in File open mode constants. If the return value is 0 or greater, the function was successful and the value is the file handle of the opened file. A return value of -1 indicates that an error occurred.: Use of the non-native Delphi language file handlers such as FileOpen is not encouraged. These routines map to system routines and return OS file handles, not normal Delphi file variables. These are low-level file access routines. For normal file operations use AssignFile, Rewrite, and Reset instead.