Save Insert FX parameters into performance

pull/764/head
jnonis 7 months ago
parent 7f110b284d
commit 7c8dc6f147
  1. 45
      src/effect_base.cpp
  2. 9
      src/effect_base.h
  3. 4
      src/effect_chorus.h
  4. 2
      src/effect_delay.cpp
  5. 4
      src/effect_delay.h
  6. 5
      src/effect_lpf.h
  7. 14
      src/minidexed.cpp
  8. 70
      src/performanceconfig.cpp
  9. 7
      src/performanceconfig.h

@ -1,5 +1,8 @@
#include <circle/logger.h>
#include "effect_base.h"
LOGMODULE ("AudioEffect");
AudioEffect::AudioEffect(float32_t samplerate)
{
this->samplerate = samplerate;
@ -24,6 +27,30 @@ unsigned AudioEffect::getId()
return EFFECT_NONE;
}
void AudioEffect::setParameters(std::vector<unsigned> params)
{
LOGNOTE("setParameters size: %d", params.size());
for (size_t i = 0; i < params.size(); i++)
{
this->setParameter(i, params[i]);
LOGNOTE("Param %d: %d", i, params[i]);
}
}
std::vector<unsigned> AudioEffect::getParameters()
{
LOGNOTE("getParameters");
size_t len = getParametersSize();
LOGNOTE("sizeof: %d", len);
std::vector<unsigned> params;
for (size_t i = 0; i < len; i++)
{
params.push_back(getParameter(i));
LOGNOTE("Param %d: %d", i, params[i]);
}
return params;
}
void AudioEffect::process(const float32_t* inblock, float32_t* outblock, uint16_t len)
{
// Mono process
@ -35,17 +62,20 @@ void AudioEffect::process(const float32_t* inblock, float32_t* outblock, uint16_
void AudioEffect::process(const float32_t* inblockL, const float32_t* inblockR, float32_t* outblockL, float32_t* outblockR, uint16_t len)
{
if (bypass) {
if (inblockL != outblockL || inblockR != outblockR) {
// if input and output buffers are different we should copy the content
for (uint16_t i=0; i < len; i++)
{
outblockL[i] = inblockL[i];
outblockR[i] = inblockR[i];
}
}
return;
}
doProcess(inblockL, inblockR, outblockL, outblockR, len);
}
void AudioEffect::doProcess(const float32_t* inblockL, const float32_t* inblockR, float32_t* outblockL, float32_t* outblockR, uint16_t len) {
for (uint16_t i=0; i < len; i++)
{
outblockL[i] = inblockL[i];
outblockR[i] = inblockR[i];
}
}
AudioEffectNone::AudioEffectNone(float32_t samplerate) : AudioEffect(samplerate)
@ -58,11 +88,6 @@ AudioEffectNone::~AudioEffectNone()
void AudioEffectNone::doProcess(const float32_t* inblockL, const float32_t* inblockR, float32_t* outblockL, float32_t* outblockR, uint16_t len)
{
for (uint16_t i=0; i < len; i++)
{
outblockL[i] = inblockL[i];
outblockR[i] = inblockR[i];
}
}
unsigned AudioEffectNone::getId()

@ -3,6 +3,7 @@
//#include <stdint.h>
#include <arm_math.h>
#include <vector>
#define EFFECT_NONE 0
#define EFFECT_CHORUS 1
@ -19,20 +20,28 @@ public:
bool getBypass();
virtual unsigned getId();
virtual void setParameter(unsigned param, unsigned value)
{
}
virtual unsigned getParameter(unsigned param)
{
return 0;
}
void setParameters(std::vector<unsigned> params);
std::vector<unsigned> getParameters();
void process(const float32_t* inblockL, float32_t* outblockL, uint16_t len);
void process(const float32_t* inblockL, const float32_t* inblockR, float32_t* outblockL, float32_t* outblockR, uint16_t len);
protected:
bool bypass = false;
float32_t samplerate;
virtual size_t getParametersSize()
{
return 0;
}
virtual void doProcess(const float32_t* inblockL, const float32_t* inblockR, float32_t* outblockL, float32_t* outblockR, uint16_t len);
};

@ -36,6 +36,10 @@ public:
unsigned getChorusIIRate();
void setChorusIIRate(unsigned int rate);
protected:
virtual size_t getParametersSize()
{
return sizeof(AudioEffectChorus::Param);
}
virtual void doProcess(const float32_t* inblockL, const float32_t* inblockR, float32_t* outblockL, float32_t* outblockR, uint16_t len);
private:

@ -19,7 +19,7 @@ AudioEffectDelay::AudioEffectDelay(float32_t samplerate) : AudioEffect(samplerat
this->timeL = 0.36f;
this->timeR = 0.36f;
this->feedback = 0.3f;
this->feedback = 0.5f;
}
AudioEffectDelay::~AudioEffectDelay()

@ -25,6 +25,10 @@ public:
virtual void setParameter(unsigned param, unsigned value);
virtual unsigned getParameter(unsigned param);
protected:
virtual size_t getParametersSize()
{
return sizeof(AudioEffectDelay::Param);
}
virtual void doProcess(const float32_t* inblockL, const float32_t* inblockR, float32_t* outblockL, float32_t* outblockR, uint16_t len);
private:
size_t bufferSize;

@ -88,6 +88,11 @@ public:
}
protected:
virtual size_t getParametersSize()
{
return sizeof(AudioEffectLPF::Param);
}
virtual void doProcess(const float32_t* inblockL, const float32_t* inblockR, float32_t* outblockL, float32_t* outblockR, uint16_t len)
{
for (int i = 0; i < len; i++) {

@ -1308,6 +1308,14 @@ bool CMiniDexed::DoSavePerformance (void)
m_PerformanceConfig.SetMIDIChannel (m_nMIDIChannel[nTG], nTG);
m_PerformanceConfig.SetVolume (m_nVolume[nTG], nTG);
m_PerformanceConfig.SetPan (m_nPan[nTG], nTG);
m_PerformanceConfig.SetInsertFX (m_InsertFX[nTG]->getId(), nTG);
LOGNOTE("Saving Insert FX Paramas");
std::vector<unsigned> pParams = m_InsertFX[nTG]->getParameters();
m_PerformanceConfig.SetInsertFXParams (pParams, nTG);
pParams.clear();
pParams.shrink_to_fit();
m_PerformanceConfig.SetDetune (m_nMasterTune[nTG], nTG);
m_PerformanceConfig.SetCutoff (m_nCutoff[nTG], nTG);
m_PerformanceConfig.SetResonance (m_nResonance[nTG], nTG);
@ -1751,6 +1759,12 @@ void CMiniDexed::LoadPerformanceParameters(void)
setPortamentoGlissando (m_PerformanceConfig.GetPortamentoGlissando (nTG), nTG);
setPortamentoTime (m_PerformanceConfig.GetPortamentoTime (nTG), nTG);
setInsertFXType(m_PerformanceConfig.GetInsertFX (nTG), nTG);
std::vector<unsigned> pParams = m_PerformanceConfig.GetInsertFXParams(nTG);
m_InsertFX[nTG]->setParameters(pParams);
pParams.clear();
pParams.shrink_to_fit();
m_nNoteLimitLow[nTG] = m_PerformanceConfig.GetNoteLimitLow (nTG);
m_nNoteLimitHigh[nTG] = m_PerformanceConfig.GetNoteLimitHigh (nTG);
m_nNoteShift[nTG] = m_PerformanceConfig.GetNoteShift (nTG);

@ -25,6 +25,7 @@
#include "mididevice.h"
#include <cstring>
#include <algorithm>
#include <sstream>
LOGMODULE ("Performance");
@ -132,6 +133,12 @@ bool CPerformanceConfig::Load (void)
PropertyName.Format ("Pan%u", nTG+1);
m_nPan[nTG] = m_Properties.GetNumber (PropertyName, 64);
PropertyName.Format ("InsertFX%u", nTG+1);
m_nInsertFX[nTG] = m_Properties.GetNumber (PropertyName, 0);
PropertyName.Format ("InsertFXParams%u", nTG+1);
m_nInsertFXParams[nTG] = m_Properties.GetString (PropertyName, "");
PropertyName.Format ("Detune%u", nTG+1);
m_nDetune[nTG] = m_Properties.GetSignedNumber (PropertyName, 0);
@ -249,6 +256,12 @@ bool CPerformanceConfig::Save (void)
PropertyName.Format ("Pan%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nPan[nTG]);
PropertyName.Format ("InsertFX%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nInsertFX[nTG]);
PropertyName.Format ("InsertFXParams%u", nTG+1);
m_Properties.SetString (PropertyName, m_nInsertFXParams[nTG].c_str());
PropertyName.Format ("Detune%u", nTG+1);
m_Properties.SetSignedNumber (PropertyName, m_nDetune[nTG]);
@ -361,6 +374,39 @@ unsigned CPerformanceConfig::GetPan (unsigned nTG) const
return m_nPan[nTG];
}
unsigned CPerformanceConfig::GetInsertFX (unsigned nTG) const
{
assert (nTG < CConfig::ToneGenerators);
return m_nInsertFX[nTG];
}
std::vector<unsigned> CPerformanceConfig::GetInsertFXParams (unsigned nTG) const
{
assert (nTG < CConfig::ToneGenerators);
LOGNOTE("Loading Insert FX Params");
std::string params = m_nInsertFXParams[nTG];
if (params.empty()) {
LOGNOTE("Empty Insert FX Params");
std::vector<unsigned int> empty;
return empty;
}
char delimiter = ',';
std::stringstream ss(params);
std::string temp;
std::vector<unsigned> tokens;
while (getline(ss, temp, delimiter))
{
LOGNOTE("Insert FX Params token: %s", temp.c_str());
tokens.push_back(stoi(temp));
}
LOGNOTE("Insert FX Params tokens size: %d\n", tokens.size());
LOGNOTE("Loaded Insert FX Params\n");
return tokens;
}
int CPerformanceConfig::GetDetune (unsigned nTG) const
{
assert (nTG < CConfig::ToneGenerators);
@ -433,6 +479,30 @@ void CPerformanceConfig::SetPan (unsigned nValue, unsigned nTG)
m_nPan[nTG] = nValue;
}
void CPerformanceConfig::SetInsertFX (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nInsertFX[nTG] = nValue;
}
void CPerformanceConfig::SetInsertFXParams (std::vector<unsigned> pParams, unsigned nTG)
{
LOGNOTE("SetInsertFXParams");
assert (nTG < CConfig::ToneGenerators);
LOGNOTE("SetInsertFXParams sizeof %d", pParams.size());
std::string params = "";
for (size_t i = 0; i < pParams.size(); i++)
{
if (i != 0) {
params += ",";
}
params += std::to_string(pParams[i]);
}
LOGNOTE("SetInsertFXParams %s", params.c_str());
m_nInsertFXParams[nTG] = params;
}
void CPerformanceConfig::SetDetune (int nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);

@ -26,6 +26,7 @@
#include "config.h"
#include <fatfs/ff.h>
#include <Properties/propertiesfatfsfile.h>
#include <vector>
#define NUM_VOICE_PARAM 156
#define NUM_PERFORMANCES 128
#define NUM_PERFORMANCE_BANKS 128
@ -48,6 +49,8 @@ public:
unsigned GetMIDIChannel (unsigned nTG) const; // 0 .. 15, omni, off
unsigned GetVolume (unsigned nTG) const; // 0 .. 127
unsigned GetPan (unsigned nTG) const; // 0 .. 127
unsigned GetInsertFX (unsigned nTG) const; // 0 .. X
std::vector<unsigned> GetInsertFXParams (unsigned nTG) const;
int GetDetune (unsigned nTG) const; // -99 .. 99
unsigned GetCutoff (unsigned nTG) const; // 0 .. 99
unsigned GetResonance (unsigned nTG) const; // 0 .. 99
@ -76,6 +79,8 @@ public:
void SetMIDIChannel (unsigned nValue, unsigned nTG);
void SetVolume (unsigned nValue, unsigned nTG);
void SetPan (unsigned nValue, unsigned nTG);
void SetInsertFX (unsigned nValue, unsigned nTG);
void SetInsertFXParams (std::vector<unsigned> pParams, unsigned nTG);
void SetDetune (int nValue, unsigned nTG);
void SetCutoff (unsigned nValue, unsigned nTG);
void SetResonance (unsigned nValue, unsigned nTG);
@ -157,6 +162,8 @@ private:
unsigned m_nMIDIChannel[CConfig::ToneGenerators];
unsigned m_nVolume[CConfig::ToneGenerators];
unsigned m_nPan[CConfig::ToneGenerators];
unsigned m_nInsertFX[CConfig::ToneGenerators];
std::string m_nInsertFXParams[CConfig::ToneGenerators];
int m_nDetune[CConfig::ToneGenerators];
unsigned m_nCutoff[CConfig::ToneGenerators];
unsigned m_nResonance[CConfig::ToneGenerators];

Loading…
Cancel
Save