Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

56 fix au validation #58

Merged
merged 13 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions FrequencyShift/Source/FrequencyShiftAudioPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ class Factory : public SpectralAudioPlugin::DependencyFactory {
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
// To debug AUval
//#if DEBUG
// while (!Process::isRunningUnderDebugger())
// {
// Thread::sleep(250);
// }
//#endif

return new SpectralAudioPlugin(
new Factory()
);
Expand Down
7 changes: 7 additions & 0 deletions PhaseLock/Source/PhaseLockAudioPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,12 @@ class Factory : public SpectralAudioPlugin::DependencyFactory {
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
// To debug AUval
//#if DEBUG
// while (!Process::isRunningUnderDebugger())
// {
// Thread::sleep(250);
// }
//#endif
return new SpectralAudioPlugin(new Factory());
}
7 changes: 7 additions & 0 deletions SinusoidalShapedFilter/Source/SSFAudioPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,12 @@ class Factory : public SpectralAudioPlugin::DependencyFactory {
// This creates new instances of the plugin..
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
// To debug AUval
//#if DEBUG
// while (!Process::isRunningUnderDebugger())
// {
// Thread::sleep(250);
// }
//#endif
return new SpectralAudioPlugin(new Factory());
}
4 changes: 4 additions & 0 deletions SinusoidalShapedFilter/Source/SSFInteractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ std::unique_ptr<StandardFFTProcessor> SSFInteractor::createSpectralProcess(
}

void SSFInteractor::onFftSizeChanged(){
if(m_wavetable == nullptr) {
m_wavetable = std::make_shared<Table<float> >(getFftSize() / 2, 1, 1);
}

m_wavetable->resize(getFftSize() / 2);
}
25 changes: 25 additions & 0 deletions auValidate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Exit early if any command fails
set -e

# Frequency shifter
auval -strict -v aumf SPFS STPW

# Bin Scrambler
auval -strict -v aumf SPBS STPW

# Frequency magnet
auval -strict -v aumf SPFM STPW

# Morph
auval -strict -v aumf SPMO STPW

# Phase lock
auval -strict -v aumf SPPL STPW

# Sinusoidal Sharped Filer
auval -strict -v aumf SPSS STPW

# Spectral Gate
auval -strict -v aumf SPSG STPW
2 changes: 2 additions & 0 deletions shared/FftSwitcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class FftSwitcherThread: public Thread {
/// Thread
/// Do not call this directly. Instead call `switchFftSize` or `switchOverlapCount`
void run() override {
if (threadShouldExit()) { return; }

if(m_switchFft) {
m_switchFft = false;
m_fftSwitcher->switchFftSize();
Expand Down
1 change: 1 addition & 0 deletions shared/FftThread.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: check if this class is unused

#include "FftThread.h"

Expand Down
85 changes: 52 additions & 33 deletions shared/SpectralAudioPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,11 @@ SpectralAudioPlugin::SpectralAudioPlugin(
m_versionCheckThread(VersionCode, "https://www.andrewreeman.com/spectral_suite_publish.json"),
m_dependencyFactory(dependencies)
{


//FileLogger* logger = new FileLogger(FileLogger::getSystemLogFileFolder().getChildFile("logs")
// .getChildFile("spectral_suite" + Time::getCurrentTime().formatted("%Y-%m-%d_%H-%M-%S"))
// .withFileExtension(".log")
// .getNonexistentSibling(),
// "Log started", 0);

File logFile = FileLogger::getSystemLogFileFolder().getChildFile("SpectralSuite").getChildFile("spectral_suite.log");
m_logger = std::unique_ptr<FileLogger>(
new FileLogger(
logFile,
"Log started"
)
);
Logger::setCurrentLogger(m_logger.get());
this->initialiseParameters();
}

SpectralAudioPlugin::~SpectralAudioPlugin()
{
Logger::setCurrentLogger(nullptr);
if(this->m_versionCheckThread.isThreadRunning()) {
this->m_versionCheckThread.stopThread(20);
}
Expand All @@ -67,6 +50,9 @@ SpectralAudioPlugin::~SpectralAudioPlugin()
/* FFT Switcher methods */
void SpectralAudioPlugin::switchFftSize()
{
if (isInvalidFftModificationState()) { return; }
// if (m_audioProcessorInteractor->isPreparingToPlay()) { return; }

setFftSize(m_fftSizeChoiceAdapter.fftSize());

if(getActiveEditor() != nullptr) {
Expand All @@ -76,6 +62,8 @@ void SpectralAudioPlugin::switchFftSize()
}
void SpectralAudioPlugin::switchFftStyle()
{
if (isInvalidFftModificationState()) { return; }

FftStyle style = m_fftStyleChoiceAdapter.fftStyle();
switch(style) {
case FftStyle::DEFAULT:
Expand All @@ -95,24 +83,52 @@ void SpectralAudioPlugin::switchFftStyle()
}

void SpectralAudioPlugin::switchOverlapCount() {
if (isInvalidFftModificationState()) { return; }

int overlaps = m_fftOverlapsChoiceAdapter.overlapCount();
m_audioProcessorInteractor->setNumOverlaps(overlaps);

const int hopSize = m_audioProcessorInteractor->getHopSize();
for(std::vector<float>& output : m_output)
{
output.resize(hopSize, 0.f);
}
for(std::vector<float>& input : m_input)
{
input.resize(hopSize, 0.f);
}


for(std::vector<float>& output : m_output)
{
if (output.size() == hopSize)
{
continue;
}

if (isInvalidFftModificationState()) { return; }
// Because we switch overlaps on a different thread m_output might be empty when we resize
// Which means we no longer own the output vector
// output vector expected to only be empty if we have been destructed
// TODO: use mutex when modifying fft buffers
if (!m_output.empty() && !output.empty())
{
output.resize(hopSize, 0.f);
}
}

for(std::vector<float>& input : m_input)
{
if (input.size() == hopSize)
{
continue;
}

if (isInvalidFftModificationState()) { return; }
if (!m_input.empty() && !input.empty())
{
input.resize(hopSize, 0.f);
}
}

setLatencySamples(m_audioProcessorInteractor->getFftSize() + hopSize);
}


void SpectralAudioPlugin::switchFftWindowType() {
if (isInvalidFftModificationState()) { return; }

auto windowType = m_fftWindowChoiceAdapter.fftWindow();
m_audioProcessorInteractor->setWindowType(windowType);
}
Expand Down Expand Up @@ -184,6 +200,7 @@ void SpectralAudioPlugin::prepareToPlay (double sampleRate, int)
{
m_output.clear();
m_input.clear();

for (
int outputChannelCount = getBusesLayout().getMainOutputChannels();
outputChannelCount > 0;
Expand All @@ -193,10 +210,11 @@ void SpectralAudioPlugin::prepareToPlay (double sampleRate, int)
m_output.push_back(std::vector<float>());
m_input.push_back(std::vector<float>());
}

const int fftSize = m_fftSizeChoiceAdapter.fftSize();
m_audioProcessorInteractor->prepareToPlay(fftSize, (int)sampleRate, getBusesLayout().getMainOutputChannels());
setFftSize(fftSize);

const int fftSize = m_fftSizeChoiceAdapter.fftSize();
m_audioProcessorInteractor->prepareToPlay(fftSize, (int)sampleRate, getBusesLayout().getMainOutputChannels());

setFftSize(fftSize);
}

void SpectralAudioPlugin::releaseResources()
Expand Down Expand Up @@ -232,9 +250,9 @@ void SpectralAudioPlugin::emptyOutputs() {

void SpectralAudioPlugin::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiBuffer)
{
if (m_fftSwitcher.isThreadRunning()) {
if (m_fftSwitcher.isThreadRunning()) {
m_internalBufferReadWriteIndex = 0;
return;
return;
}

if (m_fftSizeChoiceAdapter.shouldChangeFftSize()) {
Expand Down Expand Up @@ -329,6 +347,8 @@ void SpectralAudioPlugin::setStateInformation (const void* data, int sizeInBytes
}

void SpectralAudioPlugin::setFftSize(int size) {
if (isInvalidFftModificationState()) { return; }

m_audioProcessorInteractor->setFftSize(size);
const int hopSize = m_audioProcessorInteractor->getHopSize();

Expand All @@ -351,7 +371,6 @@ void SpectralAudioPlugin::checkForUpdates(VersionCheckThread::Listener* listener
}

void SpectralAudioPlugin::initialiseParameters() {

parameters = m_dependencyFactory->createParams(this);
m_audioProcessorInteractor = m_dependencyFactory->createProcessor(this);

Expand Down
24 changes: 12 additions & 12 deletions shared/SpectralAudioPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
#include "ParameterContainerComponentFactory.h"
#include "PluginParameters.h"

//==============================================================================
/**
*/

class SpectralAudioPluginUi;

class SpectralAudioPlugin : public AudioProcessor, private FftSwitcherThread::FftSwitcher
Expand All @@ -30,8 +26,6 @@ class SpectralAudioPlugin : public AudioProcessor, private FftSwitcherThread::Ff
virtual ~DependencyFactory(){};

virtual std::shared_ptr<PluginParameters> createParams(SpectralAudioPlugin* plugin) = 0;
// virtual std::unique_ptr<ParameterContainerComponent> createUi(SpectralAudioPlugin* plugin) = 0;
// virtual std::unique_ptr<ParameterContainerComponent> createUi(SpectralAudioPlugin* plugin) = 0;
virtual ParameterContainerComponent* createUi(SpectralAudioPlugin* plugin) = 0;
virtual std::unique_ptr<SpectralAudioProcessorInteractor> createProcessor(SpectralAudioPlugin* plugin) = 0;
virtual Array<int> fftSizesToNotInclude() { return Array<int>(); };
Expand Down Expand Up @@ -107,19 +101,25 @@ class SpectralAudioPlugin : public AudioProcessor, private FftSwitcherThread::Ff
void emptyOutputs();
void setFftSize(int fftSize);
void initialiseParameters();

std::shared_ptr<PluginParameters> parameters;
// std::unique_ptr<ParameterContainerComponent> m_parameterUiComponent;
std::unique_ptr<SpectralAudioProcessorInteractor> m_audioProcessorInteractor;
bool isPreparingToPlay() const { return m_audioProcessorInteractor->isPreparingToPlay(); }
bool isInvalidFftModificationState() const {
return
m_fftSwitcher.threadShouldExit()
|| m_audioProcessorInteractor->isPreparingToPlay()
|| m_audioProcessorInteractor->isPlaying()
|| m_output.empty()
|| m_input.empty();
};

std::shared_ptr<PluginParameters> parameters;
std::unique_ptr<SpectralAudioProcessorInteractor> m_audioProcessorInteractor;

FftSizeChoiceAdapter m_fftSizeChoiceAdapter;
FftStyleChoiceAdapter m_fftStyleChoiceAdapter;
FftOverlapsChoiceAdapter m_fftOverlapsChoiceAdapter;
FftWindowChoiceAdapter m_fftWindowChoiceAdapter;
FftSwitcherThread m_fftSwitcher;

std::unique_ptr<FileLogger> m_logger;

// io buffers: TODO n chan
int m_internalBufferReadWriteIndex;
std::vector<std::vector<float>> m_input;
Expand Down
Loading