1
0
mirror of https://github.com/AquaMorph/Droplets.git synced 2025-05-20 01:16:58 +00:00

VCO title bar changes based on wave shape

This commit is contained in:
Christian Colglazier 2020-09-26 13:24:13 -04:00
parent 62497cade0
commit b04fdf7f70
5 changed files with 64 additions and 9 deletions

@ -19,7 +19,7 @@ VCODroplet::VCODroplet(DaisyPatch* m_patch,
}
VCODroplet::~VCODroplet() {
delete wave;
// delete wave;
}
void VCODroplet::Control() {}
@ -51,10 +51,12 @@ void VCODroplet::Process(float** in, float** out, size_t size) {
void VCODroplet::Draw() {
WriteString(*Patch(), 0, 54, Font_6x8,
WaveToString(wavectrl.Process()));
SetWaveState(wavectrl.Process());
wave->DrawTile(*Patch(), GetScreenMin(), 0, GetScreenMax(), GetTitleHeight());
if(NeedUpdate()) {
//wave->AdjustXShift(1);
wave->AdjustXShift(1);
}
//testWave->DrawTile(*Patch(), 0, GetTitleHeight(), 60, GetTitleHeight()+testH);
DrawName("VCO");
AnimationInc();
}
@ -80,3 +82,33 @@ std::string VCODroplet::WaveToString(uint8_t wf) {
}
return "";
}
void VCODroplet::SetWaveState(uint8_t wf) {
switch(wf){
case Oscillator::WAVE_TRI:
wave->SetWaveShape(WaveShape::kTriangle);
return;
case Oscillator::WAVE_SQUARE:
wave->SetWaveShape(WaveShape::kSquare);
return;
case Oscillator::WAVE_SIN:
wave->SetWaveShape(WaveShape::kSine);
return;
case Oscillator::WAVE_SAW:
wave->SetWaveShape(WaveShape::kSaw);
return;
case Oscillator::WAVE_RAMP:
wave->SetWaveShape(WaveShape::kRamp);
return;
case Oscillator::WAVE_POLYBLEP_TRI:
wave->SetWaveShape(WaveShape::kTriangle);
return;
case Oscillator::WAVE_POLYBLEP_SQUARE:
wave->SetWaveShape(WaveShape::kSquare);
return;
default:
case Oscillator::WAVE_POLYBLEP_SAW:
wave->SetWaveShape(WaveShape::kSaw);
return;
}
}

@ -20,9 +20,12 @@ private:
Oscillator osc;
Parameter freqctrl, wavectrl, ampctrl, finectrl;
std::string WaveToString(uint8_t);
void SetWaveState(uint8_t);
const double pi = std::acos(-1);
int sine_width = 20;
int sine_width = 21;
Wave* wave = new Wave(WaveShape::kTriangle, sine_width, GetTitleHeight());
int testH = 20;
//Wave* testWave = new Wave(WaveShape::kSaw, 30, testH);
public:
VCODroplet(DaisyPatch*, DropletState, float);
~VCODroplet();

@ -20,7 +20,7 @@ Sprite::~Sprite() {
}
void Sprite::AddPixel(int x, int y, bool solid) {
sprite[x][y] = solid;
sprite[x][height-y-1] = solid;
}
void Sprite::AddLine(int x1,
@ -65,7 +65,7 @@ void Sprite::Draw(DaisyPatch patch, int x, int y) {
for (int h = 0; h < height; h++) {
patch.display.DrawPixel(x+w, y+h,
sprite[GetShiftArrayX(w)]
[GetShiftArrayY(h)]);
[GetShiftArrayY(height-h)]);
}
}
}
@ -79,10 +79,12 @@ void Sprite::DrawTile(DaisyPatch patch,
int x_max = std::max(x1, x2);
int y_min = std::min(y1, y2);
int y_max = std::max(y1, y2);
int x, y;
for (int w = x_min; w < x_max; w++) {
for (int h = y_min; h < y_max; h++) {
patch.display.DrawPixel(w, h, sprite[GetShiftArrayX((w-x_min) % width)]
[GetShiftArrayY((h-y_min+y_shift) % height)]);
x = GetShiftArrayX((w-x_min) % width);
y = GetShiftArrayY((h-y_min) % height);
patch.display.DrawPixel(w, h, sprite[x][y]);
}
}
}

@ -8,10 +8,22 @@ Wave::Wave(WaveShape m_wave, int width, int height) : Sprite(width, height) {
void Wave::DrawShape() {
SetBlank();
int mid = GetWidth()/2;
int x_max = GetWidth()-1;
int y_max = GetHeight()-1;
switch(wave) {
case WaveShape::kSaw:
AddLine(0, 0, x_max, y_max, true);
AddLine(x_max, y_max, x_max, 0, true);
return;
case WaveShape::kSquare:
AddLine(0, 0, mid, 0, true);
AddLine(mid, 0, mid, y_max, true);
AddLine(mid, y_max, x_max, y_max, true);
AddLine(GetWidth()-1, GetHeight()-1, GetWidth()-1, 0, true);
return;
case WaveShape::kTriangle:
AddLine(0, GetHeight()+1, mid, 0, true);
AddLine(mid, 0, GetWidth()+1, GetHeight(), true);
AddLine(0, 0, mid, y_max, true);
AddLine(mid, y_max, x_max, 0, true);
return;
case WaveShape::kSine:
default:
@ -22,3 +34,8 @@ void Wave::DrawShape() {
return;
}
}
void Wave::SetWaveShape(WaveShape m_wave) {
wave = m_wave;
DrawShape();
}

@ -14,6 +14,7 @@ class Wave: public Sprite {
void DrawShape();
public:
Wave(WaveShape, int, int);
void SetWaveShape(WaveShape);
};
#endif