<commit_before>/* 
 *	tt.wavetable~
 *	External object for Max/MSP
 *	
 *	Example project for TTBlue
 *	Copyright © 2008 by <NAME>
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#include "ext.h"					// Max Header
#include "z_dsp.h"					// MSP Header
#include "ext_strings.h"			// String Functions
#include "commonsyms.h"				// Common symbols used by the Max 4.5 API
#include "ext_obex.h"				// Max Object Extensions (attributes) Header

#include "TTBlueAPI.h"				// TTBlue Interfaces...


// Data Structure for this object
typedef struct _wavetable	{
    t_pxobject			obj;
	TTAudioObjectPtr	wavetable;
	TTAudioSignalPtr	audioOut;
	t_symbol*			attrMode;
	t_symbol*			attrInterpolation;
	float				attrFrequency;
	float				attrGain;
	TTUInt16			maxNumChannels;
	TTUInt16			vs;
} t_wavetable;


// Prototypes for methods: need a method for each incoming message type
void*		wavetable_new(t_symbol *msg, short argc, t_atom *argv);					// New Object Creation Method
void		wavetable_free(t_wavetable *x);
void		wavetable_assist(t_wavetable *x, void *b, long msg, long arg, char *dst);	// Assistance Method
t_int*		wavetable_perform(t_int *w);												// An MSP Perform (signal) Method
void		wavetable_dsp(t_wavetable *x, t_signal **sp, short *count);					// DSP Method
void		wavetable_stop(t_wavetable *x);
void		wavetable_int(t_wavetable *x, long newCurrentValue);
void		wavetable_float(t_wavetable *x, double newCurrentValue);
void		wavetable_list(t_wavetable *x, double endValue, double time);
t_max_err	wavetable_setMode(t_wavetable *x, void *attr, long argc, t_atom *argv);
t_max_err	wavetable_setInterpolation(t_wavetable *x, void *attr, long argc, t_atom *argv);
t_max_err	wavetable_setFrequency(t_wavetable *x, void *attr, long argc, t_atom *argv);
t_max_err	wavetable_setGain(t_wavetable *x, void *attr, long argc, t_atom *argv);


// Globals
static t_class *s_wavetable_class;


/************************************************************************************/
// Main() Function

int main(void)
{
	t_class *c;
	
	TTBlueInit();	
	common_symbols_init();

	c = class_new("tt.wavetable~",(method)wavetable_new, (method)wavetable_free, sizeof(t_wavetable), (method)0L, A_GIMME, 0);

 	class_addmethod(c, (method)wavetable_dsp,			"dsp",		A_CANT, 0L);		
	class_addmethod(c, (method)wavetable_assist,		"assist",	A_CANT, 0L); 
    class_addmethod(c, (method)object_obex_dumpout,		"dumpout", 	A_CANT, 0);  

	CLASS_ATTR_SYM(c,		"mode",				0,		t_wavetable,	attrInterpolation);
	CLASS_ATTR_ACCESSORS(c,	"mode",				NULL,	wavetable_setMode);
	
	CLASS_ATTR_SYM(c,		"interpolation",	0,		t_wavetable,	attrMode);
	CLASS_ATTR_ACCESSORS(c,	"interpolation",	NULL,	wavetable_setInterpolation);
	
	CLASS_ATTR_FLOAT(c,		"frequency",		0,		t_wavetable,	attrFrequency);
	CLASS_ATTR_ACCESSORS(c,	"frequency",		NULL,	wavetable_setFrequency);

	CLASS_ATTR_FLOAT(c,		"gain",				0,		t_wavetable,	attrGain);
	CLASS_ATTR_ACCESSORS(c,	"gain",				NULL,	wavetable_setGain);
	
	class_dspinit(c);
	class_register(CLASS_BOX, c);
	s_wavetable_class = c;
	return 0;
}


/************************************************************************************/
// Object Creation Method

