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 19, 2024
1 parent b6cf2e9 commit 1416eb2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
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
14 changes: 14 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,14 @@ 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") {
processor->octaveShift -= 1;
return true;
} else if (key.getTextDescription() == "C") {
processor->octaveShift += 1;
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
6 changes: 3 additions & 3 deletions Source/PluginProcessor.cpp
Expand Up @@ -566,18 +566,18 @@ void DexedAudioProcessor::keyup(uint8_t chan, uint8_t pitch, uint8_t velo) {
int DexedAudioProcessor::tuningTranspositionShift()
{
if( synthTuningState->is_standard_tuning() || ! controllers.transpose12AsScale )
return data[144] - 24;
return data[144] - 24 + octaveShift * 12;
else
{
int d144 = data[144];
if( d144 % 12 == 0 )
{
int oct = (d144 - 24) / 12;
int res = oct * synthTuningState->scale_length();
return res;
return res + octaveShift * 12;
}
else
return data[144] - 24;
return data[144] - 24 + octaveShift * 12;
}
}

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 = 0;

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

Expand Down

0 comments on commit 1416eb2

Please sign in to comment.