Csound Csound-dev Csound-tekno Search About

[CSOUND-DEV:4107] InOut/libsnd.c

Date2004-02-23 11:33
Fromjpff@codemist.co.uk
Subject[CSOUND-DEV:4107] InOut/libsnd.c
The version on the CVS is wrong, which is why after the "update"
nothing compiles.  
  The patch below is between the CVS version (second) and my version
which was committed to the CVS some time ago but seems lost.

So hopw do we recover a working system?

==John ffitch
*** Sourceforge/csound5/InOut/libsnd.c  Mon Feb 16 11:30:36 2004
--- /mnt/cage/jpff/Sourceforge/csound5/InOut/libsnd.c   Fri Jan 23 11:30:11 2004
***************
*** 31,37 ****
  #include 
  
  #ifdef RTAUDIO
! extern  int     (*rtrecord)(void *, int);
  extern  void    (*rtplay)(void *, int);
  extern  void    (*rtclose)(void);
  extern  void    (*recopen)(int, int, float, int);
--- 31,37 ----
  #include 
  
  #ifdef RTAUDIO
! extern  int     (*rtrecord)(char *, int);
  extern  void    (*rtplay)(void *, int);
  extern  void    (*rtclose)(void);
  extern  void    (*recopen)(int, int, float, int);
***************
*** 42,52 ****
  static  char    *sfoutname;                     /* soundout filename    */
  static  MYFLT   *inbuf;
          MYFLT   *outbuf;                        /* contin sndio buffers */
! static  MYFLT   *outbufp;                       /* MYFLT pntr           */
  static  unsigned inbufrem, outbufrem;           /* in monosamps         */
                                                  /* (see openin,iotranset)    *
/
  static  unsigned inbufsiz,  outbufsiz;          /* alloc in sfopenin/out     *
/
! static  int     isfd, isfopen = 0;              /* (real set in sfopenin)    *
/
  static  int     osfd, osfopen = 0;              /* (real set in sfopenout)   *
/
  static  int     pipdevin = 0, pipdevout = 0;    /* mod by sfopenin,sfopenout *
/
  #ifdef RTAUDIO
--- 42,52 ----
  static  char    *sfoutname;                     /* soundout filename    */
  static  MYFLT   *inbuf;
          MYFLT   *outbuf;                        /* contin sndio buffers */
! static  MYFLT   *inbufp, *outbufp;              /* MYFLT pntr           */
  static  unsigned inbufrem, outbufrem;           /* in monosamps         */
                                                  /* (see openin,iotranset)    *
/
  static  unsigned inbufsiz,  outbufsiz;          /* alloc in sfopenin/out     *
/
! static  int     isfd, isfopen = 0, infilend = 0;/* (real set in sfopenin)    *
/
  static  int     osfd, osfopen = 0;              /* (real set in sfopenout)   *
/
  static  int     pipdevin = 0, pipdevout = 0;    /* mod by sfopenin,sfopenout *
/
  #ifdef RTAUDIO
***************
*** 63,78 ****
  #  define _pclose pclose
  # endif
  #endif
! extern  void    (*spinrecv)(void), (*spoutran)(void), (*nzerotran)(long);
  static  int     (*audrecv)(void *, int);
  static  void    (*audtran)(void *, int);
  static  SOUNDIN *p;    /* to be passed via sreadin() */
- int sreadin(SNDFILE*, MYFLT *, int, SOUNDIN *);
- SNDFILE *sndgetset(SOUNDIN *);
  
! extern  char    *getstrformat(int format);
! extern  void    sndwrterr(unsigned, unsigned);
! extern  unsigned long   nframes;
  
  #ifdef  USE_DOUBLE
  #define sf_write_MYFLT        sf_write_double
--- 63,76 ----
  #  define _pclose pclose
  # endif
  #endif
! extern void (*spinrecv)(void), (*spoutran)(void), (*nzerotran)(long);
  static  int     (*audrecv)(void *, int);
  static  void    (*audtran)(void *, int);
  static  SOUNDIN *p;    /* to be passed via sreadin() */
  
