Skip to content

Commit

Permalink
Merge pull request #4973 from elgiano/topic/4387
Browse files Browse the repository at this point in the history
class library: PanAz: initialize amps in Ctor
  • Loading branch information
mossheim authored Aug 9, 2020
2 parents a50e14a + ccce657 commit fd48a9d
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 fd48a9d

Please sign in to comment.