-
-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement speex resampler backend #314
Comments
Hi @gavv, I've tried to advance on this, but I haven't been able to make it work. From what I've read, I concluded that most of the work for this should be done in the resample_buff method inside SpeexResampler class, like in this attempt: But I'm not sure what is the input and output of resample_buff and if there is anything else that must be done, so that I can pass the correct input to speex_resampler_process_interleaved_float and process its output to make it compatible with what is expected from resample_buff. I've studied some of the built in resampler code and the related paper mentioned in the docs, but still I got stuck with this. Have you used any tools to visualize the input and output of resample_buff?, that would be useful for me to see what is speex_resampler_process_interleaved_float doing. I've tried printing the frames and visualizing them with matplotlib, but found it suboptimal. Do you have any other advise to keep going on this? |
Hi, good to know that you're still interested! I'll prepare a reply soon. |
Let's talk about
The circular buffer consists of 3 frames:
When the pointer reaches the end,
becomes this:
( Then The pointer maintained by Finally, Each sample in the output frame is calculated from samples inside the small window inside the input circular buffer. One output sample is a product of the samples from small window with the sinc function (for which we have a pre-calculated table).
Here is how it looks when the small window center is at the beginning of
In the middle:
And at the end:
If |
Regarding tools and debugging. You can use You can generate the input wav file and visualize output wav in python or matlab, for example. Look at #153. It provides some examples and scripts. Here are some random scripts that I have locally: https://gist.github.com/gavv/41db26aa76737e72f70112293d7ddae4
Usually works good for me :) |
Regarding speex resampler. I guess it will maintain the circular buffer, and the pointer inside it, by itself. So I guess So in case of speex, we likely don't need to maintain the circular buffer by ourselves. Let's ignore this fact and keep it as is for now and make it working first. Then we'll see whether we need it for zita resampler. If we wont need circular buffer for zita too, we can do some refactoring and move circular buffer feature from |
Feel free to ask if you'll have any other questions. |
Great! Regarding the test, see also #105. Maybe you'll need to adjust the tests. |
@CristobalM BTW, even if you didn't fix the tests, creating a draft PR with your implementation is appreciated, maybe me or someone else will finish it. |
Sorry, I've been busy. Feel free anyone to continue from this, I created the draft PR. |
No worries, thanks! |
Great, this PR was a good start for me! I've cherry-picked most of the changes, fixed both resampler and resampler tests, and pushed everything to develop. What's new (see recent commits in develop):
|
A word about the new speex resampler:
|
Implement resampler interface using speex_resampler from libspeexdsp. See #235 for details and rationale.
Steps:
Add target_speexdsp to SConstruct and 3rdparty.py. See libsndfile source and sink #246 for details on adding a new target directory.
Add SpeexResampler class, implementing IResampler interface. Place it into roc_audio/target_speexdsp.
Add ResamplerBackend_Speex to ResamplerBackend enum. Add SpeexResampler to ResamplerMap.
Add ResamplerBackend_Speex to Test_n_resampler_backends and ensure that tests are passing for the new backend.
Add speex backend to command-line tools and C API.
The text was updated successfully, but these errors were encountered: