Skip to content

Commit

Permalink
added octave up and down buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
quirkylemon committed Jan 20, 2024
1 parent b6cf2e9 commit 6b672e8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -8,6 +8,8 @@ Builds/VisualStudio2017/
.vs/
*.exe

.vscode

JuceLibraryCode/
Builds/
assets/
Expand Down
2 changes: 2 additions & 0 deletions Documentation/KeyboardShortcuts.md
@@ -0,0 +1,2 @@
X = Octave down\
C = Octave up
1 change: 1 addition & 0 deletions Source/CartManager.cpp
Expand Up @@ -342,6 +342,7 @@ void CartManager::initialFocus() {
}

bool CartManager::keyPressed(const KeyPress& key, Component* originatingComponent) {
// Keycode 13 is enter.
if ( key.getKeyCode() == 13 ) {
File file = cartBrowser->getSelectedFile();
if ( file.isDirectory() )
Expand Down
20 changes: 20 additions & 0 deletions Source/PluginEditor.cpp
Expand Up @@ -37,6 +37,9 @@ DexedAudioProcessorEditor::DexedAudioProcessorEditor (DexedAudioProcessor* owner
cartManager(this)
{
setSize(WINDOW_SIZE_X, (ownerFilter->showKeyboard ? WINDOW_SIZE_Y : WINDOW_SIZE_Y - 94));

setWantsKeyboardFocus(true);
addKeyListener(this);

processor = ownerFilter;

Expand Down Expand Up @@ -441,3 +444,20 @@ void DexedAudioProcessorEditor::filesDropped (const StringArray &files, int x, i
processor->applyKBMMapping( File( fn ) );
}
}

bool DexedAudioProcessorEditor::keyPressed(const KeyPress &key, Component *originatingComponent) {
if (key.getTextDescription() == "X") {
if (processor->octaveShift > 0) {
processor->octaveShift -= 1;
midiKeyboard.setKeyPressBaseOctave(processor->octaveShift);
}
return true;
} else if (key.getTextDescription() == "C") {
if (processor->octaveShift < 10) {
processor->octaveShift += 1;
midiKeyboard.setKeyPressBaseOctave(processor->octaveShift);
}
return true;
}
return false;
}
3 changes: 2 additions & 1 deletion Source/PluginEditor.h
Expand Up @@ -32,7 +32,7 @@
/**
*/
class DexedAudioProcessorEditor : public AudioProcessorEditor, public ComboBox::Listener, public Timer,
public FileDragAndDropTarget {
public FileDragAndDropTarget, public juce::KeyListener {
MidiKeyboardComponent midiKeyboard;
OperatorEditor operators[6];
Colour background;
Expand Down Expand Up @@ -62,6 +62,7 @@ class DexedAudioProcessorEditor : public AudioProcessorEditor, public ComboBox:

virtual bool isInterestedInFileDrag (const StringArray &files) override;
virtual void filesDropped (const StringArray &files, int x, int y ) override;
virtual bool keyPressed (const KeyPress &key, Component *originatingComponent);

static const int WINDOW_SIZE_X = 866;
static const int WINDOW_SIZE_Y = 674;
Expand Down
2 changes: 2 additions & 0 deletions Source/PluginProcessor.h
Expand Up @@ -172,6 +172,8 @@ public :
std::unique_ptr<CtrlFloat> output;
std::unique_ptr<Ctrl> tune;

int octaveShift = 5;

void loadCartridge(Cartridge &cart);
void setDxValue(int offset, int v);

Expand Down

0 comments on commit 6b672e8

Please sign in to comment.