Skip to content

Commit

Permalink
+ global Analog slider
Browse files Browse the repository at this point in the history
  • Loading branch information
psemiletov committed Aug 11, 2024
1 parent f1f9d5a commit 6f2cbde
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 48 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,16 @@ This installs LV2 and VSTi versions of the plugin to ``/usr/local/lib/LV2`` and
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
```

Drumlabooh uses:
## Notes for packagers/maintainers

By default, Drumlabooh cmake file fetches and installs the all drumkits from https://github.com/psemiletov/drum_sklad. You can turn this behavior off using ```cmake .. -DINSTALLKITS=OFF``` option, and make the separated data package with drum kits from
```https://github.com/psemiletov/drum_sklad/archive/refs/heads/main.zip```


## Drumlabooh uses:

[JUCE](https://juce.com) (GPL3)

[speex_resampler_cpp](https://github.com/libaudioverse/speex_resampler_cpp) (Public Domain + Speex License, Copyright (C) 2007 Jean-Marc Valin)
[speex_resampler_cpp](https://github.com/libaudioverse/speex_resampler_cpp) (Public Domain + Speex License, Copyright (C) 2007 Jean-Marc Valin)


52 changes: 46 additions & 6 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,6 @@ CAudioProcessorEditor::CAudioProcessorEditor (CAudioProcessor& parent, juce::Aud
bt_file_open.setSize (64, 48);




addAndMakeVisible (drumcells_viewer);


Expand Down Expand Up @@ -764,22 +762,53 @@ CAudioProcessorEditor::CAudioProcessorEditor (CAudioProcessor& parent, juce::Aud

#endif


//////////////NEW GLOBAL ANALOG
addAndMakeVisible (bt_global_analog_on);
bt_global_analog_on.setButtonText ("Analog");
//bt_ignore_midi_velocity.setTooltip ("If turned on, play first layer\n of multi-layered samples,\n and with the maximun velocity");
bt_global_analog_on.setSize (80, 48);
bt_global_analog_on.setTopLeftPosition (l_base_note.getX(), gr_options.getBottom() + YFILLER);

att_global_analog_on.reset (new juce::AudioProcessorValueTreeState::ButtonAttachment (valueTreeState, "global_analog_on", bt_global_analog_on));


addAndMakeVisible (sl_global_analog_amount);
sl_global_analog_amount.setTopLeftPosition (l_base_note.getX() + bt_global_analog_on.getWidth() + XFILLER, gr_options.getBottom() + YFILLER);
sl_global_analog_amount.setSize (192, 48);
sl_global_analog_amount.setRange (0.0f, 1.0f, 0.01f);
sl_global_analog_amount.setSliderStyle (juce::Slider::LinearHorizontal);
sl_global_analog_amount.setTextBoxStyle (juce::Slider::TextBoxBelow, false, 80, 20);
sl_global_analog_amount.setColour (juce::Slider::thumbColourId, juce::Colours::orange);


att_global_analog_amount.reset (new juce::AudioProcessorValueTreeState::SliderAttachment (valueTreeState, "global_analog_amount", sl_global_analog_amount));



//sl_global_analog_amount.setTooltip ("Pan");



//////////////

addAndMakeVisible (l_plugin_name);
l_plugin_name.setSize (180 + XFILLER, 48);
l_plugin_name.setTopLeftPosition (gr_options.getX(), gr_options.getBottom() + YFILLER);
l_plugin_name.setSize (180 + XFILLER, 36);
l_plugin_name.setTopLeftPosition (gr_options.getX(), bt_global_analog_on.getBottom() + YFILLER);
l_plugin_name.setText (juce::CharPointer_UTF8("DRUMLABOOH"), juce::NotificationType::dontSendNotification);
l_plugin_name.setFont (f_logo);

addAndMakeVisible (l_plugin_author);
l_plugin_author.setSize (180 + XFILLER, 24);
l_plugin_author.setTopLeftPosition (l_plugin_name.getX(), l_plugin_name.getBottom());
l_plugin_author.setTopLeftPosition (gr_options.getX() + l_plugin_name.getWidth() + XFILLER, /*l_plugin_name.getBottom()*/bt_global_analog_on.getBottom() + YFILLER);

// l_plugin_author.setTopLeftPosition (l_plugin_name.getX(), /*l_plugin_name.getBottom()*/bt_global_analog_on.getBottom() + YFILLER);
l_plugin_author.setText (juce::CharPointer_UTF8("by Peter Semiletov"), juce::NotificationType::dontSendNotification);
//l_plugin_author.setFont (f_logo);

addAndMakeVisible (hl_homepage);
hl_homepage.setSize (280 + XFILLER, 24);
hl_homepage.setTopLeftPosition (l_plugin_author.getX() + XFILLER, l_plugin_author.getBottom() + YFILLER);
hl_homepage.setTopLeftPosition (gr_options.getX() + XFILLER, l_plugin_author.getBottom() + YFILLER);
hl_homepage.setURL (juce::URL("https://psemiletov.github.io/drumlabooh"));
hl_homepage.setButtonText ("psemiletov.github.io/drumlabooh");
hl_homepage.setFont (f_sitelink, false, juce::Justification::left);
Expand All @@ -797,6 +826,17 @@ CAudioProcessorEditor::CAudioProcessorEditor (CAudioProcessor& parent, juce::Aud

CAudioProcessorEditor::~CAudioProcessorEditor()
{

att_global_analog_amount = nullptr;
att_ignore_midi_velocity = nullptr;
att_global_analog_on = nullptr;
att_base_note = nullptr;

#ifndef MULTICHANNEL

att_pan_mode = nullptr;

#endif
}

//==============================================================================
Expand Down
9 changes: 8 additions & 1 deletion Source/PluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ class CAudioProcessorEditor: public juce::AudioProcessorEditor,
juce::ToggleButton bt_ignore_midi_velocity;


std::unique_ptr<juce::AudioProcessorValueTreeState::ButtonAttachment> att_global_analog_on = nullptr;
juce::ToggleButton bt_global_analog_on;

std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> att_global_analog_amount = nullptr;
juce::Slider sl_global_analog_amount;


#ifndef MULTICHANNEL

std::unique_ptr<juce::AudioProcessorValueTreeState::ComboBoxAttachment> att_pan_mode;
Expand Down Expand Up @@ -227,7 +234,7 @@ class CAudioProcessorEditor: public juce::AudioProcessorEditor,


juce::Font f_sitelink { 20.0f, juce::Font::bold};
juce::Font f_logo { 36.0f, juce::Font::bold};
juce::Font f_logo { 30.0f, juce::Font::bold};

juce::Font f_kitname_font { 20.0f, juce::Font::bold};
juce::ImageComponent kit_image;
Expand Down
122 changes: 95 additions & 27 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
2023-24, Peter Semiletov
*/

#include <random>


#include "PluginProcessor.h"
#include "PluginEditor.h"

Expand All @@ -12,6 +15,7 @@

//extern juce::AudioFormatManager *formatManager;

extern std::mt19937 rnd_mt19937;


juce::AudioProcessorValueTreeState::ParameterLayout CAudioProcessor::createParameterLayout()
Expand Down Expand Up @@ -118,6 +122,18 @@ juce::AudioProcessorValueTreeState::ParameterLayout CAudioProcessor::createParam
0.001f));
}



layout.add (std::make_unique<juce::AudioParameterFloat> ("global_analog_on", // parameterID
"global_analog_on", // parameter name
0, 1, 0));

layout.add (std::make_unique<juce::AudioParameterFloat> ("global_analog_amount",
"global_analog_amount",
juce::NormalisableRange<float> (0.001f, 1.0f, 0.001f), // parameter range
0.001f));


return layout;
}

Expand Down Expand Up @@ -160,6 +176,9 @@ CAudioProcessor::CAudioProcessor()

//panner_mode = parameters.getRawParameterValue ("panner_mode");
ignore_midi_velocity = parameters.getRawParameterValue ("ignore_midi_velocity");
global_analog_on = parameters.getRawParameterValue ("global_analog_on");
global_analog_amount = parameters.getRawParameterValue ("global_analog_amount");

}


Expand Down Expand Up @@ -189,24 +208,29 @@ CAudioProcessor::CAudioProcessor()

for (size_t i = 0; i < 36; i++)
{
vols[i] = parameters.getRawParameterValue ("vol" + std::to_string(i));
pans[i] = parameters.getRawParameterValue ("pan" + std::to_string(i));
mutes[i] = parameters.getRawParameterValue ("mute" + std::to_string(i));
vols[i] = parameters.getRawParameterValue ("vol" + std::to_string(i));
pans[i] = parameters.getRawParameterValue ("pan" + std::to_string(i));
mutes[i] = parameters.getRawParameterValue ("mute" + std::to_string(i));

lps[i] = parameters.getRawParameterValue ("lp" + std::to_string(i));
lp_cutoff[i] = parameters.getRawParameterValue ("lp_cutoff" + std::to_string(i));
lp_reso[i] = parameters.getRawParameterValue ("lp_reso" + std::to_string(i));
lps[i] = parameters.getRawParameterValue ("lp" + std::to_string(i));
lp_cutoff[i] = parameters.getRawParameterValue ("lp_cutoff" + std::to_string(i));
lp_reso[i] = parameters.getRawParameterValue ("lp_reso" + std::to_string(i));

hps[i] = parameters.getRawParameterValue ("hp" + std::to_string(i));
hp_cutoff[i] = parameters.getRawParameterValue ("hp_cutoff" + std::to_string(i));
hp_reso[i] = parameters.getRawParameterValue ("hp_reso" + std::to_string(i));
hps[i] = parameters.getRawParameterValue ("hp" + std::to_string(i));
hp_cutoff[i] = parameters.getRawParameterValue ("hp_cutoff" + std::to_string(i));
hp_reso[i] = parameters.getRawParameterValue ("hp_reso" + std::to_string(i));

analog[i] = parameters.getRawParameterValue ("analog" + std::to_string(i));
analog_amount[i] = parameters.getRawParameterValue ("analog_amount" + std::to_string(i));
}

panner_mode = parameters.getRawParameterValue ("panner_mode");
ignore_midi_velocity = parameters.getRawParameterValue ("ignore_midi_velocity");

global_analog_on = parameters.getRawParameterValue ("global_analog_on");
global_analog_amount = parameters.getRawParameterValue ("global_analog_amount");


}