void* wavetable_new(t_symbol *msg, short argc, t_atom *argv)
{
    t_wavetable	*x;
	TTValue		sr(sys_getsr());
 	long		attrstart = attr_args_offset(argc, argv);		// support normal arguments
	short		i;
   
    x = (t_wavetable *)object_alloc(s_wavetable_class);
    if(x){
		x->maxNumChannels = 2;
		if(attrstart && argv)
			x->maxNumChannels = atom_getlong(argv);<commit_msg>bug fix when getting attributes from this example<commit_after>/* 
 *	tt.wavetable~
 *	External object for Max/MSP
 *	
 *	Example project for TTBlue
 *	Copyright © 2008 by <NAME>
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#include "ext.h"					// Max Header
#include "z_dsp.h"					// MSP Header
#include "ext_strings.h"			// String Functions
#include "commonsyms.h"				// Common symbols used by the Max 4.5 API
#include "ext_obex.h"				// Max Object Extensions (attributes) Header

#include "TTBlueAPI.h"				// TTBlue Interfaces...


// Data Structure for this object
typedef struct _wavetable	{
    t_pxobject			obj;
	TTAudioObjectPtr	wavetable;
	TTAudioSignalPtr	audioOut;
	t_symbol*			attrMode;
	t_symbol*			attrInterpolation;
	float				attrFrequency;
	float				attrGain;
	TTUInt16			maxNumChannels;
	TTUInt16			vs;
} t_wavetable;


// Prototypes for methods: need a method for each incoming message type
void*		wavetable_new(t_symbol *msg, short argc, t_atom *argv);					// New Object Creation Method
void		wavetable_free(t_wavetable *x);
void		wavetable_assist(t_wavetable *x, void *b, long msg, long arg, char *dst);	// Assistance Method
t_int*		wavetable_perform(t_int *w);												// An MSP Perform (signal) Method
void		wavetable_dsp(t_wavetable *x, t_signal **sp, short *count);					// DSP Method
void		wavetable_stop(t_wavetable *x);
void		wavetable_int(t_wavetable *x, long newCurrentValue);
void		wavetable_float(t_wavetable *x, double newCurrentValue);
void		wavetable_list(t_wavetable *x, double endValue, double time);
t_max_err	wavetable_setMode(t_wavetable *x, void *attr, long argc, t_atom *argv);
t_max_err	wavetable_setInterpolation(t_wavetable *x, void *attr, long argc, t_atom *argv);
t_max_err	wavetable_setFrequency(t_wavetable *x, void *attr, long argc, t_atom *argv);
t_max_err	wavetable_setGain(t_wavetable *x, void *attr, long argc, t_atom *argv);


// Globals
static t_class *s_wavetable_class;


/************************************************************************************/
// Main() Function

int main(void)
{
	t_class *c;
	
	TTBlueInit();	
	common_symbols_init();

	c = class_new("tt.wavetable~",(method)wavetable_new, (method)wavetable_free, sizeof(t_wavetable), (method)0L, A_GIMME, 0);

 	class_addmethod(c, (method)wavetable_dsp,			"dsp",		A_CANT, 0L);		
	class_addmethod(c, (method)wavetable_assist,		"assist",	A_CANT, 0L); 
    class_addmethod(c, (method)object_obex_dumpout,		"dumpout", 	A_CANT, 0);  

	CLASS_ATTR_SYM(c,		"mode",				0,		t_wavetable,	attrMode);
	CLASS_ATTR_ACCESSORS(c,	"mode",				NULL,	wavetable_setMode);
	
	CLASS_ATTR_SYM(c,		"interpolation",	0,		t_wavetable,	attrInterpolation);
	CLASS_ATTR_ACCESSORS(c,	"interpolation",	NULL,	wavetable_setInterpolation);
	
	CLASS_ATTR_FLOAT(c,		"frequency",		0,		t_wavetable,	attrFrequency);
	CLASS_ATTR_ACCESSORS(c,	"frequency",		NULL,	wavetable_setFrequency);

	CLASS_ATTR_FLOAT(c,		"gain",				0,		t_wavetable,	attrGain);
	CLASS_ATTR_ACCESSORS(c,	"gain",				NULL,	wavetable_setGain);
	
	class_dspinit(c);
	class_register(CLASS_BOX, c);
	s_wavetable_class = c;
	return 0;
}


/************************************************************************************/
// Object Creation Method

void* wavetable_new(t_symbol *msg, short argc, t_atom *argv)
{
    t_wavetable	*x;
	TTValue		sr(sys_getsr());
 	long		attrstart = attr_args_offset(argc, argv);		// support normal arguments
	short		i;
   
    x = (t_wavetable *)object_alloc(s_wavetable_class);
    if(x){
		x->maxNumChannels = 2;
		if(attrstart && argv)
			x->maxNumChannels = atom_getlong(argv);
{'fraction_non_alphanumeric': 0.15680309734513273, 'fraction_numerical': 0.005807522123893806, 'mean_word_length': 4.899673735725938, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4145210', 'n_tokens_mistral': 3082, 'n_tokens_neox': 2781, 'n_words': 624}