Exemple #1
0
void
Resample::cleanup()
{
    src_reset(statel);
    src_reset(stater);

};
Exemple #2
0
SRC_STATE *
src_new (int converter_type, int channels, int *error)
{	SRC_PRIVATE	*psrc ;

	if (error)
		*error = SRC_ERR_NO_ERROR ;

	if (channels < 1)
	{	if (error)
			*error = SRC_ERR_BAD_CHANNEL_COUNT ;
		return NULL ;
		} ;

	if ((psrc = calloc (1, sizeof (*psrc))) == NULL)
	{	if (error)
			*error = SRC_ERR_MALLOC_FAILED ;
		return NULL ;
		} ;

	psrc->channels = channels ;

	if (sinc_set_converter (psrc, converter_type) != SRC_ERR_NO_ERROR &&
			zoh_set_converter (psrc, converter_type) != SRC_ERR_NO_ERROR &&
				linear_set_converter (psrc, converter_type) != SRC_ERR_NO_ERROR)
	{	if (error)
			*error = SRC_ERR_BAD_CONVERTER ;
		free (psrc) ;
		psrc = NULL ;
		} ;

	src_reset ((SRC_STATE*) psrc) ;

	return (SRC_STATE*) psrc ;
} /* src_new */
Exemple #3
0
static void bufadd (Buffer * b, float * data, int len, double ratio)
{
    int oldlen = b->len;
    int max = len * ratio + 100;
    bufgrow (b, oldlen + max);

    SRC_DATA d = {
     .data_in = data,
     .input_frames = len,
     .data_out = OFFSET (b->mem, oldlen),
     .output_frames = max,
     .src_ratio = ratio};

    src_process (srcstate, & d);
    b->len = oldlen + d.output_frames_gen;
}

static void speed_flush (void)
{
    src_reset (srcstate);

    in.len = 0;
    out.len = 0;

    /* Add silence to the beginning of the input signal. */
    bufgrow (& in, width / 2);

    trim = width / 2;
    written = 0;
    ending = FALSE;
}
void AUD_SRCResampleReader::seek(int position)
{
	AUD_Specs specs = m_reader->getSpecs();
	double factor = double(m_rate) / double(specs.rate);
	m_reader->seek(position / factor);
	src_reset(m_src);
	m_position = position;
}
Exemple #5
0
void Stream::Reset()
{
	if(file >= 0) { Disconnect(file); file = -1; }
	encoded.Clear();

	if(src_state) {
		for(int i = 0; i < bufch; ++i) {
			src_reset(src_state[i]);
			decoded[i].Clear();
		}
	}
}
Exemple #6
0
bool pass_parse(sourcefile_t *src)
{
	const lineelement_t *lelem;


	segment_reset();

	allBytesResolved = true;
	allTermsFinal = true;

	dumpPass = false;
	/* Set Pet/Screen Mode to the default */
	reset_TextMode();

	src_reset(src);
	if( !pp_init(src) ) {
		return false;
	}
	resetResolveCounter();

	while( (lelem=pp_peek())!=NULL && lelem->typ!=LE_EOF )
	{
		if( !pass_eparse() ) {
			pp_skipGarbage();
		}

		/* Change SegElem if PC was redefined in this line */
		segment_processChange();

		/* if the number of errors reached the maximum value, stop parsing now */
		if( errorcnt>=cfg_maxerrors ) {
			printf("maximum number of errors reached. aborting!\n");
			break;
		}
	};

	if( errorcnt==0 )
	{
		if( segment_getPhaseIdx()!=0 ) {
			error(EM_PseudoPCStillOpenAtEnd);
			return false;
		}

		if( getLocalBlock()!=0 ) {
			error(EM_LocalBlockStillOpenAtEnd);
			return false;
		}
	}

	return true;
}
	void ResetBuffers()
	{
		std::lock_guard<std::mutex> lk(mMutex);
		pa_sample_spec ss(mSSpec);
		ss.rate = mOutputSamplesPerSec;

		size_t bytes = pf_pa_bytes_per_second(&mSSpec) * 5;
		mQBuffer.resize(0);
		mQBuffer.reserve(bytes);

		bytes = pf_pa_bytes_per_second(&ss) * 5;
		mResampledBuffer.resize(0);
		mResampledBuffer.reserve(bytes);
		src_reset(mResampler);
	}