! extern char *getstrformat(int format);
! extern void sndwrterr(unsigned, unsigned);
! extern unsigned long   nframes;
  
  #ifdef  USE_DOUBLE
  #define sf_write_MYFLT        sf_write_double
***************
*** 82,90 ****
  #define sf_read_MYFLT sf_read_float
  #endif
  
! int type2sf(int type)
  {
!     /*    return (type<<16); */
      switch (type) {
      case TYP_WAV:
        return SF_FORMAT_WAV;
--- 80,88 ----
  #define sf_read_MYFLT sf_read_float
  #endif
  
! static int type2sf(int type)
  {
!     printf("type2sf(%x)\n",type);
      switch (type) {
      case TYP_WAV:
        return SF_FORMAT_WAV;
***************
*** 96,106 ****
      return SF_FORMAT_RAW;
  }
  
! short sf2type(int format)
  {
! /* 
!    return format>>16;
!    printf("sf2type(%x, %x)\n",format, format&SF_FORMAT_TYPEMASK); */
      switch (format&SF_FORMAT_TYPEMASK) {
      case SF_FORMAT_WAV:
        return TYP_WAV;
--- 94,102 ----
      return SF_FORMAT_RAW;
  }
  
! static int sf2type(format)
  {
!     printf("sf2type(%x, %x)\n",format, format&SF_FORMAT_TYPEMASK);
      switch (format&SF_FORMAT_TYPEMASK) {
      case SF_FORMAT_WAV:
        return TYP_WAV;
***************
*** 119,127 ****
      }
  }
  
! int format2sf(int format)
  {
! /* printf("format2sf(%d)\n",format); */
      switch (format) {
      case AE_CHAR:
        return SF_FORMAT_PCM_S8;
--- 115,123 ----
      }
  }
  
! static int format2sf(int format)
  {
!     printf("format2sf(%d)\n",format);
      switch (format) {
      case AE_CHAR:
        return SF_FORMAT_PCM_S8;
***************
*** 149,157 ****
      return SF_FORMAT_PCM_16;
  }
  
! int sf2format(int type)
  {
! /*     printf("sf2format(%x,%x)\n",type,type&SF_FORMAT_SUBMASK); */
      switch (type&SF_FORMAT_SUBMASK) {
      case SF_FORMAT_PCM_S8:
        return AE_CHAR;
--- 145,153 ----
      return SF_FORMAT_PCM_16;
  }
  
! static int sf2format(int type)
  {
!     printf("sf2format(%x,%x)\n",type,type&SF_FORMAT_SUBMASK);
      switch (type&SF_FORMAT_SUBMASK) {
      case SF_FORMAT_PCM_S8:
        return AE_CHAR;
***************
*** 180,188 ****
  }
  
  
! short sfsampsize(int type)
  {
! /*     printf("sfsampsize(%x,%x)\n",type, type&SF_FORMAT_SUBMASK); */
      switch (type&SF_FORMAT_SUBMASK) {
      case SF_FORMAT_PCM_S8:
        return 1;
--- 176,184 ----
  }
  
  
! static short sfsampsize(int type)
  {
!     printf("sfsampsize(%x,%x)\n",type, type&SF_FORMAT_SUBMASK);
      switch (type&SF_FORMAT_SUBMASK) {
      case SF_FORMAT_PCM_S8:
        return 1;
***************
*** 207,213 ****
      case SF_FORMAT_DOUBLE:
        return 8;       /* 64 bit float data */
      }
-     return 4;
  }
  
  
--- 203,208 ----
***************
*** 279,285 ****
      }
  }
  
! void zerosf(long len)
  {
      int   n, smpsrem, clearcnt = 0;
  
--- 274,280 ----
      }
  }
  
! void zerosf(int len)
  {
      int   n, smpsrem, clearcnt = 0;
  
***************
*** 304,313 ****
      }
  }
  
! void rewriteheader(int ofd)
  {
!     if (ofd>=0)
!       sf_command(outfile, SFC_UPDATE_HEADER_NOW, NULL, 0);
  }
  
  static void writesf(void *outbuf, int nbytes)
--- 299,307 ----
      }
  }
  
! void rewriteheader(int ofd, long datasize, int verbose)
  {
!     sf_command(outfile, SFC_UPDATE_HEADER_NOW, NULL, 0);
  }
  
  static void writesf(void *outbuf, int nbytes)
***************
*** 320,326 ****
      if (n < nbytes/sizeof(MYFLT))
        sndwrterr(n, nbytes);
      if (O.rewrt_hdr)
!       rewriteheader(osfd);
      nrecs++;                /* JPff fix */
      if (O.heartbeat) {
        if (O.heartbeat==1) {
--- 314,320 ----
      if (n < nbytes/sizeof(MYFLT))
        sndwrterr(n, nbytes);
      if (O.rewrt_hdr)
!       rewriteheader(osfd, nbytes +(long)nrecs*outbufsiz, 0);
      nrecs++;                /* JPff fix */
      if (O.heartbeat) {
        if (O.heartbeat==1) {
***************
*** 340,351 ****
      }
  }
  
! static int readsf(void *inbuf, int nbytes)
  {
!     return sf_read_MYFLT(infile, inbuf, nbytes/nchnls);
  }
  
- static MYFLT fzero = FL(0.0);
  int SAsndgetset(
       char    *infilnam,                          /* Stand-Alone sndgetset() */
       SOUNDIN **ap,                               /* used by SoundAnal progs */
--- 334,344 ----
      }
  }
! static void readsf(void *inbuf, int nbytes)
  {
!     sf_read_MYFLT(infile, inbuf, nbytes/nchnls);
  }
  
  int SAsndgetset(
       char    *infilnam,                          /* Stand-Alone sndgetset() */
       SOUNDIN **ap,                               /* used by SoundAnal progs */
***************
*** 354,415 ****
       MYFLT   *asr,
       int     channel)
  {                               /* Return -1 on failure */
!     SOUNDIN  *p;
!     char     quotname[80];
!     int      infd;
!     static  ARGOFFS  argoffs = {0};     /* these for sndgetset */
!     static  OPTXT    optxt;
!     static  MYFLT sstrcod = (MYFLT)SSTRCOD;
! 
!     sssfinit();                    /* stand-alone init of SFDIR etc. */
!     esr = FL(0.0);                 /* set esr 0. with no orchestra   */
!     optxt.t.outoffs = &argoffs;    /* point to dummy OUTOCOUNT       */
!     *ap = p = (SOUNDIN *) mcalloc((long)sizeof(SOUNDIN));
!     p->h.optext = &optxt;
!     p->ifilno = &sstrcod;
!     p->iskptim = abeg_time;
!     p->iformat = &fzero;
!     sprintf(quotname,"%c%s%c",'"',infilnam,'"');
!     p->STRARG = quotname;
!     p->sr = (long)*asr;
! /* G. Sullivan This modification is not really complete - calling routines
!    should now really be modified to check for channel count > 1, when they
!    are not able to handle this case. I have been lazy, and have not yet
!    bothered to do this. The reason I made this change was so that
!    cvanal could handle stereo, or quad, soundfiles */
!     if (channel < 1 || ((channel > 4) && (channel != ALLCHNLS))) {
! /*        if (channel < 1 || channel > 4)  { */   /* SAsnd is chan 1,2,3 or 4 
*/
!       printf(Str(X_658,"channel request %d illegal\n"), channel);
!       return(-1);
!     }
!     p->channel = channel;
!     p->analonly = 1;
!     if ((infile = sndgetset(p)) < 0)            /* open sndfil, do skiptime */
!       return(-1);
! 
!     if (p->framesrem < 0 ) {
!       if (O.msglevel & WARNMSG)
!         printf(Str(X_1318,
!                    "WARNING: undetermined file length, will attempt requested 
duration\n"));
!     }
!     else {
!       if (*ainput_dur == FL(0.0)) {         /* 0 durtim, use to EOF */
!         p->getframes = p->framesrem;
!         *ainput_dur = (MYFLT) p->getframes / p->sr;
!       }
!       /* else chk that input dur is within filetime rem */
!       else if ((p->getframes = (long)(p->sr * *ainput_dur)) > p->framesrem) {
!         p->getframes = p->framesrem;
!         if (O.msglevel & WARNMSG)
!           printf(Str(X_789,"WARNING: full requested duration not available\n")
);
!       }
!       printf(Str(X_598,"analyzing %ld sample frames (%3.1f secs)"),
!              p->getframes, *ainput_dur);
!       if (*abeg_time != 0.0)
!         printf(Str(X_18," from timepoint %3.1f\n"), *abeg_time);
!       else printf("\n");
!     }
!     return(infd);
  }
  
  long getsndin(int fd, MYFLT *fp, long nlocs, SOUNDIN *p)
--- 347,353 ----
       MYFLT   *asr,
       int     channel)
  {                               /* Return -1 on failure */
!     return -1;
  }
  
  long getsndin(int fd, MYFLT *fp, long nlocs, SOUNDIN *p)
***************
*** 430,443 ****
                                  /* called from sndinset, SAsndgetset, & gen01 
*/
                                  /* Return -1 on failure */
  {
!     int     n;
      long    hdrsize = 0, framesinbuf, skipframes;
      char    *sfname, soundiname[128];
      int     sinfd;
      SNDFILE *infile;
      SF_INFO sfinfo;
      long    filno;
!     long    sndinbufsiz = SNDINBUFSIZ;
  
      if ((n = p->OUTOCOUNT) && n > 24) { /* if appl,chkchnls */
        sprintf(errmsg,Str(X_1209,"soundin: illegal no of receiving channels"));
--- 368,381 ----
                                  /* called from sndinset, SAsndgetset, & gen01 
*/
                                  /* Return -1 on failure */
  {
!     int    n;
      long    hdrsize = 0, framesinbuf, skipframes;
      char    *sfname, soundiname[128];
      int     sinfd;
      SNDFILE *infile;
      SF_INFO sfinfo;
      long    filno;
!     long sndinbufsiz = SNDINBUFSIZ;
  
      if ((n = p->OUTOCOUNT) && n > 24) { /* if appl,chkchnls */
        sprintf(errmsg,Str(X_1209,"soundin: illegal no of receiving channels"));
***************
*** 453,458 ****
--- 391,397 ----
      else
        sprintf(soundiname,"soundin.%ld",filno);       /* soundin.filno */
      sfname = soundiname;
+     printf("*** opening %s\n", sfname);
      if ((sinfd = openin(sfname)) < 0) {              /* open with full dir pat
hs */
        if (isfullpath(sfname))
          sprintf(errmsg,Str(X_1206,"soundin cannot open %s"), sfname);
***************
*** 461,483 ****
                     sfname);
        goto errtn;
      }
!     infile = sf_open_fd(sinfd, SFM_READ, &sfinfo, SF_TRUE);
! #ifdef USE_DOUBLE
!     sf_command(infile, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE);
! #else
!     sf_command(infile, SFC_SET_NORM_FLOAT, NULL, SF_FALSE);
! #endif
      p->fdch.fd = infile;
! /*     printf("*** sfinfo: frames=%lld\tsamplerate=%d\tchannels=%d\n" */
! /*            "***       : format=%d\tsections=%d\tseekable=%d\n" */
! /*            "***       : infile=%p\n", */
! /*            sfinfo.frames, sfinfo.samplerate, sfinfo.channels, */
! /*            sfinfo.format, sfinfo.sections, sfinfo.seekable, */
! /*            p->fdch.fd); */
      sfname = retfilnam;                           /* & record fullpath filnam */
      p->format = sf2format(sfinfo.format);
!     if ((short)*p->iformat > 0)   /* convert spec'd format code */
!       p->format = ((short)*p->iformat) | 0x100;
      p->endfile = 0;
      p->filetyp = 0;         /* initially non-typed for readheader */
      curr_func_sr = (MYFLT)sfinfo.samplerate;
--- 400,417 ----
                     sfname);
        goto errtn;
      }
!     infile = sf_open_fd(sinfd, SFM_READ, &sfinfo, SF_TRUE); 
      p->fdch.fd = infile;
!     printf("*** sfinfo: frames=%d/%d\tsamplerate=%d\tchannels=%d\n"
!            "***       : format=%d\tsections=%d\tseekable=%d\n"
!            "***       : infile=%p\n",
!            sfinfo.frames, sfinfo.samplerate, sfinfo.channels,
!            sfinfo.format, sfinfo.sections, sfinfo.seekable,
!            p->fdch.fd);
      sfname = retfilnam;                           /* & record fullpath filnam */
      p->format = sf2format(sfinfo.format);
!     if ((p->format = (short)*p->iformat) > 0)   /* convert spec'd format code */
!       p->format |= 0x100;
      p->endfile = 0;
      p->filetyp = 0;         /* initially non-typed for readheader */
      curr_func_sr = (MYFLT)sfinfo.samplerate;
***************
*** 538,547 ****
        case AE_SHORT:
        case AE_LONG:

        case AE_FLOAT:
!       case AE_24INT:
!         break;            /*RWD 5:2001 */
!       default:
!         sprintf(errmsg,Str(X_52,"%s format %s not yet supported"),
                                sfname, getstrformat((int)p->format));
          goto errcls;
        }
--- 472,479 ----
        case AE_SHORT:
        case AE_LONG:
        case AE_FLOAT:
!       case AE_24INT:  break;            /*RWD 5:2001 */
!       default:        sprintf(errmsg,Str(X_52,"%s format %s not yet supported"
),
                                sfname, getstrformat((int)p->format));
          goto errcls;
        }
***************
*** 550,559 ****
--- 482,493 ----
        /* ******      p->aiffdata = hdr->aiffdata; */
        p->sr = sfinfo.samplerate;
        p->nchanls = (short)sfinfo.channels;
+       printf("*** p->channel=%d\n", p->channel);
        if (p->OUTOCOUNT)
          p->channel = p->OUTOCOUNT;
        else if (p->channel == ALLCHNLS)
          p->channel = 1;
+       printf("*** p->channel=%d\n", p->channel);
        printf(Str(X_604,"audio sr = %ld, "), p->sr);
        if (p->nchanls == 1)
          printf(Str(X_1006,"monaural\n"));
***************
*** 569,574 ****
--- 503,509 ----
                   p->nchanls == 2 ? Str(X_619,"both") : Str(X_591,"all"));
          else printf(Str(X_655,"channel %d\n"), p->channel);
        }
+       p->bytrev = NULL;
  #ifdef NeXT
        if (!p->filetyp)
          printf(Str(X_1095,"opening NeXT infile %s\n"), sfname);
***************
*** 579,585 ****
               sfname);
        if (p->sampframsiz <= 0)                       /* must know framsiz */
          die(Str(X_882,"illegal sampframsiz"));
!       p->audrem = sfinfo.frames * sfinfo.channels;
        p->framesrem = sfinfo.frames;    /*   find frames rem */
        skipframes = (long)(*p->iskptim * p->sr);
        framesinbuf = sndinbufsiz / p->sampframsiz;
--- 514,520 ----
               sfname);
        if (p->sampframsiz <= 0)                       /* must know framsiz */
          die(Str(X_882,"illegal sampframsiz"));
!       p->audrem = sfinfo.frames * sfinfo.channels*sizeof(MYFLT);
        p->framesrem = sfinfo.frames;    /*   find frames rem */
        skipframes = (long)(*p->iskptim * p->sr);
        framesinbuf = sndinbufsiz / p->sampframsiz;
***************
*** 587,599 ****
          int nreq;
          nreq = sndinbufsiz;
          n = sreadin(infile, p->inbuf, nreq, p);
!         p->bufend = p->inbuf+n;
          p->inbufp = p->inbuf + skipframes * p->sampframsiz;
        }
        else {                                          /* for greater skiptime:
 */
          if (sf_seek(infile, (off_t)skipframes, SEEK_SET) < 0)  /* else seek to
 bndry */
            die(Str(X_1208,"soundin seek error"));
!         if ((n = sreadin(NULL,p->inbuf,sndinbufsiz,p)) == 0) /* now rd fulbuf 
*/
            p->endfile = 1;
          p->inbufp = p->inbuf;
          p->bufend = p->inbuf + n;
--- 522,535 ----
          int nreq;
          nreq = sndinbufsiz;
          n = sreadin(infile, p->inbuf, nreq, p);
!         p->bufend = p->inbuf + n;
          p->inbufp = p->inbuf + skipframes * p->sampframsiz;
        }
        else {                                          /* for greater skiptime:
 */
+         long nbytes = skipframes * p->sampframsiz;
          if (sf_seek(infile, (off_t)skipframes, SEEK_SET) < 0)  /* else seek to
 bndry */
            die(Str(X_1208,"soundin seek error"));
!         if ((n = sreadin(sinfd,p->inbuf,sndinbufsiz,p)) == 0) /* now rd fulbuf
 */
            p->endfile = 1;
          p->inbufp = p->inbuf;
          p->bufend = p->inbuf + n;
***************
*** 607,632 ****
   errcls:
        close(sinfd);                       /* init error:  close any open file 
*/
   errtn:
!       return NULL;                        /*              return empty handed 
*/
  }
  
  int sreadin(                    /* special handling of sound input       */
!     SNDFILE *infd,              /* to accomodate reads thru pipes & net  */
!     MYFLT   *inbuf,             /* where nbytes rcvd can be < n requested*/
      int     nbytes,             /*  */
      SOUNDIN *p)                 /* extra arg passed for filetyp testing  */
  {                               /* on POST-HEADER reads of audio samples */
-     /* return the number of samples read */
      int    n, ntot=0;
      SNDFILE *infile = p->fdch.fd;
      int nsamples = nbytes/sizeof(MYFLT);
!     MYFLT *inb = (MYFLT*)inbuf;
! /*     printf("*** sreadin: %p\n",infile); */
      do {
! /*       printf("***        : ntot=%d nbytes=%d reading %d\n", */
! /*              ntot, nbytes, (nsamples-ntot)/nchnls); */
        n = sf_read_MYFLT(infile, inb+ntot, (nsamples-ntot)/nchnls);
! /*       printf("***        : n=%d\n", n); */
        if (n<0)
          die(Str(X_1201,"soundfile read error"));
      } while (n > 0 && (ntot += n*nchnls) < nsamples);
--- 543,567 ----
   errcls:
        close(sinfd);                       /* init error:  close any open file 
*/
   errtn:
!       return -1;                          /*              return empty handed 
*/
  }
  
  int sreadin(                    /* special handling of sound input       */
!     int     infd,               /* to accomodate reads thru pipes & net  */
!     char    *inbuf,             /* where nbytes rcvd can be < n requested*/
      int     nbytes,             /*  */
      SOUNDIN *p)                 /* extra arg passed for filetyp testing  */
  {                               /* on POST-HEADER reads of audio samples */
      int    n, ntot=0;
      SNDFILE *infile = p->fdch.fd;
      int nsamples = nbytes/sizeof(MYFLT);
!     printf("*** sreadin: %p\n",infile);
      do {
!       MYFLT *inb = (MYFLT*)inbuf;
!       printf("***        : ntot=%d nbytes=%d reading %d\n",
!              ntot, nbytes, (nsamples-ntot)/nchnls);
        n = sf_read_MYFLT(infile, inb+ntot, (nsamples-ntot)/nchnls);
!       printf("***        : n=%d\n", n);
        if (n<0)
          die(Str(X_1201,"soundfile read error"));
      } while (n > 0 && (ntot += n*nchnls) < nsamples);
***************
*** 636,642 ****
        p->audrem -= ntot*sizeof(MYFLT);
      }
      else ntot = 0;
