Skip to content

Commit 1416eb2

Browse files
committed
added octave up and down buttons
1 parent b6cf2e9 commit 1416eb2

File tree

7 files changed

+26
-4
lines changed

7 files changed

+26
-4
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: 14 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,14 @@ 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+
processor->octaveShift -= 1;
451+
return true;
452+
} else if (key.getTextDescription() == "C") {
453+
processor->octaveShift += 1;
454+
return true;
455+
}
456+
return false;
457+
}

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.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,18 +566,18 @@ void DexedAudioProcessor::keyup(uint8_t chan, uint8_t pitch, uint8_t velo) {
566566
int DexedAudioProcessor::tuningTranspositionShift()
567567
{
568568
if( synthTuningState->is_standard_tuning() || ! controllers.transpose12AsScale )
569-
return data[144] - 24;
569+
return data[144] - 24 + octaveShift * 12;
570570
else
571571
{
572572
int d144 = data[144];
573573
if( d144 % 12 == 0 )
574574
{
575575
int oct = (d144 - 24) / 12;
576576
int res = oct * synthTuningState->scale_length();
577-
return res;
577+
return res + octaveShift * 12;
578578
}
579579
else
580-
return data[144] - 24;
580+
return data[144] - 24 + octaveShift * 12;
581581
}
582582
}
583583

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 = 0;
176+
175177
void loadCartridge(Cartridge &cart);
176178
void setDxValue(int offset, int v);
177179

0 commit comments

Comments
 (0)