ch-nry / VCV_nozori

port of nozori eurorack module for VCV Rack
GNU General Public License v3.0
15 stars 2 forks source link

Add sample rate conversion #4

Closed AndrewBelt closed 4 years ago

AndrewBelt commented 4 years ago

If the engine sample rate is 44.1kHz for example, you can still process audio at 96kHz or whatever, you just need a sample rate converter that converts an input buffer, processes when full, and converts it back to an output buffer. See https://github.com/VCVRack/AudibleInstruments/blob/v1/src/Clouds.cpp for an example of how to do this. In 2005+, CPUs and sample rate conversion software (such as libspeexdsp or libsamplerate which are both included with Rack) is high quality enough to hear no aliasing or filtering to the human ear. It should also make a negligible difference in CPU, especially since you would be switching from single-sample processing to buffer processing (better cache locality, etc.)

ch-nry commented 4 years ago

Having an input and output buffer will kill the joy of creating feedback with a single module.

The only problem of using this module with a different SR is that frequency (VCO/VCF/LFO) or timing (ADSR) will not be the one I adjusted. At 44100KHz, VCO can no go higher than about 8KHz. The max audio delay time will also be different depending the SR. This are minor issues.

The more I think, the less I want to add this conversion.

I'm fine with a little warning when loading the module (and keep it working even with an not optimized SR) (I can update the message to a less alarming one : "This module have been optimized for XXKHz samplig Rate", if you wish)

AndrewBelt commented 4 years ago

kill the joy of creating feedback with a single module

That's a good reason, especially when self-patching a module.

I'm confused though. I haven't tried this plugin, but it seems that some posters on the Facebook group can't get past the warning message no matter how long they wait, when using your 96kHz modules with a 44.1kHz engine sample rate. It seemed to me that there is no sample rate conversion at all. Is this a bug?

ch-nry commented 4 years ago

The warning should disappear away after 5 seconds in the last version of the code.

No, there is no sample rate conversion at all. Timing and frequency range will change regarding the SR, but it's minor problem.