pstream.h

Go to the documentation of this file.
00001 /*
00002     pstream.h:
00003 
00004     Copyright (C) 2001 Richard Dobson
00005 
00006     This file is part of Csound.
00007 
00008     The Csound Library is free software; you can redistribute it
00009     and/or modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2.1 of the License, or (at your option) any later version.
00012 
00013     Csound is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with Csound; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00021     02111-1307 USA
00022 */
00023 
00024 #ifndef __PSTREAM_H_INCLUDED
00025 #define __PSTREAM_H_INCLUDED
00026 
00027 /* pstream.h.  Implementation of PVOCEX streaming opcodes.
00028    (c) Richard Dobson August 2001
00029    NB pvoc routines based on CARL distribution (Mark Dolson).
00030    This file is licensed according to the terms of the GNU LGPL.
00031  */
00032 
00033 /* opcodes:     PROVISIONAL DEFINITIONS
00034 
00035   fsig      pvsanal ain,ifftsize,ioverlap,iwinsize,iwintype[,iformat,iinit]
00036 
00037     iwintype:   0 =  HAMMING, 1 =  VonHann, 2 = Kaiser(?)
00038     iformat:    only PVS_AMP_FREQ (0) supported at present
00039                 (TODO: add f-table support for custom window)
00040                 ( But: really need a param to associate with the window too,
00041                        or just use a standard default value...)
00042 
00043   fsig      pvsfread ktimpt,ifn[,ichan]
00044 
00045   asig      pvsynth fsig[,iinit]
00046 
00047   asig      pvsadsyn fsig,inoscs,kfmod[,ibin,ibinoffset,iinit]
00048 
00049     ibin:       starting bin (defualt 0)
00050     ibinoffset: distance between successive bins (default 1)
00051     kfmod:      multiplier; 1 = no change, 2 = up one octave.
00052 
00053   fsig      pvscross fsrc,fdest,kamp1,kamp2
00054 
00055   fsig      pvsmaska  fsrc,ifn,kdepth
00056 
00057   ioverlap,inumbins,iwinsize,iformat    pvsinfo     fsig
00058 
00059     ( will need sndinfo supporting pvocex files anyway,
00060       to know numchans, wintype, etc.)
00061 
00062   fdest     =   fsrc
00063 
00064     ( woo-hoo! operator overloading in Csound!)
00065     ( NB an init statement for fsigs is not supported. One day....)
00066 
00067   kflag     pvsftw fsig,ifna [,ifnf]
00068             pvsftr fsig,ifna [,ifnf]
00069 
00070     ( this modifies an ~existing~ signal, does not create a new one,
00071       hence no output)
00072 
00073   Re iinit: not implemented yet: and I still need to establish
00074                                  if it's possible...
00075  */
00076 
00077 /* description of an fsig analysis frame*/
00078 enum PVS_WINTYPE {
00079     PVS_WIN_HAMMING = 0,
00080     PVS_WIN_HANN,
00081     PVS_WIN_KAISER,
00082     PVS_WIN_CUSTOM,
00083     PVS_WIN_BLACKMAN,
00084     PVS_WIN_BLACKMAN_EXACT,
00085     PVS_WIN_NUTTALLC3,
00086     PVS_WIN_BHARRIS_3,
00087     PVS_WIN_BHARRIS_MIN,
00088     PVS_WIN_RECT
00089 };
00090 
00091 
00092 enum PVS_ANALFORMAT {
00093     PVS_AMP_FREQ = 0,
00094     PVS_AMP_PHASE,
00095     PVS_COMPLEX,
00096     PVS_TRACKS          /* added VL, 24.06.2005 */
00097 };
00098 
00099 #ifdef SDFT
00100 typedef struct {
00101   MYFLT re;
00102   MYFLT im;
00103 } CMPLX;
00104 #endif
00105 
00106 typedef struct pvsdat {
00107         long            N;
00108 #ifdef SDFT
00109         int             sliding; /* Flag to indicate sliding case */
00110         long            NB;
00111 #endif
00112         long            overlap;
00113         long            winsize;
00114         int             wintype;
00115         long            format;         /* fixed for now to AMP:FREQ */
00116         unsigned long   framecount;
00117         AUXCH           frame;          /* RWD MUST always be 32bit floats */
00118                                         /* But not in sliding case when MYFLT */
00119 } PVSDAT;
00120 
00121 /* may be no point supporting Kaiser in an opcode unless we can support
00122    the param too but we can have kaiser in a PVOCEX file. */
00123 
00124 typedef struct {
00125         OPDS    h;
00126         PVSDAT  *fsig;                  /* output signal is an analysis frame */
00127         MYFLT   *ain;                   /* input sig is audio */
00128         MYFLT   *fftsize;               /* params */
00129         MYFLT   *overlap;
00130         MYFLT   *winsize;
00131         MYFLT   *wintype;
00132         MYFLT   *format;                /* always PVS_AMP_FREQ at present */
00133         MYFLT   *init;                  /* not yet implemented */
00134         /* internal */
00135         long    buflen;
00136         float   fund,arate;
00137         float   RoverTwoPi,TwoPioverR,Fexact;
00138         MYFLT   *nextIn;
00139         long    nI,Ii,IOi;              /* need all these ?; double as N and NB */
00140         long    inptr;
00141 
00142         AUXCH   input;
00143         AUXCH   overlapbuf;
00144         AUXCH   analbuf;
00145         AUXCH   analwinbuf;     /* prewin in SDFT case */
00146         AUXCH   oldInPhase;
00147 #ifdef SDFT
00148         AUXCH           trig;
00149         double          *cosine, *sine;
00150 #endif
00151 } PVSANAL;
00152 
00153 typedef struct {
00154         OPDS    h;
00155         MYFLT   *aout;                  /* audio output signal */
00156         PVSDAT  *fsig;                  /* input signal is an analysis frame */
00157         MYFLT   *init;                  /* not yet implemented */
00158         /* internal */
00159         /* check these against fsig vals */
00160         long    overlap,winsize,fftsize,wintype,format;
00161         /* can we allow variant window tpes?  */
00162         long    buflen;
00163         MYFLT   fund,arate;
00164         MYFLT   RoverTwoPi,TwoPioverR,Fexact;
00165         MYFLT   *nextOut;
00166         long    nO,Ii,IOi;      /* need all these ?*/
00167         long    outptr;
00168         long    bin_index;      /* for phase normalization across frames */
00169         /* renderer gets all format info from fsig */
00170 
00171         AUXCH   output;
00172         AUXCH   overlapbuf;
00173         AUXCH   synbuf;
00174         AUXCH   analwinbuf;     /* may get away with a local alloc and free */
00175         AUXCH   synwinbuf;
00176         AUXCH   oldOutPhase;
00177 
00178 } PVSYNTH;
00179 
00180 /* for pvadsyn */
00181 
00182 typedef struct {
00183         OPDS    h;
00184         MYFLT   *aout;
00185         PVSDAT  *fsig;
00186         MYFLT   *n_oscs;
00187         MYFLT   *kfmod;
00188         MYFLT   *ibin;          /* default  0 */
00189         MYFLT   *ibinoffset;    /* default 1  */
00190         MYFLT   *init;          /* not yet implemented  */
00191         /* internal */
00192         long    outptr;
00193         unsigned long   lastframe;
00194         /* check these against fsig vals */
00195         long    overlap,winsize,fftsize,wintype,format,noscs;
00196         long    maxosc;
00197         float   one_over_overlap,pi_over_sr, one_over_sr;
00198         float   fmod;
00199         AUXCH   a;
00200         AUXCH   x;
00201         AUXCH   y;
00202         AUXCH   amps;
00203         AUXCH   lastamps;
00204         AUXCH   freqs;
00205         AUXCH   outbuf;
00206 } PVADS;
00207 
00208 /* for pvscross */
00209 typedef struct {
00210         OPDS h;
00211         PVSDAT  *fout;
00212         PVSDAT  *fsrc;
00213         PVSDAT  *fdest;
00214         MYFLT   *kamp1;
00215         MYFLT   *kamp2;
00216         /* internal */
00217         long    overlap,winsize,fftsize,wintype,format;
00218         unsigned long   lastframe;
00219 } PVSCROSS;
00220 
00221 /* for pvsmaska */
00222 typedef struct {
00223         OPDS    h;
00224         PVSDAT  *fout;
00225         PVSDAT  *fsrc;
00226         MYFLT   *ifn;
00227         MYFLT   *kdepth;
00228         /* internal*/
00229         long    overlap,winsize,fftsize,wintype,format;
00230         unsigned long   lastframe;
00231         int             nwarned,pwarned;    /* range errors for kdepth */
00232         FUNC    *maskfunc;
00233 } PVSMASKA;
00234 
00235 /* for pvsftw, pvsftr */
00236 
00237 typedef struct {
00238         OPDS    h;
00239         MYFLT   *kflag;
00240         PVSDAT  *fsrc;
00241         MYFLT   *ifna;   /* amp, required */
00242         MYFLT   *ifnf;   /* freq: optional*/
00243         /* internal */
00244         long    overlap,winsize,fftsize,wintype,format;
00245         unsigned long   lastframe;
00246         FUNC    *outfna, *outfnf;
00247 } PVSFTW;
00248 
00249 typedef struct {
00250         OPDS    h;
00251         /* no output var*/
00252         PVSDAT  *fdest;
00253         MYFLT   *ifna;   /* amp, may be 0 */
00254         MYFLT   *ifnf;   /* freq: optional*/
00255         /* internal */
00256         long    overlap,winsize,fftsize,wintype,format;
00257         unsigned long   lastframe;
00258         FUNC    *infna, *infnf;
00259         MYFLT   *ftablea,*ftablef;
00260 } PVSFTR;
00261 
00262 /* for pvsfread */
00263 /*  wsig pvsread ktimpt,ifilcod */
00264 typedef struct {
00265         OPDS h;
00266         PVSDAT  *fout;
00267         MYFLT   *kpos;
00268         MYFLT   *ifilno;
00269         MYFLT   *ichan;
00270         /* internal */
00271         int             ptr;
00272         long    overlap,winsize,fftsize,wintype,format;
00273         unsigned long   chans, nframes,lastframe,chanoffset,blockalign;
00274         MYFLT   arate;
00275         float   *membase;        /* RWD MUST be 32bit: reads file */
00276 } PVSFREAD;
00277 
00278 /* for pvsinfo */
00279 
00280 typedef struct {
00281         OPDS    h;
00282         MYFLT   *ioverlap;
00283         MYFLT   *inumbins;
00284         MYFLT   *iwinsize;
00285         MYFLT   *iformat;
00286         /* internal*/
00287         PVSDAT  *fsrc;
00288 } PVSINFO;
00289 
00290 typedef struct {
00291         OPDS    h;
00292         PVSDAT  *fout;
00293         PVSDAT  *fsrc;
00294 } FASSIGN;
00295 
00296 #endif
00297 

Generated on Sun Nov 9 00:04:52 2008 for Csound and CsoundAC by  doxygen 1.5.6