diff --git a/sources/Application/Instruments/I_Instrument.h b/sources/Application/Instruments/I_Instrument.h index e0d605f4..119580a5 100644 --- a/sources/Application/Instruments/I_Instrument.h +++ b/sources/Application/Instruments/I_Instrument.h @@ -9,10 +9,16 @@ #include "Application/Player/TablePlayback.h" -enum InstrumentType { IT_NONE, IT_SAMPLE, IT_MIDI, IT_SID, IT_OPAL, IT_MACRO }; -static const char *InstrumentTypeNames[] = { - "NONE", "SAMPLE", "MIDI", "SID", "OPAL", "MACRO", +enum InstrumentType { + IT_NONE = 0, + IT_SAMPLE, + IT_MIDI, + IT_SID, + IT_OPAL, + IT_LAST }; +static const char *InstrumentTypeNames[IT_LAST] = {"NONE", "SAMPLE", "MIDI", + "SID", "OPAL"}; class I_Instrument : public VariableContainer, public Observable { public: diff --git a/sources/Application/Instruments/InstrumentBank.cpp b/sources/Application/Instruments/InstrumentBank.cpp index 5a211ab4..930ea98a 100644 --- a/sources/Application/Instruments/InstrumentBank.cpp +++ b/sources/Application/Instruments/InstrumentBank.cpp @@ -209,16 +209,6 @@ unsigned short InstrumentBank::GetNextAndAssignID(InstrumentType type, instruments_[id] = oi; return id; } break; - case IT_MACRO: { - MacroInstrument *mi = macroInstrumentPool_.create(); - // TODO check for pool exhastion AND show user UI message about it!!! - if (mi == nullptr) { - Trace::Error("Macro INSTRUMENT EXHAUSTED!!!!!!"); - } - mi->Init(); - instruments_[id] = mi; - return id; - } break; case IT_NONE: instruments_[id] = &none_; return id; @@ -245,9 +235,6 @@ void InstrumentBank::releaseInstrument(unsigned short id) { case IT_OPAL: opalInstrumentPool_.destroy(instrument); break; - case IT_MACRO: - macroInstrumentPool_.destroy(instrument); - break; case IT_NONE: // NA: None is a "singleton" so no need to release from pool // BUT it can be assigned to any number of slots diff --git a/sources/Application/Instruments/MacroInstrument.h b/sources/Application/Instruments/MacroInstrument.h index 372f6df7..0a2ed999 100644 --- a/sources/Application/Instruments/MacroInstrument.h +++ b/sources/Application/Instruments/MacroInstrument.h @@ -27,7 +27,8 @@ class MacroInstrument : public I_Instrument, I_Observer { virtual bool IsInitialized(); virtual bool IsEmpty(); - virtual InstrumentType GetType() { return IT_MACRO; }; + // TODO: set a real instrument type before shipping macro instruments + virtual InstrumentType GetType() { return IT_NONE; }; virtual etl::string<24> GetName(); // returns sample name until real // namer is implemented virtual void ProcessCommand(int channel, FourCC cc, ushort value); diff --git a/sources/Application/Views/InstrumentView.cpp b/sources/Application/Views/InstrumentView.cpp index 11a6eb60..73d4c14f 100644 --- a/sources/Application/Views/InstrumentView.cpp +++ b/sources/Application/Views/InstrumentView.cpp @@ -27,15 +27,15 @@ static void ChangeInstrumentTypeCallback(View &v, ModalView &dialog) { }; InstrumentView::InstrumentView(GUIWindow &w, ViewData *data) - : FieldView(w, data), - instrumentType_(FourCC::VarInstrumentType, InstrumentTypeNames, 5, 0) { + : FieldView(w, data), instrumentType_(FourCC::VarInstrumentType, + InstrumentTypeNames, IT_LAST, 0) { project_ = data->project_; GUIPoint position = GetAnchor(); position._y -= 2; - typeIntVarField_.emplace_back(position, *&instrumentType_, "Type: %s", 0, 4, - 1, 1); + typeIntVarField_.emplace_back(position, *&instrumentType_, "Type: %s", 0, + IT_LAST - 1, 1, 1); fieldList_.insert(fieldList_.end(), &(*typeIntVarField_.rbegin())); (*typeIntVarField_.rbegin()).AddObserver(*this); lastFocusID_ = FourCC::VarInstrumentType; @@ -59,6 +59,12 @@ void InstrumentView::onInstrumentTypeChange() { auto id = viewData_->currentInstrumentID_; // release prev instrument back to available pool if (old != nullptr) { + // first check if the instrument type actually changed, because could be + // user is at end of instrument list and just keeps pressing key combo to + // trigger next instrument event again and again + if (old->GetType() == nuType) { + return; + } bank->releaseInstrument(viewData_->currentInstrumentID_); } @@ -117,9 +123,6 @@ void InstrumentView::refreshInstrumentFields(const I_Instrument *old) { case IT_NONE: fillNoneParameters(); break; - case IT_MACRO: - fillMacroParameters(); - break; case IT_MIDI: fillMidiParameters(); break; @@ -132,6 +135,9 @@ void InstrumentView::refreshInstrumentFields(const I_Instrument *old) { case IT_OPAL: fillOpalParameters(); break; + case IT_LAST: + // NA + break; }; for (auto field : fieldList_) { @@ -665,7 +671,7 @@ void InstrumentView::ProcessButtonMask(unsigned short mask, bool pressed) { FieldView::ProcessButtonMask(mask); - // B Modifier + // EDIT Modifier if (mask & EPBM_EDIT) { if (mask & EPBM_LEFT) warpToNext(-1); @@ -703,8 +709,7 @@ void InstrumentView::ProcessButtonMask(unsigned short mask, bool pressed) { }; } else { - // A modifier - + // ENTER modifier if (mask == EPBM_ENTER) { FourCC varID = ((UIIntVarField *)GetFocus())->GetVariableID(); if ((varID == FourCC::SampleInstrumentTable) || @@ -714,8 +719,7 @@ void InstrumentView::ProcessButtonMask(unsigned short mask, bool pressed) { }; } else { - // R Modifier - + // NAV Modifier if (mask & EPBM_NAV) { if (mask & EPBM_LEFT) { ViewType vt = VT_PHRASE;