Envelop position

pull/1/head
asb2m10 11 years ago
parent bd6f556345
commit 5d654eabbb
  1. BIN
      Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate
  2. 33
      Source/DXComponents.cpp
  3. 2
      Source/DXComponents.h
  4. 4
      Source/GlobalEditor.cpp
  5. 1
      Source/GlobalEditor.h
  6. 7
      Source/OperatorEditor.cpp
  7. 4
      Source/OperatorEditor.h
  8. 27
      Source/PluginEditor.cpp
  9. 11
      Source/PluginProcessor.cpp
  10. 13
      Source/PluginProcessor.h
  11. 8
      Source/msfa/dx7note.cc
  12. 8
      Source/msfa/dx7note.h
  13. 5
      Source/msfa/env.cc
  14. 1
      Source/msfa/env.h
  15. 7
      Source/msfa/pitchenv.cc
  16. 1
      Source/msfa/pitchenv.h

@ -137,7 +137,7 @@ EnvDisplay::EnvDisplay() {
void EnvDisplay::paint(Graphics &g) { void EnvDisplay::paint(Graphics &g) {
g.setColour(Colours::black.withAlpha(0.5f)); g.setColour(Colours::black.withAlpha(0.5f));
g.fillRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 1.0f); g.fillRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 1.0f);
g.setColour(Colour(0xFF0FC00F).withAlpha(0.3f));
char *levels = pvalues + 4; char *levels = pvalues + 4;
char *rates = pvalues; char *rates = pvalues;
@ -167,13 +167,17 @@ void EnvDisplay::paint(Graphics &g) {
Path p; Path p;
p.startNewSubPath(0, 32); 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 newx = dist[i] * ratio + oldx;
int newy = 32 - ((float)levels[i] / 3.125); int newy = 32 - ((float)levels[i] / 3.125);
p.lineTo(newx, newy); p.lineTo(newx, newy);
//g.drawLine(oldx, oldy, newx, newy, 2); if ( vPos == i ) {
g.fillEllipse(oldx-2, oldy-2, 4, 4);
}
oldx = newx; oldx = newx;
oldy = newy; oldy = newy;
@ -181,6 +185,11 @@ void EnvDisplay::paint(Graphics &g) {
p.lineTo(96,32); p.lineTo(96,32);
p.lineTo(0, 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.fillPath(p);
g.setColour(Colour(0xFFFFFFFF)); g.setColour(Colour(0xFFFFFFFF));
@ -191,6 +200,7 @@ void EnvDisplay::paint(Graphics &g) {
PitchEnvDisplay::PitchEnvDisplay() { PitchEnvDisplay::PitchEnvDisplay() {
pvalues = (char *) &TMP_LEVEL_PTR; pvalues = (char *) &TMP_LEVEL_PTR;
vPos = 0;
} }
void PitchEnvDisplay::paint(Graphics &g) { void PitchEnvDisplay::paint(Graphics &g) {
@ -223,17 +233,28 @@ void PitchEnvDisplay::paint(Graphics &g) {
float ratio = 96 / total; float ratio = 96 / total;
int oldx = 0; 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 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); g.drawLine(oldx, oldy, newx, newy, 2);
if ( vPos == i ) {
g.fillEllipse(oldx-2, oldy-2, 4, 4);
}
oldx = newx; oldx = newx;
oldy = newy; oldy = newy;
} }
if ( vPos == i ) {
g.fillEllipse(oldx-2, oldy-2, 4, 4);
}
TRACE("pitch pos %d", vPos);
} }

@ -27,6 +27,7 @@ class EnvDisplay : public Component {
public: public:
EnvDisplay(); EnvDisplay();
char *pvalues; char *pvalues;
char vPos;
void paint(Graphics &g); void paint(Graphics &g);
}; };
@ -35,6 +36,7 @@ class PitchEnvDisplay : public Component {
public: public:
PitchEnvDisplay(); PitchEnvDisplay();
char *pvalues; char *pvalues;
char vPos;
void paint(Graphics &g); void paint(Graphics &g);
}; };

@ -430,6 +430,10 @@ void GlobalEditor::updateDisplay() {
repaint(); repaint();
} }
void GlobalEditor::updatePitchPos(int pos) {
pitchEnvDisplay->vPos = pos;
pitchEnvDisplay->repaint();
}
//[/MiscUserCode] //[/MiscUserCode]

@ -50,6 +50,7 @@ public:
void bind(DexedAudioProcessor *processor); void bind(DexedAudioProcessor *processor);
void setSystemMessage(String msg); void setSystemMessage(String msg);
void setParamMessage(String msg); void setParamMessage(String msg);
void updatePitchPos(int pos);
void updateDisplay(); void updateDisplay();
String systemMsg; String systemMsg;

