fldsp.h
Go to the documentation of this file.
/*
flext - C++ layer for Max and Pure Data externals
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
#ifndef __FLDSP_H
#define __FLDSP_H
// include the header file declaring the base classes
#include "flext.h"
#include "flpushns.h"
// === flext_dsp ==================================================
FLEXT_TEMPLATE class FLEXT_SHARE FLEXT_CLASSDEF(flext_dsp);
typedef FLEXT_SHARE FLEXT_TEMPINST(FLEXT_CLASSDEF(flext_dsp)) flext_dsp;
FLEXT_TEMPLATE
class FLEXT_SHARE FLEXT_CLASSDEF(flext_dsp):
public flext_base
{
FLEXT_HEADER_S(FLEXT_CLASSDEF(flext_dsp),flext_base,Setup)
friend class FLEXT_SHARE FLEXT_TEMPINST(FLEXT_CLASSDEF(flext_base));
public:
float Samplerate() const { return srate; }
int Blocksize() const { return blksz; }
t_sample *const *InSig() const { return vecs; }
t_sample *InSig(int i) const { return InSig()[i]; }
// \todo cache that returned pointer
t_sample *const *OutSig() const
{
int i = CntInSig();
// in PD we have at least one actual dsp in vector
#if FLEXT_SYS == FLEXT_SYS_PD
return vecs+(i?i:1);
#elif FLEXT_SYS == FLEXT_SYS_MAX
return vecs+i;
#else
#error
#endif
}
t_sample *OutSig(int i) const { return OutSig()[i]; }
typedef t_sample *t_signalvec;
// --- inheritable virtual methods --------------------------------
virtual bool CbDsp();
virtual void CbSignal();
virtual void m_dsp(int n,t_signalvec const *insigs,t_signalvec const *outsigs);
virtual void m_signal(int n,t_sample *const *insigs,t_sample *const *outsigs);
// --- inlet/outlet stuff -----------------------------------------
void AddInSignal(int m = 1) { AddInlet(xlet_sig,m); }
void AddInSignal(const char *desc) { AddInlet(xlet_sig,1,desc); }
void AddOutSignal(int m = 1) { AddOutlet(xlet_sig,m); }
void AddOutSignal(const char *desc) { AddOutlet(xlet_sig,1,desc); }
protected:
FLEXT_CLASSDEF(flext_dsp)();
virtual void Exit();
private:
// not static, could be different in different patchers..
float srate;
int blksz;
t_signalvec *vecs;
// setup function
static void Setup(t_classid c);
#if FLEXT_SYS == FLEXT_SYS_PD
static bool cb_enable(flext_base *c,float &on);
bool dspon;
#endif
static inline flext_dsp *thisObject(flext_hdr *c) { return FLEXT_CAST<flext_dsp *>(c->data); }
void SetupDsp(t_signal **sp);
// dsp stuff
static t_int *dspmeth(t_int *w);
};
#include "flpopns.h"
#endif
flext_dsp::AddOutSignal
void AddOutSignal(int m=1)
Add signal outlet(s)
Definition: fldsp.h:144
FLEXT_HEADER_S
#define FLEXT_HEADER_S(NEW_CLASS, PARENT_CLASS, SETUPFUN)
Flext class header with setup function.
Definition: fldefs_hdr.h:47
flext.h
This is the main flext include file.
flext_base
Definition: flclass.h:58
flext_dsp::srate
float srate
Definition: fldsp.h:164
flext_base::Exit
virtual void Exit()
Deallocate all kinds of stuff.
Definition: flext.cpp:88
flext_dsp::InSig
t_sample *const * InSig() const
returns array of input vectors (CntInSig() vectors)
Definition: fldsp.h:57
flext_base::Setup
static void Setup(t_classid c)
Definition: flext.cpp:178
flext_dsp::thisObject
static flext_dsp * thisObject(flext_hdr *c)
Definition: fldsp.h:176
flext_dsp::vecs
t_signalvec * vecs
Definition: fldsp.h:166
flext_dsp::blksz
int blksz
Definition: fldsp.h:165
flext_dsp::AddOutSignal
void AddOutSignal(const char *desc)
Add signal outlet (with description)
Definition: fldsp.h:149
flext_dsp::InSig
t_sample * InSig(int i) const
returns input vector
Definition: fldsp.h:60
flext_dsp::AddInSignal
void AddInSignal(int m=1)
Add signal inlet(s)
Definition: fldsp.h:134
flext_dsp
flext_dsp flext_dsp
Definition: fldsp.h:24
FLEXT_TEMPINST
#define FLEXT_TEMPINST(fun)
Definition: flprefix.h:457
flext_dsp::AddInSignal
void AddInSignal(const char *desc)
Add signal inlet (with description)
Definition: fldsp.h:139
FLEXT_TEMPLATE
#define FLEXT_TEMPLATE
Definition: flprefix.h:455
flext_dsp::OutSig
t_sample * OutSig(int i) const
returns output vector
Definition: fldsp.h:78
flext_dsp
Flext dsp enabled base object.
Definition: fldsp.h:31
flext_hdr
The obligatory PD or Max/MSP object header.
Definition: flbase.h:38
flpushns.h
flext_dsp::Blocksize
int Blocksize() const
returns current block (aka vector) size
Definition: fldsp.h:54
flext_dsp::OutSig
t_sample *const * OutSig() const
returns array of output vectors (CntOutSig() vectors)
Definition: fldsp.h:64
flpopns.h
flext_base::AddInlet
void AddInlet(xlettype tp, int mult=1, const char *desc=NULL)
Add one or more inlet(s)
Definition: flxlet.cpp:43
FLEXT_SHARE
#define FLEXT_SHARE
Definition: flprefix.h:418
flext_base::CntInSig
int CntInSig() const
Get number of signal inlets.
Definition: flclass.h:181
flext_base::AddOutlet
void AddOutlet(xlettype tp, int mult=1, const char *desc=NULL)
Add one or more outlet(s)
Definition: flxlet.cpp:55
FLEXT_CLASSDEF
#define FLEXT_CLASSDEF(CL)
Definition: flprefix.h:383
flext_dsp::dspon
bool dspon
Definition: fldsp.h:173
flext_dsp::t_signalvec
t_sample * t_signalvec
typedef describing a signal vector
Definition: fldsp.h:81