lossyWAV 1.3.0 source translated to C++ from Delphi |
- 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 |
Aug 26 2012, 22:02
Post
#1
|
|
|
Group: Members Posts: 345 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) Optimizations: * 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)
|
|
|
|
![]() |
Aug 27 2012, 20:22
Post
#2
|
|
|
Group: Members Posts: 1559 Joined: 24-June 02 From: Catalunya(Spain) Member No.: 2383 |
A couple of code snippets:
in nSupport.h: CODE inline std::string IntToStr(int intval) { std::stringstream st; st << intval; return st.str(); } /*Accounts for Delphi's 1-based index*/ inline std::string Copy(const std::string& in, int begin1b, int amount) { in.substr(begin1b-1, amount); } inline bool FileExists(std::string file_name) { std::fstream filetest(file_name.c_str(), std::ios_base::in | std::ios_base::binary); if (filetest.is_open()) { filetest.close(); return true; } return false; } Also, note that where you have the Copy calls, you're replacing the Length(string) for sizeof(string). That's wrong. use string.length(). in nCore.h, stdint is not present in VS 2008 and below CODE #if defined _MSC_VER #if _MSC_VER > 1500 #include <stdint> #else typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; typedef signed long long int int64_t; typedef unsigned long long int uint64_t; #endif #endif I also needed to redefine the way you declared the FFTW interface, like this: fftw_interface.h CODE typedef void * (* FUN_Plan_DFT_r2c_1d) (int, double* , double* , unsigned int ); typedef void* (* FUN_Plan_DFT_1d)(int, double* , double* , int , unsigned int ); typedef void (* FUN_Execute)(void* ); typedef void (* FUN_Destroy_Plan)(void* ); struct FFTW_Rec { FUN_Plan_DFT_r2c_1d Plan_DFT_r2c_1d; FUN_Plan_DFT_1d Plan_DFT_1d; FUN_Execute Execute; FUN_Destroy_Plan Destroy_Plan; void* Plans [ MAX_FFT_BIT_LENGTH + 1 ]; }; fftw_interface.cpp CODE FFTW.Plan_DFT_r2c_1d = (FUN_Plan_DFT_r2c_1d) GetProcAddress(FFTW_DLL_Handle, "fftw_plan_dft_r2c_1d"); FFTW.Plan_DFT_1d = (FUN_Plan_DFT_1d) GetProcAddress(FFTW_DLL_Handle, "fftw_plan_dft_1d"); FFTW.Execute = (FUN_Execute) GetProcAddress(FFTW_DLL_Handle, "fftw_execute"); FFTW.Destroy_Plan = (FUN_Destroy_Plan) GetProcAddress(FFTW_DLL_Handle, "fftw_destroy_plan"); Also, i had to add some includes here and there ( <cmath> mostly ) At last, i'm not sure if it will be of help, or it will add to confusion, but these two source files might help on the file loading riff.cpp riff.hpp That's a .wav file load/save in a mixture of C and C++. (Not the best code anyway, it was scheduled for improvement, but since it works, it has been kept) This post has been edited by [JAZ]: Aug 27 2012, 20:26 |
|
|
|
tycho lossyWAV 1.3.0 source translated to C++ from Delphi Aug 26 2012, 22:02
Nick.C Thanks tycho - I'll have a look tomorrow....
... Aug 26 2012, 22:09
tycho You're welcome, Nick.
Not sure, but your comp... Aug 26 2012, 22:59
db1989 QUOTE ([JAZ] @ Aug 27 2012, 20:22... Aug 27 2012, 21:40
[JAZ] Oops..
Yes, you're right. I should have looked... Aug 27 2012, 22:01
db1989 I was going to say it was good (and my something-n... Aug 27 2012, 22:30
tycho Thank you guys. I already did IntToStr() and Copy(... Aug 27 2012, 23:19
tycho Here is v03 of the translation. (I didn't pub... Aug 28 2012, 21:26
tycho Attached, lossyWAV-cpp_v04.
I finally made it to ... Sep 4 2012, 06:34
Nick.C Thanks Tycho.
I''ve got it to compile wit... Sep 4 2012, 18:40
tycho QUOTE (Nick.C @ Sep 4 2012, 09:40) Thanks... Sep 5 2012, 00:38
Nick.C After a bit of debugging, I've got this versio... Sep 5 2012, 13:03![]() ![]() |
|
Lo-Fi Version | Time is now: 20th May 2013 - 02:50 |