~ubuntu-branches/ubuntu/precise/csound/precise

« back to all changes in this revision

Viewing changes to util/dnoise.c

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2012-04-19 09:26:46 UTC
  • mfrom: (3.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20120419092646-96xbj1n6atuqosk2
Tags: 1:5.17.6~dfsg-1
* New upstream release
 - Do not build the wiimote opcodes (we need wiiuse).
* Add new API function to symbols file
* Disable lua opcodes, they were broken. Requires OpenMP to be enabled.
* Backport fixes from upstream:
  - Link dssi4cs with dl. Backport
  - Fix building of CsoundAC

Show diffs side-by-side

added added

removed removed

Lines of Context:
203
203
 
204
204
    MYFLT
205
205
        Ninv,       /* 1. / N */
206
 
        RoverTwoPi, /* R/D divided by 2*Pi */
207
 
        TwoPioverR, /* 2*Pi divided by R/I */
 
206
      //RoverTwoPi, /* R/D divided by 2*Pi */
 
207
      //TwoPioverR, /* 2*Pi divided by R/I */
208
208
        sum,        /* scale factor for renormalizing windows */
209
209
        rIn,        /* decimated sampling rate */
210
210
        rOut,       /* pre-interpolated sampling rate */
220
220
        R = -FL(1.0);  /* input sampling rate */
221
221
 
222
222
    int    i,j,k,   /* index variables */
223
 
        Dd,         /* number of new inputs to read (Dd <= D) */
224
 
        Ii,         /* number of new outputs to write (Ii <= I) */
225
223
        ibs,        /* current starting location in input buffer */
226
224
        ibc,        /* current location in input buffer */
227
225
        obs,        /* current starting location in output buffer */
243
241
        first = 0;  /* first-time-thru flag */
244
242
 
245
243
    SOUNDIN     *p, *pn;
246
 
    void        *dummy;
247
244
    char        *infile = NULL, *nfile = NULL;
248
245
    SNDFILE     *inf = NULL, *outfd = NULL;
249
246
    char        c, *s;
252
249
    MYFLT       beg_ntime = FL(0.0), input_ndur = FL(0.0), srn = FL(0.0);
253
250
    const char  *envoutyp = NULL;
254
251
    unsigned int  outbufsiz = 0U;
255
 
    char        outformch = 's';
256
252
    int         nrecs = 0;
257
253
 
258
254
    csound->e0dbfs = csound->dbfs_to_float = FL(1.0);
314
310
              O->sfheader = 0;           /* skip sfheader  */
315
311
              break;
316
312
            case 'c':
317
 
              outformch = c;
318
313
              O->outformat = AE_CHAR;     /* 8-bit char soundfile */
319
314
              break;
320
315
            case '8':
321
 
              outformch = c;
322
316
              O->outformat = AE_UNCH;     /* 8-bit unsigned char file */
323
317
              break;
324
318
            case 'a':
325
 
              outformch = c;
326
319
              O->outformat = AE_ALAW;     /* a-law soundfile */
327
320
              break;
328
321
            case 'u':
329
 
              outformch = c;
330
322
              O->outformat = AE_ULAW;     /* mu-law soundfile */
331
323
              break;
332
324
            case 's':
333
 
              outformch = c;
334
325
              O->outformat = AE_SHORT;    /* short_int soundfile */
335
326
              break;
336
327
            case 'l':
337
 
              outformch = c;
338
328
              O->outformat = AE_LONG;     /* long_int soundfile */
339
329
              break;
340
330
            case 'f':
341
 
              outformch = c;
342
331
              O->outformat = AE_FLOAT;    /* float soundfile */
343
332
              break;
344
333
            case 'R':
492
481
        return -1;
493
482
      }
494
483
      /* register file to be closed by csoundReset() */
495
 
      dummy = csound->CreateFileHandle(csound, &outfd, CSFILE_SND_W,
496
 
                                               O->outfilename);
 
484
      (void)csound->CreateFileHandle(csound, &outfd, CSFILE_SND_W,
 
485
                                     O->outfilename);
497
486
      sf_command(outfd, SFC_SET_CLIPPING, NULL, SF_TRUE);
498
487
    }
499
488
    csound->esr = (MYFLT) p->sr;
846
835
    rIn = ((MYFLT) R / D);
847
836
    rOut = ((MYFLT) R / I);
848
837
    invR = FL(1.0) / R;
849
 
    RoverTwoPi = rIn / TWOPI_F;
850
 
    TwoPioverR = TWOPI_F / rOut;
851
838
    nI = -(aLen / D) * D;    /* input time (in samples) */
852
839
    nO = nI;                 /* output time (in samples) */
853
 
    Dd = aLen + nI + 1;      /* number of new inputs to read */
854
 
    Ii = 0;                  /* number of new outputs to write */
855
840
    ibs = ibuflen + Chans * (nI - aLen - 1);    /* starting position in ib1 */
856
841
    ib1 = ibuf1;        /* filled with zeros to start */
857
842
    ib2 = ibuf2;        /* first buffer of speech */
1182
1167
/* report soundfile write(osfd) error      */
1183
1168
/*    called after chk of write() bytecnt  */
1184
1169
 
1185
 
static void sndwrterr(CSOUND *csound, SNDFILE *outfd, int nret, int nput)
 
1170
static void sndwrterr(CSOUND *csound, int nret, int nput)
1186
1171
{
1187
1172
    csound->Message(csound, Str("soundfile write returned sample count of %d, "
1188
1173
                                "not %d\n"), nret, nput);
1201
1186
    if (outfd == NULL) return 0;
1202
1187
    n = sf_write_MYFLT(outfd, outbuf, nsmps);
1203
1188
    if (n < nsmps) {
1204
 
      sndwrterr(csound, outfd, n, nsmps);
 
1189
      sndwrterr(csound, n, nsmps);
1205
1190
      return -1;
1206
1191
    }
1207
1192
    if (O->rewrt_hdr)