<commit_before>/*
** nw.cppan~.c
**
** MSP object
** allows mono input signal to be panned across two output channels
** 2001/03/22 started by <NAME>
**
** Copyright © 2001,2014 by <NAME>
** License: http://opensource.org/licenses/BSD-3-Clause
**
*/


#include "ext.h"		// required for all MAX external objects
#include "ext_obex.h"   // required for new style MAX objects
#include "z_dsp.h"		// required for all MSP external objects
#include <math.h>		// required for certain math functions
#include <string.h>

#define DEBUG			//enable debugging messages

#define OBJECT_NAME		"nw.cppan~"		// name of the object

/* for the assist method */
#define ASSIST_INLET	1
#define ASSIST_OUTLET	2

#define DEFAULT_POS		0.5					// default position, when no argument given
#define TABLE_SIZE 		1024				// size of table used for panning function
#define TABLE_COEFF		(sqrt(2.0) / 2.0)	// coefficient used in calculating table
#define DtoR 			2.0 * 3.1415927 / 360.0
						// allows easy conversion from degrees to radians

static t_class *trainshift_class;		// required global pointer to this class

/* structure definition for this object */
typedef struct _cpPan
{
	t_pxobject x_obj;
	float curr_pos;
	long curr_index;
	float curr_multL;
	float curr_multR;
	float table_left[TABLE_SIZE];
	float table_right[TABLE_SIZE];
} t_cpPan;

/* method definitions for this object */
void cpPan_fillTables(t_cpPan *x);
void *cpPan_new(double initial_pos);
void cpPan_dsp(t_cpPan *x, t_signal **sp, short *count);
t_int *cpPan_perform1(t_int *w);
t_int *cpPan_perform2(t_int *w);
void cpPan_float(t_cpPan *x, double f);
void cpPan_setPosVars(t_cpPan *x, double f);
void cpPan_assist(t_cpPan *x, t_object *b, long msg, long arg, char *s);
void cpPan_getinfo(t_cpPan *x);
/* method definitions for debugging this object */
#ifdef DEBUG
	void cpPan_table(t_cpPan *x, long value);
	void cpPan_position(t_cpPan *x);
#endif /* DEBUG */

/********************************************************************************
void main(void)

inputs:			nothing
description:	called the first time the object is used in MAX environment; 
		defines inlets, outlets and accepted messages
returns:		nothing
********************************************************************************/
void main(void)
{
	setup(&this_class, cpPan_new, (method)dsp_free, (short)sizeof(t_cpPan), 0L, 
				A_DEFFLOAT, 0);
	addmess((method)cpPan_dsp, "dsp", A_CANT, 0);
	
	#ifdef DEBUG
		addmess((method)cpPan_table, "table", A_DEFLONG, 0);
		addmess((method)cpPan_position, "position", 0);
	#endif /* DEBUG */
	
	/* bind method "cpPan_float" to the assistance message */
	addfloat((method)cpPan_float);
	
	/* bind method "cpPan_assist" to the assistance message */
	addmess((method)cpPan_assist, "assist", A_CANT, 0);
	
	/* bind method "cpPan_getinfo" to the getinfo message */
	addmess((method)cpPan_getinfo, "getinfo", A_NOTHING, 0);
	
	dsp_initclass();
	
}

/********************************************************************************
void cpPan_fillTables(t_cpPan *x)<commit_msg>nw.cppan~: updates to main()<commit_after>/*
** nw.cppan~.c
**
** MSP object
** allows mono input signal to be panned across two output channels
** 2001/03/22 started by <NAME>
**
** Copyright © 2001,2014 by <NAME>
** License: http://opensource.org/licenses/BSD-3-Clause
**
*/


#include "ext.h"		// required for all MAX external objects
#include "ext_obex.h"   // required for new style MAX objects
#include "z_dsp.h"		// required for all MSP external objects
#include <math.h>		// required for certain math functions
#include <string.h>

#define DEBUG			//enable debugging messages

#define OBJECT_NAME		"nw.cppan~"		// name of the object

/* for the assist method */
#define ASSIST_INLET	1
#define ASSIST_OUTLET	2

#define DEFAULT_POS		0.5					// default position, when no argument given
#define TABLE_SIZE 		1024				// size of table used for panning function
#define TABLE_COEFF		(sqrt(2.0) / 2.0)	// coefficient used in calculating table
#define DtoR 			2.0 * 3.1415927 / 360.0
						// allows easy conversion from degrees to radians

static t_class *trainshift_class;		// required global pointer to this class

/* structure definition for this object */
typedef struct _cpPan
{
	t_pxobject x_obj;
	float curr_pos;
	long curr_index;
	float curr_multL;
	float curr_multR;
	float table_left[TABLE_SIZE];
	float table_right[TABLE_SIZE];
} t_cpPan;

/* method definitions for this object */
void cpPan_fillTables(t_cpPan *x);
void *cpPan_new(double initial_pos);
void cpPan_dsp(t_cpPan *x, t_signal **sp, short *count);
t_int *cpPan_perform1(t_int *w);
t_int *cpPan_perform2(t_int *w);
void cpPan_float(t_cpPan *x, double f);
void cpPan_setPosVars(t_cpPan *x, double f);
void cpPan_assist(t_cpPan *x, t_object *b, long msg, long arg, char *s);
void cpPan_getinfo(t_cpPan *x);
/* method definitions for debugging this object */
#ifdef DEBUG
	void cpPan_table(t_cpPan *x, long value);
	void cpPan_position(t_cpPan *x);
#endif /* DEBUG */

/********************************************************************************
void main(void)

inputs:			nothing
description:	called the first time the object is used in MAX environment; 
		defines inlets, outlets and accepted messages
returns:		int
********************************************************************************/
int C74_EXPORT main(void)
{
    t_class *c;
    
    c = class_new(OBJECT_NAME, (method)cpPan_new, (method)dsp_free, (short)sizeof(t_cpPan), 0L,
                  A_DEFFLOAT, 0);
    class_dspinit(c); // add standard functions to class
    
	class_addmethod(c, (method)cpPan_dsp, "dsp", A_CANT, 0);
	
	#ifdef DEBUG
		class_addmethod(c, (method)cpPan_table, "table", A_DEFLONG, 0);
		class_addmethod(c, (method)cpPan_position, "position", 0);
	#endif /* DEBUG */
	
	/* bind method "cpPan_float" to the assistance message */
	class_addmethod(c, (method)cpPan_float, "float", A_FLOAT, 0);
	
	/* bind method "cpPan_assist" to the assistance message */
	class_addmethod(c, (method)cpPan_assist, "assist", A_CANT, 0);
	
	/* bind method "cpPan_getinfo" to the getinfo message */
	class_addmethod(c, (method)cpPan_getinfo, "getinfo", A_NOTHING, 0);
	
    class_register(CLASS_BOX, c); // register the class w max
    trainshift_class = c;
    
    #ifdef DEBUG
        post("%s: main function was called", OBJECT_NAME);
    #endif /* DEBUG */
    
    return 0;
	
}

/********************************************************************************
void cpPan_fillTables(t_cpPan *x)
{'fraction_non_alphanumeric': 0.18129918222496527, 'fraction_numerical': 0.01666409504706064, 'mean_word_length': 4.680981595092025, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4012287', 'n_tokens_mistral': 2320, 'n_tokens_neox': 2155, 'n_words': 643}