diff --git a/Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate b/Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate index e456d31..c2e58df 100644 Binary files a/Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate and b/Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Source/DXComponents.cpp b/Source/DXComponents.cpp index 35963c9..a277af3 100644 --- a/Source/DXComponents.cpp +++ b/Source/DXComponents.cpp @@ -137,7 +137,7 @@ EnvDisplay::EnvDisplay() { void EnvDisplay::paint(Graphics &g) { g.setColour(Colours::black.withAlpha(0.5f)); g.fillRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 1.0f); - g.setColour(Colour(0xFF0FC00F).withAlpha(0.3f)); + char *levels = pvalues + 4; char *rates = pvalues; @@ -167,13 +167,17 @@ void EnvDisplay::paint(Graphics &g) { Path p; p.startNewSubPath(0, 32); + g.setColour(Colours::white); - for(int i=0;i<4;i++) { + int i; + for(i=0;i<4;i++) { int newx = dist[i] * ratio + oldx; int newy = 32 - ((float)levels[i] / 3.125); p.lineTo(newx, newy); - //g.drawLine(oldx, oldy, newx, newy, 2); + if ( vPos == i ) { + g.fillEllipse(oldx-2, oldy-2, 4, 4); + } oldx = newx; oldy = newy; @@ -181,6 +185,11 @@ void EnvDisplay::paint(Graphics &g) { p.lineTo(96,32); p.lineTo(0, 32); + if ( vPos == i ) { + g.fillEllipse(oldx-2, oldy-2, 4, 4); + } + + g.setColour(Colour(0xFF0FC00F).withAlpha(0.3f)); g.fillPath(p); g.setColour(Colour(0xFFFFFFFF)); @@ -191,6 +200,7 @@ void EnvDisplay::paint(Graphics &g) { PitchEnvDisplay::PitchEnvDisplay() { pvalues = (char *) &TMP_LEVEL_PTR; + vPos = 0; } void PitchEnvDisplay::paint(Graphics &g) { @@ -223,17 +233,28 @@ void PitchEnvDisplay::paint(Graphics &g) { float ratio = 96 / total; int oldx = 0; - int oldy = (pitchenv_tab[levels[3]] + 128) / 5; + int oldy = 25 - (pitchenv_tab[levels[3]] + 128) / 10; - for(int i=0;i<4;i++) { + int i; + for(i=0;i<4;i++) { int newx = dist[i] * ratio + oldx; - int newy = (pitchenv_tab[levels[i]] + 128) / 10; + int newy = 25 - (pitchenv_tab[levels[i]] + 128) / 10; g.drawLine(oldx, oldy, newx, newy, 2); + if ( vPos == i ) { + g.fillEllipse(oldx-2, oldy-2, 4, 4); + } + oldx = newx; oldy = newy; } + + if ( vPos == i ) { + g.fillEllipse(oldx-2, oldy-2, 4, 4); + } + + TRACE("pitch pos %d", vPos); } diff --git a/Source/DXComponents.h b/Source/DXComponents.h index b63a1d6..f473994 100644 --- a/Source/DXComponents.h +++ b/Source/DXComponents.h @@ -27,6 +27,7 @@ class EnvDisplay : public Component { public: EnvDisplay(); char *pvalues; + char vPos; void paint(Graphics &g); }; @@ -35,6 +36,7 @@ class PitchEnvDisplay : public Component { public: PitchEnvDisplay(); char *pvalues; + char vPos; void paint(Graphics &g); }; diff --git a/Source/GlobalEditor.cpp b/Source/GlobalEditor.cpp index aa300e7..26cbe76 100644 --- a/Source/GlobalEditor.cpp +++ b/Source/GlobalEditor.cpp @@ -430,6 +430,10 @@ void GlobalEditor::updateDisplay() { repaint(); } +void GlobalEditor::updatePitchPos(int pos) { + pitchEnvDisplay->vPos = pos; + pitchEnvDisplay->repaint(); +} //[/MiscUserCode] diff --git a/Source/GlobalEditor.h b/Source/GlobalEditor.h index 120df20..0060436 100644 --- a/Source/GlobalEditor.h +++ b/Source/GlobalEditor.h @@ -50,6 +50,7 @@ public: void bind(DexedAudioProcessor *processor); void setSystemMessage(String msg); void setParamMessage(String msg); + void updatePitchPos(int pos); void updateDisplay(); String systemMsg; diff --git a/Source/OperatorEditor.cpp b/Source/OperatorEditor.cpp index caee165..7c98316 100644 --- a/Source/OperatorEditor.cpp +++ b/Source/OperatorEditor.cpp @@ -439,7 +439,7 @@ void OperatorEditor::bind(DexedAudioProcessor *parent, int op) { parent->opCtrl[op].sclRate->bind(sclRateScaling); parent->opCtrl[op].ampModSens->bind(ampModSens); parent->opCtrl[op].velModSens->bind(keyVelSens); - + int offset = parent->opCtrl[op].egRate[0]->getOffset(); envDisplay->pvalues = &(parent->data[offset]); } @@ -475,6 +475,11 @@ void OperatorEditor::updateDisplay() { envDisplay->repaint(); } + +void OperatorEditor::updateEnvPos(char pos) { + envDisplay->vPos = pos; + envDisplay->repaint(); +} //[/MiscUserCode] diff --git a/Source/OperatorEditor.h b/Source/OperatorEditor.h index bd92829..69b1f68 100644 --- a/Source/OperatorEditor.h +++ b/Source/OperatorEditor.h @@ -52,15 +52,13 @@ public: void bind(DexedAudioProcessor *processor, int num); void updateGain(float v); void updateDisplay(); + void updateEnvPos(char pos); //[/UserMethods] void paint (Graphics& g); void resized(); void sliderValueChanged (Slider* sliderThatWasMoved); void comboBoxChanged (ComboBox* comboBoxThatHasChanged); - - - private: //[UserVariables] -- You can add your own custom variables in this section. //[/UserVariables] diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 7c3416a..ef1de51 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -184,20 +184,9 @@ void DexedAudioProcessorEditor::buttonClicked(Button *buttonThatWasClicked) { storeProgram(); return; } -/* - if (buttonThatWasClicked == cartButton) { - AlertWindow dialog(String("Builtin cartridges"), "", AlertWindow::NoIcon, this); - dialog.addComboBox(String("cart"), processor->cartManager.cartNames); - dialog.addButton("OK", 0, KeyPress(KeyPress::returnKey)); - dialog.addButton("Cancel", 1, KeyPress(KeyPress::escapeKey)); - if ( dialog.runModalLoop() == 0 ) { - } - return; - } - */ if (buttonThatWasClicked == aboutButton) { - AlertWindow::showMessageBoxAsync(AlertWindow::NoIcon, "DEXED - DX Emulator 0.3", "https://github.com/asb2m10/dexed\n" + AlertWindow::showMessageBoxAsync(AlertWindow::NoIcon, "DEXED - DX Emulator 0.4", "https://github.com/asb2m10/dexed\n" "(c) 2013-2014 Pascal Gauthier\nUnder the GPL v2\n\n" "Based on Music Synthesizer for Android\nhttps://code.google.com/p/music-synthesizer-for-android"); return; @@ -220,15 +209,15 @@ void DexedAudioProcessorEditor::comboBoxChanged (ComboBox* comboBoxThatHasChange } } -void DexedAudioProcessorEditor::timerCallback() { - int32_t env[6]; - - if ( processor->peekEnvStatus(env) == false ) +void DexedAudioProcessorEditor::timerCallback() { + if ( ! processor->peekVoiceStatus() ) return; - + for(int i=0;i<6;i++) { - operators[i].updateGain(sqrt(env[5 - i]) / 8196); - } + operators[i].updateGain(sqrt(processor->voiceStatus.amp[5 - i]) / 8196); + operators[i].updateEnvPos(processor->voiceStatus.ampStep[5 - i]); + } + global.updatePitchPos(processor->voiceStatus.pitchStep); } void DexedAudioProcessorEditor::updateUI() { diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 682ce8f..4d096b5 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -337,7 +337,7 @@ void DexedAudioProcessor::processSamples(int n_samples, int16_t *buffer) { // ==================================================================== -bool DexedAudioProcessor::peekEnvStatus(int32_t *env) { +bool DexedAudioProcessor::peekVoiceStatus() { if ( currentNote == -1 ) return false; @@ -345,7 +345,7 @@ bool DexedAudioProcessor::peekEnvStatus(int32_t *env) { int note = currentNote; for (int i = 0; i < MAX_ACTIVE_NOTES; i++) { if (voices[note].keydown) { - voices[note].dx7_note->peekEnvStatus(env); + voices[note].dx7_note->peekVoiceStatus(voiceStatus); return true; } if ( --note < 0 ) @@ -356,15 +356,13 @@ bool DexedAudioProcessor::peekEnvStatus(int32_t *env) { note = currentNote; for (int i = 0; i < MAX_ACTIVE_NOTES; i++) { if (voices[note].live) { - voices[note].dx7_note->peekEnvStatus(env); + voices[note].dx7_note->peekVoiceStatus(voiceStatus); return true; } if ( --note < 0 ) note = MAX_ACTIVE_NOTES-1; } - // all the notes are stopped, return 0; - memset(env, 0, sizeof(int32_t) * 6); return true; } @@ -439,8 +437,7 @@ void DexedAudioProcessor::handleAsyncUpdate() { updateUI(); } - -void DexedAudioProcessor::log(const char *source, const char *fmt, ...) { +void dexed_trace(const char *source, const char *fmt, ...) { char output[4096]; va_list argptr; va_start(argptr, fmt); diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index eea87c7..4e8053d 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -103,7 +103,8 @@ public : char data[161]; CartridgeManager cartManager; - + VoiceStatus voiceStatus; + Array ctrl; OperatorCtrl opCtrl[6]; @@ -140,7 +141,7 @@ public : AudioProcessorEditor* createEditor(); bool hasEditor() const; void updateUI(); - bool peekEnvStatus(int32_t *values); + bool peekVoiceStatus(); void packProgram(int idx, const char *name); void unpackProgram(int idx); void updateProgramFromSysex(const uint8 *rawdata); @@ -183,18 +184,18 @@ public : MidiKeyboardState keyboardState; void unbindUI(); - static void log(const char *source, const char *fmt, ...); - private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DexedAudioProcessor) }; +void dexed_trace(const char *source, const char *fmt, ...); + #ifdef _MSC_VER -#define TRACE(fmt, ...) DexedAudioProcessor::log(__FUNCTION__,fmt,##__VA_ARGS__) +#define TRACE(fmt, ...) dexed_trace(__FUNCTION__,fmt,##__VA_ARGS__) #else -#define TRACE(fmt, ...) DexedAudioProcessor::log(__PRETTY_FUNCTION__,fmt,##__VA_ARGS__) +#define TRACE(fmt, ...) dexed_trace(__PRETTY_FUNCTION__,fmt,##__VA_ARGS__) #endif #endif // PLUGINPROCESSOR_H_INCLUDED diff --git a/Source/msfa/dx7note.cc b/Source/msfa/dx7note.cc index 9983467..bf7141d 100755 --- a/Source/msfa/dx7note.cc +++ b/Source/msfa/dx7note.cc @@ -236,10 +236,14 @@ void Dx7Note::update(const char patch[156], int midinote) { pitchmodsens_ = pitchmodsenstab[patch[143] & 7]; } -void Dx7Note::peekEnvStatus(int32_t *env) { +void dexed_trace(const char *source, const char *fmt, ...); + +void Dx7Note::peekVoiceStatus(VoiceStatus &status) { for(int i=0;i<6;i++) { - env[i] = params_[i].gain[1]; + status.amp[i] = params_[i].gain[1]; + env_[i].getPosition(&status.ampStep[i]); } + pitchenv_.getPosition(&status.pitchStep); } diff --git a/Source/msfa/dx7note.h b/Source/msfa/dx7note.h index 5275be6..71fb662 100755 --- a/Source/msfa/dx7note.h +++ b/Source/msfa/dx7note.h @@ -27,6 +27,12 @@ #include "pitchenv.h" #include "fm_core.h" +struct VoiceStatus { + uint32_t amp[6]; + char ampStep[6]; + char pitchStep; +}; + class Dx7Note { public: void init(const char patch[156], int midinote, int velocity); @@ -47,7 +53,7 @@ class Dx7Note { // PG:add the update void update(const char patch[156], int midinote); - void peekEnvStatus(int32_t *env); + void peekVoiceStatus(VoiceStatus &status); private: FmCore core_; diff --git a/Source/msfa/env.cc b/Source/msfa/env.cc index cb9e335..e7c1546 100755 --- a/Source/msfa/env.cc +++ b/Source/msfa/env.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include "synth.h" #include "env.h" @@ -99,3 +101,6 @@ void Env::advance(int newix) { } } +void Env::getPosition(char *step) { + *step = ix_; +} diff --git a/Source/msfa/env.h b/Source/msfa/env.h index b474530..967cf60 100755 --- a/Source/msfa/env.h +++ b/Source/msfa/env.h @@ -42,6 +42,7 @@ class Env { void keydown(bool down); void setparam(int param, int value); static int scaleoutlevel(int outlevel); + void getPosition(char *step); private: int rates_[4]; int levels_[4]; diff --git a/Source/msfa/pitchenv.cc b/Source/msfa/pitchenv.cc index 5d83528..e5aac6c 100644 --- a/Source/msfa/pitchenv.cc +++ b/Source/msfa/pitchenv.cc @@ -84,8 +84,13 @@ void PitchEnv::advance(int newix) { int newlevel = levels_[ix_]; targetlevel_ = pitchenv_tab[newlevel] << 19; rising_ = (targetlevel_ > level_); - inc_ = pitchenv_rate[rates_[ix_]] * unit_; } } +void PitchEnv::getPosition(char *step) { + *step = ix_; + +} + + diff --git a/Source/msfa/pitchenv.h b/Source/msfa/pitchenv.h index ff80d27..e106341 100755 --- a/Source/msfa/pitchenv.h +++ b/Source/msfa/pitchenv.h @@ -30,6 +30,7 @@ class PitchEnv { // Result is in Q24/octave int32_t getsample(); void keydown(bool down); + void getPosition(char *step); private: static int unit_; int rates_[4];