make table once again respond to bank changes. support bank offset again.
This commit is contained in:
parent
0587e2f68a
commit
745adf8fde
|
@ -226,11 +226,12 @@ void FluidSynthModel::parameterChanged(const String& parameterID, float newValue
|
||||||
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
||||||
preset = castParam->get();
|
preset = castParam->get();
|
||||||
}
|
}
|
||||||
|
int bankOffset{fluid_synth_get_bank_offset(synth.get(), sfont_id)};
|
||||||
fluid_synth_program_select(
|
fluid_synth_program_select(
|
||||||
synth.get(),
|
synth.get(),
|
||||||
channel,
|
channel,
|
||||||
sfont_id,
|
sfont_id,
|
||||||
static_cast<unsigned int>(bank),
|
static_cast<unsigned int>(bankOffset + bank),
|
||||||
static_cast<unsigned int>(preset));
|
static_cast<unsigned int>(preset));
|
||||||
|
|
||||||
// fluid_synth_bank_select(synth.get(), channel, value);
|
// fluid_synth_bank_select(synth.get(), channel, value);
|
||||||
|
@ -255,12 +256,12 @@ void FluidSynthModel::parameterChanged(const String& parameterID, float newValue
|
||||||
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
||||||
preset = castParam->get();
|
preset = castParam->get();
|
||||||
}
|
}
|
||||||
// int bank{fluid_synth_get_bank_offset(synth.get(), sfont_id)};
|
int bankOffset{fluid_synth_get_bank_offset(synth.get(), sfont_id)};
|
||||||
fluid_synth_program_select(
|
fluid_synth_program_select(
|
||||||
synth.get(),
|
synth.get(),
|
||||||
channel,
|
channel,
|
||||||
sfont_id,
|
sfont_id,
|
||||||
static_cast<unsigned int>(bank),
|
static_cast<unsigned int>(bankOffset + bank),
|
||||||
static_cast<unsigned int>(preset));
|
static_cast<unsigned int>(preset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,13 @@ TableComponent::TableComponent(
|
||||||
|
|
||||||
// table.setMultipleSelectionEnabled (false);
|
// table.setMultipleSelectionEnabled (false);
|
||||||
valueTreeState.state.addListener(this);
|
valueTreeState.state.addListener(this);
|
||||||
|
valueTreeState.addParameterListener("bank", this);
|
||||||
|
valueTreeState.addParameterListener("preset", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TableComponent::~TableComponent() {
|
TableComponent::~TableComponent() {
|
||||||
|
valueTreeState.removeParameterListener("bank", this);
|
||||||
|
valueTreeState.removeParameterListener("preset", this);
|
||||||
valueTreeState.state.removeListener(this);
|
valueTreeState.state.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +118,6 @@ TableComponent::~TableComponent() {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void TableComponent::loadModelFrom(ValueTree& banks) {
|
void TableComponent::loadModelFrom(ValueTree& banks) {
|
||||||
rows.clear();
|
|
||||||
banksToPresets.clear();
|
banksToPresets.clear();
|
||||||
int banksChildren{banks.getNumChildren()};
|
int banksChildren{banks.getNumChildren()};
|
||||||
for(int bankIx{0}; bankIx<banksChildren; bankIx++) {
|
for(int bankIx{0}; bankIx<banksChildren; bankIx++) {
|
||||||
|
@ -132,7 +135,24 @@ void TableComponent::loadModelFrom(ValueTree& banks) {
|
||||||
banksToPresets.emplace(bankNum, move(row));
|
banksToPresets.emplace(bankNum, move(row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
repopulateTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TableComponent::parameterChanged(const String& parameterID, float newValue) {
|
||||||
|
// valueTreeState.getParameter
|
||||||
|
if (parameterID == "bank") {
|
||||||
|
repopulateTable();
|
||||||
|
} else if (parameterID == "preset") {
|
||||||
|
selectCurrentPreset();
|
||||||
|
// RangedAudioParameter *param {valueTreeState.getParameter("preset")};
|
||||||
|
// jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
|
||||||
|
// AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
||||||
|
// int value{castParam->get()};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TableComponent::repopulateTable() {
|
||||||
|
rows.clear();
|
||||||
RangedAudioParameter *param{valueTreeState.getParameter("bank")};
|
RangedAudioParameter *param{valueTreeState.getParameter("bank")};
|
||||||
jassert(dynamic_cast<AudioParameterInt*>(param) != nullptr);
|
jassert(dynamic_cast<AudioParameterInt*>(param) != nullptr);
|
||||||
AudioParameterInt* castParam{dynamic_cast<AudioParameterInt*>(param)};
|
AudioParameterInt* castParam{dynamic_cast<AudioParameterInt*>(param)};
|
||||||
|
@ -150,10 +170,8 @@ void TableComponent::loadModelFrom(ValueTree& banks) {
|
||||||
upperBound,
|
upperBound,
|
||||||
back_inserter(rows),
|
back_inserter(rows),
|
||||||
mem_fn(&BanksToPresets::value_type::second)
|
mem_fn(&BanksToPresets::value_type::second)
|
||||||
// [](BanksToPresets::value_type element){return element.second;}
|
// [](BanksToPresets::value_type element){return element.second;}
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
table.deselectAllRows();
|
table.deselectAllRows();
|
||||||
table.updateContent();
|
table.updateContent();
|
||||||
table.getHeader().setSortColumnId(0, true);
|
table.getHeader().setSortColumnId(0, true);
|
||||||
|
@ -161,17 +179,6 @@ void TableComponent::loadModelFrom(ValueTree& banks) {
|
||||||
table.repaint();
|
table.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableComponent::parameterChanged(const String& parameterID, float newValue) {
|
|
||||||
// valueTreeState.getParameter
|
|
||||||
if (parameterID == "preset") {
|
|
||||||
selectCurrentPreset();
|
|
||||||
// RangedAudioParameter *param {valueTreeState.getParameter("preset")};
|
|
||||||
// jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
|
|
||||||
// AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
|
||||||
// int value{castParam->get()};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TableComponent::valueTreePropertyChanged(
|
void TableComponent::valueTreePropertyChanged(
|
||||||
ValueTree& treeWhosePropertyHasChanged,
|
ValueTree& treeWhosePropertyHasChanged,
|
||||||
const Identifier& property) {
|
const Identifier& property) {
|
||||||
|
@ -323,7 +330,7 @@ void TableComponent::selectCurrentPreset() {
|
||||||
|
|
||||||
for (auto it = rows.begin(); it != rows.end(); ++it) {
|
for (auto it = rows.begin(); it != rows.end(); ++it) {
|
||||||
if(it->preset == value) {
|
if(it->preset == value) {
|
||||||
int index {static_cast<int>(std::distance(rows.begin(), it))};
|
int index {static_cast<int>(distance(rows.begin(), it))};
|
||||||
table.selectRow(index);
|
table.selectRow(index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ public:
|
||||||
private:
|
private:
|
||||||
// void loadModelFrom(ValueTree& presets);
|
// void loadModelFrom(ValueTree& presets);
|
||||||
void loadModelFrom(ValueTree& banks);
|
void loadModelFrom(ValueTree& banks);
|
||||||
|
void repopulateTable();
|
||||||
void selectCurrentPreset();
|
void selectCurrentPreset();
|
||||||
|
|
||||||
AudioProcessorValueTreeState& valueTreeState;
|
AudioProcessorValueTreeState& valueTreeState;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user