Exemplo n.º 1
0
Arquivo: fm4op.c Projeto: eddyc/csound
int32_t heavymetset(CSOUND *csound, FM4OP *p)
{
    if (UNLIKELY(make_FM4Op(csound,p))) return NOTOK;
    if (UNLIKELY(FM4Op_loadWaves(csound,p))) return NOTOK;  /* Mixed -- 2 x sine;
                                                     1 x fwavblnk */
    FM4Op_setRatio(p, 0, FL(1.00)         );
    FM4Op_setRatio(p, 1, FL(4.00) * FL(0.999));
    FM4Op_setRatio(p, 2, FL(3.00) * FL(1.001));
    FM4Op_setRatio(p, 3, FL(0.50) * FL(1.002));
    ADSR_setAllTimes(csound, &p->adsr[0], FL(0.001), FL(0.001), FL(1.0), FL(0.01));
    ADSR_setAllTimes(csound, &p->adsr[1], FL(0.001), FL(0.010), FL(1.0), FL(0.50));
    ADSR_setAllTimes(csound, &p->adsr[2], FL(0.010), FL(0.005), FL(1.0), FL(0.20));
    ADSR_setAllTimes(csound, &p->adsr[3], FL(0.030), FL(0.010), FL(0.2), FL(0.20));
    /*      ADSR_setAll(&p->adsr[0], 0.050f, 0.0100f, FL(1.0), FL(0.001));  */
    /*      ADSR_setAll(&p->adsr[1], 0.050f, 0.0010f, FL(1.0), 0.0001f); */
    /*      ADSR_setAll(&p->adsr[2], FL(0.001), 0.0020f, FL(1.0), 0.0002f); */
    /*      ADSR_setAll(&p->adsr[3], 0.050f, 0.0010f, FL(0.2), 0.0002f); */
    p->twozero.gain = FL(2.0);
    /*     p->v_rate = 5.5 * p->vibWave->flen * csound->onedsr;  Vib rate */
    ADSR_keyOn(&p->adsr[0]);
    ADSR_keyOn(&p->adsr[1]);
    ADSR_keyOn(&p->adsr[2]);
    ADSR_keyOn(&p->adsr[3]);
    return OK;
}
Exemplo n.º 2
0
Arquivo: fm4op.c Projeto: eddyc/csound
int32_t b3set(CSOUND *csound, FM4OP *p)
{
    MYFLT       amp = *p->amp * AMP_RSCALE; /* Normalised */

    if (UNLIKELY(make_FM4Op(csound,p))) return NOTOK;
    if (UNLIKELY(FM4Op_loadWaves(csound,p))) return NOTOK;         /* sines */
    FM4Op_setRatio(p, 0, FL(0.999));
    FM4Op_setRatio(p, 1, FL(1.997));
    FM4Op_setRatio(p, 2, FL(3.006));
    FM4Op_setRatio(p, 3, FL(6.009));

    p->gains[0] = amp * FM4Op_gains[95];
    p->gains[1] = amp * FM4Op_gains[95];
    p->gains[2] = amp * FM4Op_gains[99];
    p->gains[3] = amp * FM4Op_gains[95];
    ADSR_setAllTimes(csound, &p->adsr[0], FL(0.005), FL(0.003), FL(1.0), FL(0.01));
    ADSR_setAllTimes(csound, &p->adsr[1], FL(0.005), FL(0.003), FL(1.0), FL(0.01));
    ADSR_setAllTimes(csound, &p->adsr[2], FL(0.005), FL(0.003), FL(1.0), FL(0.01));
    ADSR_setAllTimes(csound, &p->adsr[3], FL(0.005), FL(0.001), FL(0.4), FL(0.03));
    /*      ADSR_setAll(&p->adsr[0], 0.05f, 0.03f, FL(1.0), FL(0.04)); */
    /*      ADSR_setAll(&p->adsr[1], 0.05f, 0.03f, FL(1.0), FL(0.04)); */
    /*      ADSR_setAll(&p->adsr[2], 0.05f, 0.03f, FL(1.0), FL(0.04)); */
    /*      ADSR_setAll(&p->adsr[3], 0.05f, FL(0.001),0.4f, 0.06f); */
    p->twozero.gain = FL(0.1);
    ADSR_keyOn(&p->adsr[0]);
    ADSR_keyOn(&p->adsr[1]);
    ADSR_keyOn(&p->adsr[2]);
    ADSR_keyOn(&p->adsr[3]);
    return OK;
}
Exemplo n.º 3
0
Arquivo: fm4op.c Projeto: eddyc/csound
int32_t percfluteset(CSOUND *csound, FM4OP *p)
{
    MYFLT       amp = *p->amp * AMP_RSCALE; /* Normalised */

    if (UNLIKELY(make_FM4Op(csound,p))) return NOTOK;
    if (UNLIKELY(FM4Op_loadWaves(csound,p)))
      return NOTOK;  /* 3 x sines; 1 x fwavblnk */

    FM4Op_setRatio(p, 0, FL(1.50)            );
    FM4Op_setRatio(p, 1, FL(3.00) * FL(0.995));
    FM4Op_setRatio(p, 2, FL(2.99) * FL(1.005));
    FM4Op_setRatio(p, 3, FL(6.00) * FL(0.997));

    p->gains[0] = amp * FM4Op_gains[99];
    p->gains[1] = amp * FM4Op_gains[71];
    p->gains[2] = amp * FM4Op_gains[93];
    p->gains[3] = amp * FM4Op_gains[85];
    ADSR_setAllTimes(csound, &p->adsr[0], FL(0.05), FL(0.05),
                     FM4Op_susLevels[14], FL(0.05));
    ADSR_setAllTimes(csound, &p->adsr[1], FL(0.02), FL(0.50),
                     FM4Op_susLevels[13], FL(0.5));
    ADSR_setAllTimes(csound, &p->adsr[2], FL(0.02), FL(0.30),
                     FM4Op_susLevels[11], FL(0.05));
    ADSR_setAllTimes(csound, &p->adsr[3], FL(0.02), FL(0.05),
                     FM4Op_susLevels[13], FL(0.01));
    p->twozero.gain = FL(0.0);
    /*     modDepth = FL(0.005); */
    ADSR_keyOn(&p->adsr[0]);
    ADSR_keyOn(&p->adsr[1]);
    ADSR_keyOn(&p->adsr[2]);
    ADSR_keyOn(&p->adsr[3]);
    return OK;
}
Exemplo n.º 4
0
Arquivo: fm4op.c Projeto: eddyc/csound
int32_t FMVoiceset(CSOUND *csound, FM4OPV *q)
{
    FM4OP       *p = (FM4OP *)q;
    MYFLT       amp = *q->amp * AMP_RSCALE;

    if (UNLIKELY(make_FM4Op(csound,p))) return NOTOK;
    if (UNLIKELY(FM4Op_loadWaves(csound,p))) return NOTOK;
    FM4Op_setRatio(p, 0, FL(2.00));
    FM4Op_setRatio(p, 1, FL(4.00));
    FM4Op_setRatio(p, 2, FL(12.0));
    FM4Op_setRatio(p, 3, FL(1.00));
    p->gains[3] = FM4Op_gains[80];
    ADSR_setAllTimes(csound, &p->adsr[0], FL(0.050), FL(0.050),
                     FM4Op_susLevels[15], FL(0.050));
    ADSR_setAllTimes(csound, &p->adsr[1], FL(0.050), FL(0.050),
                     FM4Op_susLevels[15], FL(0.050));
    ADSR_setAllTimes(csound, &p->adsr[2], FL(0.050), FL(0.050),
                     FM4Op_susLevels[15], FL(0.050));
    ADSR_setAllTimes(csound, &p->adsr[3], FL(0.001), FL(0.010),
                     FM4Op_susLevels[15], FL(0.500));
    p->twozero.gain = FL(0.0);
    /*     modDepth = 0.005; */
    q->tilt[0] = FL(1.0);
    q->tilt[1] = FL(0.5);
    q->tilt[2] = FL(0.2);
    q->mods[0] = FL(1.0);
    q->mods[1] = FL(1.1);
    q->mods[2] = FL(1.1);
    p->baseFreq = FL(110.0);
    FMVoices_setFreq(q, FL(110.0));
    q->tilt[0] = amp;
    q->tilt[1] = amp * amp;
    q->tilt[2] = amp * amp * amp;
    ADSR_keyOn(&p->adsr[0]);
    ADSR_keyOn(&p->adsr[1]);
    ADSR_keyOn(&p->adsr[2]);
    ADSR_keyOn(&p->adsr[3]);
    q->last_control = -FL(1.0);
    return OK;
}
Exemplo n.º 5
0
Arquivo: fm4op.c Projeto: eddyc/csound
int32_t tubebellset(CSOUND *csound, FM4OP *p)
{
    MYFLT       amp = *p->amp * AMP_RSCALE; /* Normalised */
    MYFLT       opt = *p->opt;

    if (UNLIKELY(make_FM4Op(csound,p))) return NOTOK;
    if (UNLIKELY(FM4Op_loadWaves(csound,p)))
      return NOTOK; /* 4 x "rawwaves/sinewave.raw" */

    FM4Op_setRatio(p, 0, FL(1.0)   * FL(0.995));
    FM4Op_setRatio(p, 1, FL(1.414) * FL(0.995));
    FM4Op_setRatio(p, 2, FL(1.0)   * FL(1.005));
    FM4Op_setRatio(p, 3, FL(1.414)            );
    p->gains[0] = amp * FM4Op_gains[94];
    p->gains[1] = amp * FM4Op_gains[76];
    p->gains[2] = amp * FM4Op_gains[99];
    p->gains[3] = amp * FM4Op_gains[71];
    if (opt<= FL(0.0)) opt = FL(4.0);
    ADSR_setAllTimes(csound, &p->adsr[0], FL(0.005), opt, FL(0.0), FL(0.04));
    ADSR_setAllTimes(csound, &p->adsr[1], FL(0.005), opt, FL(0.0), FL(0.04));
    ADSR_setAllTimes(csound, &p->adsr[2], FL(0.001),FL(0.5)*opt,FL(0.0), FL(0.04));
    ADSR_setAllTimes(csound, &p->adsr[3], FL(0.004), opt, FL(0.0), FL(0.04));
    /*      ADSR_setAll(csound, &p->adsr[0], 0.03f,0.00001f,FL(0.0),0.02f); */
    /*      ADSR_setAll(csound, &p->adsr[1], 0.03f,0.00001f,FL(0.0),0.02f); */
    /*      ADSR_setAll(csound, &p->adsr[2], 0.07f,0.00002f,FL(0.0),0.02f); */
    /*      ADSR_setAll(csound, &p->adsr[3], FL(0.04),0.00001f,FL(0.0),0.02f); */
    p->twozero.gain = FL(0.5);
    p->v_rate = FL(2.0) * p->vibWave->flen * csound->onedsr; /* Vib rate */
    /* Set Freq */
    p->baseFreq = *p->frequency;
    p->w_rate[0] = p->baseFreq * p->ratios[0] * p->waves[0]->flen * csound->onedsr;
    p->w_rate[1] = p->baseFreq * p->ratios[1] * p->waves[1]->flen * csound->onedsr;
    p->w_rate[2] = p->baseFreq * p->ratios[2] * p->waves[2]->flen * csound->onedsr;
    p->w_rate[3] = p->baseFreq * p->ratios[3] * p->waves[3]->flen * csound->onedsr;
    ADSR_keyOn(&p->adsr[0]);
    ADSR_keyOn(&p->adsr[1]);
    ADSR_keyOn(&p->adsr[2]);
    ADSR_keyOn(&p->adsr[3]);
    return OK;
}
Exemplo n.º 6
0
Arquivo: fm4op.c Projeto: eddyc/csound
int32_t rhodeset(CSOUND *csound, FM4OP *p)
{
    MYFLT       amp = *p->amp * AMP_RSCALE; /* Normalised */

    if (UNLIKELY(make_FM4Op(csound,p))) return NOTOK;
    if (UNLIKELY(FM4Op_loadWaves(csound,p))) return NOTOK; /* 3 times "sinewave.raw";
                                                    1 x fwavblnk.raw */

    FM4Op_setRatio(p, 0, FL(1.0));
    FM4Op_setRatio(p, 1, FL(0.5));
    FM4Op_setRatio(p, 2, FL(1.0));
    FM4Op_setRatio(p, 3, FL(15.0));
    p->gains[0] = amp * FM4Op_gains[99];
    p->gains[1] = amp * FM4Op_gains[90];
    p->gains[2] = amp * FM4Op_gains[99];
    p->gains[3] = amp * FM4Op_gains[67];
    ADSR_setAllTimes(csound, &p->adsr[0], FL(0.001), FL(1.50), FL(0.0), FL(0.04));
    ADSR_setAllTimes(csound, &p->adsr[1], FL(0.001), FL(1.50), FL(0.0), FL(0.04));
    ADSR_setAllTimes(csound, &p->adsr[2], FL(0.001), FL(1.00), FL(0.0), FL(0.04));
    ADSR_setAllTimes(csound, &p->adsr[3], FL(0.001), FL(0.25), FL(0.0), FL(0.04));
    /*      ADSR_setAll(&p->adsr[0], 0.05f,0.00003f,FL(0.0),0.02f); */
    /*      ADSR_setAll(&p->adsr[1], 0.05f,0.00003f,FL(0.0),0.02f); */
    /*      ADSR_setAll(&p->adsr[2], 0.05f,0.00005f,FL(0.0),0.02f); */
    /*      ADSR_setAll(&p->adsr[3], 0.05f,0.0002f,FL(0.0),0.02f); */
    p->twozero.gain = FL(1.0);
    p->v_rate = FL(2.0) * p->vibWave->flen * csound->onedsr; /* Vib rate */
    /* Set Freq */
    p->baseFreq = *p->frequency;
    p->w_rate[0] = p->baseFreq * p->ratios[0] * p->waves[0]->flen * csound->onedsr;
    p->w_rate[1] = p->baseFreq * p->ratios[1] * p->waves[1]->flen * csound->onedsr;
    p->w_rate[2] = p->baseFreq * p->ratios[2] * p->waves[2]->flen * csound->onedsr;
    p->w_rate[3] = p->baseFreq * p->ratios[3] * p->waves[3]->flen * csound->onedsr;
    ADSR_keyOn(&p->adsr[0]);
    ADSR_keyOn(&p->adsr[1]);
    ADSR_keyOn(&p->adsr[2]);
    ADSR_keyOn(&p->adsr[3]);
    return OK;
}
Exemplo n.º 7
0
void sequencer_newStep_action(void) // User callback function called by sequencer_process()
{
	if ((noteG.automaticON || noteG.chRequested))
	{
		seq_sequence_new();
		noteG.chRequested = false;
		AdditiveGen_newWaveform();
	}

	if ( (noteG.someNotesMuted) && (rintf(frand_a_b(0.4f , 1)) == 0) )
		ADSR_keyOff(&adsr);
	else
		ADSR_keyOn(&adsr);

	if (autoFilterON)
		SVF_directSetFilterValue(&SVFilter, Ts * 600.f * powf(5000.f / 600.f, frand_a_b(0 , 1)));

	if (noteG.transpose != 0)
	{
		noteG.rootNote += noteG.transpose ;
		seq_transpose();
	}

	if (autoSound == 1)
	{
		switch(rand() % 4) // 4 random timbers
		{
		case 0 : sound = CHORD15; break;
		case 1 : AdditiveGen_newWaveform(); sound = ADDITIVE; break;
		case 2 : sound = CHORD13min5; break;
		case 3 : sound = VOICES3; break;
		}
	}
	if (autoSound == 2)
	{
		sound = rand() % LAST_SOUND;
		if ((sound == CHORD13min5) || (sound == CHORD135))
			sound = VOICES3;
		if ( sound == ADDITIVE)
			AdditiveGen_newWaveform();
	}

	f0 = notesFreq[seq.track1.note[seq.step_idx]]; // Main "melody" frequency
	vol = frand_a_b(0.4f , .8f); // slightly random volume for each note
}
Exemplo n.º 8
0
int brassset(CSOUND *csound, BRASS *p)
{
    FUNC        *ftp;
    MYFLT amp = (*p->amp)*AMP_RSCALE; /* Normalise */

    if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->vibr = ftp;
    else {                                      /* Expect sine wave */
      return csound->InitError(csound, Str("No table for Brass"));
    }
    p->frq = *p->frequency;     /* Remember */
    if (*p->lowestFreq>=FL(0.0)) {
      if (*p->lowestFreq!=FL(0.0)) {
        p->length = (int32) (CS_ESR / *p->lowestFreq + FL(1.0));
        p->limit = *p->lowestFreq;
      }
      else if (p->frq!=FL(0.0)) {
        p->length = (int32) (CS_ESR / p->frq + FL(1.0));
        p->limit = p->frq;
      }
      else {
        csound->Warning(csound, Str("No base frequency for brass "
                                    "-- assumed to be 50Hz\n"));
        p->length = (int32) (CS_ESR / FL(50.0) + FL(1.0));
        p->limit = FL(50.0);
      }
      make_DLineA(csound, &p->delayLine, p->length);
      make_LipFilt(&p->lipFilter);
      make_DCBlock(&p->dcBlock);
      make_ADSR(&p->adsr);
      ADSR_setAllTimes(csound, &p->adsr, FL(0.005), FL(0.001), FL(1.0), FL(0.010));
/*        ADSR_setAll(&p->adsr, 0.02f, 0.05f, FL(1.0), 0.001f); */

      ADSR_setAttackRate(csound, &p->adsr, amp * FL(0.001));

      p->maxPressure = amp;
      ADSR_keyOn(&p->adsr);

      /* Set frequency */
      /*      p->slideTarget = (CS_ESR / p->frq * FL(2.0)) + 3.0f; */
      /* fudge correction for filter delays */
      /*      DLineA_setDelay(&p->delayLine, p->slideTarget);*/
      /* we'll play a harmonic  */
      p->lipTarget = FL(0.0);
/*        LipFilt_setFreq(csound, &p->lipFilter, p->frq); */
      /* End of set frequency */
      p->frq = FL(0.0);         /* to say we do not know */
      p->lipT = FL(0.0);
      /*     LipFilt_setFreq(csound, &p->lipFilter, */
      /*                     p->lipTarget * (MYFLT)pow(4.0,
                                                       (2.0* p->lipT) -1.0)); */
      {
        int relestim = (int)(CS_EKR * FL(0.1));
        /* 1/10th second decay extention */
        if (relestim > p->h.insdshead->xtratim)
          p->h.insdshead->xtratim = relestim;
      }
      p->kloop = (int) ((int32) (p->h.insdshead->offtim * CS_EKR)
                        - (int32) (CS_EKR * *p->dettack));
    }
    return OK;
}
Exemplo n.º 9
0
int fluteset(CSOUND *csound, FLUTE *p)
{
    FUNC        *ftp;
    int32        length;

    if (LIKELY((ftp = csound->FTnp2Find(csound, p->ifn)) != NULL)) p->vibr = ftp;
    else {                                   /* Expect sine wave */
      return csound->InitError(csound, Str("No table for Flute"));
    }
    if (*p->lowestFreq>=FL(0.0)) {      /* Skip initialisation?? */
      if (*p->lowestFreq!=FL(0.0)) {
        length = (int32) (CS_ESR / *p->lowestFreq + FL(1.0));
        p->limit = *p->lowestFreq;
      }
      else if (*p->frequency!=FL(0.0)) {
        length = (int32) (CS_ESR / *p->frequency + FL(1.0));
        p->limit = *p->frequency;
      }
      else {
        csound->Warning(csound, Str("No base frequency for flute "
                                    "-- assumed to be 50Hz\n"));
        length = (int32) (CS_ESR / FL(50.0) + FL(1.0));
        p->limit = FL(50.0);
      }
      make_DLineL(csound, &p->boreDelay, length);
      length = length >> 1;        /* ??? really; yes from later version */
      make_DLineL(csound, &p->jetDelay, length);
      make_OnePole(&p->filter);
      make_DCBlock(&p->dcBlock);
      make_Noise(p->noise);
      make_ADSR(&p->adsr);
                                /* Clear */
/*     OnePole_clear(&p->filter); */
/*     DCBlock_clear(&p->dcBlock); */
                                /* End Clear */
/*       DLineL_setDelay(&p->boreDelay, 100.0f); */
/*       DLineL_setDelay(&p->jetDelay, 49.0f); */

      OnePole_setPole(&p->filter, FL(0.7) - (FL(0.1) * RATE_NORM));
      OnePole_setGain(&p->filter, -FL(1.0));
      ADSR_setAllTimes(csound, &p->adsr, FL(0.005), FL(0.01), FL(0.8), FL(0.010));
/*        ADSR_setAll(&p->adsr, 0.02f, 0.05f, 0.8f, 0.001f); */
    /* Suggested values */
    /*    p->endRefl = 0.5; */
    /*    p->jetRefl = 0.5; */
    /*    p->noiseGain = 0.15; */ /* Breath pressure random component   */
    /*    p->vibrGain = 0.05;  */ /* breath periodic vibrato component  */
    /*    p->jetRatio = 0.32;  */
      p->lastamp = FL(1.0);       /* Remember */
                                  /* This should be controlled by attack */
      ADSR_setAttackRate(csound, &p->adsr, FL(0.02));
      p->maxPress = FL(2.3) / FL(0.8);
      p->outputGain = FL(1.001);
      ADSR_keyOn(&p->adsr);
      p->kloop = (MYFLT)((int)(p->h.insdshead->offtim*CS_EKR -
                               CS_EKR*(*p->dettack)));

      p->lastFreq = FL(0.0);
      p->lastJet = -FL(1.0);
      /* freq = (2/3)*p->frequency as we're overblowing here */
      /* but 1/(2/3) is 1.5 so multiply for speed */
    }
    return OK;
}
Exemplo n.º 10
0
float newNote(t_munger *x, int whichVoice, int newNote, double frames)
{
	float newPosition;
	int i, temp;
	
	x->gvoiceSize[whichVoice] 		= newNoteSize(x, whichVoice, newNote);
	//x->gvoiceDirection[whichVoice] 	= newDirection(x);	 
	x->gvoiceDirection[whichVoice]	= x->noteDirection[newNote];
	
	if(x->num_channels == 2) {
		//x->gvoiceLPan[whichVoice] 		= ((float)rand() - 16384.) * ONE_OVER_MAXRAND * x->gpan_spread + 0.5;
		//x->gvoiceRPan[whichVoice]		= 1. - x->gvoiceLPan[whichVoice];
		//make equal power panning....
		//x->gvoiceLPan[whichVoice] 		= powf(x->gvoiceLPan[whichVoice], 0.5);
		//x->gvoiceRPan[whichVoice] 		= powf(x->gvoiceRPan[whichVoice], 0.5);
		x->gvoiceLPan[whichVoice] 		= powf(x->notePan[newNote], 0.5);
		x->gvoiceRPan[whichVoice] 		= powf((1. - x->notePan[newNote]), 0.5);
	}
	else {
		if(x->notePan[newNote] == -1.) {
			for(i=0;i<x->num_channels;i++) {
				x->channelGain[i] 		= 1.;	
				x->channelGainSpread[i] = 0.;
			}
		} else {
			for(i=0;i<x->num_channels;i++) {
				x->channelGain[i] 		= 0.;	//initialize all to 0.
				x->channelGainSpread[i] = 0.;
			}
			temp = (int)x->notePan[newNote];
			if(temp>=x->num_channels) temp=0;
			x->channelGain[temp] = 1.;			//update the one we want
		}
		for(i=0;i<x->num_channels;i++) {
			x->gvoiceSpat[whichVoice][i] = x->channelGain[i] + ((float)rand() - RAND_MAX * 0.5) * ONE_OVER_HALFRAND * x->channelGainSpread[i];
		}
	}
	
	x->gvoiceOn[whichVoice] 		= 1;
	x->gvoiceDone[whichVoice]		= 0;
	x->gvoiceGain[whichVoice]		= x->noteGain[newNote];
	
	x->gvoiceADSRon[whichVoice]		= 1;
	ADSR_setAllTimes(&x->gvoiceADSR[whichVoice], x->noteAttack[newNote], x->noteDecay[newNote], x->noteSustain[newNote], x->noteRelease[newNote], x->srate_ms);
	ADSR_keyOn(&x->gvoiceADSR[whichVoice]);
	
/*** set start point; tricky, cause of moving buffer, variable playback rates, backwards/forwards, etc.... ***/

    if(!x->externalBuffer) {
		// 1. random positioning and moving buffer (default)
		if(x->position == -1. && x->recordOn == 1) { 
			if(x->gvoiceDirection[whichVoice] == 1) {//going forward			
				if(x->gvoiceSpeed[whichVoice] > 1.) 
					newPosition = x->recordCurrent - x->onethirdBufsize - (float)rand() * ONE_OVER_MAXRAND * x->onethirdBufsize;
				else
					newPosition = x->recordCurrent - (float)rand() * ONE_OVER_MAXRAND * x->onethirdBufsize;//was 2/3rds
			}
			
			else //going backwards
				newPosition = x->recordCurrent - (float)rand() * ONE_OVER_MAXRAND * x->onethirdBufsize;
		}
		
		// 2. fixed positioning and moving buffer	
		else if (x->position >= 0. && x->recordOn == 1) {
			if(x->gvoiceDirection[whichVoice] == 1) {//going forward			
				if(x->gvoiceSpeed[whichVoice] > 1.) 
					//newPosition = x->recordCurrent - x->onethirdBufsize - x->position * x->onethirdBufsize;
					//this will follow more closely...
					newPosition = x->recordCurrent - x->gvoiceSize[whichVoice]*x->gvoiceSpeed[whichVoice] - x->position * x->onethirdBufsize;
					
				else
					newPosition = x->recordCurrent - x->position * x->onethirdBufsize;//was 2/3rds
			}
			
			else //going backwards
				newPosition = x->recordCurrent - x->position * x->onethirdBufsize;
		}
		
		// 3. random positioning and fixed buffer	
		else if (x->position == -1. && x->recordOn == 0) {
			if(x->gvoiceDirection[whichVoice] == 1) {//going forward			
				newPosition = x->recordCurrent - x->onethirdBufsize - (float)rand() * ONE_OVER_MAXRAND * x->onethirdBufsize;
			}	
			else //going backwards
				newPosition = x->recordCurrent - (float)rand() * ONE_OVER_MAXRAND * x->onethirdBufsize;
		}
		
		// 4. fixed positioning and fixed buffer	
		else if (x->position >= 0. && x->recordOn == 0) {
			if(x->gvoiceDirection[whichVoice] == 1) {//going forward			
				newPosition = x->recordCurrent - x->onethirdBufsize - x->position * x->onethirdBufsize;
			}	
			else //going backwards
				newPosition = x->recordCurrent - x->position * x->onethirdBufsize;
		}
	}
	else {
		if (x->position == -1.) {
			newPosition = (float)rand() * ONE_OVER_MAXRAND * frames;
		}
		else  if (x->position >= 0.) newPosition = x->position * frames;
	}
	
	return newPosition;
	
}