3 #include "chuck_type.h"
4 #include "chuck_ugen.h"
6 #include "chuck_globals.h"
8 /* UI class - do-nothing (from FAUST/minimal.cpp) */
15 UI() : fStopped(false) {}
18 virtual void addButton(const char* label, float* zone) {}
19 virtual void addToggleButton(const char* label, float* zone) {}
20 virtual void addCheckButton(const char* label, float* zone) {}
21 virtual void addVerticalSlider(const char* label, float* zone, float init, float min, float max, float step) {}
22 virtual void addHorizontalSlider(const char* label, float* zone, float init, float min, float max, float step) {}
23 virtual void addNumEntry(const char* label, float* zone, float init, float min, float max, float step) {}
25 virtual void openFrameBox(const char* label) {}
26 virtual void openTabBox(const char* label) {}
27 virtual void openHorizontalBox(const char* label) {}
28 virtual void openVerticalBox(const char* label) {}
29 virtual void closeBox() {}
33 void stop() { fStopped = true; }
34 bool stopped() { return fStopped; }
37 class dsp { public: float fSamplingFreq; };
45 * FAUST defines UI values as private, but provides no getters/setters.
46 * In our particular case it's way more convenient to access them directly
47 * than to set up a complicated UI structure. Also get rid of everything
48 * being "virtual", since it may stop the compiler from inlining properly!
50 #define private public
53 /* Rename the class the name of our DSP. */
54 #define mydsp %dsp_name%
68 static t_CKUINT %dsp_name%_offset_data = 0;
69 static int g_sr = 44100;
71 static void %dsp_name%_ctor( Chuck_Object * SELF, void * ARGS, Chuck_VM_Shred * SHRED )
73 // return data to be used later
74 %dsp_name% *d = new %dsp_name%;
75 OBJ_MEMBER_UINT(SELF, %dsp_name%_offset_data) = (t_CKUINT)d;
79 static void %dsp_name%_dtor( Chuck_Object * SELF, Chuck_VM_Shred * SHRED )
81 delete (%dsp_name%*) OBJ_MEMBER_UINT(SELF, %dsp_name%_offset_data);
82 OBJ_MEMBER_UINT(SELF, %dsp_name%_offset_data) = 0;
85 static t_CKBOOL %dsp_name%_tick( Chuck_Object * SELF, float in, float * out, Chuck_VM_Shred * SHRED )
87 %dsp_name% *d = (%dsp_name%*)OBJ_MEMBER_UINT(SELF, %dsp_name%_offset_data);
88 float * input, * output;
91 d->compute (1, &input, &output);
97 DLL_QUERY %dsp_name%_query( Chuck_DL_Query * QUERY )
99 Chuck_Env * env = Chuck_Env::instance();
100 Chuck_DL_Func * func = NULL;
104 if( !type_engine_import_ugen_begin( env, "%dsp_name%", "UGen", env->global(),
105 %dsp_name%_ctor, %dsp_name%_dtor, %dsp_name%_tick, NULL ) )
108 // add member variable
109 %dsp_name%_offset_data = type_engine_import_mvar( env, "int", "@%dsp_name%_data", FALSE );
110 if( %dsp_name%_offset_data == CK_INVALID_OFFSET ) goto error;
115 if( !type_engine_import_class_end( env ) )
122 if( !type_engine_import_class_end( env ) )