Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set first sample of output in Ctor #223

Merged
merged 4 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions source/DWGUGens/DWGBowed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ struct DWGBowedSimple:public Unit
float rellevel;
float rellevelstep;
};
SCWrapClass(DWGBowedSimple);
SCWrapClassZeroInit(DWGBowedSimple);
DWGBowedSimple::DWGBowedSimple(Unit* unit){
m_trig = 0.0;
float release = ZIN0(5);
relcount = SAMPLERATE * release;
rellevel = 1.0;
rellevelstep = 1.0/(float)relcount;
SETCALC(DWGBowedSimple_next);
}
void DWGBowedSimple::Release(float trig,float *out,int NumSamples){

Expand Down Expand Up @@ -78,8 +77,8 @@ struct DWGBowedStk : public DWGBowedSimple
{
DWGBowedStk(Unit* unit);
};
SCWrapClass(DWGBowedStk);
DWGBowedStk::DWGBowedStk(Unit* unit):DWGBowedSimple(unit){ SETCALC(DWGBowedStk_next);}
SCWrapClassZeroInit(DWGBowedStk);
DWGBowedStk::DWGBowedStk(Unit* unit):DWGBowedSimple(unit){ }
////////////////////////////////////////////////////
struct DWGBowed : public DWGBowedSimple
{
Expand All @@ -101,8 +100,8 @@ const float DWGBowed::mus = 0.8;
const float DWGBowed::mud = 0.3;
const float DWGBowed::mue = 0.2;

SCWrapClass(DWGBowed);
DWGBowed::DWGBowed(Unit* unit):DWGBowedSimple(unit),stickslip(0){ SETCALC(DWGBowed_next);}
SCWrapClassZeroInit(DWGBowed);
DWGBowed::DWGBowed(Unit* unit):DWGBowedSimple(unit),stickslip(0){ }
////////////////////////////////////////////////////
struct DWGBowedTor:public DWGBowed{
DCBlocker dcblock2;
Expand All @@ -111,8 +110,8 @@ struct DWGBowedTor:public DWGBowed{
DWGBowedTor(Unit* unit);
float Ztra,Ztor;
};
SCWrapClass(DWGBowedTor);
DWGBowedTor::DWGBowedTor(Unit* unit):DWGBowed(unit){ SETCALC(DWGBowedTor_next);}
SCWrapClassZeroInit(DWGBowedTor);
DWGBowedTor::DWGBowedTor(Unit* unit):DWGBowed(unit){ }
/////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////
Expand All @@ -125,10 +124,9 @@ struct DWGSoundBoard : public Unit
DWGSoundBoard(Unit *unit);
~DWGSoundBoard(){};
};
SCWrapClass(DWGSoundBoard);
SCWrapClassZeroInit(DWGSoundBoard);
DWGSoundBoard :: DWGSoundBoard(Unit *unit){
getargs(unit,true);
SETCALC(DWGSoundBoard_next);
}
void DWGSoundBoard::getargs(Unit *unit,bool force)
{
Expand Down
12 changes: 6 additions & 6 deletions source/DWGUGens/DWGPlucked.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ struct DWGPlucked : public Unit
float rellevel;
float rellevelstep;
};
SCWrapClass(DWGPlucked);
SCWrapClassZeroInit(DWGPlucked);
DWGPlucked::DWGPlucked(Unit* unit)
{
m_trig = 0.0;
float release = ZIN0(7);
relcount = SAMPLERATE * release;
rellevel = 1.0;
rellevelstep = 1.0/(float)relcount;
SETCALC(DWGPlucked_next);

}
void DWGPlucked::Release(float trig,float *out,int NumSamples){

Expand Down Expand Up @@ -112,11 +112,11 @@ struct DWGPluckedStiff : public DWGPlucked
ThirianDispersion<4> disper;
DWGPluckedStiff(Unit* unit);
};
SCWrapClass(DWGPluckedStiff);
SCWrapClassZeroInit(DWGPluckedStiff);

DWGPluckedStiff::DWGPluckedStiff(Unit* unit):DWGPlucked(unit)
{
SETCALC(DWGPluckedStiff_next);

}

void DWGPluckedStiff_next(DWGPluckedStiff *unit, int inNumSamples)
Expand Down Expand Up @@ -170,11 +170,11 @@ struct DWGPlucked2 : public DWGPlucked
FilterC1C3 Loss2;
DWGPlucked2(Unit* unit);
};
SCWrapClass(DWGPlucked2);
SCWrapClassZeroInit(DWGPlucked2);

DWGPlucked2::DWGPlucked2(Unit* unit):DWGPlucked(unit)
{
SETCALC(DWGPlucked2_next);

}

void DWGPlucked2_next(DWGPlucked2 *unit, int inNumSamples)
Expand Down
8 changes: 8 additions & 0 deletions source/DWGUGens/dwglib/DWG.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ void volcar(const char *_Message, const char *_File, unsigned _Line);
void classname##_Ctor(classname* unit){new(unit) classname(unit);}\
void classname##_Dtor(classname* unit){unit->~classname();}

#define SCWrapClassZeroInit(classname) extern "C" {\
void classname##_Ctor(classname* unit);\
void classname##_next(classname *unit, int inNumSamples);\
void classname##_Dtor(classname *unit);\
}\
void classname##_Ctor(classname* unit){new(unit) classname(unit);SETCALC(classname##_next);ClearUnitOutputs(unit, 1);}\
void classname##_Dtor(classname* unit){unit->~classname();}


