can anybody translate me these C++ code to PB?
Code: Select all
Convs[ i ] = new CDSPBlockConvolver(
CDSPFIRFilterCache :: getLPFilter( 0.5, tb, ReqAtten,
ReqPhase, 2.0 ), 2, 1, PrevLatencyFrac );
Code: Select all
Convs[ i ] = new CDSPBlockConvolver(
CDSPFIRFilterCache :: getLPFilter( 0.5, tb, ReqAtten,
ReqPhase, 2.0 ), 2, 1, PrevLatencyFrac );
From that single line, not a chance.Wolfram wrote:...can anybody translate me these C++ code to PB?Code: Select all
Convs[ i ] = new CDSPBlockConvolver( CDSPFIRFilterCache :: getLPFilter( 0.5, tb, ReqAtten, ReqPhase, 2.0 ), 2, 1, PrevLatencyFrac );
If you need the rest you can get it hereTI-994A wrote:From that single line, not a chance.Wolfram wrote:...can anybody translate me these C++ code to PB?Code: Select all
Convs[ i ] = new CDSPBlockConvolver( CDSPFIRFilterCache :: getLPFilter( 0.5, tb, ReqAtten, ReqPhase, 2.0 ), 2, 1, PrevLatencyFrac );
![]()
For one thing, we have no access to the CDSPBlockConvolver() and CDSPFIRFilterCache() object class codes.
It seems to be mainly data-manipulation, which should be quite doable in PureBasic. However, just between those two objects, you're conservatively looking at nearly a thousand lines of code.Wolfram wrote:If you need the rest you can get it here
https://github.com/avaneev/r8brain-free-src
Wolfram wrote:My Problem is, I don't understand what Convs[ i ] = new CDSPBlockConvolver() means
What ist Convs[ i ] in this case?
Is it possible to translate this to PB?
Ok that helps!Lunasole wrote:Wolfram wrote:My Problem is, I don't understand what Convs[ i ] = new CDSPBlockConvolver() means
What ist Convs[ i ] in this case?
Is it possible to translate this to PB?
Convs itself is just an array containing CDSPBlockConvolver classes.
That code just adds new element using i as array index.
There are no problems with array, the problem of translation is that Purebasic doesn't support classes. You need to rewrite CDSPBlockConvolver class in procedural way or use another solution like custom OOP implementation.
So generally yes, it is possible to translate, but much more complicated than just rewriting code as is.
Converting C++ code to PB without understating the C++ code itself, is not gonna work well.Wolfram wrote:My Problem is, I don't understand what Convs[ i ] = new CDSPBlockConvolver() means
What ist Convs[ i ] in this case?
Is it possible to translate this to PB?
Code: Select all
Convs[ i ] = new CDSPBlockConvolver(
CDSPFIRFilterCache :: getLPFilter( 0.5, tb, ReqAtten,
ReqPhase, 2.0 ), 2, 1, PrevLatencyFrac );
Code: Select all
CPtrKeeper< CDSPBlockConvolver* > Convs[ ConvCountMax ]; ///< Convolvers.
Code: Select all
class CPtrKeeper
{
R8BNOCTOR( CPtrKeeper );
public:
CPtrKeeper()
: Object( NULL )
{
}
/**
* Constructor assigns a pointer to object to *this keeper.
*
* @param aObject Pointer to object to keep, can be NULL.
*/
template< class T2 >
CPtrKeeper( T2 const aObject )
: Object( aObject )
{
}
~CPtrKeeper()
{
delete Object;
}
/**
* Function assigns a pointer to object to *this keeper. A previously
* keeped pointer will be reset and object deleted.
*
* @param aObject Pointer to object to keep, can be NULL.
*/
template< class T2 >
void operator = ( T2 const aObject )
{
reset();
Object = aObject;
}
/**
* @return Pointer to keeped object, NULL if no object is being kept.
*/
T operator -> () const
{
return( Object );
}
/**
* @return Pointer to keeped object, NULL if no object is being kept.
*/
operator T () const
{
return( Object );
}
/**
* Function resets the keeped pointer and deletes the keeped object.
*/
void reset()
{
T DelObj = Object;
Object = NULL;
delete DelObj;
}
/**
* @return Function returns the keeped pointer and resets it in *this
* keeper without object deletion.
*/
T unkeep()
{
T ResObject = Object;
Object = NULL;
return( ResObject );
}
private:
T Object; ///< Pointer to keeped object.
///<
};
Code: Select all
Structure CPtrKeeper Align #PB_Structure_AlignC
*Object.Integer ; Pointer to keeped object.
EndStructure