Exemple #8
0
bool AudioResampler::Seek(size_t offset, Origin origin) {
	if (wrapped_decoder->Seek(offset, origin)) {
		//reset conversion data
		conversion_data.input_frames = 0;
		conversion_data.input_frames_used = 0;
		finished = wrapped_decoder->IsFinished();
		#if defined(HAVE_LIBSPEEXDSP)
			speex_resampler_reset_mem(conversion_state);
		#elif defined(HAVE_LIBSAMPLERATE)
			src_reset(conversion_state);
		#endif
		return true;
	}
	return false;

}
Exemple #9
0
bool AudioPlayer::postMessage(OEComponent *sender, int message, void *data)
{
    updateAudio(false);
    
    switch (message)
    {
        case AUDIOPLAYER_PLAY:
            playing = true;
            
            break;
            
        case AUDIOPLAYER_PAUSE:
            playing = false;
            
            break;
            
        case AUDIOPLAYER_STOP:
            frameIndex = 0;
            playing = false;
            
            src_reset(srcState);
            
            break;
            
        case AUDIOPLAYER_SET_SOUND:
            sound = (OESound *)data;
            
            return true;
            
        case AUDIOPLAYER_SET_LOOP:
            loop = *((bool *)data);
            
            return true;
            
        case AUDIOPLAYER_SET_VOLUME:
            volume = *((float *)data);
            
            return true;
            
        case AUDIOPLAYER_IS_PLAYING:
            *((bool *)data) = playing;
            
            return true;
    }
    
    return false;
}
Exemple #10
0
   int VarRateResample::Process(double  factor,
                                  float  *inBuffer,
                                  int     inBufferLen,
                                  bool    lastFlag,
                                  int    *inBufferUsed,
                                  float  *outBuffer,
                                  int     outBufferLen)
   {
      src_set_ratio((SRC_STATE *)mHandle, factor);

      SRC_DATA data;
      
      if(mShouldReset) {
         if(inBufferLen > mSamplesLeft) {
            mShouldReset = false;
            src_reset((SRC_STATE *)mHandle);
         } else {
            mSamplesLeft -= inBufferLen;
         }
      }

      data.data_in = inBuffer;
      data.data_out = outBuffer;
      data.input_frames = inBufferLen;
      data.output_frames = outBufferLen;
      data.input_frames_used = 0;
      data.output_frames_gen = 0;
      data.end_of_input = (int)lastFlag;
      data.src_ratio = factor;

      int err = src_process((SRC_STATE *)mHandle, &data);
      if (err) {
         wxFprintf(stderr, _("Libsamplerate error: %d\n"), err);
         return 0;
      }
      
      if(lastFlag) {
         mShouldReset = true;
         mSamplesLeft = inBufferLen - (int)data.input_frames_used;
      }

      *inBufferUsed = (int)data.input_frames_used;
      return (int)data.output_frames_gen;
   }
bool
Deck_playback_process::reset()
{
    this->current_sample = 0;
    this->remaining_time = 0;
    this->stopped        = false;
    this->paused         = false;
    for (int i = 0; i < MAX_NB_CUE_POINTS; i++)
    {
        this->read_cue_point(i);
    }

    // Reset libsamplerate.
    if (this->src_state != nullptr)
    {
        src_reset(this->src_state);
    }

    return true;
}
Exemple #12
0
void Resample::reset() {
  Algorithm::reset();
  _data.end_of_input = 0;
  _delay = 0;

  // make sure to reset I/O sizes, failure to do this causes inconsitent behavior with libsamplerate
  // my theory is that because the signal is being chopped up in different intervals than before,
  // the sampling is performed differently
  _signal.setAcquireSize(_preferredSize);
  _signal.setReleaseSize(_preferredSize);
  _resampled.setAcquireSize(_preferredSize);
  _resampled.setReleaseSize(_preferredSize);

  int maxElementsAtOnce = (int)(_data.src_ratio * _signal.acquireSize()) + 100;
  _resampled.setAcquireSize(maxElementsAtOnce);

  BufferInfo buf;
  buf.size = maxElementsAtOnce * 32;
  buf.maxContiguousElements = maxElementsAtOnce*2;
  _resampled.setBufferInfo(buf);

  int error = src_reset(_state);
  if (error) throw EssentiaException("Resample: ", src_strerror(error));
}
static void pcm_src_reset(void *obj)
{
	struct rate_src *rate = obj;

	src_reset(rate->state);
}
Exemple #14
0
int main(int argc, char **argv)
{
printf("\33[0;40;33m\n");	
printf("    FemtoForth  Copyright (C) 2014 Victor Yurkovsky\n");
printf("    This program comes with ABSOLUTELY NO WARRANTY'.\n");
printf("    This is free software, and you are welcome to redistribute it\n");
printf("    under certain conditions; type 'license' for details.\n\n");
color(COLOR_RESET);color(FORE_WHITE);
//---------------------------------------------------------------------
// Data segment.  Houses var at the bottom...  
//
        // memmap data segment
        U8* data_base = mmap((void*)0x04000000,
                 CODE_SIZE,
                 PROT_READ+PROT_WRITE+PROT_EXEC,
                 MAP_ANONYMOUS|MAP_PRIVATE|MAP_FIXED,
                 0,0);
        //var structure is placed into bottom RESERVED (512) bytes of data!
        lay = (sMemLayout*)data_base;           // HOST_RESERVED bytes 
        var = (sVar*)(data_base+HOST_RESERVED); // SYS_RESERVED bytes 
        
        // install system var structure at bottom
        lay->data_bottom = data_base;
        lay->data_top = data_base + CODE_SIZE;
        //
        var->data_ptr = lay->data_bottom + HOST_RESERVED + SYS_RESERVED;

        printf("data at %p->%p ",lay->data_bottom,lay->data_top);

//---------------------------------------------------------------------
// Table - runtime 
//
        lay->table_bottom = mmap((U8**)(CODE_ADDRESS/4),
                 sizeof(TINDEX)*TABLE_SIZE,
                 PROT_READ+PROT_WRITE+PROT_EXEC,
                 MAP_ANONYMOUS|MAP_SHARED|MAP_FIXED,
                 0,0);
        printf("TABLE at %p ",lay->table_bottom);
        lay->table_top = (U8*)lay->table_bottom + sizeof(TINDEX)*TABLE_SIZE;
       // var->table_ptr = (U8**)var->table_bottom;
       // *var->table_ptr++ = 0 ; //first table entry is always 0 !
      
//---------------------------------------------------------------------
// DSP
//
// 
        lay->dsp_bottom = (U8*)malloc(DSP_SIZE);
        lay->dsp_top = lay->dsp_bottom + DSP_SIZE;
 printf("DSP at %p ",lay->dsp_top);
//---------------------------------------------------------------------
// RSP
        lay->rsp_bottom = (U8*)malloc(RSP_SIZE);
        lay->rsp_top = lay->rsp_bottom + RSP_SIZE;
        var->sp_meow = (sRegsMM*)lay->rsp_top;
 printf("RSP at %p ",lay->rsp_top);
//---------------------------------------------------------------------
// HEAD
        lay->head_bottom = (U8*)malloc(HEAD_SIZE);
        lay->head_top = lay->head_bottom + HEAD_SIZE;
        var->head_ptr = lay->head_bottom;
 printf("HEAD at %p \n",lay->head_bottom);
//---------------------------------------------------------------------
// SRC 
        lay->src_bottom =  (char*)malloc(256);
        src_reset(); 
      
        head_build();
     
//  printf("data pointer is now at %p\n",var->data_ptr);
        kernel_load();
//  printf("data pointer is now at %p\n",var->data_ptr);
  
        cmd_init();
        lang_init();

//        int i;
//for(i=0;i<20;i++)

      
// U32 qqq = xxx(0x3456,0x1234);
// printf("bindings returns %x\n",1);
    interpret_init();
// src_error("ass");
//  call_meow();
  
 
   while(1)
      interpret_outer();
 // line();
//        int z = armFunction(99);
//        printf("assembly returnst %d\n",z);       
        exit(0);
}
float*
mirageaudio_decode(MirageAudio *ma, const gchar *file, int *frames, int* size, int* ret)
{
    GstBus *bus;
    tic();

    ma->fftwsamples = 0;
    ma->curhop = 0;
    ma->cursample = 0;
    ma->quit = FALSE;

    g_mutex_lock(ma->decoding_mutex);
    ma->invalidate = FALSE;
    g_mutex_unlock(ma->decoding_mutex);

    // Gstreamer setup
    mirageaudio_initgstreamer(ma, file);
    if (ma->filerate < 0) {
        *size = 0;
        *frames = 0;
        *ret = -1;

        // Gstreamer cleanup
        gst_element_set_state(ma->pipeline, GST_STATE_NULL);
        gst_object_unref(GST_OBJECT(ma->pipeline));

        return NULL;
    }

    // libsamplerate initialization
    ma->src_data.src_ratio = (double)ma->rate/(double)ma->filerate;
    ma->src_data.input_frames = 0;
    ma->src_data.end_of_input = 0;
    src_reset(ma->src_state);
    g_print("libmirageaudio: rate=%d, resampling=%f\n", ma->filerate, ma->src_data.src_ratio);

    // decode...
    gst_element_set_state(ma->pipeline, GST_STATE_PLAYING);
    g_print("libmirageaudio: decoding %s\n", file);


    bus = gst_pipeline_get_bus(GST_PIPELINE(ma->pipeline));
    gboolean decoding = TRUE;
    *ret = 0;
    while (decoding) {
        GstMessage* message = gst_bus_timed_pop_filtered(bus, GST_MSECOND*100,
                GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

        if (message == NULL)
            continue;

        switch (GST_MESSAGE_TYPE(message)) {
            case GST_MESSAGE_ERROR: {
                GError *err;
                gchar *debug;

                gst_message_parse_error(message, &err, &debug);
                g_print("libmirageaudio: error: %s\n", err->message);
                g_error_free(err);
                g_free(debug);
                ma->curhop = 0;
                decoding = FALSE;
                *ret = -1;

                break;
            }
            case GST_MESSAGE_EOS: {
                g_print("libmirageaudio: EOS Message received\n");
                decoding = FALSE;
                break;
            }
            default:
                break;
        }
        gst_message_unref(message);
    }
    gst_object_unref(bus);


    g_mutex_lock(ma->decoding_mutex);

    // Gstreamer cleanup
    gst_element_set_state(ma->pipeline, GST_STATE_NULL);
    gst_object_unref(GST_OBJECT(ma->pipeline));

    toc();

    if (ma->invalidate) {
        *size = 0;
        *frames = 0;
        *ret = -2;
    } else {
        *size = ma->winsize/2 + 1;
        *frames = ma->curhop;
    }

    g_mutex_unlock(ma->decoding_mutex);

    g_print("libmirageaudio: frames=%d (maxhops=%d), size=%d\n", *frames, ma->hops, *size);
    return ma->out;
}
void
pcm_resample_lsr_reset(struct pcm_resample_state *state)
{
	if (state->state != NULL)
		src_reset(state->state);
}
void AUD_SRCResampleReader::seek(int position)
{
	m_reader->seek(position / m_factor);
	src_reset(m_src);
	m_position = position;
}
void TSampleRateAudioStream::Reset()
{
    TDecoratedAudioStream::Reset();
    src_reset(fResampler);
}
void TaudioFilterResampleSRC::onSeek(void)
{
    if (dll->ok) {
        src_reset(state);
    }
}
HRESULT CSampleRateConverter::FlushStream()
{
  HRESULT hr = S_OK;

  CAutoLock lock (&m_csOutputSample);
  if (m_pNextOutSample)
  {
    if (FAILED(OutputNextSample()))
    {
      Log("CSampleRateConverter::FlushStream OutputNextSample failed with: 0x%08x", hr);
      return hr;
    }
  }

  LONGLONG framesLeft = (m_llFramesInput * m_dSampleRateRation) - m_llFramesOutput;

  if (framesLeft > 0)
  {
    // SRC allows only one call to "flush" so we use a new sample for the last bits of the stream
    if (!m_pNextOutSample && FAILED(hr = RequestNextOutBuffer(m_rtInSampleTime)))
      return hr;

    long nSize = m_pNextOutSample->GetSize();
    BYTE *pOutData = NULL;

    if (FAILED(hr = m_pNextOutSample->GetPointer(&pOutData)))
    {
      Log("CSampleRateConverter: Failed to get output buffer pointer: 0x%08x", hr);
      return hr;
    }
  
    if (nSize / m_nFrameSize < framesLeft)
      Log("CSampleRateConverter: Overflow - Failed to flush SRC data, increase internal sample size!");

    BYTE* tmp[1];
    SRC_DATA data;
    data.data_in = (float*)tmp;
    data.data_out = (float*)pOutData;
    data.input_frames = 0;
    data.output_frames = min(nSize / m_nFrameSize, framesLeft);
    data.src_ratio = m_dSampleRateRation;
    data.end_of_input = 1;

    int srcRet = src_process(m_pSrcState, &data);

    if (srcRet == 0 && data.output_frames_gen > 0)
    {
      ASSERT(data.output_frames_gen == data.output_frames);

      m_pNextOutSample->SetActualDataLength(data.output_frames_gen * m_nFrameSize);

      UINT nFrames = m_pNextOutSample->GetActualDataLength() / m_pOutputFormat->Format.nBlockAlign;
      m_rtInSampleTime += nFrames * UNITS / m_pOutputFormat->Format.nSamplesPerSec;

      hr = OutputNextSample();
      if (FAILED(hr))
      {
        Log("CSampleRateConverter::FlushStream OutputNextSample failed with: 0x%08x", hr);
        return hr;
      }
    }
    else
      m_pNextOutSample.Release();
  }

  m_llFramesInput = 0;
  m_llFramesOutput = 0;

  int srcRet = src_reset(m_pSrcState);
  if (srcRet != 0)
    return S_FALSE;

  return hr;
}
// Processing
HRESULT CSampleRateConverter::PutSample(IMediaSample *pSample)
{
  if (!pSample)
    return S_OK;

  AM_MEDIA_TYPE* pmt = NULL;
  bool bFormatChanged = false;
  
  HRESULT hr = S_OK;

  if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt != NULL)
    bFormatChanged = !FormatsEqual((WAVEFORMATEXTENSIBLE*)pmt->pbFormat, m_pInputFormat);

  if (pSample->IsDiscontinuity() == S_OK)
    m_bDiscontinuity = true;

  CAutoLock lock (&m_csOutputSample);
  if (m_bFlushing)
    return S_OK;

  if (bFormatChanged)
  {
    // Process any remaining input
    if (!m_bPassThrough)
      hr = ProcessData(NULL, 0, NULL);
    // Apply format change locally, 
    // next filter will evaluate the format change when it receives the sample
    Log("CSampleRateConverter::PutSample: Processing format change");
    ChannelOrder chOrder;
    hr = NegotiateFormat((WAVEFORMATEXTENSIBLE*)pmt->pbFormat, 1, &chOrder);
    if (FAILED(hr))
    {
      DeleteMediaType(pmt);
      Log("SampleRateConverter: PutSample failed to change format: 0x%08x", hr);
      return hr;
    }
    m_chOrder = chOrder;
  }

  if (pmt)
    DeleteMediaType(pmt);

  if (m_bPassThrough)
  {
    if (m_pNextSink)
      return m_pNextSink->PutSample(pSample);
    return S_OK; // perhaps we should return S_FALSE to indicate sample was dropped
  }

  long nOffset = 0;
  long cbSampleData = pSample->GetActualDataLength();
  BYTE *pData = NULL;
  REFERENCE_TIME rtStop = 0;
  REFERENCE_TIME rtStart = 0;
  pSample->GetTime(&rtStart, &rtStop);

  // Detect discontinuity in stream timeline
  if ((abs(m_rtNextIncomingSampleTime - rtStart) > MAX_SAMPLE_TIME_ERROR) && m_nSampleNum != 0)
  {
    Log("CSampleRateConverter - stream discontinuity: %6.3f", (rtStart - m_rtNextIncomingSampleTime) / 10000000.0);

    m_rtInSampleTime = rtStart;

    if (m_nSampleNum > 0)
    {
      Log("CSampleRateConverter - using buffered sample data");
      FlushStream();
    }
    else
    {
      Log("CSampleRateConverter - discarding buffered sample data");
      m_llFramesInput = 0;
      m_llFramesOutput = 0;

      int srcRet = src_reset(m_pSrcState);
      if (srcRet != 0)
        Log("CSampleRateConverter - src_reset returned error: %d", srcRet);
    }
  }

  if (m_nSampleNum == 0)
    m_rtInSampleTime = rtStart;

  UINT nFrames = cbSampleData / m_pInputFormat->Format.nBlockAlign;
  REFERENCE_TIME duration = nFrames * UNITS / m_pInputFormat->Format.nSamplesPerSec;

  m_rtNextIncomingSampleTime = rtStart + duration;
  m_nSampleNum++;

  hr = pSample->GetPointer(&pData);
  ASSERT(pData);
  if (FAILED(hr))
  {
    Log("CSampleRateConverter::PutSample - failed to get sample's data pointer: 0x%08x", hr);
    return hr;
  }

  while (nOffset < cbSampleData && SUCCEEDED(hr))
  {
    long cbProcessed = 0;
    hr = ProcessData(pData+nOffset, cbSampleData - nOffset, &cbProcessed);
    nOffset += cbProcessed;
  }
  return hr;
}
Exemple #22
0
static void
callback_reset_test (int converter)
{   static TEST_CB_DATA test_callback_data ;

    static float output [BUFFER_LEN] ;

    SRC_STATE *src_state ;

    double src_ratio = 1.1 ;
    long read_count, read_total ;
    int k, error ;

    printf ("\tcallback_reset_test (%-28s) ....... ", src_get_name (converter)) ;
    fflush (stdout) ;

    for (k = 0 ; k < ARRAY_LEN (data_one) ; k++)
    {   data_one [k] = 1.0 ;
        data_zero [k] = 0.0 ;
    } ;

    if ((src_state = src_callback_new (test_callback_func, converter, 1, &error, &test_callback_data)) == NULL)
    {   printf ("\n\nLine %d : %s\n\n", __LINE__, src_strerror (error)) ;
        exit (1) ;
    } ;

    /* Process a bunch of 1.0 valued samples. */
    test_callback_data.channels = 1 ;
    test_callback_data.count = 0 ;
    test_callback_data.total = ARRAY_LEN (data_one) ;
    test_callback_data.data = data_one ;

    read_total = 0 ;
    do
    {   read_count = (ARRAY_LEN (output) - read_total > CB_READ_LEN) ? CB_READ_LEN : ARRAY_LEN (output) - read_total ;
        read_count = src_callback_read (src_state, src_ratio, read_count, output + read_total) ;
        read_total += read_count ;
    }
    while (read_count > 0) ;

    /* Check for errors. */
    if ((error = src_error (src_state)) != 0)
    {   printf ("\n\nLine %d : %s\n\n", __LINE__, src_strerror (error)) ;
        exit (1) ;
    } ;

    /* Reset the state of the converter.*/
    src_reset (src_state) ;

    /* Process a bunch of 0.0 valued samples. */
    test_callback_data.channels = 1 ;
    test_callback_data.count = 0 ;
    test_callback_data.total = ARRAY_LEN (data_zero) ;
    test_callback_data.data = data_zero ;

    /* Now process some zero data. */
    read_total = 0 ;
    do
    {   read_count = (ARRAY_LEN (output) - read_total > CB_READ_LEN) ? CB_READ_LEN : ARRAY_LEN (output) - read_total ;
        read_count = src_callback_read (src_state, src_ratio, read_count, output + read_total) ;
        read_total += read_count ;
    }
    while (read_count > 0) ;

    /* Check for errors. */
    if ((error = src_error (src_state)) != 0)
    {   printf ("\n\nLine %d : %s\n\n", __LINE__, src_strerror (error)) ;
        exit (1) ;
    } ;

    /* Finally make sure that the output data is zero ie reset was sucessful. */
    for (k = 0 ; k < BUFFER_LEN / 2 ; k++)
        if (output [k] != 0.0)
        {   printf ("\n\nLine %d : output [%d] should be 0.0, is %f.\n\n", __LINE__, k, output [k]) ;
            save_oct_float ("output.dat", data_one, ARRAY_LEN (data_one), output, ARRAY_LEN (output)) ;
            exit (1) ;
        } ;

    /* Make sure that this function has been exported. */
    src_set_ratio (src_state, 1.0) ;

    /* Delete converter. */
    src_state = src_delete (src_state) ;

    puts ("ok") ;
} /* callback_reset_test */
Exemple #23
0
static void
process_reset_test (int converter)
{   static float output [BUFFER_LEN] ;

    SRC_STATE *src_state ;
    SRC_DATA src_data ;
    int k, error ;

    printf ("\tprocess_reset_test  (%-28s) ....... ", src_get_name (converter)) ;
    fflush (stdout) ;

    for (k = 0 ; k < BUFFER_LEN ; k++)
    {   data_one [k] = 1.0 ;
        data_zero [k] = 0.0 ;
    } ;

    /* Get a converter. */
    if ((src_state = src_new (converter, 1, &error)) == NULL)
    {   printf ("\n\nLine %d : src_new() failed : %s.\n\n", __LINE__, src_strerror (error)) ;
        exit (1) ;
    } ;

    /* Process a bunch of 1.0 valued samples. */
    src_data.data_in		= data_one ;
    src_data.data_out		= output ;
    src_data.input_frames	= BUFFER_LEN ;
    src_data.output_frames	= BUFFER_LEN ;
    src_data.src_ratio		= 0.9 ;
    src_data.end_of_input	= 1 ;

    if ((error = src_process (src_state, &src_data)) != 0)
    {   printf ("\n\nLine %d : src_simple () returned error : %s\n\n", __LINE__, src_strerror (error)) ;
        exit (1) ;
    } ;

    /* Reset the state of the converter.*/
    src_reset (src_state) ;

    /* Now process some zero data. */
    src_data.data_in		= data_zero ;
    src_data.data_out		= output ;
    src_data.input_frames	= BUFFER_LEN ;
    src_data.output_frames	= BUFFER_LEN ;
    src_data.src_ratio		= 0.9 ;
    src_data.end_of_input	= 1 ;

    if ((error = src_process (src_state, &src_data)) != 0)
    {   printf ("\n\nLine %d : src_simple () returned error : %s\n\n", __LINE__, src_strerror (error)) ;
        exit (1) ;
    } ;

    /* Finally make sure that the output data is zero ie reset was sucessful. */
    for (k = 0 ; k < BUFFER_LEN / 2 ; k++)
        if (output [k] != 0.0)
        {   printf ("\n\nLine %d : output [%d] should be 0.0, is %f.\n", __LINE__, k, output [k]) ;
            exit (1) ;
        } ;

    /* Make sure that this function has been exported. */
    src_set_ratio (src_state, 1.0) ;

    /* Delete converter. */
    src_state = src_delete (src_state) ;

    puts ("ok") ;
} /* process_reset_test */
Exemple #24
0
static void op_jack_reset_src(void) {
	for (int c = 0; c < CHANNELS; c++) {
		src_reset(src_state[c]);
	}
}