Re-implement zoom

This commit is contained in:
Mike Walters
2015-08-02 23:01:39 +01:00
committed by Mike
parent 4f87b0b0a1
commit 677b8b5116
5 changed files with 24 additions and 4 deletions

View File

@@ -141,7 +141,7 @@ void Spectrogram::getLine(float *dest, int y)
{
if (inputSource && fft) {
fftwf_complex buffer[fftSize];
inputSource->getSamples(buffer, y * fftSize, fftSize);
inputSource->getSamples(buffer, y * getStride(), fftSize);
for (int i = 0; i < fftSize; i++) {
buffer[i][0] *= window[i];
@@ -187,10 +187,21 @@ void Spectrogram::setPowerMin(int power)
update();
}
void Spectrogram::setZoomLevel(int zoom)
{
zoomLevel = clamp(zoom, 0, (int)log2(fftSize));
update();
}
int Spectrogram::getHeight()
{
if (!inputSource)
return 0;
return inputSource->getSampleCount() / fftSize;
}
return inputSource->getSampleCount() / getStride();
}
int Spectrogram::getStride()
{
return fftSize / pow(2, zoomLevel);
}