<commit_before>/* 
 *	op≈
 *	External object for Max/MSP to perform basic mathematical operations on objects in a Jamoma AudioGraph dsp chain.
 *	Copyright © 2008 by <NAME>
 * 
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#include "maxAudioGraph.h"
#include "maxGraph.h"


// Data Structure for this object
struct Op {
   	Object					obj;
	TTAudioGraphObjectPtr	audioGraphObject;
	TTPtr					outlet;
	TTPtr					unused;				// NULL pointer to signal end of JAG outlets to the class wrapper functions
	TTPtr					inlet;				// proxy for the right inlet
	long					inletnum;			// proxy input inlet number
	SymbolPtr				attrOperator;
	TTFloat32				attrOperand;
};
typedef Op* OpPtr;


// Prototypes for methods
OpPtr	OpNew			(SymbolPtr msg, AtomCount argc, AtomPtr argv);
void   	OpFree			(OpPtr self);
void   	OpAssist		(OpPtr self, void* b, long msg, long arg, char* dst);
TTErr  	OpResetAudio	(OpPtr self, long vectorSize);
TTErr  	OpSetupAudio	(OpPtr self);
//TTErr	OpSetup			(OpPtr self);
TTErr  	OpConnectAudio	(OpPtr self, TTAudioGraphObjectPtr audioSourceObject, long sourceOutletNumber);
TTErr	OpDropAudio		(OpPtr self, long inletNumber, ObjectPtr sourceMaxObject, long sourceOutletNumber);
MaxErr 	OpSetOperator	(OpPtr self, void* attr, AtomCount argc, AtomPtr argv);
MaxErr	OpGetOperator	(OpPtr self, ObjectPtr attr, AtomCount* argc, AtomPtr* argv);
MaxErr 	OpSetOperand	(OpPtr self, void* attr, AtomCount argc, AtomPtr argv);
MaxErr	OpGetOperand	(OpPtr self, ObjectPtr attr, AtomCount* argc, AtomPtr* argv);


// Globals
static ClassPtr sOpClass;


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

int TTCLASSWRAPPERMAX_EXPORT main(void)
{
	ClassPtr c;
	
	TTAudioGraphInit();	
	common_symbols_init();
	
	c = class_new("jcom.op≈", (method)OpNew, (method)OpFree, sizeof(Op), (method)0L, A_GIMME, 0);
	
	class_addmethod(c, (method)OpResetAudio,		"audio.reset",		A_CANT, 0);
	class_addmethod(c, (method)OpSetupAudio,		"audio.setup",		A_CANT, 0);
	class_addmethod(c, (method)OpConnectAudio,		"audio.connect",	A_OBJ, A_LONG, 0);
	class_addmethod(c, (method)OpDropAudio,			"audio.drop",		A_CANT, 0);
	class_addmethod(c, (method)MaxAudioGraphObject,	"audio.object",		A_CANT, 0);
	class_addmethod(c, (method)MaxAudioGraphReset,	"graph.reset",			A_CANT, 0);
	//class_addmethod(c, (method)OpSetup,			"graph.setup",			A_CANT, 0); // no setup -- no graph outlets
	class_addmethod(c, (method)MaxGraphConnect,		"graph.connect",		A_OBJ, A_LONG, 0);
 	class_addmethod(c, (method)MaxGraphDrop,		"graph.drop",			A_CANT, 0);
	class_addmethod(c, (method)MaxGraphObject,		"graph.object",			A_CANT, 0);
	class_addmethod(c, (method)OpAssist,			"assist",				A_CANT, 0); 
    class_addmethod(c, (method)object_obex_dumpout,	"dumpout",				A_CANT, 0);  
	
	CLASS_ATTR_SYM(c,		"operator",	0,		Op,	attrOperator);
	CLASS_ATTR_ACCESSORS(c,	"operator",	OpGetOperator,	OpSetOperator);
	
	CLASS_ATTR_FLOAT(c,		"operand",	0,		Op,	attrOperand);
	CLASS_ATTR_ACCESSORS(c,	"operand",	OpGetOperand,	OpSetOperand);
	
	class_register(_sym_box, c);
	sOpClass = c;
	return 0;<commit_msg>adding menu attribute for operators, Fixme: ideally this should not be hardcoded, rather a list of operators should be requested from the MathLib<commit_after>/* 
 *	op≈
 *	External object for Max/MSP to perform basic mathematical operations on objects in a Jamoma AudioGraph dsp chain.
 *	Copyright © 2008 by <NAME>
 * 
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#include "maxAudioGraph.h"
#include "maxGraph.h"


// Data Structure for this object
struct Op {
   	Object					obj;
	TTAudioGraphObjectPtr	audioGraphObject;
	TTPtr					outlet;
	TTPtr					unused;				// NULL pointer to signal end of JAG outlets to the class wrapper functions
	TTPtr					inlet;				// proxy for the right inlet
	long					inletnum;			// proxy input inlet number
	SymbolPtr				attrOperator;
	TTFloat32				attrOperand;
};
typedef Op* OpPtr;


// Prototypes for methods
OpPtr	OpNew			(SymbolPtr msg, AtomCount argc, AtomPtr argv);
void   	OpFree			(OpPtr self);
void   	OpAssist		(OpPtr self, void* b, long msg, long arg, char* dst);
TTErr  	OpResetAudio	(OpPtr self, long vectorSize);
TTErr  	OpSetupAudio	(OpPtr self);
//TTErr	OpSetup			(OpPtr self);
TTErr  	OpConnectAudio	(OpPtr self, TTAudioGraphObjectPtr audioSourceObject, long sourceOutletNumber);
TTErr	OpDropAudio		(OpPtr self, long inletNumber, ObjectPtr sourceMaxObject, long sourceOutletNumber);
MaxErr 	OpSetOperator	(OpPtr self, void* attr, AtomCount argc, AtomPtr argv);
MaxErr	OpGetOperator	(OpPtr self, ObjectPtr attr, AtomCount* argc, AtomPtr* argv);
MaxErr 	OpSetOperand	(OpPtr self, void* attr, AtomCount argc, AtomPtr argv);
MaxErr	OpGetOperand	(OpPtr self, ObjectPtr attr, AtomCount* argc, AtomPtr* argv);


// Globals
static ClassPtr sOpClass;


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

int TTCLASSWRAPPERMAX_EXPORT main(void)
{
	ClassPtr c;
	
	TTAudioGraphInit();	
	common_symbols_init();
	
	c = class_new("jcom.op≈", (method)OpNew, (method)OpFree, sizeof(Op), (method)0L, A_GIMME, 0);
	
	class_addmethod(c, (method)OpResetAudio,		"audio.reset",		A_CANT, 0);
	class_addmethod(c, (method)OpSetupAudio,		"audio.setup",		A_CANT, 0);
	class_addmethod(c, (method)OpConnectAudio,		"audio.connect",	A_OBJ, A_LONG, 0);
	class_addmethod(c, (method)OpDropAudio,			"audio.drop",		A_CANT, 0);
	class_addmethod(c, (method)MaxAudioGraphObject,	"audio.object",		A_CANT, 0);
	class_addmethod(c, (method)MaxAudioGraphReset,	"graph.reset",			A_CANT, 0);
	//class_addmethod(c, (method)OpSetup,			"graph.setup",			A_CANT, 0); // no setup -- no graph outlets
	class_addmethod(c, (method)MaxGraphConnect,		"graph.connect",		A_OBJ, A_LONG, 0);
 	class_addmethod(c, (method)MaxGraphDrop,		"graph.drop",			A_CANT, 0);
	class_addmethod(c, (method)MaxGraphObject,		"graph.object",			A_CANT, 0);
	class_addmethod(c, (method)OpAssist,			"assist",				A_CANT, 0); 
    class_addmethod(c, (method)object_obex_dumpout,	"dumpout",				A_CANT, 0);  
	
	CLASS_ATTR_SYM(c,		"operator",	0,		Op,	attrOperator);
	CLASS_ATTR_ACCESSORS(c,	"operator",	OpGetOperator,	OpSetOperator);
	CLASS_ATTR_ENUM(c,		"operator",	0,	"+ - * / % > >= == != <= < abs acos asin atan ceil cos cosh exp floor log log10 sin sinh sqrt tan tanh");
	
	CLASS_ATTR_FLOAT(c,		"operand",	0,		Op,	attrOperand);
	CLASS_ATTR_ACCESSORS(c,	"operand",	OpGetOperand,	OpSetOperand);
	
	class_register(_sym_box, c);
	sOpClass = c;
	return 0;
{'fraction_non_alphanumeric': 0.1385959626393492, 'fraction_numerical': 0.0073817414884001205, 'mean_word_length': 4.911843276936777, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4653269', 'n_tokens_mistral': 2612, 'n_tokens_neox': 2428, 'n_words': 642}