-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
title: FFTLFO node documentation | ||
description: FFTLFO: FFT LFO. Requires an FFT* input. | ||
|
||
[Reference library](../../index.md) > [FFT](../index.md) > [FFTLFO](index.md) | ||
|
||
# FFTLFO | ||
|
||
```python | ||
FFTLFO(input=0, frequency=1.0, spectral_cycles=1.0) | ||
``` | ||
|
||
FFT LFO. Requires an FFT* input. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include "signalflow/node/fft/fftnode.h" | ||
|
||
namespace signalflow | ||
{ | ||
|
||
/**--------------------------------------------------------------------------------* | ||
* FFT LFO. | ||
* Requires an FFT* input. | ||
*---------------------------------------------------------------------------------*/ | ||
class FFTLFO : public FFTOpNode | ||
{ | ||
public: | ||
FFTLFO(NodeRef input = 0, NodeRef frequency = 1.0, NodeRef spectral_cycles = 1.0); | ||
virtual void process(Buffer &out, int num_frames); | ||
|
||
private: | ||
NodeRef frequency; | ||
NodeRef spectral_cycles; | ||
double phase; | ||
}; | ||
|
||
REGISTER(FFTLFO, "fft-lfo") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "signalflow/core/graph.h" | ||
#include "signalflow/node/fft/fft-lfo.h" | ||
|
||
namespace signalflow | ||
{ | ||
|
||
FFTLFO::FFTLFO(NodeRef input, NodeRef frequency, NodeRef spectral_cycles) | ||
: FFTOpNode(input), frequency(frequency), spectral_cycles(spectral_cycles) | ||
{ | ||
this->name = "fft-contrast"; | ||
|
||
this->create_input("frequency", this->frequency); | ||
this->create_input("spectral_cycles", this->spectral_cycles); | ||
this->phase = 0.0; | ||
} | ||
|
||
void FFTLFO::process(Buffer &out, int num_frames) | ||
{ | ||
FFTNode *fftnode = (FFTNode *) this->input.get(); | ||
this->num_hops = fftnode->num_hops; | ||
// TODO: Could this update per hop if I index based on hop? | ||
float increment_per_bin = this->spectral_cycles->out[0][0] / (M_PI * 2); | ||
|
||
for (int hop = 0; hop < this->num_hops; hop++) | ||
{ | ||
float frequency = this->frequency->out[0][0]; | ||
|
||
for (int frame = 0; frame < this->fft_size; frame++) | ||
{ | ||
if (frame < this->num_bins) | ||
{ | ||
float phase_accum = phase + (increment_per_bin * frame / num_frames); | ||
out[hop][frame] = input->out[hop][frame] * (sinf(M_PI * 2 * phase_accum) * 2 + 1.0); | ||
} | ||
else | ||
{ | ||
out[hop][frame] = input->out[hop][frame]; | ||
} | ||
|
||
phase += frequency / this->graph->get_sample_rate(); | ||
while (phase > 1.0) | ||
{ | ||
phase -= 1.0; | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters