Skip to content

Commit

Permalink
PanAz: initialize amps in Ctor
Browse files Browse the repository at this point in the history
Fixes an hardcoded fade-in from 0 in ak/kr cases, due to missing
initialization of amplitudes
  • Loading branch information
elgiano committed May 26, 2020
1 parent ee50e10 commit ccce657
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/plugins/PanUGens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,9 +1268,10 @@ void PanAz_next_ak_nova(PanAz* unit, int inNumSamples);
#endif

void PanAz_Ctor(PanAz* unit) {
unit->m_chanamp = nullptr;
if (INRATE(1) == calc_FullRate) {
unit->m_chanamp = NULL;
SETCALC(PanAz_next_aa);
PanAz_next_aa(unit, 1);
} else {
int numOutputs = unit->mNumOutputs;
for (int i = 0; i < numOutputs; ++i)
Expand All @@ -1293,6 +1294,7 @@ void PanAz_Ctor(PanAz* unit) {
#else
SETCALC(PanAz_next_ak);
#endif
PanAz_next_ak(unit, 1);
}
}

Expand Down
44 changes: 44 additions & 0 deletions testsuite/classlibrary/TestPanAz.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
TestPanAz : UnitTest {

var server;

setUp {
server = Server(this.class.name);
}

tearDown {
if(server.serverRunning) { server.quit };
server.remove;
}

test_PanAz_ak_initializesAmps {
var firstSample;
var cond = Condition.new;

server.bootSync;

{ PanAz.ar(2, DC.ar(1), -0.5) }.loadToFloatArray( 1 / server.sampleRate, server, { |output|
firstSample = output[0];
cond.unhang;
});

cond.hang;
this.assertEquals(firstSample, 1.0, "Initial amplitude should match signals' amp");
}

test_PanAz_ar_initializesAmps {
var firstSample;
var cond = Condition.new;

server.bootSync;

{ PanAz.ar(2, DC.ar(1), DC.ar(-0.5)) }.loadToFloatArray( 1 / server.sampleRate, server, { |output|
firstSample = output[0];
cond.unhang;
});

cond.hang;
this.assertEquals(firstSample, 1.0, "Initial amplitude should match signals' amp");
}

}

0 comments on commit ccce657

Please sign in to comment.