Home
Top.Mail.Ru Yandeks.Metrika
Forum: "System";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Down

How to remove from the sound card, the waveform. Find similar branches


Pasha   (2001-09-21 15:58) [0]

How to remove from the sound card, the waveform.
In order to calculate the sound signal changes over time.



REL   (2001-09-25 20:04) [1]

It is quite simple:
Use WinAPI
Here is the program (someone long ago in the Inet threw):

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, MMSystem;

type
TData8 = array [0..127] of byte;
PData8 = ^ TData8;
TData16 = array [0..127] of smallint;
PData16 = ^ TData16;
TPointArr = array [0..127] of TPoint;
PPointArr = ^ TPointArr;
TForm1 = class (TForm)
Button1: TButton;
Button2: TButton;
PaintBox1: TPaintBox;
TrackBar1: TTrackBar;
CheckBox1: TCheckBox;
procedure Button1Click (Sender: TObject);
procedure Button2Click (Sender: TObject);
private
{Private declarations}
public
procedure OnWaveIn (var Msg: TMessage); message MM_WIM_DATA;
end;

was
Form1: TForm1;

implementation

{$ R * .DFM}

was
WaveIn: hWaveIn;
hBuf: THandle;
BufHead: TWaveHdr;
bufsize: integer;
Bits16: boolean;
p: PPointArr;
stop: boolean = false;

procedure TForm1.Button1Click (Sender: TObject);
was
header: TWaveFormatEx;
BufLen: word;
buf: pointer;
begin
BufSize: = TrackBar1.Position * 500 + 100;
Bits16: = CheckBox1.Checked;
with header do begin
wFormatTag: = WAVE_FORMAT_PCM;
nChannels: = 1;
nSamplesPerSec: = 22050;
wBitsPerSample: = integer (Bits16) * 8 + 8;
nBlockAlign: = nChannels * (wBitsPerSample div 8);
nAvgBytesPerSec: = nSamplesPerSec * nBlockAlign;
cbSize: = 0;
end;
WaveInOpen (Addr (WaveIn), WAVE_MAPPER, addr (header),
Form1.Handle, 0, CALLBACK_WINDOW);
BufLen: = header.nBlockAlign * BufSize;
hBuf: = GlobalAlloc (GMEM_MOVEABLE and GMEM_SHARE, BufLen);
Buf: = GlobalLock (hBuf);
with BufHead do begin
lpData: = Buf;
dwBufferLength: = BufLen;
dwFlags: = WHDR_BEGINLOOP;
end;
WaveInPrepareHeader (WaveIn, Addr (BufHead), sizeof (BufHead));
WaveInAddBuffer (WaveIn, addr (BufHead), sizeof (BufHead));
GetMem (p, BufSize * sizeof (TPoint));
stop: = true;
WaveInStart (WaveIn);
end;

procedure TForm1.Button2Click (Sender: TObject);
begin
if stop = false then Exit;
stop: = false;
while not stop do Application.ProcessMessages;
stop: = false;
WaveInReset (WaveIn);
WaveInUnPrepareHeader (WaveIn, addr (BufHead), sizeof (BufHead));
WaveInClose (WaveIn);
GlobalUnlock (hBuf);
GlobalFree (hBuf);
FreeMem (p, BufSize * sizeof (TPoint));
end;

procedure TForm1.OnWaveIn;
was
i: integer;
data8: PData8;
data16: PData16;
h: integer;
XScale, YScale: single;
begin
h: = PaintBox1.Height;
XScale: = PaintBox1.Width / BufSize;
if Bits16 then begin
data16: = PData16 (PWaveHdr (Msg.lParam) ^. lpData);
YScale: = h / (1 shl 16);
for i: = 0 to BufSize - 1 do
p ^ [i]: = Point (round (i * XScale),
round (h / 2 - data16 ^ [i] * YScale));
end else begin
Data8: = PData8 (PWaveHdr (Msg.lParam) ^. LpData);
YScale: = h / (1 shl 8);
for i: = 0 to BufSize - 1 do
p ^ [i]: = Point (round (i * XScale),
round (h - data8 ^ [i] * YScale));
end;
with PaintBox1.Canvas do begin
Brush.Color: = clWhite;
FillRect (ClipRect);
Polyline (Slice (p ^, BufSize));
end;
if stop
then WaveInAddBuffer (WaveIn, PWaveHdr (Msg.lParam),
SizeOf (TWaveHdr))
else stop: = true;
end;

procedure TForm1.FormDestroy (Sender: TObject);
begin
Button2.Click;
end;




Pages: 1 whole branch

Forum: "System";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Top









Memory: 0.56 MB
Time: 0.024 c
1-22105
Gonza
2001-12-19 16:35
2002.01.08
MDI Application ???


1-22170
AVALLOGIGS
2001-12-20 19:37
2002.01.08
Help!


1-22029
neo_
2001-12-18 12:33
2002.01.08
kill tThread


14-22337
Alexander
2001-11-05 13:20
2002.01.08
Print Server DP-101 (D-Link) and printing from under DOS


14-22417
Yuraz
2001-10-25 15:02
2002.01.08
I wonder what Yandex is spinning on (IIS ..) DB, hardware.





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish