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. 5
      Source/OperatorEditor.cpp
  7. 4
      Source/OperatorEditor.h
  8. 21
      Source/PluginEditor.cpp
  9. 11
      Source/PluginProcessor.cpp
  10. 11
      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) {
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);
}

@ -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);
};

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

@ -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;

@ -475,6 +475,11 @@ void OperatorEditor::updateDisplay() {
envDisplay->repaint();
}
void OperatorEditor::updateEnvPos(char pos) {
envDisplay->vPos = pos;
envDisplay->repaint();
}
//[/MiscUserCode]

@ -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]

@ -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;
@ -221,14 +210,14 @@ void DexedAudioProcessorEditor::comboBoxChanged (ComboBox* comboBoxThatHasChange
}
void DexedAudioProcessorEditor::timerCallback() {
int32_t env[6];
if ( processor->peekEnvStatus(env) == false )
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() {

@ -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);

@ -103,6 +103,7 @@ public :
char data[161];
CartridgeManager cartManager;
VoiceStatus voiceStatus;
Array<Ctrl*> ctrl;
@ -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

@ -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);
}

@ -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_;

@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <math.h>
#include "synth.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 setparam(int param, int value);
static int scaleoutlevel(int outlevel);
void getPosition(char *step);
private:
int rates_[4];
int levels_[4];

@ -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_;
}

@ -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];

Loading…
Cancel
Save