GUI: initial wave synth UI
This commit is contained in:
parent
4dfe9f97fb
commit
500ce8086d
4 changed files with 191 additions and 7 deletions
|
|
@ -485,6 +485,9 @@ enum DivWaveSynthEffects {
|
|||
DIV_WS_SUBTRACT,
|
||||
DIV_WS_AVERAGE,
|
||||
DIV_WS_PHASE,
|
||||
|
||||
DIV_WS_SINGLE_MAX,
|
||||
|
||||
// two waveform effects
|
||||
DIV_WS_NONE_DUAL=128,
|
||||
DIV_WS_WIPE,
|
||||
|
|
@ -493,12 +496,14 @@ enum DivWaveSynthEffects {
|
|||
DIV_WS_OVERLAY,
|
||||
DIV_WS_NEGATIVE_OVERLAY,
|
||||
DIV_WS_PHASE_DUAL,
|
||||
|
||||
DIV_WS_DUAL_MAX
|
||||
};
|
||||
|
||||
struct DivInstrumentWaveSynth {
|
||||
int wave1, wave2;
|
||||
unsigned char rateDivider, width, height;
|
||||
DivWaveSynthEffects effect;
|
||||
unsigned char effect;
|
||||
bool oneShot, enabled, global;
|
||||
unsigned char speed, param1, param2, param3, param4;
|
||||
DivInstrumentWaveSynth():
|
||||
|
|
|
|||
|
|
@ -1,5 +1,52 @@
|
|||
#include "waveSynth.h"
|
||||
#include "engine.h"
|
||||
|
||||
bool DivWaveSynth::tick() {
|
||||
return false;
|
||||
bool updated=first;
|
||||
first=false;
|
||||
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
void DivWaveSynth::setEngine(DivEngine* engine) {
|
||||
e=engine;
|
||||
}
|
||||
|
||||
void DivWaveSynth::init(DivInstrument* which, int w, int h, bool insChanged) {
|
||||
if (e==NULL) return;
|
||||
if (which==NULL) {
|
||||
state=DivInstrumentWaveSynth();
|
||||
}
|
||||
state=which->ws;
|
||||
width=w;
|
||||
height=h;
|
||||
pos=0;
|
||||
stage=0;
|
||||
divCounter=0;
|
||||
first=true;
|
||||
|
||||
DivWavetable* w1=e->getWave(state.wave1);
|
||||
DivWavetable* w2=e->getWave(state.wave2);
|
||||
for (int i=0; i<width; i++) {
|
||||
if (w1->max<1 || w1->len<1) {
|
||||
wave1[i]=0;
|
||||
} else {
|
||||
int data=w1->data[i*w1->len/width]*height/w1->max;
|
||||
if (data<0) data=0;
|
||||
if (data>31) data=31;
|
||||
wave1[i]=data;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<width; i++) {
|
||||
if (w2->max<1 || w2->len<1) {
|
||||
wave2[i]=0;
|
||||
} else {
|
||||
int data=w2->data[i*w2->len/width]*height/w2->max;
|
||||
if (data<0) data=0;
|
||||
if (data>31) data=31;
|
||||
wave2[i]=data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,9 +23,15 @@
|
|||
#include "instrument.h"
|
||||
#include "wavetable.h"
|
||||
|
||||
class DivEngine;
|
||||
|
||||
class DivWaveSynth {
|
||||
DivInstrument* ins;
|
||||
int pos, stage, divCounter;
|
||||
DivEngine* e;
|
||||
DivInstrumentWaveSynth state;
|
||||
int pos, stage, divCounter, width, height;
|
||||
bool first;
|
||||
unsigned char wave1[256];
|
||||
unsigned char wave2[256];
|
||||
int output[256];
|
||||
public:
|
||||
/**
|
||||
|
|
@ -33,12 +39,18 @@ class DivWaveSynth {
|
|||
* @return whether the wave has changed.
|
||||
*/
|
||||
bool tick();
|
||||
void init(DivInstrument* ins);
|
||||
void init(DivInstrument* which, int width, int height, bool insChanged=false);
|
||||
void setEngine(DivEngine* engine);
|
||||
DivWaveSynth():
|
||||
ins(NULL),
|
||||
e(NULL),
|
||||
pos(0),
|
||||
stage(0),
|
||||
divCounter(0) {
|
||||
divCounter(0),
|
||||
width(32),
|
||||
height(31),
|
||||
first(false) {
|
||||
memset(wave1,0,sizeof(int)*256);
|
||||
memset(wave2,0,sizeof(int)*256);
|
||||
memset(output,0,sizeof(int)*256);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue