21 typedef struct _oscil {
24 TTPtr audioGraphOutlet;
25 t_symbol *attrWaveform;
26 t_symbol *attrInterpolation;
34 t_oscil* OscilNew(t_symbol *msg,
long argc, t_atom* argv);
35 void OscilFree(t_oscil*
self);
36 void OscilAssist(t_oscil*
self,
void* b,
long msg,
long arg,
char* dst);
37 TTErr OscilReset(t_oscil*
self);
38 TTErr OscilSetup(t_oscil*
self);
40 TTErr OscilDropAudio(t_oscil*
self,
long inletNumber, t_object* sourceMaxObject,
long sourceOutletNumber);
41 t_max_err OscilSetMode(t_oscil*
self,
void* attr,
long argc, t_atom* argv);
42 t_max_err OscilSetInterpolation(t_oscil*
self,
void* attr,
long argc, t_atom* argv);
43 t_max_err OscilSetFrequency(t_oscil*
self,
void* attr,
long argc, t_atom* argv);
44 t_max_err OscilSetGain(t_oscil*
self,
void* attr,
long argc, t_atom* argv);
45 t_max_err OscilSetNumChannels(t_oscil*
self,
void* attr,
long argc, t_atom* argv);
49 static t_class* s_oscil_class;
60 common_symbols_init();
62 c = class_new(
"j.wavetable=", (method)OscilNew, (method)OscilFree,
sizeof(t_oscil), (method)0L, A_GIMME, 0);
64 class_addmethod(c, (method)OscilReset,
"audio.reset", A_CANT, 0);
65 class_addmethod(c, (method)OscilSetup,
"audio.setup", A_CANT, 0);
66 class_addmethod(c, (method)OscilConnectAudio,
"audio.connect", A_OBJ, A_LONG, 0);
67 class_addmethod(c, (method)OscilDropAudio,
"audio.drop", A_CANT, 0);
69 class_addmethod(c, (method)OscilAssist,
"assist", A_CANT, 0);
70 class_addmethod(c, (method)object_obex_dumpout,
"dumpout", A_CANT, 0);
72 CLASS_ATTR_SYM(c,
"waveform", 0, t_oscil, attrWaveform);
73 CLASS_ATTR_ACCESSORS(c,
"waveform", NULL, OscilSetMode);
74 CLASS_ATTR_ENUM(c,
"waveform", 0,
"cosine ramp sawtooth sine square triangle");
75 CLASS_ATTR_DEFAULTNAME(c,
"waveform", 0,
"sine");
77 CLASS_ATTR_SYM(c,
"interpolation", 0, t_oscil, attrInterpolation);
78 CLASS_ATTR_ACCESSORS(c,
"interpolation", NULL, OscilSetInterpolation);
79 CLASS_ATTR_ENUM(c,
"interpolation", 0,
"none linear lfo");
80 CLASS_ATTR_DEFAULTNAME(c,
"interpolation", 0,
"linear");
82 CLASS_ATTR_FLOAT(c,
"frequency", 0, t_oscil, attrFrequency);
83 CLASS_ATTR_ACCESSORS(c,
"frequency", NULL, OscilSetFrequency);
84 CLASS_ATTR_DEFAULT(c,
"frequency", 0,
"1000");
86 CLASS_ATTR_FLOAT(c,
"gain", 0, t_oscil, attrGain);
87 CLASS_ATTR_DEFAULT(c,
"gain", 0,
"1.0");
88 CLASS_ATTR_ACCESSORS(c,
"gain", NULL, OscilSetGain);
90 CLASS_ATTR_LONG(c,
"numChannels", 0, t_oscil, attrNumChannels);
91 CLASS_ATTR_ACCESSORS(c,
"numChannels", NULL, OscilSetNumChannels);
92 CLASS_ATTR_DEFAULT(c,
"numChannels", 0,
"1");
94 class_register(_sym_box, c);
103 t_oscil* OscilNew(t_symbol *msg,
long argc, t_atom* argv)
105 t_oscil*
self = (t_oscil*)object_alloc(s_oscil_class);
117 attr_args_process(
self, argc, argv);
118 object_obex_store((
TTPtr)
self, _sym_dumpout, (t_object*)outlet_new(
self, NULL));
119 self->audioGraphOutlet = outlet_new((t_pxobject*)
self,
"audio.connect");
125 void OscilFree(t_oscil*
self)
135 void OscilAssist(t_oscil*
self,
void* b,
long msg,
long arg,
char* dst)
138 strcpy(dst,
"multichannel audio connection and control messages");
141 strcpy(dst,
"multichannel audio connection");
143 strcpy(dst,
"dumpout");
148 TTErr OscilReset(t_oscil*
self)
150 return self->audioGraphObject->resetAudio();
154 TTErr OscilSetup(t_oscil*
self)
158 atom_setobj(a+0, (t_object*)(self->audioGraphObject));
159 atom_setlong(a+1, 0);
160 outlet_anything(self->audioGraphOutlet, gensym(
"audio.connect"), 2, a);
168 self->audioGraphObject->setAttributeValue(
TT(
"numAudioInlets"), 1);
169 return self->audioGraphObject->connectAudio(audioSourceObject, sourceOutletNumber);
173 TTErr OscilDropAudio(t_oscil*
self,
long inletNumber, t_object* sourceMaxObject,
long sourceOutletNumber)
180 err = (
TTErr)(
TTPtrSizedInt)(object_method(sourceMaxObject, gensym(
"audio.object"), &sourceObject));
181 if (self->audioGraphObject && sourceObject && !err)
182 err =
self->audioGraphObject->dropAudio(sourceObject, sourceOutletNumber, inletNumber);
188 t_max_err OscilSetMode(t_oscil*
self,
void* attr,
long argc, t_atom* argv)
195 for (
int i=0; i<argc; i++)
196 v[i] =
TT(atom_getsym(argv+i)->s_name);
198 self->attrWaveform = atom_getsym(argv);
199 self->audioGraphObject->getUnitGenerator().set(
TT(
"mode"), v);
205 t_max_err OscilSetInterpolation(t_oscil*
self,
void* attr,
long argc, t_atom* argv)
208 self->attrInterpolation = atom_getsym(argv);
209 self->audioGraphObject->getUnitGenerator().set(
TT(
"interpolation"),
TT(self->attrInterpolation->s_name));
215 t_max_err OscilSetFrequency(t_oscil*
self,
void* attr,
long argc, t_atom* argv)
218 self->attrFrequency = atom_getfloat(argv);
219 self->audioGraphObject->getUnitGenerator().set(
TT(
"frequency"), self->attrFrequency);
225 t_max_err OscilSetGain(t_oscil*
self,
void* attr,
long argc, t_atom* argv)
228 self->attrGain = atom_getfloat(argv);
229 self->audioGraphObject->getUnitGenerator().set(
TT(
"gain"), self->attrGain);
235 t_max_err OscilSetNumChannels(t_oscil*
self,
void* attr,
long argc, t_atom* argv)
238 self->attrNumChannels = atom_getlong(argv);
239 self->audioGraphObject->setOutputNumChannels(0, self->attrNumChannels);
TTErr TTObjectBaseRelease(TTObjectBasePtr *anObject)
DEPRECATED.
Base class for all first-class Jamoma objects.
This object is an audio generator, and do not expect audio input.
TTErr setAttributeValue(const TTSymbol name, TTValue &value)
Set an attribute value for an object.
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
void * TTPtr
A generic pointer.
TTErr TTObjectBaseInstantiate(const TTSymbol className, TTObjectBasePtr *returnedObjectPtr, const TTValue arguments)
DEPRECATED.
A thin wrapper of Jamoma AudioGraph for use in the Cycling '74 Max/MSP environment.
TTErr MaxAudioGraphObject(t_object *x, TTAudioGraphObjectBasePtr *returnedAudioGraphObject)
Returns a pointer to the Jamoma Audio Graph object that is wrapped by this Max object.
long TTPtrSizedInt
An integer that is the same size as a pointer.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
The TTAudioGraphObjectBase wraps a TTDSP object such that it is possible to build a dynamic graph of ...
void resize(size_type n)
Change the number of elements.
[doxygenAppendixC_copyExample]
int C74_EXPORT main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.