mirror of
https://github.com/tildearrow/furnace.git
synced 2024-10-31 18:12:40 +00:00
parent
d4e60e0c03
commit
6e28a8b01c
2 changed files with 25 additions and 6 deletions
|
@ -22,6 +22,22 @@
|
||||||
#include "instrument.h"
|
#include "instrument.h"
|
||||||
#include "../ta-log.h"
|
#include "../ta-log.h"
|
||||||
|
|
||||||
|
inline bool effectOnlyAltersOutput(unsigned char effect) {
|
||||||
|
switch (effect) {
|
||||||
|
case DIV_WS_NONE:
|
||||||
|
case DIV_WS_INVERT:
|
||||||
|
case DIV_WS_ADD:
|
||||||
|
case DIV_WS_SUBTRACT:
|
||||||
|
case DIV_WS_AVERAGE:
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool DivWaveSynth::activeChanged() {
|
bool DivWaveSynth::activeChanged() {
|
||||||
if (activeChangedB) {
|
if (activeChangedB) {
|
||||||
activeChangedB=false;
|
activeChangedB=false;
|
||||||
|
@ -211,19 +227,21 @@ void DivWaveSynth::setWidth(int val) {
|
||||||
if (width>256) width=256;
|
if (width>256) width=256;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivWaveSynth::changeWave1(int num) {
|
#define SHALL_UPDATE_OUT (!state.enabled || force || (state.enabled && effectOnlyAltersOutput(state.effect)))
|
||||||
|
|
||||||
|
void DivWaveSynth::changeWave1(int num, bool force) {
|
||||||
DivWavetable* w1=e->getWave(num);
|
DivWavetable* w1=e->getWave(num);
|
||||||
if (width<1) return;
|
if (width<1) return;
|
||||||
for (int i=0; i<width; i++) {
|
for (int i=0; i<width; i++) {
|
||||||
if (w1->max<1 || w1->len<1) {
|
if (w1->max<1 || w1->len<1) {
|
||||||
wave1[i]=0;
|
wave1[i]=0;
|
||||||
output[i]=0;
|
if (SHALL_UPDATE_OUT) output[i]=0;
|
||||||
} else {
|
} else {
|
||||||
int data=w1->data[i*w1->len/width]*height/w1->max;
|
int data=w1->data[i*w1->len/width]*height/w1->max;
|
||||||
if (data<0) data=0;
|
if (data<0) data=0;
|
||||||
if (data>height) data=height;
|
if (data>height) data=height;
|
||||||
wave1[i]=data;
|
wave1[i]=data;
|
||||||
output[i]=data;
|
if (SHALL_UPDATE_OUT) output[i]=data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
first=true;
|
first=true;
|
||||||
|
@ -280,9 +298,9 @@ void DivWaveSynth::init(DivInstrument* which, int w, int h, bool insChanged) {
|
||||||
divCounter=0;
|
divCounter=0;
|
||||||
subDivCounter=0;
|
subDivCounter=0;
|
||||||
|
|
||||||
changeWave1(state.wave1);
|
changeWave1(state.wave1,true);
|
||||||
changeWave2(state.wave2);
|
changeWave2(state.wave2);
|
||||||
tick(true);
|
//tick(true); // ???
|
||||||
first=true;
|
first=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,9 @@ class DivWaveSynth {
|
||||||
/**
|
/**
|
||||||
* change the first wave.
|
* change the first wave.
|
||||||
* @param num wavetable number.
|
* @param num wavetable number.
|
||||||
|
* @param force whether to force overwriting the current wave.
|
||||||
*/
|
*/
|
||||||
void changeWave1(int num);
|
void changeWave1(int num, bool force=false);
|
||||||
/**
|
/**
|
||||||
* change the second wave.
|
* change the second wave.
|
||||||
* @param num wavetable number.
|
* @param num wavetable number.
|
||||||
|
|
Loading…
Reference in a new issue