COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 02-08-2018, 02:41 PM   #1
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default WDF and IPlug

Hello,

I'm trying to model some gears with WDF.But i can't import it to IPlugEffect.

Can you help me to use with it IPlug?

https://github.com/AndrewBelt/WDFplu.../WDF%2B%2B.hpp

Thanks.
Tunca is offline   Reply With Quote
Old 02-09-2018, 07:02 AM   #2
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

It's JUCE based.I need to convert it to WDL.

Now i have trouble with "string".

I'm using std::string but i can't use std::string::empty.Can you help,please?

Code:
template <typename T>
class OnePort
{
    public:
        OnePort (T R, String n = String::empty)
            : _name (n), Rp (R), a (0), b (0), port(this) {}
        //----------------------------------------------------------------------
        virtual String name () const { return _name.isEmpty() ? label() : _name; }
        virtual String label () const = 0;
        //----------------------------------------------------------------------
        virtual inline void incident (T wave) = 0;
        //----------------------------------------------------------------------
        virtual inline T reflected () = 0;
        //----------------------------------------------------------------------
        virtual T R () { return port->Rp; }       // Port resistance
        virtual T G () { return 1.0 / port->Rp; } // Port conductance (inv.Rp)
        //----------------------------------------------------------------------
        virtual void connect (OnePort<T>* other)
        {
            port = other;
            other->port = this;
        }
        //----------------------------------------------------------------------
        T voltage () // v
        {
            return (port->a + port->b) / 2.0;
        }
        //----------------------------------------------------------------------
        T current () // i
        {
            return (port->a - port->b) / (port->Rp + port->Rp);
        }
        //----------------------------------------------------------------------
    protected:
        //----------------------------------------------------------------------
        String _name; // Port name
        T Rp; // Port resistance
        //----------------------------------------------------------------------
        T a; // incident wave (incoming wave)
        T b; // reflected wave (outgoing wave)
        //----------------------------------------------------------------------
        OnePort<T>* port; // internal pointer (used for direct connect form)
        //----------------------------------------------------------------------
};
Tunca is offline   Reply With Quote
Old 02-10-2018, 02:33 AM   #3
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

AFAIK std::string::empty() is a non-static method, so you can only use it like this:

Code:
if (str.empty()) ...
But not like this:

Code:
if (str == std::string::empty()) ...
Nor this:

Code:
if (str == std::string::empty) ...
But if you are converting to WDL, then maybe it would be better to replace String with WDL_String? I dunno, just a suggestion.
Tale is offline   Reply With Quote
Old 02-10-2018, 02:47 AM   #4
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Thanks Tale!

Now i converted to WDL with no problem but i have problem with processing.

I'm trying to build simple LC circuit to understand processing output.

I can process with MATLAB but no luck with WDL.

MATLAB

Code:
Fs = 44100; % sample rate (Hz)
N = 20000; % number of samples to simulate
 
output = zeros(N,1);
 
CapVal1 = 3.6e-4; % the capacitance value in Farads
C1 = Capacitor(CapVal1, Fs);
Lval1 = 3.6e-4;
L1 = Inductor(Lval1, Fs);
L1.State = 10;
 
 
p1 =  Parallel(C1,L1); % create WDF 

CapVal2 = 4.6e-4; % the capacitance value in Farads
C2 = Capacitor(CapVal2, Fs);
Lval2 = 4.6e-4;
L2 = Inductor(Lval2, Fs);

L2.State = 10;

p2 =  Parallel(C2,L2); % create WDF 

s1 = Series(p1,p2);
  
for i=1:N
    myB = WaveUp(s1); 
    WaveDown(s1,myB); % open circuit 
    output(i) = Voltage(p1) +  Voltage(p2);
end
plot(output)
%soundsc(output, Fs)
WDL

Code:
double LC (double &input, double &Fs)
{
    // 1 ohm is the Ri voltage source resistor
    double Ri = 1.0;
    
    // Internal circuit parameters
    VoltageSource Vin (0.0, Ri); // initialize voltage at 0V

    Capacitor C1 (3.6e-4, Fs);
    Inductor L1 (3.6e-4, Fs);
    
    
    // create WDF circuit
    Parallel CL1 (&C1,&L1);
    
    Capacitor C2 (4.6e-4, Fs);
    Inductor L2 (4.6e-4, Fs);
    
    Parallel CL2 (&C2,&L2);
    
    Serie CL (&CL1, &CL2);
    

    
    // for simulation
    double output;
    
    int n=0; int max=input.size();
    for (; n<max; ++n)
    {
      //Can't write here//
    }
    return output;
}
Also i have issue with "int max=input.size();" it giving error.How to get size? And how to process according to MATLAB?

Thanks.
Tunca is offline   Reply With Quote
Old 02-10-2018, 10:55 AM   #5
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Any help?
Tunca is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:26 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.