#endif
Expand Down Expand Up @@ -517,6 +541,14 @@ void CAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::Midi
{
float fl = l->channel_data[0][l->sample_offset++];

/*
if (s->use_random_noice)
{
std::uniform_int_distribution <> distrib (-0.001f, 0.001f);
fl = fl + distrib (rnd_mt19937);
}
*/
// float fl = 0.5f;

//DSP
Expand Down Expand Up @@ -548,14 +580,28 @@ void CAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::Midi
}

//NEW
// if (s->layer_index_mode != LAYER_INDEX_MODE_NOVELOCITY)
fl *= s->velocity;
if (s->layer_index_mode != LAYER_INDEX_MODE_NOVELOCITY)
fl *= s->velocity;

channel_data[drum_sample_index][out_buf_offs] = fl;
}


if (*global_analog_on > 0.5f)
{
channel_data[drum_sample_index][out_buf_offs] = warmify (channel_data[0][out_buf_offs],*(global_analog_amount));
// channel_data[1][out_buf_offs] = warmify (channel_data[1][out_buf_offs],*(global_analog_amount));
}


}
}






}
//std::cout << "CAudioProcessor::processBlock -6 " << std::endl;
//}
}
Expand Down Expand Up @@ -673,7 +719,8 @@ void CAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::Midi
//for each sample out_buf_offs
for (int out_buf_offs = 0; out_buf_offs < out_buf_length; out_buf_offs++)
//for each drum instrument
for (int drum_sample_index = 0; drum_sample_index < v_samples_size; drum_sample_index++)
{
for (int drum_sample_index = 0; drum_sample_index < v_samples_size; drum_sample_index++)
{
CDrumSample *s = drumkit->v_samples[drum_sample_index];

Expand Down Expand Up @@ -715,6 +762,16 @@ void CAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::Midi

//take mono audio data from the current layer with incremented offset
float fl = l->channel_data[0][l->sample_offset++];

/*
if (s->use_random_noice)
{
std::uniform_int_distribution <> distrib (-0.001f, 0.001f);
fl = fl + distrib (rnd_mt19937);
}
*/

float fr = fl;

//DSP
Expand Down Expand Up @@ -784,28 +841,39 @@ void CAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::Midi



float coef_right;
float coef_left;
float coef_right = 0;
float coef_left = 0;


//if (s->layer_index_mode != LAYER_INDEX_MODE_NOVELOCITY)
//{
coef_right = pan_right * vol * s->velocity;
coef_left = pan_left * vol * s->velocity;
//}
/* else
{
coef_right = pan_right * vol;
coef_left = pan_left * vol;
}
*/
if (s->layer_index_mode != LAYER_INDEX_MODE_NOVELOCITY)
{
coef_right = pan_right * vol * s->velocity;
coef_left = pan_left * vol * s->velocity;
}
else
{
coef_right = pan_right * vol;
coef_left = pan_left * vol;
}




channel_data[0][out_buf_offs] += fl * coef_left;
channel_data[1][out_buf_offs] += fl * coef_right;
}


}



if (*global_analog_on > 0.5f)
{
channel_data[0][out_buf_offs] = warmify (channel_data[0][out_buf_offs],*(global_analog_amount));
channel_data[1][out_buf_offs] = warmify (channel_data[1][out_buf_offs],*(global_analog_amount));
}

}
//std::cout << "CAudioProcessor::processBlock -6 " << std::endl;
}

Expand Down
3 changes: 3 additions & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class CAudioProcessor: public juce::AudioProcessor

std::atomic<float>* ignore_midi_velocity = nullptr;


std::atomic<float>* global_analog_on = nullptr;
std::atomic<float>* global_analog_amount = nullptr;

//Filters

Expand Down
Loading

0 comments on commit 6f2cbde

Please sign in to comment.