Hallo,
as i described in
https://www.un4seen.com/forum/?topic=19858.0, i want to access the sample data via BASS_ChannelGetData. I now have written a first, "quick and dirty" program that should just get me the data. But all i get are segmentation faults and i don't understand why.
Prerequisites: I use the VLC-Media player to play the attached WAV-File. The used device is (at the moment) hard-coded (Device #5) so it should be changed. As i have no microphone at my notebook i use a program called "Line1 (Virtual Audio Cable") to send the audio from the VLC-Player to my program.
Maybe someone can have a look at the following sourcecode (please ignore small blemishes - i know there is much to improve, but remember "Quick and dirty

) and give me hints where i have to change the code to get my wished sample data?
-------------------------------------------------------------snip----------------------------------------------------------------------
program sync004;
uses
LCLIntf, LCLType, LMessages, windows, Classes, SysUtils, crt, BASS;
type
PSampleBuffer = ^TSampleBuffer;
TSampleBuffer = array of SmallInt;
var
win: HWND = 0;
WaveStream: TMemoryStream ;
rchan: HRecord = 0;
Chan: HStream = 0;
AktDeviceName : string;
SampleBuffer : TSampleBuffer;
PSBuffer : PSampleBuffer;
devinf : BASS_DEVICEINFO;
isDeviceCorrectJN : string;
SampleIndex : integer;
SampleValue : integer;
function RecordingCallback(Handle: HRecord; buffer: Pointer; length: DWord; user: Pointer): LongBool; stdcall;
begin
Result := True;
PSBuffer:=nil;
BASS_ChannelGetData(rchan, PSBuffer, BASS_DATA_FIXED);
for SampleIndex:= 0 to 127 do
begin
SampleValue:=PSBuffer^[SampleIndex];
Writeln(inttostr(SampleValue));
end;
end; // function RecordingCallback
begin
if not BASS_Init(-1, 44100, 0, win, nil) then
Halt(0);
BASS_RecordGetDeviceInfo(5, devinf);
WriteLn(devinf.name);
WriteLn('Ist das das richtige Device? (J/N)'); // Diese Prüfung sollte
ReadLn(isDeviceCorrectJN); // später entfallen können
if isDeviceCorrectJN[1] = 'n' then // oder sicher gemacht
begin // werden (Fehlerprüfungen
BASS_Free; // bei der Eingabe oder
Halt(0); // geeignet abgesicherte
end; // Eingabe)
if not BASS_RecordInit(5) then // Entspr. Stand 20220923 ist das "LINE 1 (Virtual Audio Cable)"
begin
BASS_Free;
Halt(0);
end; // if not BASS_RecordInit(5)
AktDeviceName:=BASS_RecordGetInputName(5);
BASS_RecordSetInput(5, BASS_INPUT_ON, -1);
rchan:=BASS_RecordStart(44100, 1, 0, @RecordingCallback, nil);
BASS_Free;
Readln;
end.
-----------------------------------------------------------snip--------------------------------------------------------------------
many thanks in advance
Greetings
GUMeyer