Skip to content

Commit

Permalink
Merge pull request #17 from GuitarML/feature-model-level-adjust
Browse files Browse the repository at this point in the history
Added optional level_adjust param to models for adjusting overall volume of model
  • Loading branch information
GuitarML authored Nov 27, 2020
2 parents 3e27b2d + 1aed4ca commit a568f13
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion models/bluej_clean_p0088.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion models/bluej_fullD_p0153.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions plugins/SmartAmp/SmartAmp.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<FILE id="h9gaSb" name="amp_clean.png" compile="0" resource="1" file="../../resources/amp_clean.png"/>
<FILE id="R8YnqS" name="amp_lead.png" compile="0" resource="1" file="../../resources/amp_lead.png"/>
<FILE id="u62tqr" name="amp_off.png" compile="0" resource="1" file="../../resources/amp_off.png"/>
<FILE id="Qawvu2" name="bluej_clean_p0088.json" compile="0" resource="1"
<FILE id="XoWq0R" name="bluej_clean_p0088.json" compile="0" resource="1"
file="../../models/bluej_clean_p0088.json"/>
<FILE id="duZ4fD" name="bluej_fullD_p0153.json" compile="0" resource="1"
<FILE id="ov9ufS" name="bluej_fullD_p0153.json" compile="0" resource="1"
file="../../models/bluej_fullD_p0153.json"/>
<FILE id="jmOgHo" name="knob_silver.png" compile="0" resource="1" file="../../resources/knob_silver.png"/>
<FILE id="Kaw2lp" name="led_blue_off.png" compile="0" resource="1"
Expand Down
14 changes: 9 additions & 5 deletions plugins/SmartAmp/Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ void WaveNetVaAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuff
// Master Volume
buffer.applyGain(ampMaster);

if (amp_lead == 1 && custom_tone == 0 ) {// add extra clean boost because this particular clean model is very quiet
buffer.applyGain(8.0);
// Apply levelAdjust from model param (for adjusting quiet or loud models)
if ( waveNet.levelAdjust != 0.0 ) {
buffer.applyGain(waveNet.levelAdjust);
}

}
Expand Down Expand Up @@ -206,25 +207,27 @@ void WaveNetVaAudioProcessor::loadConfigAmp()

if (amp_lead == 0) { // if lead on
WaveNetLoader loader2(BinaryData::bluej_fullD_p0153_json);
float levelAdjust = loader2.levelAdjust;
int numChannels2 = loader2.numChannels;
int inputChannels2 = loader2.inputChannels;
int outputChannels2 = loader2.outputChannels;
int filterWidth2 = loader2.filterWidth;
std::vector<int> dilations2 = loader2.dilations;
std::string activation2 = loader2.activation;
waveNet.setParams(inputChannels2, outputChannels2, numChannels2, filterWidth2, activation2,
dilations2);
dilations2, levelAdjust);
loader2.loadVariables(waveNet);
} else { // else if clean on
WaveNetLoader loader2(BinaryData::bluej_clean_p0088_json);
float levelAdjust = loader2.levelAdjust;
int numChannels2 = loader2.numChannels;
int inputChannels2 = loader2.inputChannels;
int outputChannels2 = loader2.outputChannels;
int filterWidth2 = loader2.filterWidth;
std::vector<int> dilations2 = loader2.dilations;
std::string activation2 = loader2.activation;
waveNet.setParams(inputChannels2, outputChannels2, numChannels2, filterWidth2, activation2,
dilations2);
dilations2, levelAdjust);
loader2.loadVariables(waveNet);
}

Expand All @@ -235,14 +238,15 @@ void WaveNetVaAudioProcessor::loadConfig(File configFile)
{
this->suspendProcessing(true);
WaveNetLoader loader(dummyVar, configFile);
float levelAdjust = loader.levelAdjust;
int numChannels = loader.numChannels;
int inputChannels = loader.inputChannels;
int outputChannels = loader.outputChannels;
int filterWidth = loader.filterWidth;
std::vector<int> dilations = loader.dilations;
std::string activation = loader.activation;
waveNet.setParams(inputChannels, outputChannels, numChannels, filterWidth, activation,
dilations);
dilations, levelAdjust);
loader.loadVariables(waveNet);
this->suspendProcessing(false);
}
Expand Down
1 change: 0 additions & 1 deletion plugins/SmartAmp/Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class WaveNetVaAudioProcessor : public AudioProcessor

private:
WaveNet waveNet; // Amp Clean Channel / Lead Channel

Eq4Band eq4band; // Amp EQ


Expand Down
3 changes: 2 additions & 1 deletion plugins/SmartAmp/Source/WaveNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ void WaveNet::setWeight(std::vector<float> W, int layerIdx, std::string name)

void WaveNet::setParams(int newInputChannels, int newOutputChannels, int newConvChannels,
int newFilterWidth, std::string newActivation,
std::vector<int> newDilations)
std::vector<int> newDilations, float levelAdjust_in)
{
levelAdjust = levelAdjust_in;
inputChannels = newInputChannels;
outputChannels = newOutputChannels;
activation = newActivation;
Expand Down
5 changes: 3 additions & 2 deletions plugins/SmartAmp/Source/WaveNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class WaveNet
void setWeight(std::vector<float> W, int layerIdx, std::string name);
void setParams(int newInputChannels, int newOutputChannels, int newConvChannels,
int newFilterWidth, std::string newActivation,
std::vector<int> newDilations);

std::vector<int> newDilations, float levelAdjust_in);
float levelAdjust = 0.0;

private:
ConvolutionStack convStack;
ConvolutionLayer inputLayer;
Expand Down
9 changes: 8 additions & 1 deletion plugins/SmartAmp/Source/WaveNetLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ WaveNetLoader::WaveNetLoader(var jsonFile)
{
// Edit this line to point to your binary json file in project resources
config = JSON::parse(jsonFile);

if (config.hasProperty("level_adjust"))
{
levelAdjust = config["level_adjust"];
}
numChannels = config["residual_channels"];
inputChannels = config["input_channels"];
outputChannels = config["output_channels"];
Expand All @@ -30,6 +33,10 @@ WaveNetLoader::WaveNetLoader(var jsonFile, File configFile)
// Edit this line to point to your binary json file in project resources
config = JSON::parse(configFile);

if (config.hasProperty("level_adjust"))
{
levelAdjust = config["level_adjust"];
}
numChannels = config["residual_channels"];
inputChannels = config["input_channels"];
outputChannels = config["output_channels"];
Expand Down
1 change: 1 addition & 0 deletions plugins/SmartAmp/Source/WaveNetLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class WaveNetLoader
public:
WaveNetLoader(var jsonFile);
WaveNetLoader(var jsonFile, File configFile);
float levelAdjust;
int numChannels;
int inputChannels;
int outputChannels;
Expand Down

0 comments on commit a568f13

Please sign in to comment.