<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jan 20, 2017 at 3:45 PM, fredvs <span dir="ltr"><<a href="mailto:fiens@hotmail.com" target="_blank">fiens@hotmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Here, for example from OpusFile.h =><br>
<br>
OP_WARN_UNUSED_RESULT int op_read_float(OggOpusFile *_of,<br>
 float *_pcm,int _buf_size,int *_li) OP_ARG_NONNULL(1);<br>
<br>
Translated in fpc with:<br>
<br>
op_read: function(OpusFile: TOggOpusFile; var pcm; SampleCount: Integer; li:<br>
pointer): Integer;<br>
<br>
And used like this:<br>
BufferIn : array of cfloat;<br>
<br>
outframes := op_read_float(HandleOF,BufferI<wbr>n[0],Wantframes *Channels, nil);<br></blockquote><div><br></div><div><div>You should keep the Pascal code syntax closest to the C one, something like this:</div><div><br></div><div>uses ctypes;</div><div><br></div><div>POggOpusFile = ^TOggOpusFile<br></div><div>TOggOpusFile = record // please check if original C struct uses some alignment ...</div><div>end;<br></div><div><br></div><div>function op_read_float(_of: POggOpusFile; _pcm: Pcfloat; _buf_size: cint; _li: pcint): cint; cdecl; ... blah blah blah<br></div><div>// or dynamic loading like you showed (on Delphi you can use the `delayed` keyword instead of declaring `GetProcedureAddress` by hand :-) )</div><div><div><br></div><div>{$MACRO ON}</div><div>{$DEFINE OP_ARG_NONNULL := op_read_float}</div></div><div><br></div><div>It is useful when we need to translate the examples.<br></div><div><br></div><div>It seems that function just increment the address of a (float) buffer, so:</div><div><br></div><div>var<br></div><div><div>...</div><div>  buf: pcfloat;</div><div>begin</div><div>  ... HandleOF/buf initialization etc. ...<br></div><div>  outframes := OP_ARG_NONNULL(HandleOF, buf, Wantframes * Channels, nil);</div><div>... code ...</div><div>  buf += (Wantframes * Channels) * sizeof(cfloat) // or inc(buf, (Wantframes * Channels) * sizeof(cfloat));<br></div></div><div><br></div><div>( you can try "buf += Wantframes * Channels; // or inc(buf, Wantframes * Channels);" too )</div><div><br></div><div>I'm not sure if it works, but you can check it by yourself. :-)</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The nice thing is that BufferIn can be used for portaudio, soundfile,<br>
mpg123, aac buffers and is working like charm.</blockquote><div><br></div><div>Awesome. :-)</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_7365205917413716572gmail-m_7800880709546515362m_4081086835340048282gmail-m_3928291999428754310gmail-m_622625255189251130gmail-">
Fre;D<br>
<br>
-----<br>
Many thanks ;-)</span></blockquote></div><div><br></div>-- <br><div class="m_7365205917413716572gmail-m_7800880709546515362m_4081086835340048282gmail-m_3928291999428754310gmail-m_622625255189251130gmail_signature"><div dir="ltr"><div>Silvio Clécio</div></div></div>
</div></div>