Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. Thank you both for replying. @Anders MelanderThanks for your suggestions, I implemented your solution and at least i get no compiler error. I have to complete some other parts of the software before checking if everything works fine. By convention what would be an appropriate name for pointer variable of type PRadio? var ?MyRadioPointer? : PRadio; Heritage from school 😉 Thanks again Frate
  2. Hi everyone, first post for me so I shortly introduce myself. I'm Aerospace Eng. student in Italy, passionate about electronics, PCs and aviation. Learned Lazarus at high school, now moving to Delphi some personal projects. I'll drop here the code I'm having issues with: uses bass, [...] type TRadio = record counter : word; [...] function MakeSine(handle: HSTREAM; buffer: Pointer; Alength: DWORD; user: Pointer): DWORD; stdcall; // BLOCK TONE GENERATION end; type TRadioPointer = ^TRadio; function TRadio.MakeSine(handle: HSTREAM; buffer: Pointer; Alength: DWORD; user: Pointer): DWORD; stdcall; //3 var buf: ^WORD; i, k, len: Integer; ampl: real; j: word; begin // Does stuff using properties from TRadio inc(cunter); [...] Result := Alength; end; procedure initRadio(PRadio : TRadioPointer); //2 [...] begin [...] resultValue := BASS_StreamCreate(cSAMPLE_RATE, 2, 0, @PRadio^.MakeSine, nil); // Error here : E2036 Variable Required [...] end; procedure mainProgram; //1 var MyRadio : TRadio; begin initRadio(@MyRadio); end; What I'm trying to achieve : I'm using an audio library called Bass. I have to create a waveform (TRadio.MakeSine) using parameters from a TRadio record. There is no possibility to change the parameters on the MakeSine function because BASS_StreamCreate wants specific function paramters (so for instance I can't pass the TRadio.parameters directly to the MakeSine function). I decided to put MakeSine inside the TRadio record to allow access to the parameters i need (also for the program logic makes sense to do that). BASS_StreamCreate requires a pointer to MakeSine function as input (see reference below). The problem I have: When i try to pass the function pointer to StreamCreate i get error E2036 Variable Required. I don't understand what i'm doing wrong. Kindly asking for help Frate Bass reference: HSTREAM BASS_StreamCreate( DWORD freq, DWORD chans, DWORD flags, STREAMPROC *proc, void *user ); DWORD CALLBACK StreamProc( HSTREAM handle, void *buffer, DWORD length, void *user );