Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread Michael Van Canneyt
On Mon, 6 Mar 2017, fredvs wrote: Hello Michael and thanks for answer. You must write FileBuffer.Data.WriteBuffer(buffer[0],Length(Buffer)*Sizeof(Float)); Ha, perfect, many thanks. But there is something that I do not catch, why is it working for integer ? Sizeof Integer is 2 bits so,

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread fredvs
> I don't know. By all logic, it should not work either. Yes, it is I think too. Some more explanation: I use a "global" buffer of float to store data. Those data can be int16, int32 or float32. For example, If data are integer (16 or 32 bit), I do: bufferfloat[x] := 127.0 ; (for int16)

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread fredvs
Define "much less success". How are you writing the array and how are you reading it? Hello and thanks for answer. Here how the array is written: var buffer : array of float; FileBuffer.Data := TFileStream.Create(filename,fmCreate); FileBuffer.Data.Seek(0, soFromBeginning);

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread Sven Barth via fpc-pascal
Am 06.03.2017 13:42 schrieb "fredvs" : > > > I don't know. By all logic, it should not work either. > > Yes, it is I think too. > > Some more explanation: > > I use a "global" buffer of float to store data. > Those data can be int16, int32 or float32. > > For example, > > If

[fpc-pascal] Incomplete code example in FPC docs

2017-03-06 Thread Graeme Geldenhuys
Hi, http://www.freepascal.org/docs-html/rtl/typinfo/ispublishedprop.html According to the above URL, that code example is not compilable as-is, because TMyTestObject is not defined anywhere. Shouldn't the code examples in the documentation be compilable as-is? ie: allow the developer to copy

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread fredvs
> I don't know. By all logic, it should not work either. OK, It comes from a "lucky" bug (thanks to reveal it). There was a setlength(buffer, length(buffer) * channels) not needed. Ok, fixed. But the problem remain: If data are int16 or int32: OK, the file is created with +- 1 mega bytes and I

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread Michael Van Canneyt
On Mon, 6 Mar 2017, fredvs wrote: I don't know. By all logic, it should not work either. OK, It comes from a "lucky" bug (thanks to reveal it). There was a setlength(buffer, length(buffer) * channels) not needed. Ok, fixed. But the problem remain: If data are int16 or int32: OK, the file

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread Lukasz Sokol
Or, quite comically maybe: use a text file... write/writeln and read/readln, and use zip compression on the text file to compress data... -L. On 06/03/17 15:59, Lukasz Sokol wrote: > On 06/03/17 14:50, fredvs wrote: >>> I don't know. By all logic, it should not work either. >> >> OK, It comes

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread Lukasz Sokol
On 06/03/17 14:50, fredvs wrote: >> I don't know. By all logic, it should not work either. > > OK, It comes from a "lucky" bug (thanks to reveal it). > There was a setlength(buffer, length(buffer) * channels) not needed. > > Ok, fixed. > > But the problem remain: > > If data are int16 or

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread Michael Van Canneyt
On Mon, 6 Mar 2017, Lukasz Sokol wrote: On 06/03/17 14:50, fredvs wrote: I don't know. By all logic, it should not work either. OK, It comes from a "lucky" bug (thanks to reveal it). There was a setlength(buffer, length(buffer) * channels) not needed. Ok, fixed. But the problem remain:

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread fredvs
> Or, quite comically maybe: use a text file Or maybe, like in my second post, convert float32 ---> integer32 for x := 0 to length(floatbuffer) -1 do begin floatbuffer[x] := round(floatbuffer[x] * 2147483647); if floatbuffer[x] > 2147483647 then floatbuffer[x] := 2147483647; if

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread Sven Barth via fpc-pascal
On 06.03.2017 19:31, fredvs wrote: >> Or, quite comically maybe: use a text file > > Or maybe, like in my second post, convert float32 ---> integer32 > > for x := 0 to length(floatbuffer) -1 do > begin >floatbuffer[x] := round(floatbuffer[x] * 2147483647); >if floatbuffer[x] >

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread fredvs
> I don't know what you're doing wrong, but the following works: Huh, it is exactly what I (think to) do. And re-reading hundred times my code does not see any difference. OK, I will re-read thousand times the code, maybe I will find what is wrong. Many thanks for your code Sven. Fre;D

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread fredvs
Re-hello. Ok, I do not find yet the guilty in my code, I will re-try a other day. By the way, your code is working perfectly Sven. Now, last part of the question: how to convert that file stored into ressource but without to write to the disk (only memory stream)? A TFileStream could be used

Re: [fpc-pascal] Adding a array of float in ressource and use it ?

2017-03-06 Thread Sven Barth via fpc-pascal
Am 06.03.2017 22:45 schrieb "fredvs" : > > > I don't know what you're doing wrong, but the following works: > > Huh, it is exactly what I (think to) do. > And re-reading hundred times my code does not see any difference. > > OK, I will re-read thousand times the code, maybe I