Skip to content

Commit

Permalink
make metronome tempo utilize the float parameters for nice display wh…
Browse files Browse the repository at this point in the history
…en changing
  • Loading branch information
xconverge committed Dec 29, 2024
1 parent 3f33c10 commit 3a0bfc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions Software/GuitarPedal/Effect-Modules/metro_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ static const ParameterMetaData s_metaData[s_paramCount] = {{
name : "Tempo",
valueType : ParameterValueType::Float,
valueBinCount : 0,
defaultValue : {.float_value = 0.5f},
defaultValue : {.float_value = 165.f},
knobMapping : 0,
midiCCMapping : 23
midiCCMapping : 23,
minValue : minTempo,
maxValue : maxTempo
},
{
name : "Mix",
Expand Down Expand Up @@ -115,13 +117,14 @@ void MetroModule::Init(float sample_rate) {
m_env.SetSustainLevel(.5);

// Set metronome
const float freq = tempo_to_freq(DefaultTempoBpm);
m_bpm = static_cast<uint32_t>(GetParameterAsFloat(0));
const float freq = tempo_to_freq(m_bpm);
m_metro.Init(freq, sample_rate);
}

void MetroModule::ParameterChanged(int parameter_id) {
if (parameter_id == 0) {
m_bpm = minTempo + GetParameterAsFloat(0) * static_cast<float>(maxTempo - minTempo);
m_bpm = static_cast<uint32_t>(GetParameterAsFloat(0));
}
}

Expand Down
1 change: 0 additions & 1 deletion Software/GuitarPedal/Effect-Modules/metro_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class Metronome {
};

enum TimeSignature { meter4x4 = 0, meter3x4 = 1, meter2x4 = 2 };
const uint16_t DefaultTempoBpm = 120;

class MetroModule : public BaseEffectModule {
public:
Expand Down

0 comments on commit 3a0bfc2

Please sign in to comment.