本文整理汇总了C++中dsp_setup函数的典型用法代码示例。如果您正苦于以下问题:C++ dsp_setup函数的具体用法?C++ dsp_setup怎么用?C++ dsp_setup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dsp_setup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attr_args_offset
// Create
void *out_new(t_symbol *s, long argc, t_atom *argv)
{
long attrstart = attr_args_offset(argc, argv); // support normal arguments
t_out *x = (t_out *)object_alloc(out_class);
short i;
if(x){
x->dumpout = outlet_new(x, NULL);
object_obex_store((void *)x, jps_dumpout, (object *)x->dumpout); // setup the dumpout
x->numOutputs = 1;
x->attr_preview = 0;
x->preview_object = NULL;
x->attr_bypass = 0;
x->attr_mute = 0;
x->attr_mix = 100; // Assume 100%, so that processed signal is passed through if @has_mix is false
if(attrstart > 0){
int argument = atom_getlong(argv);
x->numOutputs = TTClip(argument, 1, MAX_NUM_CHANNELS);
}
#ifdef JCOM_OUT_TILDE
if(x->numOutputs > 0)
dsp_setup((t_pxobject *)x, x->numOutputs); // Create Object and Inlets
else
dsp_setup((t_pxobject *)x, 1); // Create Object and Inlets
x->common.ob.z_misc = Z_NO_INPLACE | Z_PUT_LAST; // Z_PUT_LAST so that thispoly~ gets it's message properly?
for(i=0; i < (x->numOutputs); i++)
outlet_new((t_pxobject *)x, "signal"); // Create a signal Outlet
x->clock = clock_new(x, (method)update_meters);
x->clock_is_set = 0;
TTObjectInstantiate(kTTSym_audiosignal, &x->audioIn, x->numOutputs);
TTObjectInstantiate(kTTSym_audiosignal, &x->audioOut, x->numOutputs);
TTObjectInstantiate(kTTSym_audiosignal, &x->audioTemp, x->numOutputs);
TTObjectInstantiate(kTTSym_audiosignal, &x->zeroSignal, x->numOutputs);
TTObjectInstantiate(TT("crossfade"), &x->xfade, x->numOutputs);
x->xfade->setAttributeValue(TT("position"), 1.0);
TTObjectInstantiate(TT("gain"), &x->gain, x->numOutputs);
TTObjectInstantiate(TT("ramp"), &x->ramp_gain, x->numOutputs);
TTObjectInstantiate(TT("ramp"), &x->ramp_xfade, x->numOutputs);
// out_alloc(x, sys_getblksize()); // allocates the vectors for the audio signals
x->gain->setAttributeValue(TT("linearGain"), 1.0);
#else
for(i=x->numOutputs-1; i >= 1; i--)
x->inlet[i] = proxy_new(x, i, 0L);
for(i=x->numOutputs-1; i >= 0; i--)
x->outlet[i] = outlet_new(x, 0L);
#endif
jcom_core_subscriber_new_common(&x->common, jps__jcom_out__, jps_subscribe_out);
jcom_core_subscriber_setcustomsubscribe_method(&x->common, &out_subscribe);
attr_args_process(x, argc, argv); // handle attribute args
jcom_core_subscriber_subscribe((t_jcom_core_subscriber_common*)x);
}
return (x); // Return the pointer
}
示例2: SinkerNew
void*
SinkerNew(
SymbolPtr,
short iArgC,
Atom iArgV[])
{
const float kDefVal = 0.0;
short valCount = (iArgC > 0) ? iArgC : 1;
objSinker* me = NIL;
tCurPendPair* vals = (tCurPendPair*) NewPtrClear(valCount * sizeof(tCurPendPair));
tSampleVector* inSigs = (tSampleVector*) NewPtrClear(valCount * sizeof(tSampleVector));
tSampleVector* outSigs = (tSampleVector*) NewPtrClear(valCount * sizeof(tSampleVector));
if (vals == NIL || inSigs == NIL || outSigs == NIL) {
// Quick punt before any damage can be done
if (vals != NIL) DisposePtr((Ptr) vals);
if (inSigs != NIL) DisposePtr((Ptr) inSigs);
if (outSigs != NIL) DisposePtr((Ptr) outSigs);
return NIL;
}
// Let Max/MSP allocate us and inlets
me = (objSinker*) newobject(gObjectClass);
// Add outlets, right to left, and initialize values
if (iArgC == 0) {
// Default to two inlets, one outlet
dsp_setup(&me->coreObject, 2);
outlet_new(me, "signal");
// Don't actually need to initialize as long as kDefVal is zero
// vals[0].current = vals[0].pending = kDefVal;
}
else {
dsp_setup(&me->coreObject, iArgC + 1);
while (--iArgC >= 0) {
outlet_new(me, "signal");
vals[iArgC].current = vals[iArgC].pending = AtomGetFloat(&iArgV[iArgC]);
}
}
// My own initialization. Do this now before we lose the value of iArgCount
me->lastSync = 0.0;
me->valCount = valCount;
me->mode = trigDef;
me->vals = vals;
me->inSigs = inSigs;
me->outSigs = outSigs;
punt:
return me;
}
示例3: object_error
void *bench_new(t_symbol *msg, short argc, t_atom *argv){
t_bench *x;
x = (t_bench *)object_alloc(bench_class);
if(!x){
return NULL;
}
if(!argc){
object_error((t_object *)x, "bench~: one argument is required, either in or out");
return NULL;
}else{
if(!argv[0].a_type == A_SYM){
object_error((t_object *)x, "bench~: the first argument to bench must be a symbol (either \"in\" or \"out\")");
return NULL;
}else if(!strcmp(argv[0].a_w.w_sym->s_name, "in")){
dsp_setup((t_pxobject *)x, 1);
outlet_new((t_object *)x, "signal");
outlet_new((t_object *)x, "signal");
x->t_objmode = BENCH_IN;
if(argc == 1) x->t_mode = BENCH_MODE_ONES;
else{
if(!strcmp(argv[1].a_w.w_sym->s_name, "zeros")){
x->t_mode = BENCH_MODE_ZEROS;
}else if(!strcmp(argv[1].a_w.w_sym->s_name, "ones")){
x->t_mode = BENCH_MODE_ONES;
}else if(!strcmp(argv[1].a_w.w_sym->s_name, "rand")){
x->t_mode = BENCH_MODE_RAND;
}else if(!strcmp(argv[1].a_w.w_sym->s_name, "thru")){
x->t_mode = BENCH_MODE_THRU;
}else {
object_error((t_object *)x, "bench~: unrecognized argument %s. Setting the mode to \"ones\"", argv[1].a_w.w_sym->s_name);
x->t_mode = BENCH_MODE_ONES;
}
}
}else if(!strcmp(argv[0].a_w.w_sym->s_name, "out")){
dsp_setup((t_pxobject *)x, 2);
outlet_new((t_object *)x, "signal");
x->t_objmode = BENCH_OUT;
}else {
object_error((t_object *)x, "bench~: unrecognized argument %s", argv[0].a_w.w_sym->s_name);
return NULL;
}
}
//x->t_ob.z_misc |= Z_NO_INPLACE;
return x;
}
示例4: atom_getlong
void *freeverb_new(t_symbol *s, long argc, t_atom *argv)
{
t_freeverb *x = NULL;
int aSide = 0;
x = ((t_freeverb *)object_alloc(freeverb_class));
if (x)
{
if(atom_gettype(argv) == A_LONG)
aSide = atom_getlong(argv);
else if(atom_gettype(argv) == A_FLOAT)
aSide = atom_getfloat(argv);
else if(atom_gettype(argv) == A_SYM)
{
if(atom_getsym(argv) == gensym("right"))
aSide = 1;
}
if(aSide <= 0)
aSide = 0;
x->f_freeverb = new Freeverb(aSide);
dsp_setup((t_pxobject *)x, 1);
outlet_new(x, "signal");
attr_args_process(x, argc, argv);
}
return (x);
}
示例5: atom_getfloatarg
void *shoehorn_new(t_symbol *s, int argc, t_atom *argv)
{
int i;
double fullFrac, thisFrac, panloc;
long outIndex;
t_shoehorn *x = (t_shoehorn *)object_alloc(shoehorn_class);
x->inChans = (long) atom_getfloatarg(0,argc,argv);
x->outChans = (long) atom_getfloatarg(1,argc,argv);
if( x->outChans < 2 || x->inChans < 2){
object_error((t_object *)x, "%s: illegal channel count: [in = %d] [out = %d]",OBJECT_NAME,x->inChans,x->outChans);
return NULL;
}
dsp_setup((t_pxobject *)x, x->inChans);
for(i=0; i < x->outChans; i++){
outlet_new((t_pxobject *)x, "signal");
}
x->pio2 = PI / 2.0;
x->inarr = (double *) malloc(x->inChans * sizeof(double));
x->pangains1 = (double *) malloc(x->inChans * sizeof(double));
x->pangains2 = (double *) malloc(x->inChans * sizeof(double));
x->indexList = (long *) malloc(x->inChans * sizeof(long));
x->advFrac = (double)(x->outChans - 1)/(double)(x->inChans - 1);
for(i = 1; i < x->inChans - 1; i++){
fullFrac = i * x->advFrac;
outIndex = floor(fullFrac);
thisFrac = fullFrac - outIndex;
panloc = thisFrac * x->pio2;
x->indexList[i] = outIndex;
x->pangains1[i] = cos(panloc);
x->pangains2[i] = sin(panloc);
}
return x;
}
示例6: error
void *errfilt_new(int order, float interp)
{
t_errfilt *x = NULL;
if (order == 0)
{
error("mbc.errfilt~: must specify filter order (this should match the order of mbc.lpc~ and mbc.allpole~)");
return NULL;
}
if (x = (t_errfilt *)object_alloc(errfilt_class))
{
dsp_setup((t_pxobject *)x,3);
outlet_new(x, "signal");
if (order < 1) {
error("mbc.errfilt~: mbc.errfilt~ needs a positive integer value for order");
order = 1;
} else if (order > 199) {
error("mbc.errfilt~: max order is 199");
order = 199;
}
x->a_order = order;
x->a_interp = interp;
errfilt_init(x);
}
return (x);
}
示例7: dsp_setup
void *pvcompand_new(t_symbol *s, int argc, t_atom *argv)
{
#if MSP
t_pvcompand *x = (t_pvcompand *)newobject(pvcompand_class);
dsp_setup((t_pxobject *)x,2);
outlet_new((t_pxobject *)x, "signal");
#endif
#if PD
t_pvcompand *x = (t_pvcompand *)pd_new(pvcompand_class);
inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal"));
outlet_new(&x->x_obj, gensym("signal"));
#endif
// INITIALIZATIONS
x->D = sys_getblksize();
x->R = sys_getsr();
x->max_atten = atom_getfloatarg(0,argc,argv);
x->overlap = atom_getfloatarg(1,argc,argv);
x->winfac = atom_getfloatarg(2,argc,argv);
if(!x->max_atten)
x->max_atten = -6;
if(x->D <= 0)
x->D = 256;
if(x->R <= 0)
x->R = 44100;
pvcompand_init(x,0);
return (x);
}
示例8: attr_args_offset
// Create
void *audiosend_new(t_symbol *s, long argc, t_atom *argv)
{
long attrstart = attr_args_offset(argc, argv); // support normal arguments
t_audiosend *x = (t_audiosend *)object_alloc(s_audiosend_class);
short i;
if (x) {
x->dumpout = outlet_new(x, NULL);
object_obex_store(x, _sym_dumpout, (t_object *)x->dumpout);
x->attr_target = _sym_nothing;
x->num_inputs = 2; // TODO: make this dynamic from args
for (i=0; i<attrstart; i++) {
if (argv[i].a_type == A_LONG)
x->num_inputs = atom_getlong(argv+i);
else if (argv[i].a_type == A_SYM)
x->attr_target = atom_getsym(argv+i);
}
dsp_setup((t_pxobject *)x, x->num_inputs);
x->obj.z_misc = Z_NO_INPLACE;
attr_args_process(x, argc, argv); // handle attribute args
}
return x;
}
示例9: newobject
void *ether_new(t_symbol *s, int argc, t_atom *argv)
{
#if MSP
t_ether *x = (t_ether *) newobject(ether_class);
dsp_setup((t_pxobject *)x,3);
outlet_new((t_pxobject *)x, "signal");
#endif
#if PD
t_ether *x = (t_ether *)pd_new(ether_class);
/* add two additional signal inlets */
inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
outlet_new(&x->x_obj, gensym("signal"));
#endif
/* optional arguments: overlap winfac */
x->overlap = atom_getfloatarg(0,argc,argv);
x->winfac = atom_getfloatarg(1,argc,argv);
if(!power_of_two(x->overlap)){
x->overlap = 4;
}
if(!power_of_two(x->winfac)){
x->winfac = 1;
}
x->vs = sys_getblksize();
x->R = sys_getsr();
ether_init(x,0);
return (x);
}
示例10: listout
void *bthresher_new(t_symbol *s, int argc, t_atom *argv)
{
#if MSP
t_bthresher *x = (t_bthresher *)newobject(bthresher_class);
x->list_outlet = listout((t_pxobject *)x);
dsp_setup((t_pxobject *)x,3);
outlet_new((t_pxobject *)x, "signal");
#endif
#if PD
t_bthresher *x = (t_bthresher *)pd_new(bthresher_class);
inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal"));
inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal"));
outlet_new(&x->x_obj, gensym("signal"));
x->list_outlet = outlet_new(&x->x_obj,gensym("list"));
#endif
x->D = sys_getblksize();
x->R = sys_getsr();
x->init_thresh = atom_getfloatarg(0,argc,argv);
x->init_damping = atom_getfloatarg(1,argc,argv);
x->overlap = atom_getintarg(2,argc,argv);
x->winfac = atom_getintarg(3,argc,argv);
bthresher_init(x,0);
return (x);
}
示例11: dialer_dial
/* an entry point for an address book or the like */
void dialer_dial( char * number )
{
int x = 0;
int ret;
dsp_st dspz;
if( !number ) return;
#ifdef __linux__
ret = dsp_open(&dspz, DSP_LINEOUT);
if( ret < 0 ) {
pz_error( "/dev/dsp" );
return;
}
ret = dsp_setup(&dspz, 1, 44100);
#else
ret = ret;
#endif
while ( number[x] != '\0' )
{
dtmf_play( &dspz, number[x++] );
}
#ifdef __linux__
dsp_close(&dspz);
#endif
}
示例12: newobject
void *shapee_new(t_symbol *s, int argc, t_atom *argv)
{
#if MSP
t_shapee *x = (t_shapee *) newobject(shapee_class);
dsp_setup((t_pxobject *)x, 3);
outlet_new((t_pxobject *)x, "signal");
#endif
#if PD
t_shapee *x = (t_shapee *)pd_new(shapee_class);
inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
outlet_new(&x->x_obj, gensym("signal"));
#endif
/* INITIALIZATIONS */
x->overlap = atom_getfloatarg(0,argc,argv);
x->winfac = atom_getfloatarg(1,argc,argv);
if(!x->winfac)
x->winfac = 1;
if(!x->overlap)
x->overlap = 4;
x->vs = sys_getblksize();
x->R = sys_getsr();
shapee_init(x,0);
return (x);
}
示例13: balance_new
void* balance_new(t_symbol *msg, short argc, t_atom *argv)
{
t_balance *x;
TTValue sr(sys_getsr());
long attrstart = attr_args_offset(argc, argv); // support normal arguments
short i;
x = (t_balance *)object_alloc(balance_class);
if(x){
// Default values
x->attrFrequency = 10;
x->attrBypass = 0;
// An initial argument to this object will set the maximum number of channels to process
// Two input channels are required for each processed channel (source and comperator)
x->maxNumChannels = 1;
if(attrstart && argv)
x->maxNumChannels = atom_getlong(argv);
ttEnvironment->setAttributeValue(kTTSym_SampleRate, sr);
TTObjectInstantiate(TT("balance"), &x->balance, x->maxNumChannels);
TTObjectInstantiate(TT("audiosignal"), &x->audioIn, x->maxNumChannels*2);
TTObjectInstantiate(TT("audiosignal"), &x->audioOut, x->maxNumChannels);
attr_args_process(x,argc,argv); // handle attribute args
object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout
dsp_setup((t_pxobject *)x, x->maxNumChannels*2); // inlets
for(i=0; i < x->maxNumChannels; i++)
outlet_new((t_pxobject *)x, "signal"); // outlets
x->obj.z_misc = Z_NO_INPLACE;
}
return (x); // Return the pointer
}
示例14: dsp_setup
void *leaker_new(t_symbol *msg, short argc, t_atom *argv)
{
#if MSP
t_leaker *x = (t_leaker *)newobject(leaker_class);
dsp_setup((t_pxobject *)x,3);
outlet_new((t_pxobject *)x, "signal");
#endif
#if PD
t_leaker *x = (t_leaker *)pd_new(leaker_class);
inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("signal"), gensym("signal"));
outlet_new(&x->x_obj, gensym("signal"));
#endif
x->D = sys_getblksize();
x->R = sys_getsr();
if(!x->D)
x->D = 256;
if(!x->R)
x->R = 44100;
x->overlap = atom_getfloatarg(0,argc,argv);
x->winfac = atom_getfloatarg(1,argc,argv);
if(!x->overlap)
x->overlap = 4;
if(!x->winfac)
x->winfac = 1;
leaker_init(x,0);
return (x);
}
示例15: object_alloc
/********************************************************************************
void *grainstream_new(double initial_pos)
inputs: *snd -- name of buffer holding sound
*win -- name of buffer holding window
description: called for each new instance of object in the MAX environment;
defines inlets and outlets; sets variables and buffers
returns: nothing
********************************************************************************/
void *grainstream_new(t_symbol *snd, t_symbol *win)
{
t_grainstream *x = (t_grainstream *) object_alloc((t_class*) grainstream_class);
dsp_setup((t_pxobject *)x, 4); // four inlets
outlet_new((t_pxobject *)x, "signal"); // sample count outlet
outlet_new((t_pxobject *)x, "signal"); // signal ch2 outlet
outlet_new((t_pxobject *)x, "signal"); // signal ch1 outlet
/* set buffer names */
x->snd_sym = snd;
x->win_sym = win;
/* zero pointers */
x->snd_buf_ptr = x->next_snd_buf_ptr = NULL;
x->win_buf_ptr = x->next_win_buf_ptr = NULL;
/* setup variables */
x->grain_freq = x->next_grain_freq = 20.0;
x->grain_pos_start = x->next_grain_pos_start = 0.0;
x->grain_pitch = x->next_grain_pitch = 1.0;
x->grain_gain = x->next_grain_gain = 1.0;
x->win_step_size = x->snd_step_size = 0.0;
x->curr_win_pos = x->curr_snd_pos = 0.0;
/* set flags to defaults */
x->snd_interp = INTERP_ON;
x->win_interp = INTERP_ON;
x->grain_direction = x->next_grain_direction = FORWARD_GRAINS;
x->x_obj.z_misc = Z_NO_INPLACE;
/* return a pointer to the new object */
return (x);
}