Skip to content

Commit

Permalink
Merge branch 'GUIBigRedesignNoMenu_55keys' into GUIBigRedesignNoMenu
Browse files Browse the repository at this point in the history
# Conflicts:
#	Source/KeyboardDataStructure.cpp
  • Loading branch information
hsstraub committed Dec 12, 2020
2 parents 707a735 + 24f46f1 commit d89a060
Show file tree
Hide file tree
Showing 16 changed files with 141 additions and 150 deletions.
6 changes: 6 additions & 0 deletions Source/AllKeysOverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ void KeyMiniDisplayInsideAllKeysOverview::mouseDown(const MouseEvent& e)
{
Component::mouseDown(e);

// Select this octave board
jassert(getParentComponent() != nullptr);
jassert(getParentComponent()->getParentComponent() != nullptr);
dynamic_cast<MainContentComponent*>(getParentComponent()->getParentComponent())->
getOctaveBoardSelectorTab()->setCurrentTabIndex(boardIndex);

// ToDo NoteOn MIDI message (here or in parent component)
}

Expand Down
23 changes: 16 additions & 7 deletions Source/CurvesArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 6.0.4
Created with Projucer version: 6.0.5
------------------------------------------------------------------------------
Expand All @@ -26,6 +26,17 @@


//[MiscUserDefs] You can add your own user definitions and misc code here...

CurvesArea::CurvesTabComponent::CurvesTabComponent(TabbedButtonBar::Orientation orientation)
: TabbedComponent::TabbedComponent(orientation)
{
}

void CurvesArea::CurvesTabComponent::currentTabChanged(int newCurrentTabIndex, const String &newCurrentTabName)
{
dynamic_cast<VelocityCurveDlgBase*>(getTabContentComponent(newCurrentTabIndex))->loadFromMapping();
}

//[/MiscUserDefs]

//==============================================================================
Expand All @@ -45,7 +56,7 @@ CurvesArea::CurvesArea ()

labelWindowTitle->setBounds (8, 8, 150, 24);

curvesTab.reset (new juce::TabbedComponent (juce::TabbedButtonBar::TabsAtTop));
curvesTab.reset (new CurvesTabComponent (juce::TabbedButtonBar::TabsAtTop));
addAndMakeVisible (curvesTab.get());
curvesTab->setTabBarDepth (30);
curvesTab->addTab (TRANS("Note Velocity"), juce::Colours::lightgrey, new NoteOnOffVelocityCurveDialog(), true);
Expand Down Expand Up @@ -114,9 +125,7 @@ void CurvesArea::resized()

void CurvesArea::loadFromMapping()
{
dynamic_cast<NoteOnOffVelocityCurveDialog*>(curvesTab->getTabContentComponent(curvesTabIndex::noteOnOffVelocityCurve))->loadFromMapping();
dynamic_cast<FaderVelocityCurveDialog*>(curvesTab->getTabContentComponent(curvesTabIndex::faderConfig))->loadFromMapping();
dynamic_cast<AftertouchVelocityCurveDialog*>(curvesTab->getTabContentComponent(curvesTabIndex::aftertouchConfig))->loadFromMapping();
dynamic_cast<VelocityCurveDlgBase*>(curvesTab->getCurrentContentComponent())->loadFromMapping();
}

//[/MiscUserCode]
Expand All @@ -142,8 +151,8 @@ BEGIN_JUCER_METADATA
focusDiscardsChanges="0" fontname="Default font" fontsize="18.0"
kerning="0.0" bold="0" italic="0" justification="33"/>
<TABBEDCOMPONENT name="curvesTab" id="795631386b24b3ba" memberName="curvesTab"
virtualName="" explicitFocusOrder="0" pos="8 40 464 200" orientation="top"
tabBarDepth="30" initialTab="0">
virtualName="CurvesTabComponent" explicitFocusOrder="0" pos="8 40 464 200"
orientation="top" tabBarDepth="30" initialTab="0">
<TAB name="Note Velocity" colour="ffd3d3d3" useJucerComp="0" contentClassName="NoteOnOffVelocityCurveDialog"
constructorParams="" jucerComponentFile=""/>
<TAB name="CC Fader" colour="ffd3d3d3" useJucerComp="0" contentClassName="FaderVelocityCurveDialog"
Expand Down
19 changes: 9 additions & 10 deletions Source/CurvesArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 6.0.4
Created with Projucer version: 6.0.5
------------------------------------------------------------------------------
Expand Down Expand Up @@ -44,6 +44,13 @@ class CurvesArea : public juce::Component

