类似于QQ或MSN调音视频音量时对着麦克讲话,显示声音的振幅的东西。谁做过,谢了。

解决方案 »

  1.   

    给岾上来瞧瞧,我这用PCM的一种格式好使,PCM换一种格式原来的就不好使了。谢谢你。
      

  2.   

    首先从网上下载一个Aduio的pas文件。下面是我自己模仿写的一个小东西的源代码:
    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.
      

  3.   

    下面是窗体文件:
    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
      

  4.   

    就是希望实现象QQ和MSN的麦克风向导功能,关键是如何将麦克采来的数据如何换算成音量柱,即显示音频的振幅。我试试你的代码
      

  5.   

    你有MSN吗?加我[email protected]或给个audio的下载地址
      

  6.   

    我只用QQ,号码:58774491。现在发个audio文件给你。
      

  7.   

    哥们你的代码不好使啊。运行时在哪个show函数中for  哪儿就死掉了,显示不了主窗体出来就。不过还是谢谢了,hubdog写过一个混音器,正在研究呢,不过在我这儿哪个progress显示不了,不知道选哪个