Compare commits
2 Commits
6fcdd0a158
...
4529d88042
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4529d88042 | ||
|
|
487a53dcc7 |
20
analyser.h
20
analyser.h
@ -36,7 +36,7 @@ struct AnalyserSTFX : public BaseEffect {
|
|||||||
|
|
||||||
storage.range("barkResolution", barkResolution)
|
storage.range("barkResolution", barkResolution)
|
||||||
.info("res.", "in Bark scale")
|
.info("res.", "in Bark scale")
|
||||||
.range(1, 10, 25)
|
.range(2, 10, 25)
|
||||||
.unit("", 0);
|
.unit("", 0);
|
||||||
|
|
||||||
if (storage.extra()) {
|
if (storage.extra()) {
|
||||||
@ -52,7 +52,7 @@ struct AnalyserSTFX : public BaseEffect {
|
|||||||
|
|
||||||
stft.configure(channels, 0, stftBlockMs*0.001*sampleRate, stftIntervalMs*0.001*sampleRate);
|
stft.configure(channels, 0, stftBlockMs*0.001*sampleRate, stftIntervalMs*0.001*sampleRate);
|
||||||
subRate = sampleRate/stft.defaultInterval();
|
subRate = sampleRate/stft.defaultInterval();
|
||||||
bands = spectrum.resize(channels, barkResolution, sampleRate);
|
bands = spectrum.resize(channels, barkResolution, sampleRate, stft.blockSamples());
|
||||||
updateBands();
|
updateBands();
|
||||||
tmp.resize(stft.defaultInterval());
|
tmp.resize(stft.defaultInterval());
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ private:
|
|||||||
void stftStep() {
|
void stftStep() {
|
||||||
if (barkResolution != prevBarkResolution) {
|
if (barkResolution != prevBarkResolution) {
|
||||||
prevBarkResolution = barkResolution;
|
prevBarkResolution = barkResolution;
|
||||||
bands = spectrum.resize(channels, barkResolution, sampleRate);
|
bands = spectrum.resize(channels, barkResolution, sampleRate, stft.blockSamples());
|
||||||
updateBands();
|
updateBands();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,16 +196,26 @@ private:
|
|||||||
std::vector<Sample> hz, bwHz;
|
std::vector<Sample> hz, bwHz;
|
||||||
std::vector<std::vector<Sample>> energy;
|
std::vector<std::vector<Sample>> energy;
|
||||||
|
|
||||||
size_t resize(size_t channels, Sample barkResolution, Sample sampleRate) {
|
size_t resize(size_t channels, Sample barkResolution, Sample sampleRate, size_t fftBands) {
|
||||||
bandsChanged = true;
|
bandsChanged = true;
|
||||||
hz.resize(0);
|
hz.resize(0);
|
||||||
bwHz.resize(0);
|
bwHz.resize(0);
|
||||||
|
|
||||||
|
Sample maxBwHz = sampleRate/fftBands;
|
||||||
auto barkScale = signalsmith::curves::Reciprocal<Sample>::barkScale();
|
auto barkScale = signalsmith::curves::Reciprocal<Sample>::barkScale();
|
||||||
Sample barkStep = 1/barkResolution, barkEnd = barkScale.inverse(sampleRate/2);
|
Sample barkStep = 1/barkResolution, barkEnd = barkScale.inverse(sampleRate/2);
|
||||||
for (Sample bark = barkScale.inverse(0); bark < barkEnd; bark += barkStep) {
|
for (Sample bark = barkScale.inverse(0); bark < barkEnd; bark += barkStep) {
|
||||||
|
auto bw = barkScale.dx(bark)*barkStep;
|
||||||
|
if (!hz.empty() && bw >= maxBwHz) {
|
||||||
|
// our Bark scale would be less dense than the FFT, so we might miss data
|
||||||
|
for (auto linearHz = hz.back() + maxBwHz; linearHz < sampleRate/2; linearHz += maxBwHz) {
|
||||||
|
hz.push_back(linearHz);
|
||||||
|
bwHz.push_back(maxBwHz);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
hz.push_back(barkScale(bark));
|
hz.push_back(barkScale(bark));
|
||||||
bwHz.push_back(barkScale.dx(bark)*barkStep);
|
bwHz.push_back(bw);
|
||||||
}
|
}
|
||||||
hz.push_back(sampleRate/2);
|
hz.push_back(sampleRate/2);
|
||||||
bwHz.push_back(barkScale.dx(barkEnd)*barkStep);
|
bwHz.push_back(barkScale.dx(barkEnd)*barkStep);
|
||||||
|
|||||||
@ -334,7 +334,7 @@ struct WebUILibraryEffect : public LibraryEffect<Sample, WebUIHelper<EffectSTFX,
|
|||||||
auto &message = queue[readIndex];
|
auto &message = queue[readIndex];
|
||||||
return message.readyToSend.test();
|
return message.readyToSend.test();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll on the main thread (and directly after any `.webReceive()`), calling `.sent()` after you've sent it, repeat until you get `nullptr`
|
// Poll on the main thread (and directly after any `.webReceive()`), calling `.sent()` after you've sent it, repeat until you get `nullptr`
|
||||||
WebMessage * getPendingWebMessage() {
|
WebMessage * getPendingWebMessage() {
|
||||||
auto &message = queue[readIndex];
|
auto &message = queue[readIndex];
|
||||||
@ -385,6 +385,11 @@ struct WebUILibraryEffect : public LibraryEffect<Sample, WebUIHelper<EffectSTFX,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void webClosed() {
|
||||||
|
// stops new messages from being queued up until the reset message is sent
|
||||||
|
requestEntireState();
|
||||||
|
}
|
||||||
|
|
||||||
// Replace `.process()` to add meter messages if they exist
|
// Replace `.process()` to add meter messages if they exist
|
||||||
template<class Buffers>
|
template<class Buffers>
|
||||||
void process(Buffers &&buffers, int blockLength) {
|
void process(Buffers &&buffers, int blockLength) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user