Beispiel #1
0
static void netdist_send(t_netdist *x, t_symbol *s, int argc, t_atom *argv)
{
	int i = 0;

	for(i = 0; i <= x->x_numconnect; i++)
	{
		if (x->x_fd[i] >= 0)
		{
			t_binbuf *b = binbuf_new();
			char *buf, *bp;
			int length, sent;
			t_atom at;
			binbuf_add(b, argc, argv);
			SETSEMI(&at);
			binbuf_add(b, 1, &at);
			binbuf_gettext(b, &buf, &length);
			for (bp = buf, sent = 0; sent < length;)
			{
				static double lastwarntime;
				static double pleasewarn;
				double timebefore = clock_getlogicaltime();
    				int res = send(x->x_fd[i], buf, length-sent, 0);
    				double timeafter = clock_getlogicaltime();
    				int late = (timeafter - timebefore > 0.005);
    				if (late || pleasewarn)
    				{
    	    			if (timeafter > lastwarntime + 2)
    	    			{
    	    				 post("netdist blocked %d msec",
    	    	     			(int)(1000 * ((timeafter - timebefore) + pleasewarn)));
    	    				 pleasewarn = 0;
    	    				 lastwarntime = timeafter;
    	    			}
    	    			else if (late) pleasewarn += timeafter - timebefore;
    				}
    				if (res <= 0)
    				{
    					sys_sockerror("netdist");
    					netdist_disconnect(x, gensym(x->x_hostname[i]), x->x_port[i]);
    					break;
    				}
    				else
    				{
    					sent += res;
    					bp += res;
    				}
			}
			t_freebytes(buf, length);
			binbuf_free(b);
		}
	}
	if(x->x_numconnect == -1) error("netdist: not connected");
}
Beispiel #2
0
static void mtrack_setmode(t_mtrack *tp, int newmode)
{
    if (tp->tr_mode == MTR_PLAYMODE)
    {
	clock_unset(tp->tr_clock);
	tp->tr_ixnext = 0;
    }
    switch (tp->tr_mode = newmode)
    {
    case MTR_STEPMODE:
	break;
    case MTR_RECMODE:
	binbuf_clear(tp->tr_binbuf);
	tp->tr_prevtime = clock_getlogicaltime();
	break;
    case MTR_PLAYMODE:
	tp->tr_atdelta = 0;
	tp->tr_ixnext = 0;
	tp->tr_prevtime = 0.;
	mtrack_donext(tp);
	break;
    default:
	loudbug_bug("mtrack_setmode");
    }
}
Beispiel #3
0
static void mtrack_tempo(t_mtrack *tp, t_floatarg f)
{
    float newtempo;
    static int warned = 0;
    if (fittermax_get() && !warned)
    {
	fittermax_warning(mtr_class, "no 'tempo' control in Max");
	warned = 1;
    }
    if (f < 1e-20)
	f = 1e-20;
    else if (f > 1e20)
	f = 1e20;
    newtempo = 1. / f;
    if (tp->tr_prevtime > 0.)
    {
    	tp->tr_clockdelay -= clock_gettimesince(tp->tr_prevtime);
	tp->tr_clockdelay *= newtempo / tp->tr_tempo;
	if (tp->tr_clockdelay < 0.)
	    tp->tr_clockdelay = 0.;
    	clock_delay(tp->tr_clock, tp->tr_clockdelay);
	tp->tr_prevtime = clock_getlogicaltime();
    }
    tp->tr_tempo = newtempo;
}
Beispiel #4
0
// called when a new measure starts
void start_measure(t_rhythms_memory *x)
{
	// I call the pd functions to get a representation
	// of this very moment
	x->measure_start_time = clock_getlogicaltime();
	x->last_event_out_time = 0;
}
Beispiel #5
0
static void specRolloff_tilde_dsp(t_specRolloff_tilde *x, t_signal **sp)
{
	int i;

	dsp_add(
		specRolloff_tilde_perform,
		3,
		x,
		sp[0]->s_vec,
		sp[0]->s_n
	);

// compare n to stored n and recalculate filterbank if different
	if(sp[0]->s_sr != (x->sr*x->overlap) || sp[0]->s_n != x->n)
	{
		x->signal_R = (t_sample *)t_resizebytes(x->signal_R, (x->window+x->n) * sizeof(t_sample), (x->window+sp[0]->s_n) * sizeof(t_sample));

		x->sr = sp[0]->s_sr/x->overlap;
		x->n = sp[0]->s_n;
		x->lastDspTime = clock_getlogicaltime();

		// init signal buffer
		for(i=0; i<(x->window+x->n); i++)
			x->signal_R[i] = 0.0;

		// freqs for each bin based on current window size and sample rate
		for(i=0; i<x->window; i++)
			x->binFreqs[i] = (x->sr/x->window)*i;

    	post("specRolloff~: window size: %i. overlap: %i. sampling rate: %i, block size: %i", (int)x->window, x->overlap, (int)x->sr, (int)x->n);
	};
};
Beispiel #6
0
	/* main processing function */