@ -439,7 +439,7 @@ void OperatorEditor::bind(DexedAudioProcessor *parent, int op) {
parent->opCtrl[op].sclRate->bind(sclRateScaling); parent->opCtrl[op].sclRate->bind(sclRateScaling);
parent->opCtrl[op].ampModSens->bind(ampModSens); parent->opCtrl[op].ampModSens->bind(ampModSens);
parent->opCtrl[op].velModSens->bind(keyVelSens); parent->opCtrl[op].velModSens->bind(keyVelSens);
int offset = parent->opCtrl[op].egRate[0]->getOffset(); int offset = parent->opCtrl[op].egRate[0]->getOffset();
envDisplay->pvalues = &(parent->data[offset]); envDisplay->pvalues = &(parent->data[offset]);
} }
@ -475,6 +475,11 @@ void OperatorEditor::updateDisplay() {
envDisplay->repaint(); envDisplay->repaint();
} }
void OperatorEditor::updateEnvPos(char pos) {
envDisplay->vPos = pos;
envDisplay->repaint();
}
//[/MiscUserCode] //[/MiscUserCode]

@ -52,15 +52,13 @@ public:
void bind(DexedAudioProcessor *processor, int num); void bind(DexedAudioProcessor *processor, int num);
void updateGain(float v); void updateGain(float v);
void updateDisplay(); void updateDisplay();
void updateEnvPos(char pos);
//[/UserMethods] //[/UserMethods]
void paint (Graphics& g); void paint (Graphics& g);
void resized(); void resized();
void sliderValueChanged (Slider* sliderThatWasMoved); void sliderValueChanged (Slider* sliderThatWasMoved);
void comboBoxChanged (ComboBox* comboBoxThatHasChanged); void comboBoxChanged (ComboBox* comboBoxThatHasChanged);
private: private:
//[UserVariables] -- You can add your own custom variables in this section. //[UserVariables] -- You can add your own custom variables in this section.
//[/UserVariables] //[/UserVariables]

