//audioein2:=4;
// 0=intern 1=6-USB 2=intewrn 3=8-USB
//audioaus2:=3;
// 0=noSound 1=Default 2=intern 3=8-USB 4=6-USB
if BASS_Init(audioaus2,44100,0,BASS_DEVICE_SPEAKERS,
nil)
then
begin
ChannelOR:=Bass_StreamCreate(44100,2,0,@StreamProc_Out,
nil);
if ChannelOR > 0
then
begin
BASS_ChannelPlay(ChannelOR, True);
BASS_ChannelSetAttribute(ChannelOR,BASS_ATTRIB_VOL,1);
if BASS_RecordInit(audioein2)
then
begin
Def:=audioein2;
WaveStream:=TMemoryStream.Create;
if (rchan > 0)
then
rchan := 1;
InitDevice(audioein2);
if WaveStream.Size > 0
then
begin
BASS_StreamFree(rchan);
WaveStream.Clear;
end;
with WaveHdr
do
begin
riff := '
RIFF';
len := 36;
cWavFmt := '
WAVEfmt ';
dwHdrLen := 16;
wFormat := 1;
wNumChannels := 2;
dwSampleRate := 44100;
wBlockAlign := 4;
dwBytesPerSec := 176400;
wBitsPerSample := 16;
cData := '
data';
dwDataLen := 0;
end;
WaveStream.
Write(WaveHdr, SizeOf(WAVHDR));
rchan:=BASS_RecordStart(44100, 2, BASS_INPUT_TYPE_MIC
and BASS_INPUT_ON, @RecordingCallback,
nil);
if (rchan > 0)
then
begin
BASS_ChannelPlay(rchan, True);
BASS_ChannelSetAttribute(rchan,BASS_ATTRIB_VOL,1);
BASS_ChannelStop(ChannelOR);
Bass_StreamFree(ChannelOR);
BASS_ChannelStop(rchan);
if (rchan > 0)
then
begin
if (rchan <> 1)
then
begin
if (BASS_ChannelIsActive(rchan) = 0)
then
begin
rchan := 0;
WaveStream.Position := 4;
i:=WaveStream.Size - 8;
WaveStream.
Write(i, 4);
i:=i - $24;
WaveStream.Position:=40;
WaveStream.
Write(i, 4);
WaveStream.Position:=0;
chan:=BASS_StreamCreateFile(True,WaveStream.Memory,0,WaveStream.Size,0);
if chan = 0
then
begin
Label2.Caption:='
Fehler erzeugen Filedaten von Audiodaten';
basslauf:=False;
end else begin
WaveStream.SaveToFile(wavfile);
end;
end;
end;
end;
bassret:=BASS_RecordFree();
BASS_Free;
WaveStream.Free;
function StreamProc_Out(channel: HRECORD; buffer: pointer; length: DWord; user: pointer): Boolean;
stdcall;
begin
Result:=True;
end;
function RecordingCallback(
Handle: HRecord; buffer: Pointer; length: DWord; user: Pointer): boolean;
stdcall;
var rueck: Boolean;
begin
rueck:=False;
if Length > 0
then
begin
WaveStream.
Write(buffer^, length);
Bass_StreamPutData(ChannelOR, buffer, length);
rueck:=True;
end;
Result:=rueck;
end;