Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default default octave depending on KK model #12

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions inc/cabl/devices/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ class Device

virtual size_t numOfLedArrays() const = 0;

virtual size_t currentOctave() const { return 0; }

virtual void setButtonLed(Button, const Color&);

virtual void setKeyLed(unsigned, const Color&);
Expand Down
34 changes: 34 additions & 0 deletions src/devices/ni/KompleteKontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ enum class KompleteKontrolBase::Button : uint8_t
KompleteKontrolBase::KompleteKontrolBase()
: m_isDirtyLeds(true)
, m_isDirtyKeyLeds(true)
, m_hasValidOctave(false)
#if defined(_WIN32) || defined(__APPLE__) || defined(__linux)
, m_pMidiOut(new RtMidiOut)
, m_pMidiIn(new RtMidiIn)
Expand Down Expand Up @@ -515,6 +516,7 @@ void KompleteKontrolBase::processButtons(const Transfer& input_)
}

m_firstOctave = input_.data()[37];
m_hasValidOctave = true;
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -692,5 +694,37 @@ void KompleteKontrolBase::midiInCallback(

//--------------------------------------------------------------------------------------------------

template <>
size_t KompleteKontrolS25::defaultOctave() const
{
return 48;
}

//--------------------------------------------------------------------------------------------------

template <>
size_t KompleteKontrolS49::defaultOctave() const
{
return 36;
}

//--------------------------------------------------------------------------------------------------

template <>
size_t KompleteKontrolS61::defaultOctave() const
{
return 36;
}

//--------------------------------------------------------------------------------------------------

template <>
size_t KompleteKontrolS88::defaultOctave() const
{
return 21;
}

//--------------------------------------------------------------------------------------------------

} // namespace cabl
} // namespace sl
13 changes: 13 additions & 0 deletions src/devices/ni/KompleteKontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ class KompleteKontrolBase : public Device
return 0;
}

size_t currentOctave() const override
{
return m_hasValidOctave ? m_firstOctave : defaultOctave();
}

virtual size_t defaultOctave() const
{
assert(false);
}

bool tick() override;

private:
Expand Down Expand Up @@ -99,6 +109,7 @@ class KompleteKontrolBase : public Device
bool m_isDirtyKeyLeds;

uint8_t m_firstOctave;
bool m_hasValidOctave;

TextDisplayKompleteKontrol m_displays[kKK_nDisplays];

Expand All @@ -125,6 +136,8 @@ class KompleteKontrol final : public KompleteKontrolBase
return kKK_keysLedDataSize;
}

size_t defaultOctave() const override;

private:
uint8_t* ledsKeysData() override
{
Expand Down