static void rhythm_float(t_rhythm *x, t_floatarg f)
{
	t_int velo = x->x_velo;
	double time = clock_gettimesince(x->x_last_input);
	x->x_pitch = (t_int)f;

	if(velo != 0)	/* note-on received */
	{
		if (x->x_startTime == 0) {
			x->x_startTime = time;
			return;
		}
		
		if (x->x_period < 2.0) {
			x->x_period = (t_float)(time - x->x_startTime);
			x->x_phiVel_at_pulse = 1000.0 / x->x_period;
		}

		rhythm_move(x, 1, time);

		if (x->x_lastPulseTime >= 0)
		{
			x->x_lastIoi = time - x->x_lastPulseTime;
		}
		x->x_lastPulseTime = time; 
		x->x_last_input = clock_getlogicaltime();

		outlet_float(x->x_out_period, x->x_period);
		outlet_float(x->x_out_bpm, 60000.0/x->x_period);
	}
	return;
}
Beispiel #7
0
static void specBrightness_tilde_dsp(t_specBrightness_tilde *x, t_signal **sp)
{
	int i;
	
	dsp_add(
		specBrightness_tilde_perform,
		3,
		x,
		sp[0]->s_vec,
		sp[0]->s_n
	); 

// compare n to stored n and recalculate filterbank if different
	if( sp[0]->s_sr != x->sr || sp[0]->s_n != x->n )
	{
		x->signal_R = (t_sample *)t_resizebytes(x->signal_R, (x->window+x->n) * sizeof(t_sample), (x->window+sp[0]->s_n) * sizeof(t_sample));

		x->sr = sp[0]->s_sr;
		x->n = sp[0]->s_n;
		x->last_dsp_time = clock_getlogicaltime();

		// init signal buffer
		for(i=0; i<(x->window+x->n); i++)
			x->signal_R[i] = 0.0;
			
    	post("specBrightness~: window size: %i. overlap: %i. sampling rate: %i, block size: %i", (int)x->window, x->overlap, (int)(x->sr/x->overlap), (int)x->n);
	};
};
Beispiel #8
0
static void *velocity_new(t_floatarg f)
{
    t_velocity *x = (t_velocity *)pd_new(velocity_class);
	x->x_out = outlet_new(&x->x_ob, gensym("float"));
	x->x_lasttime = clock_getlogicaltime();

    return (void *)x;
}
// ---------------------------------------------------
// Constructor of the class
// ---------------------------------------------------
void * time_post_new(t_floatarg time_arg){
   t_time_post *x = (t_time_post *) pd_new(time_post_class);
   x->time = time_arg;

   x->x_clock = clock_new(x, (t_method)time_post_doit);
   x->last_time = clock_getlogicaltime();
   clock_delay(x->x_clock, x->time);
   return (void *) x;
}
Beispiel #10
0
static void record_tick(t_record *x)
{
    double timesince = clock_gettimesince(x->x_clocklasttick);
    if (timesince >= RECORD_REDRAWPAUSE)
    {
	arsic_redraw((t_arsic *)x);
	x->x_clocklasttick = clock_getlogicaltime();
    }
    else clock_delay(x->x_clock, RECORD_REDRAWPAUSE - timesince);
}
Beispiel #11
0
static void velocity_bang(t_velocity *x)
{
	double thistime;
	t_float vel;
	
	thistime = clock_getlogicaltime();
	vel = (1000 * (x->x_xn - x->x_xn1) ) / (clock_gettimesince(x->x_lasttime));
	x->x_lasttime = thistime;
	outlet_float(x->x_out, vel);
}
Beispiel #12
0
static void Borax_reset(t_Borax *x)
{
    x->x_vel = 0;
    x->x_onset = clock_getlogicaltime();
    x->x_nonsets = x->x_ndurs = x->x_ndtimes = 0;
    x->x_minindex = 0;
    memset(x->x_indices, 0, sizeof(x->x_indices));
    x->x_nvoices = 0;
    memset(x->x_voices, 0, sizeof(x->x_voices));
}
Beispiel #13
0
static void *specSkewness_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
    t_specSkewness_tilde *x = (t_specSkewness_tilde *)pd_new(specSkewness_tilde_class);
	int i, isPow2;
	s=s;

	x->x_skewness = outlet_new(&x->x_obj, &s_float);

	if(argc > 0)
	{
		x->window = atom_getfloat(argv);
		isPow2 = (int)x->window && !( ((int)x->window-1) & (int)x->window );

		if(!isPow2)
		{
			error("requested window size is not a power of 2. default value of 1024 used instead");
			x->window = 1024;
		};
	}
	else
		x->window = 1024;

	x->sr = 44100.0;
	x->n = 64.0;
	x->overlap = 1;
	x->windowFunction = 4; // 4 is hann window
	x->powerSpectrum = 0;
	x->lastDspTime = clock_getlogicaltime();

	x->signal_R = (t_sample *)t_getbytes((x->window+x->n) * sizeof(t_sample));

 	for(i=0; i<(x->window+x->n); i++)
		x->signal_R[i] = 0.0;

  	x->blackman = (t_float *)t_getbytes(x->window*sizeof(t_float));
  	x->cosine = (t_float *)t_getbytes(x->window*sizeof(t_float));
  	x->hamming = (t_float *)t_getbytes(x->window*sizeof(t_float));
  	x->hann = (t_float *)t_getbytes(x->window*sizeof(t_float));

 	// initialize signal windowing functions
	tIDLib_blackmanWindow(x->blackman, x->window);
	tIDLib_cosineWindow(x->cosine, x->window);
	tIDLib_hammingWindow(x->hamming, x->window);
	tIDLib_hannWindow(x->hann, x->window);

	x->binFreqs = (t_float *)t_getbytes(x->window*sizeof(t_float));

	// freqs for each bin based on current window size and sample rate
	for(i=0; i<x->window; i++)
		x->binFreqs[i] = (x->sr/x->window)*i;

    post("specSkewness~: window size: %i", (int)x->window);

    return (x);
}
Beispiel #14
0
static t_int *vsnapshot_tilde_perform(t_int *w)
{
    t_sample *in = (t_sample *)(w[1]);
    t_vsnapshot *x = (t_vsnapshot *)(w[2]);
    t_sample *out = x->x_vec;
    int n = x->x_n, i;
    for (i = 0; i < n; i++)
        out[i] = in[i];
    x->x_time = clock_getlogicaltime();
    x->x_gotone = 1;
    return (w+3);
}
Beispiel #15
0
static void *specSpread_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
    t_specSpread_tilde *x = (t_specSpread_tilde *)pd_new(specSpread_tilde_class);
	int i, isPow2;
	s=s;
	
	x->x_spread = outlet_new(&x->x_obj, &s_float);

	x->signal_R = (t_sample *)getbytes(0);
	x->hann = (float *)getbytes(0);
	x->bin_freqs = (float *)getbytes(0);

	if(argc > 0)
	{
		x->window = atom_getfloat(argv);
		isPow2 = (int)x->window && !( ((int)x->window-1) & (int)x->window );
		
		if(!isPow2)
		{
			error("requested window size is not a power of 2. default value of 1024 used instead");
			x->window = 1024;
		};
	}
	else
		x->window = 1024;	
	
	
	x->sr = 44100.0;
	x->n = 64.0;
	x->overlap = 1;
	x->normalize = 1;
	x->last_dsp_time = clock_getlogicaltime();

	x->signal_R = (t_sample *)t_resizebytes(x->signal_R, 0, (x->window+x->n) * sizeof(t_sample));
	x->hann = (float *)t_resizebytes(x->hann, 0, x->window * sizeof(float));
	x->bin_freqs = (float *)t_resizebytes(x->bin_freqs, 0, x->window * sizeof(float));

	// freqs for each bin based on current window size
	for(i=0; i<x->window; i++)
		x->bin_freqs[i] = ((x->sr/x->overlap)/x->window) * i;

	// initialize hann window
 	for(i=0; i<x->window; i++)
 		x->hann[i] = 0.5 * (1 - cos(2*M_PI*i/x->window));

 	for(i=0; i<(x->window+x->n); i++)
		x->signal_R[i] = 0.0;
		
    post("specSpread~: window size: %i", (int)x->window);
    
    return (x);
}
Beispiel #16
0
static void wiimote_setbasetime(t_wiimote*x) {
  if(NULL==x->basetime) {
    x->basetime=(struct timespec*)getbytes(sizeof(struct timespec));
  }

  if (clock_gettime(CLOCK_REALTIME, x->basetime)) {
    // oops
    freebytes(x->basetime, sizeof(struct timespec));
    x->basetime=NULL;
  }

  x->baselogicaltime=clock_getlogicaltime();
}
Beispiel #17
0
static void *vline_tilde_new(void)
{
    t_vline *x = (t_vline *)pd_new(vline_tilde_class);
    outlet_new(&x->x_obj, gensym("signal"));
    floatinlet_new(&x->x_obj, &x->x_inlet1);
    floatinlet_new(&x->x_obj, &x->x_inlet2);
    x->x_inlet1 = x->x_inlet2 = 0;
    x->x_value = x->x_inc = 0;
    x->x_referencetime = clock_getlogicaltime();
    x->x_list = 0;
    x->x_samppermsec = 0;
    return (x);
}
Beispiel #18
0
static void *magSpec_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
    t_magSpec_tilde *x = (t_magSpec_tilde *)pd_new(magSpec_tilde_class);
	int i, isPow2;
	s=s;
	
	x->x_mag = outlet_new(&x->x_obj, gensym("list"));
	
	if(argc > 0)
	{
		x->window = atom_getfloat(argv);
		isPow2 = (int)x->window && !( ((int)x->window-1) & (int)x->window );
		
		if(!isPow2)
		{
			error("requested window size is not a power of 2. default value of 1024 used instead");
			x->window = 1024;
		};
	}
	else
		x->window = 1024;	
	
	
	x->sr = 44100.0;
	x->n = 64.0;
	x->overlap = 1;
	x->windowFunction = 4; // 4 is hann window
	x->normalize = 1;
	x->powerSpectrum = 0;
	x->lastDspTime = clock_getlogicaltime();

	x->signal_R = (t_sample *)t_getbytes((x->window+x->n) * sizeof(t_sample));

 	for(i=0; i<(x->window+x->n); i++)
		x->signal_R[i] = 0.0;

  	x->blackman = (t_float *)t_getbytes(x->window*sizeof(t_float));
  	x->cosine = (t_float *)t_getbytes(x->window*sizeof(t_float));
  	x->hamming = (t_float *)t_getbytes(x->window*sizeof(t_float));
  	x->hann = (t_float *)t_getbytes(x->window*sizeof(t_float));

 	// initialize signal windowing functions
	tIDLib_blackmanWindow(x->blackman, x->window);
	tIDLib_cosineWindow(x->cosine, x->window);
	tIDLib_hammingWindow(x->hamming, x->window);
	tIDLib_hannWindow(x->hann, x->window);

    post("magSpec~: window size: %i", (int)x->window);
    
    return (x);
}
Beispiel #19
0
static void *gestalt_new(t_floatarg f)
{
    t_gestalt *x = (t_gestalt *)pd_new(gestalt_class);
    inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("float"), gensym("ft1"));
	inlet_new(&x->x_ob, &x->x_ob.ob_pd, gensym("float"), gensym("ft2"));
	x->x_outgestalt = outlet_new(&x->x_ob, gensym("float"));

	x->x_lastontime = clock_getlogicaltime();

	x->x_reftime = f;
	if(x->x_reftime < 1) x->x_reftime = 1;

    return (void *)x;
}
Beispiel #20
0
static void mtrack_doadd(t_mtrack *tp, int ac, t_atom *av)
{
    if (tp->tr_prevtime > 0.)
    {
	t_binbuf *bb = tp->tr_binbuf;
	t_atom at;
    	float elapsed = clock_gettimesince(tp->tr_prevtime);
	SETFLOAT(&at, elapsed);
	binbuf_add(bb, 1, &at);
	binbuf_add(bb, ac, av);
	SETSEMI(&at);
	binbuf_add(bb, 1, &at);
	tp->tr_prevtime = clock_getlogicaltime();
    }
}
Beispiel #21
0
static void Borax_float(t_Borax *x, t_float f)
{
    int pitch;
    if (loud_checkint((t_pd *)x, f, &pitch, &s_float))  /* CHECKME */
    {
	int index;
	if (pitch < 0 || pitch >= BORAX_MAXVOICES)
	{
	    /* CHECKME pitch range, complaints */
	    return;
	}
	index = x->x_voices[pitch].v_index;
	if (x->x_vel)
	{
	    if (index)
		return;  /* CHECKME */
	    x->x_indices[index = x->x_minindex] = 1;
	    while (x->x_indices[++x->x_minindex]);
	    index++;  /* CHECKME one-based? */
	    Borax_delta(x);
	    x->x_onset = clock_getlogicaltime();  /* CHECKME (in delta?) */
	    x->x_voices[pitch].v_index = index;
	    x->x_voices[pitch].v_onset = x->x_onset;
	    x->x_voices[pitch].v_nonsets = ++x->x_nonsets;
	    x->x_nvoices++;
	}
	else
	{
	    if (!index)
		return;  /* CHECKME */
	    index--;
	    x->x_indices[index] = 0;
	    if (index < x->x_minindex) x->x_minindex = index;
	    index++;
	    Borax_durout(x, pitch);
	    x->x_voices[pitch].v_index = 0;
	    x->x_nvoices--;
	}
	outlet_float(x->x_velout, x->x_vel);
	outlet_float(x->x_pitchout, pitch);
	outlet_float(x->x_nvoicesout, x->x_nvoices);
	outlet_float(x->x_voiceout, index);
	outlet_float(((t_object *)x)->ob_outlet, x->x_voices[pitch].v_nonsets);
    }
}
Beispiel #22
0
static void *cepstrum_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
    t_cepstrum_tilde *x = (t_cepstrum_tilde *)pd_new(cepstrum_tilde_class);
	int i, isPow2;
	s=s;
	
	x->x_featureList = outlet_new(&x->x_obj, gensym("list"));

	x->signal_R = (t_sample *)getbytes(0);
	x->hann = (float *)getbytes(0);

	if(argc > 0)
	{
		x->window = atom_getfloat(argv);
		isPow2 = (int)x->window && !( ((int)x->window-1) & (int)x->window );
		
		if(!isPow2)
		{
			error("requested window size is not a power of 2. default value of 1024 used instead");
			x->window = 1024;
		};
	}
	else
		x->window = 1024;

	x->sr = 44100;
	x->n = 64.0;
	x->overlap = 1;
	x->normalize = 0; // normalization doesn't seem to matter at all
	x->last_dsp_time = clock_getlogicaltime();

	x->signal_R = (t_sample *)t_resizebytes(x->signal_R, 0, (x->window+x->n) * sizeof(t_sample));
	x->hann = (float *)t_resizebytes(x->hann, 0, x->window * sizeof(float));
	
	// initialize hann window
 	for(i=0; i<x->window; i++)
 		x->hann[i] = 0.5 * (1 - cos(2*M_PI*i/x->window));

 	for(i=0; i<(x->window+x->n); i++)
		x->signal_R[i] = 0.0;
		
    post("cepstrum~: window size: %i", (int)x->window);
    
    return (x);
}
Beispiel #23
0
void sched_set_using_audio(int flag)
{
    sched_useaudio = flag;
    if (flag == SCHED_AUDIO_NONE)
    {
        sched_referencerealtime = sys_getrealtime();
        sched_referencelogicaltime = clock_getlogicaltime();
    }
        if (flag == SCHED_AUDIO_CALLBACK &&
            sched_useaudio != SCHED_AUDIO_CALLBACK)
                sys_quit = SYS_QUIT_RESTART;
        if (flag != SCHED_AUDIO_CALLBACK &&
            sched_useaudio == SCHED_AUDIO_CALLBACK)
                post("sorry, can't turn off callbacks yet; restart Pd");
                    /* not right yet! */
        
    sys_time_per_dsp_tick = (TIMEUNITPERSEC) *
        ((double)sys_schedblocksize) / sys_dacsr;
}
Beispiel #24
0
static t_int *specBrightness_tilde_perform(t_int *w)
{
    int i, n;

    t_specBrightness_tilde *x = (t_specBrightness_tilde *)(w[1]);

    t_sample *in = (t_float *)(w[2]);
    n = w[3];
 			
 	// shift signal buffer contents back.
	for(i=0; i<x->window; i++)
		x->signal_R[i] = x->signal_R[i+n];
	
	// write new block to end of signal buffer.
	for(i=0; i<n; i++)
		x->signal_R[(int)x->window+i] = in[i];
		
	x->last_dsp_time = clock_getlogicaltime();

    return (w+4);
}
Beispiel #25
0
static t_int *barkSpec_tilde_perform(t_int *w)
{
	int i, n;

	t_barkSpec_tilde *x = (t_barkSpec_tilde *)(w[1]);

	t_sample *in = (t_sample *)(w[2]);
	n = w[3];

 	// shift signal buffer contents back.
	for(i=0; i<(x->window-n); i++)
		x->signal_R[i] = x->signal_R[i+n];

	// write new block to end of signal buffer.
	for(i=0; i<n; i++)
		x->signal_R[(int)x->window-n+i] = in[i];

	x->lastDspTime = clock_getlogicaltime();

	return (w+4);
}
Beispiel #26
0
static void *record_new(t_symbol *s, t_floatarg f)
{
    /* one auxiliary signal:  sync output */
    t_record *x = (t_record *)arsic_new(record_class, s, (int)f, 0, 1);
    if (x)
    {
	int nch = arsic_getnchannels((t_arsic *)x);
	arsic_setminsize((t_arsic *)x, 2);
	x->x_appendmode = 0;
	x->x_loopmode = 0;
	record_reset(x);
	x->x_clock = clock_new(x, (t_method)record_tick);
	x->x_clocklasttick = clock_getlogicaltime();
	while (--nch)
	    inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal);
	inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft-2"));
	inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft-1"));
	outlet_new((t_object *)x, &s_signal);
    }
    return (x);
}
Beispiel #27
0
static void *zeroCrossing_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
    t_zeroCrossing_tilde *x = (t_zeroCrossing_tilde *)pd_new(zeroCrossing_tilde_class);
	int i;
	
	x->x_crossings = outlet_new(&x->x_obj, &s_float);
	s=s;
	
	x->signal_R = (t_sample *)getbytes(0);

	if(argc > 0)
	{
		x->window = atom_getfloat(argv);
		
		if(x->window < 64)
		{
			error("minimum window size is 64 samples.");
			x->window = 64;
		};
	}
	else
		x->window = 1024;	
	
	
	x->sr = 44100.0;
	x->n = 64.0;
	x->overlap = 1;
	x->last_dsp_time = clock_getlogicaltime();

	x->signal_R = (t_sample *)t_resizebytes(x->signal_R, 0, (x->window+x->n) * sizeof(t_sample));

 	for(i=0; i<(x->window+x->n); i++)
		x->signal_R[i] = 0.0;
		
    post("zeroCrossing~: window size: %i", (int)x->window);
    
    return (x);
}
Beispiel #28
0
static void *peek_new(t_symbol *s, t_floatarg f1, t_floatarg f2)
{
    int ch = (f1 > 0 ? (int)f1 : 0);
    t_peek *x = (t_peek *)arsic_new(peek_class, s,
				    (ch ? PEEK_MAXCHANNELS : 0), 0, 0);
    if (x)
    {
	if (ch > PEEK_MAXCHANNELS)
	    ch = PEEK_MAXCHANNELS;
	x->x_maxchannels = (ch ? PEEK_MAXCHANNELS : 1);
	x->x_effchannel = x->x_reqchannel = (ch ? ch - 1 : 0);
	/* CHECKED (refman's error) clipping is disabled by default */
	x->x_clipmode = ((int)f2 != 0);
	x->x_pokemode = 0;
	inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft1"));
	inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft2"));
	outlet_new((t_object *)x, &s_float);
	x->x_clock = clock_new(x, (t_method)peek_tick);
	x->x_clocklasttick = clock_getlogicaltime();
	x->x_clockset = 0;
    }
    return (x);
}
Beispiel #29
0
static void gestalt_float(t_gestalt *x, t_floatarg f)
{

	int interval, pitch, gestalt;
	double ontime = clock_getlogicaltime();
	
	if(x->x_velocity)	/* only process note-ons */
	{

		pitch = (t_int)f;
		if(pitch < 1) pitch = 0;
		if(pitch > 127) pitch = 127;

		interval = abs(pitch - x->x_lastpitch);
		gestalt = (clock_gettimesince(x->x_lastontime)/x->x_reftime) + interval;

		x->x_lastpitch = pitch;
		x->x_lastontime = ontime;

			/* output values from right to left */
		outlet_float(x->x_outgestalt, gestalt);
	}
}
Beispiel #30
0
static void *poke_new(t_symbol *s, t_floatarg f)
{
    int ch = (f > 0 ? (int)f : 0);
    t_poke *x = (t_poke *)arsic_new(poke_class, s,
				    (ch ? POKE_MAXCHANNELS : 0), 2, 0);
    if (x)
    {
	t_inlet *in2;
	if (ch > POKE_MAXCHANNELS)
	    ch = POKE_MAXCHANNELS;
	x->x_maxchannels = (ch ? POKE_MAXCHANNELS : 1);
	x->x_effchannel = x->x_reqchannel = (ch ? ch - 1 : 0);
	/* CHECKED: no float-to-signal conversion.
	   Floats in 2nd inlet are ignored when dsp is on, but only if a signal
	   is connected to this inlet.  Incompatible (revisit LATER). */
	in2 = inlet_new((t_object *)x, (t_pd *)x, &s_signal, &s_signal);
	x->x_indexptr = fragile_inlet_signalscalar(in2);
	inlet_new((t_object *)x, (t_pd *)x, &s_float, gensym("ft2"));
	x->x_clock = clock_new(x, (t_method)poke_tick);
	x->x_clocklasttick = clock_getlogicaltime();
	x->x_clockset = 0;
    }
    return (x);
}