void meter_tick(t_meter *x) { meter_output(x); if(x->f_ramp == x->f_vector->getNumberOfChannels()) x->f_ramp = 0; x->f_vector->process(x->f_signals, x->f_vector_coords + x->f_vector->getNumberOfChannels() * x->f_ramp); for(int i = 0; i < x->f_meter->getNumberOfChannels(); i++) { if(x->f_meter->getChannelEnergy(i) >= 0.) x->f_overled[i] = OVERLED_DRAWTIME; else x->f_overled[i] -= x->f_interval; if(x->f_overled[i] < 0) x->f_overled[i] = 0; } jbox_invalidate_layer((t_object *)x, NULL, s_leds_layer); jbox_invalidate_layer((t_object *)x, NULL, s_energy_layer); jbox_invalidate_layer((t_object *)x, NULL, s_velocity_layer); jbox_redraw((t_jbox *)x); if (sys_getdspstate()) clock_fdelay(x->f_clock, x->f_interval); }
void hoa_meter_tick(t_hoa_meter *x) { if(x->f_vector_type == hoa_sym_both) x->f_vector->process(x->f_signals, x->f_vector_coords); else if(x->f_vector_type == hoa_sym_velocity) x->f_vector->processVelocity(x->f_signals, x->f_vector_coords); else if(x->f_vector_type == hoa_sym_energy) x->f_vector->processEnergy(x->f_signals, x->f_vector_coords + 2); double peak; for (int i = 0; i < x->f_meter->getNumberOfChannels(); i++) { peak = x->f_meter->getChannelEnergy(i); if(peak >= 0.) x->f_over_leds[i] = 1000; else x->f_over_leds[i] -= x->f_interval; if(x->f_over_leds[i] < 0) x->f_over_leds[i] = 0; } ebox_invalidate_layer((t_ebox *)x, hoa_sym_leds_layer); ebox_invalidate_layer((t_ebox *)x, hoa_sym_vector_layer); ebox_redraw((t_ebox *)x); if (sys_getdspstate()) clock_delay(x->f_clock, x->f_interval); }
void number_tilde_tick(t_number_tilde *x) { number_tilde_output(x); ebox_invalidate_layer((t_ebox *)x, gensym("value_layer")); ebox_redraw((t_ebox *)x); if(sys_getdspstate()) clock_delay(x->f_clock, x->f_interval); }
void hoa_3d_scope_tick(t_hoa_3d_scope *x) { x->f_scope->process(x->f_signals); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_harmonics_layer); jbox_redraw((t_jbox *)x); if (sys_getdspstate()) clock_delay(x->f_clock, x->f_interval); }
void hoa_scope_tick(t_hoa_scope *x) { x->f_scope->process(x->f_signals + x->f_index * x->f_scope->getNumberOfHarmonics()); ebox_invalidate_layer((t_ebox *)x, hoa_sym_harmonics_layer); ebox_redraw((t_ebox *)x); if(sys_getdspstate()) clock_delay(x->f_clock, x->f_interval); }
void scope_tick(t_scope *x) { x->f_viewer->processContribAndRep(x->f_harmonicsValues); jbox_invalidate_layer((t_object *)x, NULL, gensym("contrib_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("harmonics_layer")); jbox_redraw((t_jbox *)x); if (sys_getdspstate()) clock_delay(x->f_clock, x->f_interval); }
void scope_tick(t_scope *x) { ebox_invalidate_layer((t_ebox *)x, gensym("signal_layer")); ebox_redraw((t_ebox *)x); if(!sys_getdspstate()) { x->f_startclock = 0; clock_unset(x->f_clock); } }
static void dsp_tilde_mousedown(t_dsp_tilde *x, t_object *patcherview, t_pt pt, long modifiers) { if(sys_getdspstate()) { dsp_tilde_stop(x); } else { dsp_tilde_start(x); } }
static void dsp_tilde_paint(t_dsp_tilde *x, t_object *view) { t_rect rect; if(!x->f_init) { x->f_state = sys_getdspstate(); x->f_init = 1; } ebox_get_rect_for_view((t_ebox *)x, &rect); draw_background(x, view, &rect); }
void meter_clock(t_meter *x) { double delta = fabs(x->newEnvelope - x->envelope); x->envelope = x->newEnvelope; x->newEnvelope = 0; // Only re-draw if there was a change of some significance if (delta > kMinimumChangeForRedraw) jbox_redraw((t_jbox *)x); outlet_float(x->outlet, x->envelope); if (sys_getdspstate()) { // if dsp is on then we schedule another tick if (x->attrDefeat == 0) clock_delay(x->clock, kPollIntervalDefault); } }
t_max_err meter_notify(t_meter *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { t_symbol* name; if (msg == _sym_attr_modified) { name = (t_symbol *)object_method((t_object *)data, _sym_getname); if (name == _sym_bgcolor) jbox_redraw((t_jbox*)x); if (name == _sym_patching_rect || name == gensym("orientation")) meterEffectOrientation(x); if (name == gensym("defeat")) { if (sys_getdspstate()) { // if dsp is on & defeat is off then we schedule another tick if (x->attrDefeat == 0) clock_delay(x->clock, kPollIntervalDefault); } } } return jbox_notify((t_jbox*)x, s, msg, sender, data); }
void meter_tick(t_meter *x) { if(x->f_drawvector == VECTOR_BOTH) { x->f_vector->process(x->f_signals, x->f_vector_coords); } else if(x->f_drawvector == VECTOR_VELOCITY) { x->f_vector->processVelocity(x->f_signals, x->f_vector_coords); } else if(x->f_drawvector == VECTOR_ENERGY) { x->f_vector->processEnergy(x->f_signals, x->f_vector_coords + 2); } x->f_meter->tick(1000 / x->f_interval); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_leds_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_vectors_layer); jbox_redraw((t_jbox *)x); if (sys_getdspstate()) clock_delay(x->f_clock, x->f_interval); }
void meter_tick(t_meter *x) { if(x->f_peak_value >= 0) { x->f_over_led_preserved = 1; } else if(x->f_over_led_preserved > 0) { x->f_over_led_preserved++; } if(x->f_over_led_preserved >= 1000. / x->f_interval) { x->f_over_led_preserved = 0; } meter_output(x); ebox_invalidate_layer((t_ebox *)x, gensym("leds_layer")); ebox_redraw((t_ebox *)x); if(sys_getdspstate()) clock_delay(x->f_clock, x->f_interval); }
void pictmeter_tick(t_pictmeter *x) { // for the astute student of the Max SDK: // // this method is called by the scheduler thread // x->p_max is also accessed by the perform method in the audio thread // we could use a mutex or critical region to protect the following block of code from having the value of x->p_max modified during its execution. // however, mutexes and critical regions carry a performance penalty. // // in this case, due to the nature of what we are doing (drawing something every tenth of second showing the history of the previous samples), // the mutex or critical region will not add anything to the object, or protect us from crashes, and it carries a performance penalty. // so we have made a conscious decision to not use the aforementioned thread locking mechanisms. if (x->p_value != x->p_max) { x->p_value = x->p_max; if (x->p_value > 1.) x->p_value = 1.; x->p_max = 0; jbox_redraw((t_jbox *)x); } if (sys_getdspstate()) // if the dsp is still on, schedule a next pictmeter_tick() call clock_fdelay(x->p_clock, 100); }
void amaranth_grain(t_amaranth *x, Symbol *s, short argc, Atom *argv) { if(sys_getdspstate() == 0) { return; } int g, samplesNeeded; float location, dur, trans; Symbol *bufName; if (argc != 4) { post("¥ amaranth~: grain needs exactly 4 arguments (location, duration, transposition, buffer)"); return; } if (argv[0].a_type == A_FLOAT) location = argv[0].a_w.w_float; else if (argv[0].a_type == A_LONG) location = (float) argv[0].a_w.w_long; else { post("¥ amaranth~: grain location must be a number"); return; } if (argv[1].a_type == A_FLOAT) dur = argv[1].a_w.w_float; else if (argv[1].a_type == A_LONG) dur = (float) argv[1].a_w.w_long; else { post("¥ amaranth~: grain duration must be a number"); return; } if (argv[2].a_type == A_FLOAT) trans = argv[2].a_w.w_float; else if (argv[2].a_type == A_LONG) trans = (float) argv[2].a_w.w_long; else { post("¥ amaranth~: grain transposition ratio must be a number"); return; } if (argv[3].a_type == A_SYM) bufName = argv[3].a_w.w_sym; else { post("¥ amaranth~: grain buffer name must be a symbol"); return; } g = AllocGrain(x); if (g == -1) { outlet_bang(x->outlet); return; } // post("amaranth_grain(%p, %f, %f, %f, %s)", x, location, dur, trans, bufName->s_name); x->grains[g].buffer = SymbolToBuffer(bufName); if (x->grains[g].buffer == 0) { error("amaranth~: no buffer~ %s", bufName->s_name); FreeGrain(x, g); return; } x->grains[g].location = ((int) location * x->grains[g].buffer->b_sr * 0.001); x->grains[g].bufIndex = x->grains[g].location << 8; x->grains[g].bufStep = (int) (INTERPOLATION_TABLE_SIZE * trans); x->grains[g].duration = x->grains[g].samplesToGo = dur * sys_getsr() * 0.001; x->grains[g].transpose = trans; x->grains[g].windowPos = 0; x->grains[g].windowStep = (HANNING_WINDOW_TABLE_SIZE << 8) / x->grains[g].duration; samplesNeeded = x->grains[g].location + x->grains[g].duration / trans; if(samplesNeeded <= 1) { FreeGrain(x, g); return; } //if (samplesNeeded > x->grains[g].buffer->b_frames) { /* Buffer is too small; drop this grain */ /* xxx make this complaint only happen once...*/ /* post("¥ amaranth~: %ld-sample buffer %s is too small for loc %f, duration %f, trans %f", x->grains[g].buffer->b_frames, bufName->s_name, x->grains[g].location, x->grains[g].duration, trans); */ // FreeGrain(x, g); // return; //} /* post("*** grain %ld, loc %ld, dur %ld, trans %f, buf %s", g, x->grains[g].location, x->grains[g].duration, x->grains[g].transpose, x->grains[g].buffer->b_name->s_name); */ }
void hoa_scope_tick(t_hoa_scope *x) { float value; float one, two; t_atom av[3]; t_atom red[3]; t_atom blue[3]; x->f_scope->process(x->f_signals + x->f_index * x->f_scope->getNumberOfHarmonics()); if (sys_getdspstate()) clock_fdelay(x->f_clock, 500.); outlet_anything(x->f_out, gensym("reset"), 0, NULL); atom_setfloat(red, 1); atom_setfloat(red+1, 0); atom_setfloat(red+2, 0); atom_setfloat(blue, 0); atom_setfloat(blue+1, 0); atom_setfloat(blue+2, 1); for(int i = 0; i < x->f_scope->getNumberOfRows(); i++) { one = 0; two = (double)i / (double)(x->f_scope->getNumberOfRows() - 1) * CICM_PI; value = x->f_scope->getValue(i, 0); if(value < 0) { outlet_anything(x->f_out, gensym("glcolor"), 3, blue); value= -value; } else outlet_anything(x->f_out, gensym("glcolor"), 3, red); atom_setfloat(av, value * sin(two) * cos(one)); atom_setfloat(av+1, value * cos(two)); atom_setfloat(av+2, value * sin(two) * sin(one)); outlet_anything(x->f_out, gensym("moveto"), 3, av); for(int j = 1; j < x->f_scope->getNumberOfColumns(); j++) { one = (double)j / (double)x->f_scope->getNumberOfColumns() * CICM_2PI; value = x->f_scope->getValue(i, j); if(value < 0) { outlet_anything(x->f_out, gensym("glcolor"), 3, blue); value= -value; } else outlet_anything(x->f_out, gensym("glcolor"), 3, red); atom_setfloat(av, value * sin(two) * cos(one)); atom_setfloat(av+1, value * cos(two)); atom_setfloat(av+2, value * sin(two) * sin(one)); outlet_anything(x->f_out, gensym("lineto"), 3, av); } one = 0; value = x->f_scope->getValue(i, 0); if(value < 0) { outlet_anything(x->f_out, gensym("glcolor"), 3, blue); value= -value; } else outlet_anything(x->f_out, gensym("glcolor"), 3, red); atom_setfloat(av, value * sin(two) * cos(one)); atom_setfloat(av+1, value * cos(two)); atom_setfloat(av+2, value * sin(two) * sin(one)); outlet_anything(x->f_out, gensym("lineto"), 3, av); } for(int j = 0; j < x->f_scope->getNumberOfColumns(); j++) { one = (double)j / (double)x->f_scope->getNumberOfColumns() * CICM_2PI; two = 0.; value = x->f_scope->getValue(0, j); if(value < 0) { outlet_anything(x->f_out, gensym("glcolor"), 3, blue); value= -value; } else outlet_anything(x->f_out, gensym("glcolor"), 3, red); atom_setfloat(av, value * sin(two) * cos(one)); atom_setfloat(av+1, value * cos(two)); atom_setfloat(av+2, value * sin(two) * sin(one)); outlet_anything(x->f_out, gensym("moveto"), 3, av); for(int i = 1; i < x->f_scope->getNumberOfRows(); i++) { two = (double)i / (double)(x->f_scope->getNumberOfRows() - 1) * CICM_PI; value = x->f_scope->getValue(i, j); if(value < 0) { outlet_anything(x->f_out, gensym("glcolor"), 3, blue); value= -value; } else outlet_anything(x->f_out, gensym("glcolor"), 3, red); atom_setfloat(av, value * sin(two) * cos(one)); atom_setfloat(av+1, value * cos(two)); atom_setfloat(av+2, value * sin(two) * sin(one)); outlet_anything(x->f_out, gensym("lineto"), 3, av); } } }
void *multigrain_grain(t_multigrain *x, t_symbol *msg, short argc, t_atom *argv) { short inserted; int j; float duration, incr, amplitude, pan; t_grain *grains; long eframes; long frames; float sr; float skip; if(!sys_getdspstate()){ error("scheduler halted until DSP is turned on."); return NIL; } grains = x->grains; eframes = buffer_getframecount(buffer_ref_getobject(x->windowbuf)); frames = buffer_getframecount(buffer_ref_getobject(x->wavebuf)); sr = x->sr; if(argc < 5){ error("grain takes 5 arguments, not %d",argc); post("duration increment amplitude pan skip(in ms)"); return NIL; } duration = atom_getintarg(0,argc,argv); incr = atom_getfloatarg(1,argc,argv); // in ms amplitude = atom_getfloatarg(2,argc,argv); pan = atom_getfloatarg(3,argc,argv); skip = atom_getfloatarg(4,argc,argv) * .001 * sr; if(skip < 0){ error("negative skip is illegal"); return NIL; } if(skip >= frames){ error("skip exceeds length of buffer"); return NIL; } if(incr == 0.0){ error("zero increment prohibited"); return NIL; } if(duration <= 0.0){ error("illegal duration:%f",duration); return NIL; } if(pan < 0.0 || pan > 1.0){ error("illegal pan:%f",pan); return NIL; } inserted = 0; for(j = 0; j < MAXGRAINS; j++ ){ if(!grains[j].active){ grains[j].delay = 0.0;// immediate deployment grains[j].duration = (long) (.001 * x->sr * duration); grains[j].phase = skip; grains[j].ephase = 0.0; grains[j].amplitude = amplitude * .707; // grains[j].panL = amplitude * cos(pan * PIOVERTWO); // grains[j].panR = amplitude * sin(pan * PIOVERTWO); grains[j].esi = (float)eframes / (float)grains[j].duration; grains[j].si = incr; grains[j].active = 1; return NIL; } } error("could not insert grain"); return NIL; }
void multigrain_spray(t_multigrain *x) { int i,j; long grainframes; long eframes = buffer_getframecount(buffer_ref_getobject(x->windowbuf)); long b_frames = buffer_getframecount(buffer_ref_getobject(x->wavebuf)); long horizon = x->horizon; // length of block for random events float mindur = x->mindur; float maxdur = x->maxdur; float min_incr = x->min_incr; // minimum incr for a grain (must be positive!) float max_incr = x->max_incr; // maximum incr for a grain (must be positive!) float minpan = x->minpan; // minimum pan for a grain float maxpan = x->maxpan; // maxium pan for a grain float minamp = x->minamp; // minimum amplitude for a grain float maxamp = x->maxamp; // maximum amplitude for a grain float transpose = x->transpose; // pitch scalar long minskip = x->minskip; long maxskip = x->maxskip; short steady = x->steady; float retro_odds = x->retro_odds; float pan; t_grain *grains = x->grains; short inserted; float tmp; long minchanr = x->minchanr; long maxchanr = x->maxchanr; long *changroup = x->changroup; long changroup_length = x->changroup_length; long dex; long groupflag = x->groupflag; if( !sys_getdspstate() ){ return; } for( i = 0; i < x->events; i++ ){ inserted = 0; for(j = 0; j < MAXGRAINS; j++ ){ if(!grains[j].active){ grains[j].active = 1; if(steady){ grains[j].delay = (float)(i * horizon) / (float) x->events ; } else { grains[j].delay = multigrain_boundrand(0.0,(float) horizon); } grains[j].duration = (long) multigrain_boundrand(mindur, maxdur);//frames for this grain grains[j].ephase = 0.0; pan = multigrain_boundrand(minpan, maxpan); grains[j].amplitude = multigrain_boundrand(minamp, maxamp); grains[j].si = transpose * multigrain_boundrand(min_incr, max_incr); if(groupflag == 1){ dex = random() % changroup_length; grains[j].output_channel = changroup[dex]; } else { grains[j].output_channel = minchanr + (random() % (maxchanr - minchanr)); } grainframes = grains[j].duration * grains[j].si;//frames to be read from buffer grains[j].esi = (float) eframes / (float) grains[j].duration; if(grainframes >= b_frames ){ error("grain size %.0f is too long for buffer which is %d",grainframes, b_frames); grains[j].active = 0; goto nextgrain; } if(minskip > b_frames - grainframes){//bad minskip error("minskip time is illegal"); grains[j].phase = 0.0; grains[j].endframe = grainframes - 1; } else { if(maxskip > b_frames - grainframes){ grains[j].phase = multigrain_boundrand((float)minskip, (float) (b_frames - grainframes)); //post("1. minskip %d maxskip %d",minskip,b_frames - grainframes); } else { grains[j].phase = multigrain_boundrand((float)minskip, (float)maxskip); //post("2. minskip %d maxskip %d",minskip,maxskip); } grains[j].endframe = grains[j].phase + grainframes - 1; } if( multigrain_boundrand(0.0,1.0) < retro_odds){//go backwards - make sure to test both boundaries grains[j].si *= -1.0; tmp = grains[j].phase; grains[j].phase = grains[j].endframe; grains[j].endframe = tmp; } inserted = 1; goto nextgrain; } } if(! inserted){ error("multigrain~: could not insert grain"); return; } nextgrain: ; } }
void multigrain_pitchspray(t_multigrain *x) { int i,j; long grainframes; long eframes = buffer_getframecount(buffer_ref_getobject(x->windowbuf)); long b_frames = buffer_getframecount(buffer_ref_getobject(x->wavebuf)); long minskip = x->minskip; long maxskip = x->maxskip; float retro_odds = x->retro_odds; long horizon = x->horizon; // length of block for random events float mindur = x->mindur; float maxdur = x->maxdur; float min_incr = x->min_incr; // minimum frequency for a grain float max_incr = x->max_incr; // maximum frequency for a grain float minamp = x->minamp; // minimum amplitude for a grain float maxamp = x->maxamp; // maximum amplitude for a grain float transpose = x->transpose; // pitch scalar float lowblock_increment = x->lowblock_increment; float highblock_increment = x->highblock_increment; short steady = x->steady; float pitch_deviation = x->pitch_deviation; float pdev = 0; float pdev_invert = 0; int index_min, index_max; int steps = x->pitchsteps; float *scale = x->pitchscale; int windex; short inserted = 0; short constrain_scale = x->constrain_scale; t_grain *grains = x->grains; float tmp; if(! sys_getdspstate()){ // error("scheduler halted until DSP is turned on."); return; } if( steps < 2 ){ error("scale is undefined"); return; } if( pitch_deviation ){ pdev = 1.0 + pitch_deviation; pdev_invert = 1.0 / pdev; } for( i = 0; i < x->events; i++ ){ inserted = 0; for(j = 0; j < MAXGRAINS; j++ ){ if(!grains[j].active){ if(steady){ grains[j].delay = (float)(i * horizon) / (float) x->events ; } else { grains[j].delay = multigrain_boundrand(0.0,(float) horizon); } grains[j].duration = (long) multigrain_boundrand(mindur, maxdur); grains[j].phase = 0.0; grains[j].ephase = 0.0; grains[j].amplitude = multigrain_boundrand(minamp, maxamp); grains[j].amplitude *= .707;//used directly only for "nopan" grains[j].output_channel = random() % x->output_channels; if(constrain_scale){ multigrain_constrain(&index_min,&index_max,min_incr, max_incr, scale, steps); windex = (int) multigrain_boundrand((float)index_min, (float)index_max); } else { windex = (int) multigrain_boundrand(0.0, (float)(steps)); } grains[j].si = transpose * scale[windex]; // post("windex %d scale[w] %f transpose %f si %f",windex, scale[windex], transpose, grains[j].si ); grainframes = grains[j].duration * grains[j].si; grains[j].esi = (float) eframes / (float) grains[j].duration; if( pitch_deviation ){ grains[j].si *= multigrain_boundrand(pdev_invert,pdev); } // post("new si: %f", grains[j].si); /* must add this code to spray, and also do for high frequencies */ if(lowblock_increment > 0.0) { if(grains[j].si < lowblock_increment){ post("lowblock: aborted grain with %f frequency",grains[j].si); grains[j].active = 0; // abort grain goto nextgrain; } } if(highblock_increment > 0.0) { if(grains[j].si > highblock_increment){ post("highblock: aborted grain with %f frequency, greater than %f", grains[j].si, highblock_increment); grains[j].active = 0; // abort grain goto nextgrain; } } /* set skip time into sample */ if(grainframes >= b_frames ){ error("grain size %.0f is too long for buffer which is %d",grainframes, b_frames); grains[j].active = 0; goto nextgrain; } if(minskip > b_frames - grainframes){//bad minskip error("minskip time is illegal"); grains[j].phase = 0.0; grains[j].endframe = grainframes - 1; } else { if(maxskip > b_frames - grainframes){ grains[j].phase = multigrain_boundrand((float)minskip, (float) (b_frames - grainframes)); //post("1. minskip %d maxskip %d",minskip,b_frames - grainframes); } else { grains[j].phase = multigrain_boundrand((float)minskip, (float)maxskip); //post("2. minskip %d maxskip %d",minskip,maxskip); } grains[j].endframe = grains[j].phase + grainframes - 1; } if( multigrain_boundrand(0.0,1.0) < retro_odds){//go backwards - make sure to test both boundaries grains[j].si *= -1.0; tmp = grains[j].phase; grains[j].phase = grains[j].endframe; grains[j].endframe = tmp; } /*post("grain: grainframes %d phase %f endframe %f amp %f", grainframes, grains[j].phase, grains[j].endframe, grains[j].amplitude);*/ grains[j].active = 1; inserted = 1; goto nextgrain; } } if(!inserted){ error("could not insert grain with increment %f",grains[j].si); return; } nextgrain: ; } }
void hoa_meter_tick(t_hoa_meter *x) { jbox_redraw((t_jbox *)x); if (sys_getdspstate()) clock_fdelay(x->f_clock, x->f_interval); }
/* void bvplay_verbose(t_bvplay *x, t_symbol *msg, short argc, t_atom *argv) { x->verbose = argv[0].a_w.w_long; } */ void bvplay_notelist(t_bvplay *x, t_symbol *msg, short argc, t_atom *argv) { // int i; // t_buffer *b = x->l_buf; t_buffer *b; ////////////////////// // set data from buffer size if uninitialized /* NB - THIS CRASHES IF THE DACS ARE NOT TURNED ON !!! */ if( ! sys_getdspstate() ){ if( x->verbose ) error("cannot receive notes when the DSP is off!"); return; } if( x->active ){ if( x->verbose ) error("object still playing - cannot add note!"); return; } b = x->l_buf; if( x->framesize != b->b_frames ) { if( x->verbose ) { post("framesize reset"); } x->framesize = b->b_frames ; x->buffer_duration = (float) b->b_frames / (float) x->R ; if( x->verbose ) { post("there are %d frames in this buffer. Duration = %.2f, Channels: %d ", b->b_frames, x->buffer_duration, b->b_nchans); } } else if( x->buffer_duration <= 0.0 ) { x->framesize = b->b_frames ; x->buffer_duration = (float) b->b_frames / (float) x->R ; if( x->verbose ){ post("there are %d frames in this buffer. Duration = %.2f ", b->b_frames, x->buffer_duration); } } if( x->buffer_duration <= 0.0 ) { post("buffer contains no data. Please fill it and try again"); return; } // read note data if( argc != 4 ){ if( x->verbose ){ post("improper note data"); post("notelist parameters: skiptime, duration, increment, amplitude"); } } x->notedata[0] = atom_getfloatarg(0,argc,argv) / 1000.0; x->notedata[1] = atom_getfloatarg(1,argc,argv) / 1000.0; x->notedata[2] = atom_getfloatarg(2,argc,argv); x->notedata[3] = atom_getfloatarg(3,argc,argv); x->start_frame = x->notedata[0] * x->R; x->increment = x->notedata[2]; x->index = x->findex = x->start_frame; if( x->increment == 0.0 ){ if( x->verbose ) post("zero increment!"); return; } x->note_frames = x->notedata[1] * x->increment * x->R; x->end_frame = x->start_frame + x->note_frames; x->amp = x->notedata[3]; if( x->start_frame < 0 || x->start_frame >= x->framesize){ if( x->verbose ) post("bad start time"); return; } if( x->end_frame < 0 || x->end_frame >= x->framesize){ if( x->verbose ) post("bad end time"); return; } x->active = 1; }