Bugfix for very large buffers (e.g. whole audio file)
This commit is contained in:
parent
088dad47f6
commit
85df203ba7
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
This is a C++11 library for pitch and time stretching, using the final approach from the ADC22 presentation _Four Ways To Write A Pitch-Shifter_.
|
This is a C++11 library for pitch and time stretching, using the final approach from the ADC22 presentation _Four Ways To Write A Pitch-Shifter_.
|
||||||
|
|
||||||
It can handle a wide-range of pitch-shifts (multiple octaves) but time-stretching sounds best for more modest changes (between 0.5x and 2x).
|
It can handle a wide-range of pitch-shifts (multiple octaves) but time-stretching sounds best for more modest changes (between 0.75x and 1.5x). There are some audio examples on the [main project page](https://signalsmith-audio.co.uk/code/stretch/).
|
||||||
|
|
||||||
## How to use it
|
## How to use it
|
||||||
|
|
||||||
|
|||||||
@ -126,7 +126,7 @@ struct SignalsmithStretch {
|
|||||||
for (int outputIndex = 0; outputIndex < outputSamples; ++outputIndex) {
|
for (int outputIndex = 0; outputIndex < outputSamples; ++outputIndex) {
|
||||||
stft.ensureValid(outputIndex, [&](int outputOffset) {
|
stft.ensureValid(outputIndex, [&](int outputOffset) {
|
||||||
// Time to process a spectrum! Where should it come from in the input?
|
// Time to process a spectrum! Where should it come from in the input?
|
||||||
int inputOffset = (outputOffset*inputSamples)/outputSamples - stft.windowSize();
|
int inputOffset = std::round(outputOffset*Sample(inputSamples)/outputSamples) - stft.windowSize();
|
||||||
int inputInterval = inputOffset - prevInputOffset;
|
int inputInterval = inputOffset - prevInputOffset;
|
||||||
prevInputOffset = inputOffset;
|
prevInputOffset = inputOffset;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user