//==============================================================================
//[UserMethods] -- You can add your own custom methods in this section.
class CurvesTabComponent : public juce::TabbedComponent
{
public:
CurvesTabComponent(TabbedButtonBar::Orientation orientation);
void currentTabChanged(int newCurrentTabIndex, const String &newCurrentTabName) override;
};

// New mapping is loaded. Display data.
void loadFromMapping();
//[/UserMethods]
Expand All @@ -55,19 +62,11 @@ class CurvesArea : public juce::Component

private:
//[UserVariables] -- You can add your own custom variables in this section.

enum curvesTabIndex
{
noteOnOffVelocityCurve = 0,
faderConfig = 1,
aftertouchConfig = 2
};

//[/UserVariables]

//==============================================================================
std::unique_ptr<juce::Label> labelWindowTitle;
std::unique_ptr<juce::TabbedComponent> curvesTab;
std::unique_ptr<CurvesTabComponent> curvesTab;


//==============================================================================
Expand Down
6 changes: 3 additions & 3 deletions Source/IsomorphicMassAssign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,16 +641,16 @@ bool IsomorphicMassAssign::performMouseDown(int setSelection, int keySelection)
for ( auto octaveBoardIndex = setSelection+1; octaveBoardIndex < NUMBEROFBOARDS; octaveBoardIndex++)
{
// Find a field that can be filled, from the values of the preceding octave board
for ( auto horizLine : linesWithRightContinuation)
for ( auto succeedinghorizLine : linesWithRightContinuation)
{
int noteIndex = this->mappingLogic->terpstraKeyToIndex(
mainComponent->getMappingInEdit().sets[octaveBoardIndex-1].theKeys[horizLine.getLast()]);
mainComponent->getMappingInEdit().sets[octaveBoardIndex-1].theKeys[succeedinghorizLine.getLast()]);

if ( noteIndex >= 0 )
{
// A field in preceding octave board with an assigned value has been found-
// Value can be assigned to continuation on current board.
auto newHorizLine = boardGeometry.continuationOfHorizontalLine(horizLine, 1);
auto newHorizLine = boardGeometry.continuationOfHorizontalLine(succeedinghorizLine, 1);

setSaveSend(octaveBoardIndex, newHorizLine.getFirst(), noteIndex + horizStepSize);

Expand Down
1 change: 0 additions & 1 deletion Source/KeyboardDataStructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ String TerpstraVelocityCurveConfig::createConfigStringForSaving()
}

default:
jassertfalse;
return "";
}
}
Expand Down
51 changes: 29 additions & 22 deletions Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,37 +183,44 @@ void MainContentComponent::midiMessageReceived(const MidiMessage& midiMessage)
// Velocity curves
if (TerpstraSysExApplication::getApp().getMidiDriver().messageIsVelocityIntervalConfigReceptionMessage(midiMessage))
{
auto sysExData = midiMessage.getSysExData();
auto answerState = sysExData[5];
// After the answer state byte there must be 254 bytes of data
jassert(midiMessage.getSysExDataSize() >= (6 + 2 * VELOCITYINTERVALTABLESIZE)); // ToDo display error otherwise

if (answerState == TerpstraMidiDriver::ACK)
{
// After the answer state byte there must be 254 bytes of data
jassert(midiMessage.getSysExDataSize() >= (6 + 2 * VELOCITYINTERVALTABLESIZE)); // ToDo display error otherwise

for (int i = 0; i < VELOCITYINTERVALTABLESIZE; i++)
this->mappingData.velocityIntervalTableValues[i] = (sysExData[6 + 2 * i] << 6) + sysExData[7 + 2 * i];
}
for (int i = 0; i < VELOCITYINTERVALTABLESIZE; i++)
this->mappingData.velocityIntervalTableValues[i] = (sysExData[6 + 2 * i] << 6) + sysExData[7 + 2 * i];

curvesArea->resized();
curvesArea->repaint();
}
else if (TerpstraSysExApplication::getApp().getMidiDriver().messageIsTerpstraVelocityConfigReceptionMessage(midiMessage, TerpstraMidiDriver::VelocityCurveType::noteOnNoteOff))
{
auto sysExData = midiMessage.getSysExData();
auto answerState = sysExData[5];

if (answerState == TerpstraMidiDriver::ACK)
{
// After the answer state byte there must be 128 bytes of data
jassert(midiMessage.getSysExDataSize() >= 134); // ToDo display error otherwise

// XXX Same logic as in VelocityCurveFreeDrawingStrategy::createPropertiesStringForSaving()
curvesArea->loadFromMapping();
}
// After the answer state byte there must be 128 bytes of data
jassert(midiMessage.getSysExDataSize() >= 134); // ToDo display error otherwise
this->mappingData.noteOnOffVelocityCurveConfig.editStrategy = TerpstraVelocityCurveConfig::EDITSTRATEGYINDEX::freeDrawing;
for (int x = 0; x < 128; x++)
this->mappingData.noteOnOffVelocityCurveConfig.velocityValues[x] = sysExData[6 + x];
curvesArea->loadFromMapping();
}
else if (TerpstraSysExApplication::getApp().getMidiDriver().messageIsTerpstraVelocityConfigReceptionMessage(midiMessage, TerpstraMidiDriver::VelocityCurveType::fader))
{
// After the answer state byte there must be 128 bytes of data
jassert(midiMessage.getSysExDataSize() >= 134); // ToDo display error otherwise
this->mappingData.faderConfig.editStrategy = TerpstraVelocityCurveConfig::EDITSTRATEGYINDEX::freeDrawing;
for (int x = 0; x < 128; x++)
this->mappingData.faderConfig.velocityValues[x] = sysExData[6 + x];
curvesArea->loadFromMapping();
}
else if (TerpstraSysExApplication::getApp().getMidiDriver().messageIsTerpstraVelocityConfigReceptionMessage(midiMessage, TerpstraMidiDriver::VelocityCurveType::afterTouch))
{
// After the answer state byte there must be 128 bytes of data
jassert(midiMessage.getSysExDataSize() >= 134); // ToDo display error otherwise
this->mappingData.afterTouchConfig.editStrategy = TerpstraVelocityCurveConfig::EDITSTRATEGYINDEX::freeDrawing;
for (int x = 0; x < 128; x++)
this->mappingData.afterTouchConfig.velocityValues[x] = sysExData[6 + x];
curvesArea->loadFromMapping();
}
// ToDo more curve data

