[Stk] WvIn Problem

Yair Ghitza yghitza@umich.edu
Thu, 3 Apr 2003 02:06:45 -0500 (EST)


Hi everyone,

So, first off, let me apologize if this is a trivial question, or if I am
clearly doing something wrong.  Here is my problem.

I am using the WvIn class to read in a wav file, and using the tick()
function to store MY_FLOAT values of the wav file to an array.
When I do this, it seems that the second half of any wav file I read only
has repeating numbers.

Below, I've included a small test program that shows how I am reading in
the wav file and exactly when the numbers begin to repeat.  With any wav
file as input, the size of the wav file is printed to the screen, using
getSize().  Then, I pring out where the numbers begin and end
repeating.  In every case I've tried, the numbers repeat indefinitely from
exactly half-way through the wav file to the end.

My question is, what am I doing wrong here?  Is there an easier way to
do this?  Any help would be greatly appreciated.  Thanks a lot,

	-Yair

-------------------------------------------------------------------------------

#include <WvIn.h>
#include <iostream.h>

void main()
{

  WvIn * input = new WvIn;
  input->openFile("../../wav/test/Beatles - Day Tripper - 0_20.wav", FALSE);
  cout << "Size: " << input->getSize() << endl;

  int wav_length = input->getSize();
  MY_FLOAT * input_wav = new MY_FLOAT[wav_length];

  bool repeating = false;
  for (int i = 0; i < wav_length; i++)
  {
    input_wav[i] = input->tick();
    if (i > 0)
    {
        if ((input_wav[i] == input_wav[i-1]) && !repeating)
	{
            repeating = true;
            cout << "REPEAT BEGINS at index =\t" << i-1 << endl;
        }
        if ((input_wav[i] != input_wav[i-1]) && repeating)
        {
            repeating = false;
            cout << "ENDS at index =\t\t\t" << i-1 << endl;
	}
     }
  }

}

-------------------------------------------------------------------------------