!     return ntot;
  }
  
  void writeheader(int ofd, char *ofname) 
--- 571,578 ----
        p->audrem -= ntot*sizeof(MYFLT);
      }
      else ntot = 0;
!     printf("*** sreadin: result=%d\n", ntot*sizeof(MYFLT));
!     return ntot*sizeof(MYFLT);
  }
  
  void writeheader(int ofd, char *ofname) 
***************
*** 650,655 ****
--- 586,592 ----
      SNDFILE *sinfd;
      int     reinit = 0;
  
+     printf("*** sndinset: %s %p\n", p->STRARG,p->fdch.fd);
      if (p->fdch.fd!=NULL) {                 /* if file already open, close it 
*/
            /* RWD: it is not safe to assume all compilers init this to 0 */
            /* (IV: but it is allocated with mcalloc...) */
***************
*** 665,670 ****
--- 602,608 ----
      }
      else
        return initerror(errmsg);              /* else just print the errmsg*/
+     printf("*** sndinset: %s %p\n", p->STRARG,p->fdch.fd);
      return OK;
  }
  
***************
*** 682,719 ****
          scalefac *= p->fscalefac;
      }
      else scalefac = FL(1.0);
  
      if (!p->inbufp) {
        return perferror(Str(X_1210,"soundin: not initialised"));
      }
      chnsout = p->OUTOCOUNT;
      blksiz = chnsout * ksmps;