inline bool approximatelyEqual(float a, float b, float epsilon = 1e-7f)
{
Expand Down
3 changes: 3 additions & 0 deletions source/OteyPianoUGens/OteyPiano.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ OteySoundBoard::OteySoundBoard(Unit *unit){
shaping3.setcoeffs(800.0,SAMPLERATE,1.0,Biquad::low);
soundboard.setcoeffs(c1b,c3b,-1.0/4.0,mix,SAMPLERATE);
SETCALC(OteySoundBoard_next);
ClearUnitOutputs(unit, 1);
}

void OteyPianoStrings_Ctor(OteyPianoStrings* unit) {
Expand Down Expand Up @@ -328,6 +329,7 @@ void OteyPianoStrings_Ctor(OteyPianoStrings* unit) {
new(unit) OteyPianoStrings(unit);
unit->piano.init(freq,SAMPLERATE,velocity*10,minr,maxr,amprl,amprr,rcore,minl,maxl,ampll,amplr,rho,young,zb,zh,mh,k,alpha,p,ph,loss,detune,hammer_type);
SETCALC(OteyPianoStrings_next);
ClearUnitOutputs(unit, 1);
}

void OteyPianoStrings_Dtor(OteyPianoStrings* unit) {
Expand Down Expand Up @@ -384,6 +386,7 @@ void OteyPiano_Ctor(OteyPiano* unit) {
unit->piano.init(freq,SAMPLERATE,velocity*10,minr,maxr,ampr,centerr,rcore,minl,maxl,ampl,centerl,rho,young,zb,zh,mh,k,alpha,p,ph,loss,detune,hammer_type);

SETCALC(OteyPiano_next);
ClearUnitOutputs(unit, 1);
}

void OteyPiano_Dtor(OteyPiano* unit) {
Expand Down
6 changes: 4 additions & 2 deletions source/StkInst/StkInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ void StkInst_Ctor(StkInst* unit) {
}

SETCALC(StkInst_next);
ClearUnitOutputs(unit, 1);
}

void StkInst_Dtor(StkInst* unit)
Expand Down Expand Up @@ -318,10 +319,10 @@ void StkMesh2D_Ctor(StkMesh2D* unit) {
SETCALC(StkMesh2D_next_nop);
return;
}
//Print("Mesh created\n");

unit->inst->setDecay(unit->decay);
SETCALC(StkMesh2D_next);
//Print("Mesh created2\n");
ClearUnitOutputs(unit, 1);
}

void StkMesh2D_Dtor(StkMesh2D* unit)
Expand Down Expand Up @@ -411,6 +412,7 @@ void StkGlobals_Ctor(StkGlobals* unit) {
Stk::printErrors(unit->printErrors);
RTFree(unit->mWorld,unit->rawwavePath);
SETCALC(StkGlobals_next);
(unit->mCalcFunc)(unit, 1);
}
////////////////////////////////////////
PluginLoad(StkUnit){
Expand Down