Re: [fpc-pascal] Good FFT example anywhere?
On 2017-04-09 11:06, Bo Berglund wrote: I am looking for some good example of FFT functions in pascal but it seems like what Google serves up is rather old and refers to Turbo-pascal and the like... So maybe someone here knows about some open-source example of FFT using FreePascal (or Delphi)? Hi, I was using attached unit some 7 years ago for various speech processing purposes. Best regards, Žilvinas I want to analyze the frequency content of transient responses measured using a 24 bit A/D converter. It will produce 8192 samples for each measurement. Any suggestions welcome! PS: I have saved this list from Sept 2003 and I searched it for the word FFT without success, except the hits on the word offtopic.. DS (*== fourier.pas - Don Cross This is a Turbo Pascal Unit for calculating the Fast Fourier Transform (FFT) and the Inverse Fast Fourier Transform (IFFT). Visit the following URL for the latest version of this code. This page also has a C/C++ version, and a brief discussion of the theory behind the FFT algorithm. http://www.intersrv.com/~dcross/fft.html#pascal Revision history [most recent first]: 1996 December 11 [Don Cross] Improved documentation of the procedure CalcFrequency. Fixed some messed up comments in procedure ifft. 1996 December 6 [Don Cross] Made procedure 'fft_integer' more efficient when buffer size changes in successive calls: the buffer is now only resized when the input has more samples, not a differing number of samples. Also changed the way 'fft_integer_cleanup' works so that it is more "bullet-proof". 1996 December 4 [Don Cross] Adding the procedure 'CalcFrequency', which calculates the FFT at a specific frequency index p=0..n-1, instead of the whole FFT. This is O(n) instead of O(n*log(n)). 1996 November 30 [Don Cross] Adding a routine to allow FFT of an input array of integers. It is called 'fft_integer'. 1996 November 18 [Don Cross] Added some comments. 1996 November 17 [Don Cross] Wrote and debugged first version. ==*) //{$N+,E+} (* Allows code to use type 'double' and run on any iX86 machine *) {$R-} (* Turn off range checking...we violate array bounds rules *) unit Fourier; interface //uses definition; (*--- procedure fft Calculates the Fast Fourier Transform of the array of complex numbers represented by 'RealIn' and 'ImagIn' to produce the output complex numbers in 'RealOut' and 'ImagOut'. ---*) procedure fft ( NumSamples: word; { must be a positive integer power of 2 } var RealIn: array of double; var ImagIn: array of double; var RealOut: array of double; var ImagOut: array of double ); (*--- procedure ifft Calculates the Inverse Fast Fourier Transform of the array of complex numbers represented by 'RealIn' and 'ImagIn' to produce the output complex numbers in 'RealOut' and 'ImagOut'. ---*) procedure ifft ( NumSamples: word; { must be a positive integer power of 2 } var RealIn: array of double; var ImagIn: array of double; var RealOut: array of double; var ImagOut: array of double ); (*--- procedure fft_integer Same as procedure fft, but uses integer input arrays instead of double. Make sure you call fft_integer_cleanup after the last time you call fft_integer to free up memory it allocates. ---*) procedure fft_integer ( NumSamples: word; var RealIn: array of integer; var ImagIn: array of integer; var RealOut: array of double; var ImagOut: array of double ); (*-- procedure fft_integer_cleanup If you call the procedure 'fft_integer', you must call 'fft_integer_cleanup' after the last time you call 'fft_integer' in order to free up dynamic memory. --*) procedure fft_integer_cleanup; (*-- procedure CalcFrequency This procedure calculates the complex frequency sample at a given index directly. Use this instead of 'fft' when you only need one or two frequency samples, not the whole spectrum. It is also useful for calculating the Discrete Fourier Transform (DFT) of a number of data which is not an
Re: [fpc-pascal] FPImage and mult-page TIFF support
Hi, when I needed to read multi-page tiff files some years ago, I used TLazReaderTiff. I don't remember if multi-page code worked out of the box, but I had to extend tiff reader to handle some more exotic format that came from some imaging software (I think I didn't contribute the changes back - never found a time to create proper bug report...). Best regards, Žilvinas On 2016-12-07 11:58, Graeme Geldenhuys wrote: Hi, Does anybody know if FPImage supports multi-page TIFF's? Reading or Writing. Regards, Graeme ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Official/recommended citations for scientific papers
Hello all, this is a cross-post to FPC-Pascal and Lazarus mailing lists. I'm finishing my PhD thesis and because I was implementing some partial differential equation solvers and visualization/image processing tools using FPC and Lazarus, I need to add some references. I was wandering are there any published official/recommended/written-by-core-developers articles or books about Free Pascal and/or Lazarus I could use as references in my thesis (English preferably)? Currently I'm referencing these: @Book{Leestma93, Title= {Pascal Programming and Problem Solving}, Author = {S. Leestma and L. Nyhoff}, Publisher= {Prentice Hall}, Year = {1993}, Address = {New York}, Edition = {Fourth} } @book{Person13, Title= {Getting Started with the Lazarus IDE}, Author = {R. Person}, Publisher= {Packt Publishing Ltd}, Year = {2013}, Address = {United Kingdom} } @book{Ellison15, Author = {M. Abiola-Ellison}, Title= {Getting Started with Lazarus and Free Pascal: Learning by Doing}, Publisher= {Mka Publishing Ltd}, Year = {2015}, Address = {United Kingdom} } Any other suggestions? Best regards, Žilvinas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Reference in an articles to fpc
Hello all, I'm doing some research involving numerical simulations and I'm using fpc for it. And as I really like fpc, I would like to mention it with a reference. So the question: is there some king of (published) paper/article concerning high-performance [numerical] computing I could use as a reference when writing papers for (serious) journals? The example for JAVA could be: "Java programming for high-performance numerical computing" http://www.cs.cmu.edu/~artigas/papers/sysjour2000.pdf Regards, Žilvinas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How create a full text search with TChmWriter?
I think you should set chmPrj.MakeSearchable := true; (where chmPrj: TChmProject;). At least I set it (with an ~1 year old lazarus+fpc and lhelp build) and I can search for (complete) words in generated chm using lhelp. (I think I do not set FullTextSearch to true though). Regards, Žilvinas On 2012-02-21 10:18, Mattias Gaertner wrote: On Mon, 20 Feb 2012 23:59:18 -0500 Andrew Haines wrote: On 02/20/12 18:00, Mattias Gaertner wrote: Hi, I'm using TChmWriter to pack some html files into a chm file. The index works. I don't have a TOC. Now I want a full text search. I set Writer.FullTextSearch to true, it takes a long time to process and the resulting chm is 30% bigger than the total of all files. So I guess it has created some index. 30% bigger than the size of the uncompressed html files?! Yes. But in lhelp I don't see a search, only the index. There was some bug somewhere a while ago where $FIftiMain was incorrectly searched for as $FiftiMain (i vs I) so maybe make sure lhelp is a recent build. I updated once more. No change. chmmaker can show a search for the example.chm, but can not find anything. I attached the example.chm file that I made a couple of minutes ago using chmmaker with the project in the example subfolder. Can you see if it works for you? I opened it in lhelp and the toc, index and search were all working. Yes, that has a search. And it works. I wonder, what you are doing different. Can you PM me the chm(s) that are not working for you? Also what version of fpc are you using for which platform? linux, fpc 2.7.1 Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Getting Hardware information in Linux
Hello, On 2011-10-18 22:44, Michael Van Canneyt wrote: use DBUS to query HAL. Normally you should get most of the info. I wrote an article on how to do this in FPC. if you want, I can send it to you. Could you send it to me as well? Regards, Žilvinas Ledas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPImage and GetDataLineStart
On 2011-04-22 20:05, Michael Van Canneyt wrote: IMO a helper is bound closer to a type than an operator. Please explain ? To my understanding, they're on exactly the same level ? (from a language feature point of view). I mean, what can be more close to a type than a := operator ? From MY point of view operator is a (special) function, that takes (one/two/...) parameters and returns a result. So I would agree that helper is "closer" than an operator. Regards Žilvinas Ledas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPImage and GetDataLineStart
On 2011-04-22 14:47, michael.vancann...@wisa.be wrote: On Fri, 22 Apr 2011, Marco van de Voort wrote: In our previous episode, michael.vancann...@wisa.be said: class for each storage type and deal with delegation overhead. I've complete understanding for the fact that generics are too early, but IMHO it is the long term solution. Anything else would be madness, or minor damage control at best. Most of the more "recent" or "new" languages I know do not have generics, What do you mean, C++,C#, Java ? No, they are "old" languages too. I was more thinking in terms of PHP, Ruby, Python, Javascript (and its variations). I haven't come accross generics for these languages. Yet they are widely adopted. I don't think that either group could be caller "newer": JAVA (1995): Sun Microsystems released the first public implementation as Java 1.0 in 1995 (James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991) C++ (~1980): It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs as an enhancement to the C language and originally named C with Classes. It was renamed C++ in 1983.[3] C# (2000): By the time the .NET project was publicly announced at the July 2000 Professional Developers Conference, the language had been renamed C#, and the class libraries and ASP.NET runtime had been ported to C#. PHP (1995): PHP was originally created by Rasmus Lerdorf in 1995 JavaScript (1995): LiveScript was the official name for the language when it first shipped in beta releases of Netscape Navigator 2.0 in September 1995, but it was renamed JavaScript in a joint announcement with Sun Microsystems on December 4, 1995 Ruby (1990): Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto. Python (1980-89): Python was conceived in the late 1980s [8] and its implementation was started in December 1989[9] by Guido van Rossum at CWI in the Netherlands Regards Žilvinas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Generics in Delphi mode?
Hi, On 2011-03-30 21:59, timveldhuizen wrote: I hope very much that this will be changed to a delphi compatible style It is already implemented in Trunk ;) Regards, Žilvinas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Re: interested in building a library for functions?
Hello, On 2011-02-26 14:12, Angel Montesinos wrote: An added difficulty that I have thumped with is that the debugger of fpc-Lazarus does not move, by pressing F7 I think this may be solved already in the latest Lazarus version: "Single Instruction step (over/into)" (http://wiki.lazarus.freepascal.org/Lazarus_0.9.30_release_notes). What Lazarus version are you using? If it is not RC of 0.9.30, then you should try using it. You can find it at: http://www.hu.freepascal.org/lazarus/ and it is called "Lazarus-0.9.29-*". Regards Žilvinas Ledas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Basics of profiling -- some comments on fpprofiler bugs
Sorry, forgot to ask - to what category should I submit bugs for fpprofiler? I can't find anything mentioning fpprofiler in http://bugs.freepascal.org ... Regards Žilvinas Ledas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Basics of profiling -- some comments on fpprofiler bugs
On 2010-09-06 15:48, Darius Blaszyk wrote: On Mon, 2010-09-06 at 13:01 +0200, Graeme Geldenhuys wrote: Recently I took a look at Darius's old project 'fpprofiler. Links below. It was over 2 years since anybody worked on it, and riddled with bugs. I fixed all memory leaks, added some improvements, and used the new fcl-passrc code included with FPC Trunk (though it only uses the tokenizer for speed reasons, so FPC 2.4.x should work to - maybe with minor one line code change). I've tested fpprofiler on FPC 2.4 and it works, provided the fcl-passrc is from 2.5.1. I'll add this folder as external to the SVN repository. Few notes (parts that need some improvement): 1) fpp.pp needs at least tkAsm in "case tokenlist[i].token of" in "procedure ModifyCode(AFileName: string; tokenlist: TPasTokenList);" 2) it works wrong with ifdef's (it leaves only ELSE code) -- (I modified my copy to output comments as well and had to "modify" pscanner.pp to have directives as simple comments); 3) in "procedure TPasTokenList.SaveToFile(const AFileName: string);" no need for writeLN's - writes are enough; 4) Asm procedures are handeled wrong (fpprof_exit_profile; is inserted before end;) function IsCPUID_Available : Boolean; register; assembler; asm ... end; 5) records with cases (or some other type) is handeled wrong (fpprof_exit_profile; is inserted before end;) -- I don't remember what type it was exactly. In my opinion 2) is the biggest problem now :) P. S. These comments are with Graemes changes. P. P. S. Good luck with improvements and updates! Regards Žilvinas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to get address of MyFunction in MyFunction?
On 2010-07-18 15:42, Jonas Maebe wrote: On 18 Jul 2010, at 13:14, Žilvinas Ledas wrote: I want to use it this way: 1) Gel all @unitname.function addresses. 2) Use disassembler to find nearest next RET. 3) Then I assume that I have start and end of the function in the binary file. It works at least for the concept-showing app with some functions and enabled optimizations when compiling. Do I have some conceptual flaw? Yes: there is no guarantee that a function will contain only one "ret" (it is that way currently for compiler-generated code, but that can change at any time). I understand that there can be more than one "ret" and I know current version of compiler generates only one so at least for now I am OK. Thanks Jonas for your answers! P. S. I was unable to get any info with "nm" utility from MinGW. Regards Žilvinas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] How to get address of MyFunction in MyFunction?
On 2010-07-18 13:51, Jonas Maebe wrote: On 18 Jul 2010, at 12:50, Jonas Maebe wrote: On 18 Jul 2010, at 12:11, Žilvinas Ledas wrote: to get address of function I can use @MyFunction, but if I use it within MyFunction - I get address of Result. How can I get address of current function? @unitname.function (or @programname.function if you are in the main program file) PS: if you want to use this to calculate the size of functions: don't. The linker can reorder the functions compared to how they are declared in your source file. Thanks, I'll try it. I want to use it this way: 1) Gel all @unitname.function addresses. 2) Use disassembler to find nearest next RET. 3) Then I assume that I have start and end of the function in the binary file. It works at least for the concept-showing app with some functions and enabled optimizations when compiling. Do I have some conceptual flaw? And maybe there is an easier way to get function RET addresses in the binary file? Regards Žilvinas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] How to get address of MyFunction in MyFunction?
Hello all, to get address of function I can use @MyFunction, but if I use it within MyFunction - I get address of Result. How can I get address of current function? (It's not for assigning to something else. It is for a kind of self modifying code.) Regards Žilvinas Ledas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] A patched unit overriding the default - like Delphi supports
On 2010-06-17 12:14, Graeme Geldenhuys wrote: Op 2010-06-17 10:51, Marco van de Voort het geskryf: Well, it is hard to implement fuzzy details :-) :-) I was simply asking if somebody tried that with Free Pascal - it wasn't meant as a feature request. Were it third party or components that come with Delphi that you replaced? I believe it was third party components only. But I would expect FCL to be considered a "third party" components. I guess one way to find out if it works, is to give it a try and see how FPC processes search paths and if two paths contain the same unit, what does it do (which one takes preference), or does it simply halt compiling. The reason I'm asking is, say I have a project that uses fcl-passrc, and in my project I implemented a new feature or bugfix to fcl-passrc (a requirement for my project to work), is there a way I can include that "fixed" unit in my project source so the end-user (developer) doesn't need to override the original fcl-passrc, and that fix/feature will only be limited/applied to my project that really needs it. Then hopefully in future FPC releases that fixes unit will become obsolete as the fix is included with FPC. eg: In MSEide, it included units for FPC 2.0.2 and 2.0.4 that the developer needed to copy over the official released versions to get MSEide to work. Maybe the idea we used in Delphi 7 could prevent having to overwrite the official *.pas files in such a case. Anyway, I'll try it with FPC and report back how it goes. I am using this copy-to-my-custom-dir-method for some fpc packages (eg. chm) and for some lcl units. Regards Žilvinas Ledas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Using Move() with dynamic arrays -> RunError(0)
Marco van de Voort wrote: The move also tries to take the address element 0 for arrays when they are 0. The for loop doesn't execute in that case. Thanks! Didn't thought about that. Regards, Žilvinas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Using Move() with dynamic arrays -> RunError(0)
Hello all, I'm trying to use Move() with dynamic arrays, but don't know why it fails... When instead commented out "for .. do" code I use Move() code my app gets RunError(0) after some time. When I use "for .. do" everything works ok. I'm using Free Pascal Compiler version 2.3.1 [2009/11/03] for i386 on Windows 7. What can be the problem here? type TArrayOfSmallInt = array of SmallInt; function TFrame.getAllFrame(): TArrayOfSmallInt; var tmpBuf: TArrayOfSmallInt; i: Integer; begin startOverlapLen := Length(startOverlap); mainAreaLen := Length(mainArea); endOverlapLen := Length(endOverlap); SetLength(tmpBuf, startOverlapLen+mainAreaLen+endOverlapLen); { for i := 0 to startOverlapLen-1 do tmpBuf[i] := startOverlap[i]; for i := 0 to mainAreaLen-1 do tmpBuf[i+startOverlapLen] := mainArea[i]; for i := 0 to endOverlapLen-1 do tmpBuf[i+startOverlapLen+mainAreaLen] := endOverlap[i]; } Move(startOverlap[0], tmpBuf[0], SizeOf(SmallInt)*startOverlapLen); Move(mainArea[0], tmpBuf[startOverlapLen], SizeOf(SmallInt)*mainAreaLen); Move(endOverlap[0], tmpBuf[startOverlapLen+mainAreaLen], SizeOf(SmallInt)*endOverlapLen); Result := tmpBuf; end; Regards, Žilvinas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] TIOStream and .Position
Yes, I am. But I thought that it is not that logical after I found function: --- FPos: Int64; --- and --- function TIOStream.Seek(Offset: Longint; Origin: Word): Longint; <...> { Try to fake seek by reading and discarding } <...> --- Either way, I have modified mine iostream code to return currently available FPos: Int64 and now I can use Position to know how many bytes were read from the time I have created input stream. It is usefull as I am using generic TStream which in my app can be TFileStream, TStringStream or TIOStream and now I can use the same stream.Position with valid result (as long as I do not seek). If it is intended behaviour to return -1 it is ok by me ;) I just wanted to check if it wasn't a bug. Regards, Zilvinas Ledas Jonas Maebe wrote: On 05 Dec 2009, at 21:42, Žilvinas Ledas wrote: is this intended behavior or it is a bug that iostream.Position always returns -1? Are you reading from standard input or so? In that case it's logical that the position is always -1, since you can't seek standard input (in theory it's infinitely large). Jonas___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] TIOStream and .Position
Hello all, is this intended behavior or it is a bug that iostream.Position always returns -1? In iostream unit I see that there is <...> TIOStream = class(THandleStream) private FType : longint; FPos : Int64; <...> but if I use code like: <...> var iostream: TIOStream; begin iostream := TIOStream.Create(iosInput); iostream.Position; // = -1 iostream.Read(bufferin, 10); iostream.Position; // = -1 end; <...> I don't get the right Position value... Regards, Zilvinas Ledas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] [Fwd: [Lazarus] IOI: Lazarus and Free Pascal]
Yes, i'ts so frustrating when you can't write solutions in ACM using your best known programming language... leledumbo wrote: Brilliant! Incredible! Amazing! I don't know what else to say, I hope ACM will do the same ... ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal