Skip to content

Commit 6b672e8

Browse files
committed
added octave up and down buttons
1 parent b6cf2e9 commit 6b672e8

File tree

6 files changed

+29
-1
lines changed

6 files changed

+29
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Builds/VisualStudio2017/
88
.vs/
99
*.exe
1010

11+
.vscode
12+
1113
JuceLibraryCode/
1214
Builds/
1315
assets/

Documentation/KeyboardShortcuts.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
X = Octave down\
2+
C = Octave up

Source/CartManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ void CartManager::initialFocus() {
342342
}
343343

344344
bool CartManager::keyPressed(const KeyPress& key, Component* originatingComponent) {
345+
// Keycode 13 is enter.
345346
if ( key.getKeyCode() == 13 ) {
346347
File file = cartBrowser->getSelectedFile();
347348
if ( file.isDirectory() )

Source/PluginEditor.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ DexedAudioProcessorEditor::DexedAudioProcessorEditor (DexedAudioProcessor* owner
3737
cartManager(this)
3838
{
3939
setSize(WINDOW_SIZE_X, (ownerFilter->showKeyboard ? WINDOW_SIZE_Y : WINDOW_SIZE_Y - 94));
40+
41+
setWantsKeyboardFocus(true);
42+
addKeyListener(this);
4043

4144
processor = ownerFilter;
4245

@@ -441,3 +444,20 @@ void DexedAudioProcessorEditor::filesDropped (const StringArray &files, int x, i
441444
processor->applyKBMMapping( File( fn ) );
442445
}
443446
}
447+
448+
bool DexedAudioProcessorEditor::keyPressed(const KeyPress &key, Component *originatingComponent) {
449+
if (key.getTextDescription() == "X") {
450+
if (processor->octaveShift > 0) {
451+
processor->octaveShift -= 1;
452+
midiKeyboard.setKeyPressBaseOctave(processor->octaveShift);
453+
}
454+
return true;
455+
} else if (key.getTextDescription() == "C") {
456+
if (processor->octaveShift < 10) {
457+
processor->octaveShift += 1;
458+
midiKeyboard.setKeyPressBaseOctave(processor->octaveShift);
459+
}
460+
return true;
461+
}
462+
return false;
463+
}

Source/PluginEditor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
/**
3333
*/
3434
class DexedAudioProcessorEditor : public AudioProcessorEditor, public ComboBox::Listener, public Timer,
35-
public FileDragAndDropTarget {
35+
public FileDragAndDropTarget, public juce::KeyListener {
3636
MidiKeyboardComponent midiKeyboard;
3737
OperatorEditor operators[6];
3838
Colour background;
@@ -62,6 +62,7 @@ class DexedAudioProcessorEditor : public AudioProcessorEditor, public ComboBox:
6262

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

6667
static const int WINDOW_SIZE_X = 866;
6768
static const int WINDOW_SIZE_Y = 674;

Source/PluginProcessor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ public :
172172
std::unique_ptr<CtrlFloat> output;
173173
std::unique_ptr<Ctrl> tune;
174174

175+
int octaveShift = 5;
176+
175177
void loadCartridge(Cartridge &cart);
176178
void setDxValue(int offset, int v);
177179

0 commit comments

Comments
 (0)