Beispiel #1
0
/* ChopWave: return wave chopped to st and end. end = 0 means all */
Wave ChopWave(Wave srcW, HTime start, HTime end, HTime sampRate)
{
   Wave tgtW;
   HTime length;                /* HTime length of file */
   long stSamp, endSamp, nSamps;
   short *data;
   
   data = GetWaveDirect(srcW,&nSamps);
   length = nSamps * sampRate;
   if(start >= length)
      HError(1030,"ChopWave: Source too short to get data from %.0f",start); 
   ClampStEn(length,&start,&end);
   if(trace & T_SEGMENT)
      printf("ChopWave: Extracting data %.0f to %.0f\n",start,end);
   stSamp = (long) (start/sampRate);
   endSamp = (long) (end/sampRate);
   nSamps = endSamp - stSamp;
   if(nSamps <= 0)
      HError(1030,"ChopWave: Truncation options result in zero-length file"); 
   tgtW = OpenWaveOutput(&cStack,&sampRate,nSamps);
   PutWaveSample(tgtW,nSamps,data + stSamp);
   CloseWaveInput(srcW);
   if(chopF && labF) ChopLabs(tr,start,end);
   return(tgtW);
}
Beispiel #2
0
/* OpenWaveFile: open source wave file and extract portion if indicated */
HTime OpenWaveFile(char *src)
{
   Wave w, cw;
   long nSamps;
   short *data;

   if((w = OpenWaveInput(&iStack,src,srcFF,0,0,&srcSampRate))==NULL)
      HError(1013,"OpenWaveFile: OpenWaveInput failed");
   srcPK = WAVEFORM;
   tgtSampRate = srcSampRate;
   cw = (chopF)?ChopWave(w,st,en,srcSampRate) : w;
   data = GetWaveDirect(cw,&nSamps);
   wv = OpenWaveOutput(&oStack, &srcSampRate, nSamps);
   PutWaveSample(wv,nSamps,data);
   CloseWaveInput(cw);
   return(nSamps*srcSampRate);
}
Beispiel #3
0
   HTime period;

   int sampSize;

   int numComps;

   long nSamples;

}HeadInfo;



/* PrBar: print a horizantal bar of length n including title */

void PrBar(char *title)

{

   int i,len,n;

   

   if (rawOut) return;

   len = strlen(title);

   n = (barwidth - len)/2;

   for (i=1; i<n; i++) putchar(barc);

   printf(" %s ",title);

   n = barwidth - n - len;

   for (i=1; i<n; i++) putchar(barc);

   putchar('\n');

}

   

/* SetBarWidth: set bar width according to nItems and item type */

void SetBarWidth(int itemWidth)
Beispiel #4
0
/* AppendWave: append the src file to global wave wv */
HTime AppendWave(char *src)
{
   Wave w, cw;
   HTime period=0.0;
   long nSamps;
   short *data;

   if((w = OpenWaveInput(&iStack,src, srcFF, 0, 0, &period))==NULL)
      HError(1013,"AppendWave: OpenWaveInput failed");
   if(trace & T_KINDS )
      printf("Appending file %s format: %s [WAVEFORM]\n",src,
             Format2Str(WaveFormat(w)));   
   if(period != srcSampRate)
      HError(1032,"AppendWave: Input file %s has inconsistent sampling rate",src);
   cw = (chopF)? ChopWave(w,st,en,srcSampRate) : w;
   data = GetWaveDirect(cw,&nSamps);
   PutWaveSample(wv,nSamps,data);
   CloseWaveInput(cw);
   return(nSamps*period);
}