4ms / 4ms-vcv

4ms modules for VCV Rack platform
Other
23 stars 3 forks source link

Djembe sample rate change #33

Closed codygeary closed 3 weeks ago

codygeary commented 1 month ago

When I change sample rates in VCV the tone of Djembe changes dramatically. It should ideally sound at least a little bit similar at different sample rates. I think that when the sample rate changes you will need to invoke this function from VCV:

void onSampleRateChange() override {
}

edit: I should add I'm using MacM1

danngreen commented 1 month ago

So, actually that function is defined for all 4ms modules, here:

https://github.com/4ms/4ms-vcv/blob/74a5bb84e0e1116d4f687ba4fe2c6f2ed9538489/src/comm/comm_module.cc#L3-L5

Then the actual sample rate change is handled by the Djembe here: https://github.com/4ms/metamodule-core-modules/blob/62fa4f9cdc576ad29ff292f315f51d256f855719/4ms/core/DjembeCore.cc#L302C1-L312C1

The issue is really that rather than taking extra CPU cycles to re-sample the audio, it just adjusts the pitch parameter to attempt to keep the same pitch as you change the samplerate. I agree though, that it doesn't do a good job at preserving the overall tone/timbre of the sound. Possibly the internal noise needs to be resampled as well, that might help.

I'm also working on a resampling library that's more suitable for the MetaModule hardware, which would be the ideal solution

codygeary commented 1 month ago

Thanks for the detailed explanation! The module is really great sounding anyways, and I don't frequently change sample rates.. I only noticed it because I was testing my new delay module at different sample rates to make sure IT was switching correctly, and the sound kept changing. Then I realized it wasn't the delay but the drum.

Thanks again for making your cool 4MS collection free for us to all use.

Cheers!

danngreen commented 1 month ago

Thanks, yeah I actually merged in the sample rate converter last night, so I'll test it out on the Djembe and see how it sounds

danngreen commented 1 month ago

I played with this a bit and got some decent results without resampling -- just by changing the coefficients when the SR changes. The timbre changes a little, and the balance of harmonics shifts a little bit, too, but overall it's more similar sounding than previously, and it adds no extra CPU load on hardware (except at the moment when you change samplerate)

It's in firmware v1.4.4 on the MetaModule hardware, and will be in the next VCV plugin release

codygeary commented 1 month ago

That's awesome!! Looking forward to playing with it in the next release. It's clever how you got it to work without adding CPU load.