voidsox_upsample(float*input_sample_buff,float*upsample_buff,sf_count_tinsize){size_tilen=(size_t)(insize/2);//insizeistheinterleavedstereocountofsamplesreadsize_tolen=(size_t)(insize/2*(double)process_srate/(double)input_srate+.5);size_todone;unsignedlongconstq_recipe=SOXR_VHQ;unsignedlongconstq_flags=SOXR_LINEAR_PHASE;soxr_quality_spec_tq_spec=soxr_quality_spec(q_recipe,q_flags);soxr_error_terror=soxr_oneshot(input_srate,process_srate,1,/* Rates and # of chans. */input_sample_buff,ilen,NULL,/* Input. */upsample_buff,olen,&odone,/* Output. */NULL,&q_spec,NULL);printf("\n\t\t\t\tUpSampleby%ldxto%ldSRateStatus:%sSamplesIn:%luSamplesOut:%lu",oversample,process_srate,soxr_strerror(error),ilen,olen);/* and reported result. */}
I have tried all the different qualities/recipes.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I believe this occurs because the resampler sees the buffer edges as discontinuities in the audio data. E.g. the first sample in the buffer is seen as having an infinite rise time from the "previous" sample, which causes and overshoot and high frequency ringing in the upsampled audio.
So, I fixed the problem by making the buffer 100 samples larger than needed, and filling the first 50 buffer locations with a copy of the first sample, and the last 50 locations with a copy of the last sample.
Then I loaded the audio data into the buffer with a 50 sample offset.
When consuming the up sampled result, I used a 50 * oversampleratio offset, and the length of the original audio in samples * oversampleratio.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm getting a little "glitch" or "pop" at the start of each buffer when upsampling and streaming, using code similar to example 2.
https://drive.google.com/file/d/1DhNIO6c50qhG-cEYvRGFjrpojy9iJsx3/view?usp=sharing
https://drive.google.com/file/d/12GyS9hpyTjeTK5wmc9x7drNds4avFSTH/view?usp=sharing
How can I avoid this?
I have tried all the different qualities/recipes.
Well for those that come after...
I believe this occurs because the resampler sees the buffer edges as discontinuities in the audio data. E.g. the first sample in the buffer is seen as having an infinite rise time from the "previous" sample, which causes and overshoot and high frequency ringing in the upsampled audio.
So, I fixed the problem by making the buffer 100 samples larger than needed, and filling the first 50 buffer locations with a copy of the first sample, and the last 50 locations with a copy of the last sample.
Then I loaded the audio data into the buffer with a 50 sample offset.
When consuming the up sampled result, I used a 50 * oversampleratio offset, and the length of the original audio in samples * oversampleratio.