类似于QQ或MSN调音视频音量时对着麦克讲话,显示声音的振幅的东西。谁做过,谢了。
解决方案 »
- 项目外包 高薪找人作个游戏外挂
- 添加记录类型出错,过不去呀急急!!!
- 关于Panel控件上嵌入form窗体的问题
- 用循环向数据表中插入数据,为什么循环一次会插入两条相同的数据,最后一次循环插入一条数据???
- pascal 语言和C 语言编写的程序之间相互调用时,参数类型是否可以传递结构和链表
- 关于数据库备份后恢复的问题,高分想送?
- c#客户端发送udp数据到delphi服务器端,c#数据报如何打包发送过去
- 几个数据控件的问题。
- 何处有第三方控件下载??
- 在FORM1中創建 FORM2, 在FORM2中創建 FORM3 ,form3關閉時,希望form2也關閉.怎麼寫???
- AVICAP,如果在机器上装两个USB摄像头,如果获取两路视频
- 大家能帮忙看一看这段代码那里有问题吗,急!!!
unit uMain;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons,audio, OleCtrls, WMPLib_TLB,IniFiles;const cd=360;type
TfrmMain = class(TForm)
pl: TPanel;
pBox: TPaintBox;
btnBegin: TBitBtn;
Timer: TTimer;
RadioGrp: TRadioGroup;
rbR: TRadioButton;
rbP: TRadioButton;
rbB: TRadioButton;
rbE: TRadioButton;
procedure TimerTimer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnBeginClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
procedure Audio1Record(Sender: TObject; LP,RP: Pointer;
BufferSize: Word);
procedure Show;
public
{ Public declarations }
pstr:array of byte;
yszb: array[0..cd] of tpoint;
end;var
frmMain: TfrmMain;
audio1:taudio;
LeftStream,RightStream:TMemoryStream;
pstr:array of short;
implementation{$R *.dfm}procedure TfrmMain.Audio1Record(Sender: TObject; LP, RP: Pointer;
BufferSize: Word);
begin
if BufferSize>0 then
begin
setlength(pstr,buffersize);
move(lp^,pstr[0],buffersize);
end;
end;procedure TfrmMain.Show;
var
i,j : integer;
k,n : integer;
p:integer;
tg :TBitMap;
tt : integer;
angle,r:real;
x,y:integer;
begin pBox.Canvas.Pen.Width := 2;
for p:= 0 to cd do
begin
yszb[p].y:= 40-round(pstr[p]/8);
yszb[p].x:=p;
pBox.Canvas.Pen.Color := RGB(Random(255),Random(255),Random(255)); //随机效果
if rbR.Checked then
k := Random(7); //频谱
if rbP.Checked then
k := 0; //示波器
if rbB.Checked then
k := 1; //椭圆
if rbE.Checked then
k := 2; case k of
0,3,4: //频谱仪
begin
for i := 180 downto pstr[p] do
begin
//向上画线
if (p mod 4)= 0 then
begin
pBox.Canvas.Pen.Style := psDash;
pBox.Canvas.MoveTo(p,40);
if Abs(36-round(pstr[p]/4)) < 38 then
pBox.Canvas.LineTo(p,36-round(pstr[p]/6))
else
pBox.Canvas.LineTo(p,40); pl.Color := RGB(Random(255),Random(255),Random(255));
for tt := 0 to 100000 do
begin
end;
end; for j := 0 to 100 do
begin
end;
end; for j := 0 to 100000 do
begin
end;
end;
1,5,6: // 示波器
begin
pBox.Canvas.Pen.Width := 1;
pBox.Canvas.Polyline(yszb);
pl.Color := clBlack;
for j := 0 to 100000 do
begin
end;
end;
2: //椭圆
begin
pBox.Canvas.Pen.Width := 2;
for n := 0 to (cd div 2) do
begin
if round(pstr[p]/8) < 40 then
pBox.Canvas.Ellipse(((cd div 4)-n),40,(cd div 4)+n,38-round(pstr[p]/8))
else
pBox.Canvas.Ellipse(((cd div 4)-n),40,(cd div 4)+n,40);
pl.Color := clBlack;
for tt := 0 to 100000 do
begin
end;
end;
end;
{3: //弧形
begin
pBox.Canvas.Pen.Width := 1;
pBox.Canvas.PolyBezier(yszb);
end;
4: //
begin
//pBox.Canvas.Polygon(yszb);
pBox.Canvas.PolyBezier(yszb);
end;
5: //
begin
tg := TBitMap.Create;
tg.LoadFromFile(ExtractFilePath(Application.ExeName)+'show.bmp');
pBox.Canvas.Draw(yszb[p].X,yszb[p].Y,tg);
tg.Free;
end;
7: //
begin
while(j<300) do
begin
for i:=0 to 1023 do
begin
angle:=i*3.14/512;
r:=j*sin(2*angle);
x:=round(r*cos(angle));
y:=round(r*sin(angle)/2);
canvas.Pixels[p+x,yszb[p].Y+y]:=RGB(Random(255),Random(255),Random(255));//colorBox1.Selected;
end;
j:=j+20;
end;
end; }
end;
end; for j := 0 to 20000000 do
begin end; pBox.Repaint;end;procedure TfrmMain.TimerTimer(Sender: TObject);
begin
Show;
end;procedure TfrmMain.FormCreate(Sender: TObject);
begin
audio1:=taudio.create(self); //初始化声卡
audio1.OnRecord:=audio1record;
Audio1.Recorder.Triggered:=false;
if not (Audio1.Recorder.Start) then showmessage('Audio1.ErrorMessage');
if LeftStream <> nil then begin
LeftStream.Free; RightStream.Free;
LeftStream := nil; RightStream:=nil;
end;
try
LeftStream :=TMemoryStream.Create;
RightStream:=TMemoryStream.Create;
except
LeftStream:=nil; RightStream:=nil;
if not (Audio1.Recorder.Stop) then showmessage('Audio1.ErrorMessage');
exit;
end;end;procedure TfrmMain.btnBeginClick(Sender: TObject);
begin
if btnBegin.Caption='开始' then
begin
timer.Enabled:=true;
btnBegin.Caption:='暂停';
end else
begin
timer.Enabled:=false;
btnBegin.Caption:='开始';
end;
end;procedure TfrmMain.FormShow(Sender: TObject);
var
Inia : TInifile;
fTop,fLeft : string;
begin
Inia := TIniFile.Create(ExtractFilePath(Application.ExeName)+'position.ini');
try
fTop := Inia.ReadString('position','Top','800');
fLeft := Inia.ReadString('position','Left','20');
finally
Inia.Free;
end; frmMain.Left := StrToInt(fLeft);
frmMain.Top := StrToInt(fTop);
Timer.Enabled := True;
end;end.
object frmMain: TfrmMain
Left = 296
Top = 284
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsDialog
Caption = '曙光数码科技-LED方灯特技效果控制'
ClientHeight = 86
ClientWidth = 243
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsStayOnTop
Icon.Data = {
0000010001002020040000000000E80200001600000028000000200000004000
0000010004000000000000020000000000000000000000000000000000000000
000000008000008000000080800080000000800080008080000080808000C0C0
C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000
0000000000000000000000000000000000000000030703333300000000000000
0000000033070333333000000000000000000000330703333333000000000000
0000000033070333333300000000000000000000000000003333000000000000
0000000888877077033300000000000000000008888777077033000000000000
000000833337777077030000000000000000008FF88877707700000000000000
0000000000000000070000000000000000000101133033110700000000000000
00003000011111107300000000000000000030F7000000077300000000000000
000030F730333387730000000000000000003088333FFF877300000000000000
000FF33833000037718000000000000000000008300808077188000000000000
00000008000FFF07718800000000000000003388033000077188000000000000
0033388333333000710030000000000000888888888833337113300000000000
0088888888888777713310000000000000880000088887770333100000000000
0000013330088770333100000000000003301333333000033111000000000000
0330333333333333311100000000000003113331111111111110000000000000
0311331111111111111000000000000000111311111111111100000000000000
000011111111111100000000000000000000000000000000000000000000FFF0
03FFFFE001FFFFE000FFFFE0007FFFE0007FFFE0007FFFC0007FFFC0007FFF80
007FFF8000FFFF0001FFFF0001FFFE0001FFFE0001FFFE0001FFFE0000FFFC00
00FFFC00007FFC00007FF800007FF800003FF800003FF800003FF800003FF800
007FF000007FF000007FF00000FFF00000FFF80001FFFC0003FFFF000FFF}
OldCreateOrder = False
OnCreate = FormCreate
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object pl: TPanel
Left = 0
Top = 0
Width = 181
Height = 41
BevelInner = bvLowered
BevelOuter = bvLowered
Color = clBtnText
TabOrder = 0
object pBox: TPaintBox
Left = 0
Top = 0
Width = 180
Height = 40
end
end
object btnBegin: TBitBtn
Left = 193
Top = 12
Width = 42
Height = 25
Caption = '暂停'
TabOrder = 1
OnClick = btnBeginClick
end
object RadioGrp: TRadioGroup
Left = 0
Top = 45
Width = 243
Height = 41
Align = alBottom
TabOrder = 2
end
object rbR: TRadioButton
Left = 6
Top = 61
Width = 49
Height = 17
Caption = '随机'
TabOrder = 3
end
object rbP: TRadioButton
Left = 66
Top = 61
Width = 49
Height = 17
Caption = '频谱'
Checked = True
TabOrder = 4
TabStop = True
end
object rbB: TRadioButton
Left = 125
Top = 61
Width = 48
Height = 17
Caption = '示波'
TabOrder = 5
end
object rbE: TRadioButton
Left = 187
Top = 61
Width = 48
Height = 17
Caption = '其他'
TabOrder = 6
end
object Timer: TTimer
Enabled = False
Interval = 200
OnTimer = TimerTimer
Left = 32
end
end