Author Topic: What i am doing wrong?  (Read 950 times)

nikos

  • Posts: 63
What i am doing wrong?
« on: 28 Oct '18 - 10:30 »
I am using delphi tokyo


procedure DownloadProc(buffer: Pointer; length: DWORD; user: DWORD); stdcall;
var FileName:String;
begin
Filename:='Myfile.caf';
  if (filestream = nil) then
    FileStream := TFileStream.Create(Filename, fmCreate); // create the   file
  if (buffer = nil) then
    FileStream.Free // finished   downloading
  else
  begin
    FileStream.Write(buffer^, length);
  end;
end;


BASS_Init(-1,44100,0,Handle,nil)  ------------------->/// works
BASS_RecordInit(-1)  ------------------->//works
uStream :=BASS_RecordStart(44100,2,BASS_UNICODE,@DownloadProc,0 ); //////////works

Stop Record
BASS_ChannelStop(uStream); //works

And not i am trying to Listen it
 uStream := BASS_StreamCreateFile(false, PChar(FileName), 0, 0, BASS_UNICODE or BASS_STREAM_DECODE );

I get error BASS_ERROR_FILEFORM

what i am doing wrong????????





Chris

  • Posts: 1864
Re: What i am doing wrong?
« Reply #1 on: 28 Oct '18 - 10:43 »
Hi
Quote
procedure DownloadProc(buffer: Pointer; length: DWORD; user: DWORD); stdcall;
// The User Param must be always a Pointer (on 32 Bit Pointer and DWORD have 4 Bytes on 64 Bit DWORD=4bytes and Pointer will have 8Bytes)
var FileName:String;
begin
Filename:='Myfile.caf';
  if (filestream = nil) then
    FileStream := TFileStream.Create(Filename, fmCreate); // create the   file
  if (buffer = nil) then
    FileStream.Free // finished   downloading
  else
  begin
    FileStream.Write(buffer^, length);
  end;
end;
should be

Code: [Select]
var
  FileName:String = 'Myfile.caf';

Code: [Select]
procedure DownloadProc(buffer: Pointer; length: DWORD; user: Pointer); stdcall;
begin
  if (filestream = nil) then
    FileStream := TFileStream.Create(Filename, fmCreate); // create the   file
  if (buffer = nil) then
    FileStream.Free // finished   downloading
  else
  begin
    FileStream.Write(buffer^, length);
  end;
end;

Quote
uStream := BASS_StreamCreateFile(false, PChar(FileName), 0, 0, BASS_UNICODE or BASS_STREAM_DECODE );
should be
Code: [Select]
uStream := BASS_StreamCreateFile(false, PChar(FileName), 0, 0, BASS_UNICODE  );
« Last Edit: 28 Oct '18 - 11:02 by Chris »

nikos

  • Posts: 63
Re: What i am doing wrong?
« Reply #2 on: 28 Oct '18 - 10:48 »
I am checkign right now thanks ( someone to delete my double post ) i did not notice i have posted it corect.

nikos

  • Posts: 63
Re: What i am doing wrong?
« Reply #3 on: 28 Oct '18 - 10:52 »
I am checkign right now thanks ( someone to delete my double post ) i did not notice i have posted it corect.

I get the same error Maybe is that i am record in ios32 with file extension myfile.caf?????
what is the corect extension of file to use?

Chris

  • Posts: 1864
Re: What i am doing wrong?
« Reply #4 on: 28 Oct '18 - 11:10 »
If i right understand do you want to record and then save it to a File?
So you have  forget to add the Wave Header.(Wavehdr)
So take a look @the Delphi Recording Example that make it more clear;

nikos

  • Posts: 63
Re: What i am doing wrong?
« Reply #5 on: 28 Oct '18 - 13:19 »
Yes thsi is excatly what i want to do to create a WAV file in Ios is that possible?
I have the header

type
  WAVHDR = packed record
    riff:         array[0..3] of Char;
    len:         DWord;
    cWavFmt:      array[0..7] of Char;
    dwHdrLen:      DWord;
    wFormat:      Word;
    wNumChannels:   Word;
    dwSampleRate:   DWord;
    dwBytesPerSec:   DWord;
    wBlockAlign:   Word;
    wBitsPerSample:   Word;
    cData:         array[0..3] of Char;
    dwDataLen:      DWord;
  end;



but i dont know how to write the channel stream to the file  with delphi
« Last Edit: 28 Oct '18 - 13:24 by nikos »

nikos

  • Posts: 63
Re: What i am doing wrong?
« Reply #6 on: 28 Oct '18 - 15:10 »
Everyhting is fine Problem was the Ansistring array
« Last Edit: 29 Oct '18 - 07:37 by nikos »