Browse Source

waveform render fixing

tags/2018-04-16
Andre Sklenar 10 years ago
parent
commit
c9f19b0c75
3 changed files with 48 additions and 34 deletions
  1. +21
    -9
      plugins/SegmentJuice/source/SegmentJuicePlugin.cpp
  2. +25
    -19
      plugins/SegmentJuice/source/SegmentJuiceUI.cpp
  3. +2
    -6
      plugins/SegmentJuice/source/Synth.hxx

+ 21
- 9
plugins/SegmentJuice/source/SegmentJuicePlugin.cpp View File

@@ -263,7 +263,7 @@ void SegmentJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter)
parameter.name = "Attack";
parameter.symbol = "att";
parameter.unit = "";
parameter.ranges.def = 0.5f;
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
@@ -272,7 +272,7 @@ void SegmentJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter)
parameter.name = "Decay";
parameter.symbol = "dec";
parameter.unit = "";
parameter.ranges.def = 0.5f;
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
@@ -281,7 +281,7 @@ void SegmentJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter)
parameter.name = "Sustain";
parameter.symbol = "sus";
parameter.unit = "";
parameter.ranges.def = 0.5f;
parameter.ranges.def = 1.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
@@ -290,7 +290,7 @@ void SegmentJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter)
parameter.name = "Release";
parameter.symbol = "rel";
parameter.unit = "";
parameter.ranges.def = 0.5f;
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
@@ -326,7 +326,7 @@ void SegmentJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter)
parameter.name = "Glide";
parameter.symbol = "gld";
parameter.unit = "";
parameter.ranges.def = 0.5f;
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
break;
@@ -594,8 +594,9 @@ void SegmentJuicePlugin::d_setProgram(uint32_t index)
FM1=FM2=FM3=FM4=FM5=FM6=0.5f;
pan1=pan2=pan3=pan4=pan5=pan6=0.0f;
amp1=amp2=amp3=amp4=amp5=amp6=0.5f;
attack=decay=sustain=release=volume=0.5f;
stereo=tune=0.0f;
attack=decay=release=stereo=tune=glide=0.0f;
sustain=1.0f;
volume=0.5f;
for (int i=0; i<6; i++) {
synthL.setFM(i, 0.5f);
@@ -621,9 +622,20 @@ void SegmentJuicePlugin::d_setProgram(uint32_t index)
synthL.setStereo(0.0f);
synthR.setStereo(0.0f);
synthL.setGlide(0.5f);
synthR.setGlide(0.5f);
synthL.setGlide(0.0f);
synthR.setGlide(0.0f);
synthL.setAttack(0.0f);
synthR.setAttack(0.0f);
synthL.setDecay(0.0f);
synthR.setDecay(0.0f);
synthL.setSustain(1.0f);
synthR.setSustain(1.0f);
synthL.setRelease(0.0f);
synthR.setRelease(0.0f);
/* reset filter values */
d_activate();


+ 25
- 19
plugins/SegmentJuice/source/SegmentJuiceUI.cpp View File

@@ -245,7 +245,7 @@ SegmentJuiceUI::SegmentJuiceUI()
fKnobAttack = new ImageKnob(this, knobImage2);
fKnobAttack->setPos(34, 248);
fKnobAttack->setRange(0.0f, 1.0f);
fKnobAttack->setValue(0.5f);
fKnobAttack->setValue(0.0f);
fKnobAttack->setRotationAngle(270);
fKnobAttack->setCallback(this);

@@ -253,7 +253,7 @@ SegmentJuiceUI::SegmentJuiceUI()
fKnobDecay = new ImageKnob(this, knobImage2);
fKnobDecay->setPos(132, 248);
fKnobDecay->setRange(0.0f, 1.0f);
fKnobDecay->setValue(0.5f);
fKnobDecay->setValue(0.0f);
fKnobDecay->setRotationAngle(270);
fKnobDecay->setCallback(this);

@@ -261,7 +261,7 @@ SegmentJuiceUI::SegmentJuiceUI()
fKnobSustain = new ImageKnob(this, knobImage2);
fKnobSustain->setPos(232, 248);
fKnobSustain->setRange(0.0f, 1.0f);
fKnobSustain->setValue(0.5f);
fKnobSustain->setValue(1.0f);
fKnobSustain->setRotationAngle(270);
fKnobSustain->setCallback(this);
@@ -269,7 +269,7 @@ SegmentJuiceUI::SegmentJuiceUI()
fKnobRelease = new ImageKnob(this, knobImage2);
fKnobRelease->setPos(330, 248);
fKnobRelease->setRange(0.0f, 1.0f);
fKnobRelease->setValue(0.5f);
fKnobRelease->setValue(0.0f);
fKnobRelease->setRotationAngle(270);
fKnobRelease->setCallback(this);

@@ -301,7 +301,7 @@ SegmentJuiceUI::SegmentJuiceUI()
fKnobGlide = new ImageKnob(this, knobImage2);
fKnobGlide->setPos(330, 339);
fKnobGlide->setRange(0.0f, 1.0f);
fKnobGlide->setValue(0.5f);
fKnobGlide->setValue(0.0f);
fKnobGlide->setRotationAngle(270);
fKnobGlide->setCallback(this);

@@ -551,15 +551,15 @@ void SegmentJuiceUI::d_programChanged(uint32_t index)
fKnobAmp5->setValue(0.5f);
fKnobAmp6->setValue(0.5f);
fKnobAttack->setValue(0.5f);
fKnobDecay->setValue(0.5f);
fKnobSustain->setValue(0.5f);
fKnobRelease->setValue(0.5f);
fKnobAttack->setValue(0.0f);
fKnobDecay->setValue(0.0f);
fKnobSustain->setValue(1.0f);
fKnobRelease->setValue(0.0f);

fKnobStereo->setValue(0.0f);
fKnobTune->setValue(0.0f);
fKnobVolume->setValue(0.5f);
fKnobGlide->setValue(0.5f);
fKnobGlide->setValue(0.0f);

for (int i=0; i<6; i++) {
synthL.setFM(i, 0.5f);
@@ -588,6 +588,10 @@ void SegmentJuiceUI::d_programChanged(uint32_t index)
synthR.setSustain(1);
synthL.setRelease(0);
synthR.setRelease(0);
synthL.setGlide(0);
synthR.setGlide(0);
synthL.setTune(0);
synthR.setTune(0);
}

// -----------------------------------------------------------------------
@@ -816,22 +820,24 @@ void SegmentJuiceUI::onDisplay()
int cY = 50;
int cW = 388-cX-3;
int cH = 216-cY;


//draw waveform
synthL.play(71);
synthR.play(71);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable( GL_LINE_SMOOTH );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
glLineWidth(0.06f);

//glEnable(GL_BLEND);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glEnable( GL_LINE_SMOOTH );
//glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
glLineWidth(1.0f);
//draw #left waveform
glColor4f(0.0f, 1.0f, 0.0f, 0.5f);
glBegin(GL_LINE_STRIP);
for (int i = 0; i<cW; i++) {
glVertex2i(i+cX, synthL.run()*cH/2+cH/2+cY);
float out = synthL.run()*cH/2+cH/2+cY;
glVertex2i(i+cX, out);
std::cout << out << std::endl;
}
//draw #right waveform
glEnd();
@@ -843,8 +849,8 @@ void SegmentJuiceUI::onDisplay()
glEnd();

//draw 0dc line
glLineWidth(1.0f);
glColor4f(1.0f, 1.0f, 1.0f, 0.2f);
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
glBegin(GL_LINES);
glVertex2i(cX, cY+cH/2);
glVertex2i(cX+cW, cY+cH/2);


+ 2
- 6
plugins/SegmentJuice/source/Synth.hxx View File

@@ -44,7 +44,7 @@ public:
glideDistance = 0;
attack=decay=sustain=release=0.5f;
attack=decay=sustain=release=0.0f;
mAmp = 0.5;
freqOffset = 0;
}
@@ -214,7 +214,6 @@ public:
float out = 0;
if (playing) {

if (freq!=tFreq) {
//gliding yo
gl+=gCoeff * ((1.0/1.0) - gl);
@@ -235,7 +234,6 @@ public:
} else {// if (phaseAccum<cycleSize*0.875) {
out += getBlendedPhase((phaseAccum/cycleSize)*(getBlendedPhase(phaseAccum/(cycleSize*8), waves[5], -1)*FMs[5])*16*(2*M_PI), waves[5], -1)*pans[5]*amps[5]*0.5*2;
}

phaseAccum++;
if (phaseAccum>cycleSize) {
phaseAccum = 0;
@@ -260,13 +258,11 @@ public:
out*=env;

//apply master volume
out*=mAmp*1.5;
out*=mAmp*0.5;
//apply hard clipping
if (out>1) out=1;
if (out<-1) out=-1;
}

return out;
}


Loading…
Cancel
Save