Pitch, Frequency and sample buffer length.

Hello, Sorry for a beginner’s question, but is there a simple recipe for keeping the pitch when changing the length of the sample buffer? For example, if I have a BPM of 120, I calculate the length of 60/120 * samplerate for a 1/4 note, the pitch will be let’s say A=27.5 (I generate a sine wave) and the tuning fits, but if I change the BPM, the length of the sample buffer changes, and A is still equal 27.5 but the tuning is gone. Thanks.

I can’t quite follow this. Are you asking “how can I transpose a looping sample buffer of a fixed length”?

maybe the pictures will tell more. I’m trying somehow to keep tuning with different sample buffer lengths. But from what I’ve read now, it probably won’t work without FFT. tune_prob tune_prob_2

I still don’t know what you are trying to do. That picture tells me nothing. Depending on what you want to do, you may not need to do anything very fancy.

It it possible to express the problem in a single sentence? If so, I may be able to answer it.

If it was not my first guess, my second guess is that the problem is “I would like to change the pitch of a sample buffer without changing its duration”? If that is indeed the question, you are right - it is quite difficult, although there is probably code that can be found to do it so that you don’t have to figure it out yourself.

If the problem is actually my first guess, that is easy.

it is this Time Stretching.

I need change duration of sample without affecting its pitch (frequency). so it won’t be that simple for me. Thanks anyway

Ah, oh. Yes that is “difficult”. But I think there is a library build into VCV that does it, making it “easy”. Speexdsp in including with VCV. I’ve never used it, but there was some discussion in the past here

1 Like

thanks a lot, but I make this tool for Renoise, everything is programmed in Lua and it is ‘offline’ rendering to the sample buffer.Something like this