! /*     printf("***        : chnsout=%d blksiz=%d\n", chnsout, blksiz); */
! /*     printf("***        : p->r[0]=%p, p->r[1]=%p\n", p->r[0], p->r[1]); */
      memcpy(r, p->r, chnsout * sizeof(MYFLT*));
      ntogo = blksiz;
      if (p->endfile)
        goto filend;
!     nsmps = (p->bufend - p->inbufp);
      if (nsmps > blksiz)
        nsmps = blksiz;
      ntogo -= nsmps;
   sndin:
      {
!       MYFLT *inbufp = p->inbufp;
! /*       printf("***        : loop start p->fdch.fd=%p\n", p->fdch.fd); */
        do {
- /*         printf("Writing %p %d <- %f\n", r[i], i, *inbufp * scalefac); */
          *(r[i]++) = *inbufp++ * scalefac;
- /*         printf("        %f\n", *(r[i]-1)); */
          if (++i >= chnsout) i = 0;
        } while (--nsmps);
! /*       printf("***        : loop endp->fdch.fd=%p\n", p->fdch.fd); */
!       p->inbufp = inbufp;
      }
      if (p->inbufp >= p->bufend) {
! /*       printf("***        : need new data p->fdch.fd=%p\n", p->fdch.fd); */
!       if ((n = sreadin(NULL, p->inbuf, SNDINBUFSIZ, p)) == 0) {
          p->endfile = 1;
          if (ntogo) goto filend;
          else return OK;
--- 620,655 ----
          scalefac *= p->fscalefac;
      }
      else scalefac = FL(1.0);
+     printf("*** soundin: %p\n", p->fdch.fd);
  
      if (!p->inbufp) {
        return perferror(Str(X_1210,"soundin: not initialised"));
      }
      chnsout = p->OUTOCOUNT;
      blksiz = chnsout * ksmps;
!     printf("***        : chnsout=%d blksiz=%d\n", chnsout, blksiz);
      memcpy(r, p->r, chnsout * sizeof(MYFLT*));
      ntogo = blksiz;
      if (p->endfile)
        goto filend;
!     nsmps = (p->bufend - p->inbufp) / p->sampframsiz;
      if (nsmps > blksiz)
        nsmps = blksiz;
      ntogo -= nsmps;
   sndin:
      {
!       MYFLT *inbufp = (MYFLT *)p->inbufp;
!       printf("***        : loop start p->fdch.fd=%p\n", p->fdch.fd);
        do {
          *(r[i]++) = *inbufp++ * scalefac;
          if (++i >= chnsout) i = 0;
        } while (--nsmps);
!       printf("***        : loop endp->fdch.fd=%p\n", p->fdch.fd);
!       p->inbufp = (void*)inbufp;
      }
      if (p->inbufp >= p->bufend) {
!       printf("***        : need new data p->fdch.fd=%p\n", p->fdch.fd);
!       if ((n = sreadin(-1, p->inbuf, SNDINBUFSIZ, p)) == 0) {
          p->endfile = 1;
          if (ntogo) goto filend;
          else return OK;
***************
*** 812,817 ****
--- 748,754 ----
          p->filetyp = 0;                          /*  (see also soundin.c) */
          p->audrem = -1;
        }
+       p->bytrev = NULL;
        audrecv = readsf;  /* will use standard audio gets  */
      }
  #ifdef RTAUDIO
***************
*** 966,971 ****
--- 903,914 ----
      outbufrem = O.outbufsamps;
  }
  
+ void iotranset(void)
+ {
+     return;
+ }
+ 
+ 
  void sfclosein(void)
  {
      if (!isfopen) return;