예제 #1
0
파일: revsc.c 프로젝트: BillGrim/AudioKit
static int init_delay_line(sp_revsc *p, sp_revsc_dl *lp, int n)
{
    SPFLOAT readPos;
    /* int     i; */

    /* calculate length of delay line */
    lp->bufferSize = delay_line_max_samples(p->sampleRate, 1, n);
    lp->dummy = 0;
    lp->writePos = 0;
    /* set random seed */
    lp->seedVal = (int) (reverbParams[n][3] + 0.5);
    /* set initial delay time */
    readPos = (SPFLOAT) lp->seedVal * reverbParams[n][1] / 32768;
    readPos = reverbParams[n][0] + (readPos * (SPFLOAT) p->iPitchMod);
    readPos = (SPFLOAT) lp->bufferSize - (readPos * p->sampleRate);
    lp->readPos = (int) readPos;
    readPos = (readPos - (SPFLOAT) lp->readPos) * (SPFLOAT) DELAYPOS_SCALE;
    lp->readPosFrac = (int) (readPos + 0.5);
    /* initialise first random line segment */
    next_random_lineseg(p, lp, n);
    /* clear delay line to zero */
    lp->filterState = 0.0;
    memset(lp->buf, 0, sizeof(SPFLOAT) * lp->bufferSize);
    return SP_OK;
}
예제 #2
0
파일: revsc.c 프로젝트: BillGrim/AudioKit
static int delay_line_bytes_alloc(SPFLOAT sr, SPFLOAT iPitchMod, int n)
{
    int nBytes = 0;

    nBytes += (delay_line_max_samples(sr, iPitchMod, n) * (int) sizeof(SPFLOAT));
    return nBytes;
}
예제 #3
0
파일: reverbsc.c 프로젝트: eddyc/csound
static void init_delay_line(SC_REVERB *p, delayLine *lp, int32_t n)
{
    double  readPos;
    /* int32_t     i; */

    /* calculate length of delay line */
    lp->bufferSize = delay_line_max_samples(p, n);
    lp->dummy = 0;
    lp->writePos = 0;
    /* set random seed */
    lp->seedVal = (int32_t) (reverbParams[n][3] + 0.5);
    /* set initial delay time */
    readPos = (double) lp->seedVal * reverbParams[n][1] / 32768;
    readPos = reverbParams[n][0] + (readPos * (double) *(p->iPitchMod));
    readPos = (double) lp->bufferSize - (readPos * p->sampleRate);
    lp->readPos = (int32_t) readPos;
    readPos = (readPos - (double) lp->readPos) * (double) DELAYPOS_SCALE;
    lp->readPosFrac = (int32_t) (readPos + 0.5);
    /* initialise first random line segment */
    next_random_lineseg(p, lp, n);
    /* clear delay line to zero */
    lp->filterState = 0.0;
    memset(lp->buf, 0, sizeof(MYFLT)*lp->bufferSize);
    /* for (i = 0; i < lp->bufferSize; i++) */
    /*   lp->buf[i] = FL(0.0); */
}
예제 #4
0
파일: reverbsc.c 프로젝트: eddyc/csound
static int32_t delay_line_bytes_alloc(SC_REVERB *p, int32_t n)
{
    int32_t nBytes;

    nBytes = (int32_t) sizeof(delayLine) - (int32_t) sizeof(MYFLT);
    nBytes += (delay_line_max_samples(p, n) * (int32_t) sizeof(MYFLT));
    nBytes = (nBytes + 15) & (~15);
    return nBytes;
}
예제 #5
0
void
effect_screverb_request_buffers(y_synth_t *synth)
{
    SC_REVERB *p = (SC_REVERB *)effects_request_buffer(synth, sizeof(SC_REVERB));
    int i, nBytes;

    memset(p, 0, sizeof(SC_REVERB));

    effects_request_silencing_of_subsequent_allocations(synth);

    /* calculate the number of bytes to allocate */
    nBytes = 0;
    for (i = 0; i < 8; i++) {
        p->delayLines[i].bufferSize = delay_line_max_samples(synth, i);
        nBytes = p->delayLines[i].bufferSize * sizeof(float);
        nBytes = (nBytes + 15) & (~15);
        p->delayLines[i].buf = (float *) effects_request_buffer(synth, nBytes);
    }
}