Beispiel #1
0
short
FIR::DoProcess(){
if(!m_error){     
 if(m_input){
	 float out;
	 int i;
  for(m_vecpos=0; m_vecpos < m_vecsize;m_vecpos++){
  if(m_enable){     
	  PutSample(m_input->Output(m_vecpos));
	  // wpointer is already incremented, so that the
	  // current sample is at wpointer - 1
	  // and oldest sample at wpointer - m_size
	  for(i=1,out=0.f; i <= m_size; i++){
       m_rpointer = m_wpointer - i;
       out += GetSample(m_rpointer)*m_table->Lookup(i);
	  }
     m_output[m_vecpos] = out;
    }
 else m_output[m_vecpos] = 0.f;
   }
  return 1;
 } 
 else {
        m_error = 11;        
		return 0;
    }
}
 else return 0;






}
HRESULT CTimeStretchFilter::EndOfStream()
{
  // Queue an EOS marker so that it gets processed in 
  // the same thread as the audio data.
  PutSample(NULL);
  // wait until input queue is empty
  //if(m_hInputQueueEmptyEvent)
  //  WaitForSingleObject(m_hInputQueueEmptyEvent, END_OF_STREAM_FLUSH_TIMEOUT); // TODO make this depend on the amount of data in the queue
  return S_OK;
}
Beispiel #3
0
STDMETHODIMP CDecodeThread::Decode(IMediaSample *pSample)
{
  CAutoLock decoderLock(this);

  if (!CAMThread::ThreadExists() || !m_pDecoder)
    return E_UNEXPECTED;

  // Wait until the queue is empty
  while(HasSample())
    Sleep(1);

  // Re-init the decoder, if requested
  // Doing this inside the worker thread alone causes problems
  // when switching from non-sync to sync, so ensure we're in sync.
  if (m_bDecoderNeedsReInit) {
    CAMThread::CallWorker(CMD_REINIT);
    while (!m_evEOSDone.Check()) {
      m_evSample.Wait();
      ProcessOutput();
    }
  }

  m_evDeliver.Reset();
  m_evSample.Reset();
  m_evDecodeDone.Reset();

  pSample->AddRef();

  // Send data to worker thread, and wake it (if it was waiting)
  PutSample(pSample);

  // If we don't have thread safe buffers, we need to synchronize
  // with the worker thread and deliver them when they are available
  // and then let it know that we did so
  if (m_bSyncToProcess) {
    while (!m_evDecodeDone.Check()) {
      m_evSample.Wait();
      ProcessOutput();
    }
  }

  ProcessOutput();

  return S_OK;
}
Beispiel #4
0
short
Pitch::DoProcess(){
     
	if(!m_error){	
if(m_input){   
    float s1, s3;
	float absdiff;
	int halfsize;

 for(m_vecpos=0; m_vecpos<m_vecsize;m_vecpos++){	 
   if(m_enable){
	halfsize = m_size/2;
	absdiff = (float) (int) m_pointer1 - m_wpointer;
	absdiff = absdiff > 0 ? absdiff : -absdiff;
	
	if(absdiff > halfsize){
		if(m_pointer1 > m_wpointer) absdiff = m_wpointer+m_size - m_pointer1;
		else absdiff = m_pointer1+m_size - m_wpointer;
	}
	absdiff = absdiff/halfsize;

    s1 = GetSample(m_pointer1); 
	s3 = GetSample(m_pointer3);

	PutSample(m_input->Output(m_vecpos));
    m_output[m_vecpos] =  absdiff*s1+ (1.f - absdiff)*s3;
	
	m_incr += m_pitch;

	while(m_incr >= m_size) m_incr -= m_size;
	m_pointer1 = m_incr;
    m_pointer3 = m_pointer1+m_size/2;
    while(m_pointer3 >= m_size) m_pointer3 -= m_size;
   }
  else m_output[m_vecpos] = 0.f;
 }
 return 1;
}
 else{        
 m_error = 11;
        return 0;
 }
	}
 else return 0;
}
Beispiel #5
0
short
DelayLine::DoProcess(){
if(!m_error){     
 if(m_input){
  for(m_vecpos=0; m_vecpos < m_vecsize;m_vecpos++){
  if(m_enable){
    m_output[m_vecpos] = GetSample();
    PutSample(m_input->Output(m_vecpos));
    }
 else m_output[m_vecpos] = 0.f;
   }
  return 1;
 } 
 else {
        m_error = 11;        
		return 0;
    }
}
 else return 0;
            }
Beispiel #6
0
void
DelayLine::Reset(){
for(int n = 0; n < m_size; n++)
     PutSample(0.f);
}