Welcome Guest ( Log In | Register )

> Upload forum rules

- No over 30 sec clips of copyrighted music. Cite properly and never more than necessary for the discussion.

- No copyrighted software without permission.

- Click here for complete Hydrogenaudio Terms of Service

lossyWAV 1.3.0 source translated to C++ from Delphi
post Aug 26 2012, 22:02
Post #1

Group: Members
Posts: 346
Joined: 5-August 03
Member No.: 8183

Here is the first public preview of the source translation of lossyWAV 1.3.0 to C++. It is not finished, but the main work is done.

- vc10_err.txt list the current compiler output in Visual Studio C++ 2010.
- A number of built-in Delphi functions are not yet converted. Most are trivial, but Write() involves some work.

Please note, I know very little of how the code actually works, I basically translated it line by line, and did minor optimizations.
Developers can look over the code and compare with the Delphi source. I have tried to take into account a number of C++'s quirks, e.g.:
- integer / integer -> integer (not floating point, but if one operand is float, it returns float)
- unsigned int (opr) signed int -> unsigned int
- & is bitwise-and, && is boolean-and, likewise with or: |, ||
- c++ base 0 arrays, versus base X in delphi. (range_array class in nSupport.h emulates that)

* var = var opr value --> var opr= value;
* var = var + 1 --> ++ var;
* and a few more

I added file nSupport.h that has a few Delphi emulation functions and classes. The shared global variables are only declared in the header file. I've not defined them in the cpp files yet.
Attached File(s)
Attached File  lossyWAV_cpp.7z ( 90.42K ) Number of downloads: 116
Go to the top of the page
+Quote Post
Start new topic
post Sep 4 2012, 06:34
Post #2

Group: Members
Posts: 346
Joined: 5-August 03
Member No.: 8183

Attached, lossyWAV-cpp_v04.

I finally made it to link successfully, however it does not work yet. I have only tried it once, and it fails on trying to read a wav file although no arguments are given. Something with the parameter checking must be wrong. The program must be compiled and run with a debugger, to ensure that it does what it is supposed to.
  • I have used gnu g++ 4.7.0 via Qt Creator (CMake) for the last part of the translation, not sure if it will compile cleanly in Visual Studio anylonger.
  • Many of the Delphi structs were "Packed Record" types, meaning they have non-aligned members. There is a #pragma pack() feature in C as well, but it's not portable, and slows down processing. Please identify which, if any structs needs to be "packed". Typically if the WAV format has "unaligned fields" that are directly read from/written to data structures. Check sizeof(struct) if they are of expected size.
  • The Delphi functions filegetattr(), filesetattr() are not translated (yet), only used for checking and forcing to write on read-only output files.
  • Version checking stuff is translated, but commented out. The version is simply set (some constants should be made or a file with version could be #included). Also, this code wouldn't be possible to translate to Linux anyhow.
  • Global initialization objects in each translation unit (each .cpp file) may have some issues because the sequence of them are random. Initialization could better be done explicitly from the main() routine, in a controlled sequence.
  • The Delphi text Write() function calls has optional formatting in arguments (like :6:4). These are commented out, but can be emulated closely by by inserting << setw(n) and << setprecision(m), etc.
  • I may have done all sorts of other errors during translation, please verify with the original source. The translation still matches the original closely, and it should stay so until it works.
  • DirectoryExist() function is not translated yet. Only an empty function returning true in nSupport.h for now. Must be done.

I have limited time to follow up on this before Christmas, so any help to get this working is welcome..

Attached File(s)
Attached File  lossyWAV_cpp_v04.7z ( 341.91K ) Number of downloads: 138
Go to the top of the page
+Quote Post

Posts in this topic

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 29th November 2015 - 07:10