Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/csound/csound into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
vlazzarini committed Jan 25, 2015
2 parents 5aa513a + 4e02ccf commit 2a12736
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 47 deletions.
1 change: 1 addition & 0 deletions Opcodes/bowed.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ typedef struct BOWED {
MYFLT lastfreq;
MYFLT lastbeta;
MYFLT lastamp;
MYFLT limit;
int kloop;
} BOWED;

Expand Down
3 changes: 2 additions & 1 deletion Opcodes/brass.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ MYFLT LipFilt_lastOut(LipFilt*);

/* ---------------------------------------------------------------------- */
typedef struct BRASS {
OPDS h;
OPDS h;
MYFLT *ar; /* Output */
MYFLT *amp, *frequency;
MYFLT *liptension, *dettack;
Expand All @@ -117,6 +117,7 @@ typedef struct BRASS {
MYFLT lipTarget;
MYFLT frq; /* Remember previous value */
MYFLT lipT; /* and lip tension */
MYFLT limit;
int kloop;
} BRASS;

Expand Down
1 change: 1 addition & 0 deletions Opcodes/flute.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ typedef struct FLUTE {
MYFLT outputGain;
MYFLT kloop;
MYFLT lastamp;
MYFLT limit;
} FLUTE;

#endif
76 changes: 42 additions & 34 deletions Opcodes/hrtferX.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static const int elevation_data[N_ELEV] = {56, 60, 72, 72, 72, 72, 72,

static int hrtferxkSet(CSOUND *csound, HRTFER *p)
{
int i; /* standard loop counter */
/* int i; /* standard loop counter */
char filename[MAXNAME];
int bytrev_test;
MEMFIL *mfp;
Expand Down Expand Up @@ -120,21 +120,27 @@ static int hrtferxkSet(CSOUND *csound, HRTFER *p)
/* initialize right result buffer */
/* initialize left output buffer */
/* initialize right output buffer */
for (i=0; i<BUF_LEN; i++) {
p->x[i] = FL(0.0);
p->yl[i] = FL(0.0);
p->yr[i] = FL(0.0);
p->outl[i] = FL(0.0);
p->outr[i] = FL(0.0);
}

/* for (i=0; i<BUF_LEN; i++) { */
/* p->x[i] = FL(0.0); */
/* p->yl[i] = FL(0.0); */
/* p->yr[i] = FL(0.0); */
/* p->outl[i] = FL(0.0); */
/* p->outr[i] = FL(0.0); */
/* } */
memset(p->x, 0, BUF_LEN*sizeof(MYFLT));
memset(p->yl, 0, BUF_LEN*sizeof(MYFLT));
memset(p->yr, 0, BUF_LEN*sizeof(MYFLT));
memset(p->outl, 0, BUF_LEN*sizeof(MYFLT));
memset(p->outr, 0, BUF_LEN*sizeof(MYFLT));

/* initialize left overlap buffer */
/* initialize right overlap buffer */
for (i=0; i<FILT_LENm1; i++) {
p->bl[i] = FL(0.0);
p->br[i] = FL(0.0);
}

/* for (i=0; i<FILT_LENm1; i++) { */
/* p->bl[i] = FL(0.0); */
/* p->br[i] = FL(0.0); */
/* } */
memset(p->bl, 0, FILT_LENm1*sizeof(MYFLT));
memset(p->br, 0, FILT_LENm1*sizeof(MYFLT));
return OK;
}

Expand Down Expand Up @@ -303,12 +309,12 @@ static int hrtferxk(CSOUND *csound, HRTFER *p)

/* reading in audio into x */
if (incount == 0) {
for (ii = 0; ii < toread; ii++)
x[ii] = (ii<offset||ii>early ? FL(0.0) : aIn[ii]);
for (i = 0; i < toread; i++)
x[i] = *aIn++;
}
else {
for (ii = incount; ii<(incount + toread); ii++)
x[ii] = (ii<offset||ii>early ? FL(0.0) : aIn[ii]);
for (i = incount; i<(incount + toread); i++)
x[i] = *aIn++;
}

/* update counters for amount of audio read */
Expand Down Expand Up @@ -378,42 +384,44 @@ static int hrtferxk(CSOUND *csound, HRTFER *p)
nsmpso = 0;
}
else {
uint32 j = 0;
/* account for circular reference */
for (i = outfront; i < BUF_LEN; i++) {
*aLeft++ = outl[i];
*aRight++ = outr[i];
for (i = outfront; i < BUF_LEN; i++, j++) {
*aLeft++ = (j<offset || j>early) ? FL(0.0) : outl[i];
*aRight++ = (j<offset || j>early) ? FL(0.0) : outr[i];
}
outcount -= nsmpso;
nsmpso -= (BUF_LEN - outfront);
for (i = 0; i < nsmpso; i++) {
*aLeft++ = outl[i];
*aRight++ = outr[i];
for (i = 0; i < nsmpso; i++, j++) {
*aLeft++ = (j<offset || j>early) ? FL(0.0) : outl[i];
*aRight++ = (j<offset || j>early) ? FL(0.0) : outr[i];
}
outfront = nsmpso;
nsmpso = 0;
}
}
else {
uint32 j = 0;
if ((outfront+nsmpso) < BUF_LEN) {
for (i = 0; i < outcount; i++) {
*aLeft++ = outl[outfront + i];
*aRight++ = outr[outfront + i];
for (i = 0; i < outcount; i++, j++) {
*aLeft++ = (j<offset || j>early) ? FL(0.0) : outl[outfront + i];
*aRight++ = (j<offset || j>early) ? FL(0.0) : outr[outfront + i];
}
nsmpso -= outcount;
outfront += outcount;
outcount = 0;
}
else {
/* account for circular reference */
for (i = outfront; i < BUF_LEN; i++) {
*aLeft++ = outl[i];
*aRight++ = outr[i];
for (i = outfront; i < BUF_LEN; i++, j++) {
*aLeft++ = (j<offset || j>early) ? FL(0.0) : outl[i];
*aRight++ = (j<offset || j>early) ? FL(0.0) : outr[i];
}
nsmpso -= outcount;
outcount -= (BUF_LEN - outfront);
for (i = 0; i < outcount; i++) {
*aLeft++ = outl[i];
*aRight++ = outr[i];
for (i = 0; i < outcount; i++, j++) {
*aLeft++ = (j<offset || j>early) ? FL(0.0) : outl[i];
*aRight++ = (j<offset || j>early) ? FL(0.0) : outr[i];
}
outfront = outcount;
outcount = 0;
Expand All @@ -435,7 +443,7 @@ static int hrtferxk(CSOUND *csound, HRTFER *p)
}

static OENTRY hrtferX_localops[] = {
{ "hrtfer", sizeof(HRTFER), 0, 5, "aa", "akkS",
{ "hrtfer", sizeof(HRTFER), _QQ, 5, "aa", "akkS",
(SUBR)hrtferxkSet, NULL, (SUBR)hrtferxk},
};

Expand Down
7 changes: 2 additions & 5 deletions Opcodes/hrtferx.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

typedef struct {
OPDS h;
MYFLT *aLeft, *aRight, /* outputs */
*aIn, *kAz, *kElev;
MYFLT *aLeft, *aRight; /* outputs */
MYFLT *aIn, *kAz, *kElev; /* inputs */
STRINGDAT *ifilno; /* and inputs */
MEMFIL *mfp; /* file pointer */
int16 *fpbegin;
Expand All @@ -39,7 +39,4 @@ typedef struct {
MYFLT outl[BUF_LEN], outr[BUF_LEN];
MYFLT x[BUF_LEN], yl[BUF_LEN], yr[BUF_LEN];
MYFLT bl[FILT_LENm1], br[FILT_LENm1];
#ifdef CLICKS
MYFLT rampup[FILT_LEN], rampdown[FILT_LEN];
#endif
} HRTFER;
42 changes: 35 additions & 7 deletions Opcodes/physmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,19 @@ int fluteset(CSOUND *csound, FLUTE *p)
return csound->InitError(csound, Str("No table for Flute"));
}
if (*p->lowestFreq>=FL(0.0)) { /* Skip initialisation?? */
if (*p->lowestFreq!=FL(0.0))
if (*p->lowestFreq!=FL(0.0)) {
length = (int32) (CS_ESR / *p->lowestFreq + FL(1.0));
else if (*p->frequency!=FL(0.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 */
Expand Down Expand Up @@ -365,6 +370,10 @@ int flute(CSOUND *csound, FLUTE *p)
/* Start SetFreq */
if (p->lastFreq != *p->frequency) { /* It changed */
p->lastFreq = *p->frequency;
if (p->limit>p->lastFreq) {
p->lastFreq = p->limit;
csound->Warning(csound, Str("frequency too low, set to minimum"));
}
p->lastJet = *p->jetRatio;
/* freq = (2/3)*p->frequency as we're overblowing here */
/* but 1/(2/3) is 1.5 so multiply for speed */
Expand Down Expand Up @@ -495,14 +504,19 @@ int bowedset(CSOUND *csound, BOWED *p)
return csound->InitError(csound, Str("No table for wgbow vibrato"));
}
if (*p->lowestFreq>=FL(0.0)) { /* If no init skip */
if (*p->lowestFreq!=FL(0.0))
if (*p->lowestFreq!=FL(0.0)) {
length = (int32) (CS_ESR / *p->lowestFreq + FL(1.0));
else if (*p->frequency!=FL(0.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("unknown lowest frequency for bowed string "
"-- assuming 50Hz\n"));
length = (int32) (CS_ESR / FL(50.0) + FL(1.0));
p->limit = FL(50.0);
}
make_DLineL(csound, &p->neckDelay, length);
length = length >> 1; /* Unsure about this; seems correct in later code */
Expand Down Expand Up @@ -565,7 +579,12 @@ int bowed(CSOUND *csound, BOWED *p)
/* Set Frequency if changed */
if (p->lastfreq != *p->frequency) {
/* delay - approx. filter delay */
p->lastfreq = *p->frequency;
if (p->limit<=*p->frequency)
p->lastfreq = *p->frequency;
else {
p->lastfreq = p->limit;
csound->Warning(csound, Str("frequency too low, set to minimum"));
}
p->baseDelay = CS_ESR / p->lastfreq - FL(4.0);
freq_changed = 1;
}
Expand Down Expand Up @@ -779,14 +798,19 @@ int brassset(CSOUND *csound, BRASS *p)
}
p->frq = *p->frequency; /* Remember */
if (*p->lowestFreq>=FL(0.0)) {
if (*p->lowestFreq!=FL(0.0))
if (*p->lowestFreq!=FL(0.0)) {
p->length = (int32) (CS_ESR / *p->lowestFreq + FL(1.0));
else if (p->frq!=FL(0.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);
Expand Down Expand Up @@ -848,6 +872,10 @@ int brass(CSOUND *csound, BRASS *p)
}
if (p->frq != *p->frequency) { /* Set frequency if changed */
p->frq = *p->frequency;
if (p->limit > p->frq) {
p->frq =p->limit;
csound->Warning(csound, Str("frequency too low, set to minimum"));
}
p->slideTarget = (CS_ESR / p->frq * FL(2.0)) + FL(3.0);
/* fudge correction for filter delays */
/* we'll play a harmonic */
Expand Down

0 comments on commit 2a12736

Please sign in to comment.