@ -184,20 +184,9 @@ void DexedAudioProcessorEditor::buttonClicked(Button *buttonThatWasClicked) {
storeProgram(); storeProgram();
return; 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) { 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" "(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"); "Based on Music Synthesizer for Android\nhttps://code.google.com/p/music-synthesizer-for-android");
return; return;
@ -220,15 +209,15 @@ void DexedAudioProcessorEditor::comboBoxChanged (ComboBox* comboBoxThatHasChange
} }
} }
void DexedAudioProcessorEditor::timerCallback() { void DexedAudioProcessorEditor::timerCallback() {
int32_t env[6]; if ( ! processor->peekVoiceStatus() )
if ( processor->peekEnvStatus(env) == false )
return; return;
for(int i=0;i<6;i++) { 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() { void DexedAudioProcessorEditor::updateUI() {

@ -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 ) if ( currentNote == -1 )
return false; return false;
@ -345,7 +345,7 @@ bool DexedAudioProcessor::peekEnvStatus(int32_t *env) {
int note = currentNote; int note = currentNote;
for (int i = 0; i < MAX_ACTIVE_NOTES; i++) { for (int i = 0; i < MAX_ACTIVE_NOTES; i++) {
if (voices[note].keydown) { if (voices[note].keydown) {
voices[note].dx7_note->peekEnvStatus(env); voices[note].dx7_note->peekVoiceStatus(voiceStatus);
return true; return true;
} }
if ( --note < 0 ) if ( --note < 0 )
@ -356,15 +356,13 @@ bool DexedAudioProcessor::peekEnvStatus(int32_t *env) {
note = currentNote; note = currentNote;
for (int i = 0; i < MAX_ACTIVE_NOTES; i++) { for (int i = 0; i < MAX_ACTIVE_NOTES; i++) {
if (voices[note].live) { if (voices[note].live) {
voices[note].dx7_note->peekEnvStatus(env); voices[note].dx7_note->peekVoiceStatus(voiceStatus);
return true; return true;
} }
if ( --note < 0 ) if ( --note < 0 )
note = MAX_ACTIVE_NOTES-1; note = MAX_ACTIVE_NOTES-1;
} }
// all the notes are stopped, return 0;
memset(env, 0, sizeof(int32_t) * 6);
return true; return true;
} }
@ -439,8 +437,7 @@ void DexedAudioProcessor::handleAsyncUpdate() {
updateUI(); updateUI();
} }
void dexed_trace(const char *source, const char *fmt, ...) {
void DexedAudioProcessor::log(const char *source, const char *fmt, ...) {
char output[4096]; char output[4096];
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);

@ -103,7 +103,8 @@ public :
char data[161]; char data[161];
CartridgeManager cartManager; CartridgeManager cartManager;
VoiceStatus voiceStatus;
Array<Ctrl*> ctrl; Array<Ctrl*> ctrl;
OperatorCtrl opCtrl[6]; OperatorCtrl opCtrl[6];
@ -140,7 +141,7 @@ public :
AudioProcessorEditor* createEditor(); AudioProcessorEditor* createEditor();
bool hasEditor() const; bool hasEditor() const;
void updateUI(); void updateUI();
bool peekEnvStatus(int32_t *values); bool peekVoiceStatus();
void packProgram(int idx, const char *name); void packProgram(int idx, const char *name);
void unpackProgram(int idx); void unpackProgram(int idx);
void updateProgramFromSysex(const uint8 *rawdata); void updateProgramFromSysex(const uint8 *rawdata);
@ -183,18 +184,18 @@ public :
MidiKeyboardState keyboardState; MidiKeyboardState keyboardState;
void unbindUI(); void unbindUI();
static void log(const char *source, const char *fmt, ...);
private: private:
//============================================================================== //==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DexedAudioProcessor) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DexedAudioProcessor)
}; };
void dexed_trace(const char *source, const char *fmt, ...);
#ifdef _MSC_VER #ifdef _MSC_VER
#define TRACE(fmt, ...) DexedAudioProcessor::log(__FUNCTION__,fmt,##__VA_ARGS__) #define TRACE(fmt, ...) dexed_trace(__FUNCTION__,fmt,##__VA_ARGS__)
#else #else
#define TRACE(fmt, ...) DexedAudioProcessor::log(__PRETTY_FUNCTION__,fmt,##__VA_ARGS__) #define TRACE(fmt, ...) dexed_trace(__PRETTY_FUNCTION__,fmt,##__VA_ARGS__)
#endif #endif
#endif // PLUGINPROCESSOR_H_INCLUDED #endif // PLUGINPROCESSOR_H_INCLUDED

@ -236,10 +236,14 @@ void Dx7Note::update(const char patch[156], int midinote) {
pitchmodsens_ = pitchmodsenstab[patch[143] & 7]; 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++) { 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);
} }

@ -27,6 +27,12 @@
#include "pitchenv.h" #include "pitchenv.h"
#include "fm_core.h" #include "fm_core.h"
struct VoiceStatus {
uint32_t amp[6];
char ampStep[6];
char pitchStep;
};
class Dx7Note { class Dx7Note {
public: public:
void init(const char patch[156], int midinote, int velocity); void init(const char patch[156], int midinote, int velocity);
@ -47,7 +53,7 @@ class Dx7Note {
// PG:add the update // PG:add the update
void update(const char patch[156], int midinote); void update(const char patch[156], int midinote);
void peekEnvStatus(int32_t *env); void peekVoiceStatus(VoiceStatus &status);
private: private:
FmCore core_; FmCore core_;

@ -14,6 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
#include <math.h>
#include "synth.h" #include "synth.h"
#include "env.h" #include "env.h"
@ -99,3 +101,6 @@ void Env::advance(int newix) {
} }
} }
void Env::getPosition(char *step) {
*step = ix_;
}

@ -42,6 +42,7 @@ class Env {
void keydown(bool down); void keydown(bool down);
void setparam(int param, int value); void setparam(int param, int value);
static int scaleoutlevel(int outlevel); static int scaleoutlevel(int outlevel);
void getPosition(char *step);
private: private:
int rates_[4]; int rates_[4];
int levels_[4]; int levels_[4];

@ -84,8 +84,13 @@ void PitchEnv::advance(int newix) {
int newlevel = levels_[ix_]; int newlevel = levels_[ix_];
targetlevel_ = pitchenv_tab[newlevel] << 19; targetlevel_ = pitchenv_tab[newlevel] << 19;
rising_ = (targetlevel_ > level_); rising_ = (targetlevel_ > level_);
inc_ = pitchenv_rate[rates_[ix_]] * unit_; inc_ = pitchenv_rate[rates_[ix_]] * unit_;
} }
} }
void PitchEnv::getPosition(char *step) {
*step = ix_;
}

@ -30,6 +30,7 @@ class PitchEnv {
// Result is in Q24/octave // Result is in Q24/octave
int32_t getsample(); int32_t getsample();
void keydown(bool down); void keydown(bool down);
void getPosition(char *step);
private: private:
static int unit_; static int unit_;
int rates_[4]; int rates_[4];

Loading…
Cancel
Save