[Stk] WvIn Problem

Gary Scavone gary@ccrma.Stanford.EDU
Fri, 4 Apr 2003 14:03:30 -0800 (PST)


On Fri, 4 Apr 2003, Perry R Cook wrote:

>>I think it could also be a stereo issue.  If you opened a
>>stereo file and then ticked it using the usual mono tick()
>>method, you'd read only the left (or mixed??) samples, then
>>get repeating numbers after reaching the end.  Maybe...

Yes, good point.  The tick() method mixes all channels down to a 
single value (i.e. [chan0 + chan1 + chan2 + chan3] / 4 ).

--gary

>>On Fri, 4 Apr 2003, Gary Scavone wrote:
>>
>>> Hi Yair,
>>>
>>> I think you might be running into a sample rate issue here.  After you
>>> open the file, you should get its sample rate and then
>>> set the default STK sample rate to that value ... something like:
>>>
>>>   Stk::setSampleRate( input->getFileRate() );
>>>
>>> Or you should explicitly set the read rate of the WvIn class to 1.0
>>> after you open the file (input->setRate( 1.0 )).  Let me know if that
>>> doesn't work.  The repeating happens when the end of the file is
>>> reached ... WvIn automatically keeps outputting the last sample value.
>>>
>>> --gary
>>>
>>> On Thu, 3 Apr 2003, Yair Ghitza wrote:
>>>
>>> >>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;
>>> >>	}
>>> >>     }
>>> >>  }
>>> >>
>>> >>}
>>>
>>> _______________________________________________
>>> Stk mailing list
>>> Stk@ccrma.stanford.edu
>>> http://ccrma-mail.stanford.edu/mailman/listinfo/stk