// Key configurations
else if (midiCmd == GET_RED_LED_CONFIG || midiCmd == GET_GREEN_LED_CONFIG || midiCmd == GET_BLUE_LED_CONFIG ||
midiCmd == GET_CHANNEL_CONFIG || midiCmd == GET_NOTE_CONFIG || midiCmd == GET_KEYTYPE_CONFIG)
{
Expand Down
2 changes: 2 additions & 0 deletions Source/MainComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class MainContentComponent : public Component, public TerpstraMidiDriver::Listen
void getData(TerpstraKeyMapping& newData);
TerpstraKeyMapping& getMappingInEdit() { return this->mappingData; }

TabbedButtonBar* getOctaveBoardSelectorTab() { return noteEditArea->getOctaveBoardSelectorTab(); }

// Board edit operations
bool deleteCurrentSubBoardData();
bool copyCurrentSubBoardData();
Expand Down
17 changes: 10 additions & 7 deletions Source/MidiEditArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@


//[MiscUserDefs] You can add your own user definitions and misc code here...

// Index in edit mode tab coincides with sysExSendingMode. In case that changes in the future, modify this here.
TerpstraMidiDriver::sysExSendingMode editModeTabIndexToMidiSysExSendingMode(int tabIndex) { return static_cast<TerpstraMidiDriver::sysExSendingMode>(tabIndex); }

//[/MiscUserDefs]

//==============================================================================
Expand Down Expand Up @@ -279,23 +283,22 @@ void MidiEditArea::changeListenerCallback(ChangeBroadcaster *source)
{
if (source == editModeSelector.get())
{
auto editMode = editModeSelector->getCurrentTabIndex();
auto sysExSendingMode = editModeTabIndexToMidiSysExSendingMode(editModeSelector->getCurrentTabIndex());

switch (editMode)
TerpstraSysExApplication::getApp().getMidiDriver().setSysExSendingMode(sysExSendingMode);

switch (sysExSendingMode)
{
case midiEditMode::liveEditor:
case TerpstraMidiDriver::sysExSendingMode::liveEditor:
onOpenConnectionToDevice();
break;

case midiEditMode::offlineEditor:
case TerpstraMidiDriver::sysExSendingMode::offlineEditor:
lblConnectionState->setText("Offline mode", NotificationType::dontSendNotification);
errorVisualizer.setErrorLevel(
*lblConnectionState.get(),
HajuErrorVisualizer::ErrorLevel::noError,
"Offline mode");

// Remove all MIDI messages in queue waiting to be sent
TerpstraSysExApplication::getApp().getMidiDriver().clearMIDIMessageBuffer();
break;

default:
Expand Down
1 change: 1 addition & 0 deletions Source/MidiEditArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class MidiEditArea : public Component,

private:
//[UserVariables] -- You can add your own custom variables in this section.
// Indices of the editModeSelector tab
enum midiEditMode
{
liveEditor = 0,
Expand Down
18 changes: 16 additions & 2 deletions Source/TerpstraMidiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ void TerpstraMidiDriver::removeListener(TerpstraMidiDriver::Listener* listener)
listeners.remove(listener);
}

void TerpstraMidiDriver::setSysExSendingMode(sysExSendingMode newMode)
{
if (newMode != currentSysExSendingMode)
{
currentSysExSendingMode = newMode;
if (currentSysExSendingMode == sysExSendingMode::offlineEditor)
{
clearMIDIMessageBuffer(); // ToDo remove only SysEx messages (leave NoteOn/NoteOff)?
stopTimer();
hasMsgWaitingForAck = false;
}
}
}

/*
==============================================================================
Combined (hi-level) commands
Expand Down Expand Up @@ -296,8 +310,8 @@ Low-level SysEx calls

void TerpstraMidiDriver::sendSysEx(int boardIndex, unsigned char cmd, unsigned char data1, unsigned char data2, unsigned char data3, unsigned char data4)
{
// Send only if output device is there
if (midiOutput != nullptr)
// Send only if output device is there and SysEx sending is meant to be active
if (midiOutput != nullptr & currentSysExSendingMode == sysExSendingMode::liveEditor)
{
unsigned char sysExData[9];
sysExData[0] = (manufacturerId >> 16) & 0xff;
Expand Down
17 changes: 15 additions & 2 deletions Source/TerpstraMidiDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ class TerpstraMidiDriver : public HajuMidiDriver, public MidiInputCallback, publ
ERROR = 0x03, // Error
} TerpstraMIDIAnswerReturnCode;

enum sysExSendingMode
{
liveEditor = 0,
offlineEditor = 1
};


private:
typedef enum
{
Expand All @@ -125,6 +132,9 @@ class TerpstraMidiDriver : public HajuMidiDriver, public MidiInputCallback, publ
void addListener(Listener* listenerToAdd);
void removeListener(Listener* listenerToRemove);

sysExSendingMode getSysExSendingMode() const { return currentSysExSendingMode; }
void setSysExSendingMode(sysExSendingMode newMode);

//////////////////////////////////
// Combined (hi-level) commands

Expand Down Expand Up @@ -201,8 +211,8 @@ class TerpstraMidiDriver : public HajuMidiDriver, public MidiInputCallback, publ
// Handle timeout
void timerCallback() override;

// Clear MIDI message buffer;
void clearMIDIMessageBuffer() { messageBuffer.clear(); this->listeners.call(&Listener::midiSendQueueSize, 0); hasMsgWaitingForAck = false; stopTimer(); }
// Clear MIDI message buffer
void clearMIDIMessageBuffer() { messageBuffer.clear(); this->listeners.call(&Listener::midiSendQueueSize, 0); }

// Message is an answer to a sent message yes/no
static bool messageIsResponseToMessage(const MidiMessage& answer, const MidiMessage& originalMessage);
Expand Down Expand Up @@ -244,6 +254,9 @@ class TerpstraMidiDriver : public HajuMidiDriver, public MidiInputCallback, publ

Array<MidiMessage> messageBuffer;

// Whether SysEx messages are sent or not
sysExSendingMode currentSysExSendingMode = sysExSendingMode::liveEditor;

const int receiveTimeoutInMilliseconds = 2000;
const int busyTimeDelayInMilliseconds = 20;
TimerType timerType;
Expand Down
2 changes: 1 addition & 1 deletion Source/VelocityCurveComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Display of one beam in a velocity curve table
==============================================================================
*/
class VelocityCurveBeam : public Component
class VelocityCurveBeam : public Component, public SettableTooltipClient
{
public:
VelocityCurveBeam();
Expand Down
Loading

0 comments on commit d89a060

Please sign in to comment.