Esempio n. 1
0
void TestChainElement::TestMultiItemBoostOnlySomeItemsBoosted()
{
	ComparisonContext cContext;
	WBP chain1Weights[] = {WBP(2.,1.), WBP(0.75, 2.0), WBP(0.3, 1.0), WBP(-1,-1)};
	// 0.75*2 + 0.3*1 = 1.8 - less than 2, boosting doesn't change the move
	// (0.75 + 0.3) * 2 = 1.05 * 2 = 2.1 - more than 2, boosting does change the move
	// which should it be?
	// it should be the first option - only boost the elements which have the boosting value set, not to apply the boost 
	// of the first element to all
	// however, that's much too hard - it involves a big change to the 'patterson' section of the move determination algorithm
	// and that's a black box as far as I'm concerned. Oh Well...


	TestChainArray chain1( &cContext, Original, chain1Weights );

	WBP chain2Weights[] = {WBP(0.75, 2.5), WBP(0.3, 1.0), WBP(2. ,1.), WBP(-1,-1)};
	TestChainArray chain2( &cContext, Modified, chain2Weights );

	chain1[0]->Bridge(chain2[2]);
	chain1[1]->Bridge(chain2[0]);
	chain1[2]->Bridge(chain2[1]);

	chain1[0]->FindMoves(chain2[0]);

	assertMessage(chain1[0]->IsMoved(), _T("The higher weighted item should be moved, as it scores less when the others are boosted"));
	assertMessage(!chain1[1]->IsMoved(), _T("the second item has a higher weight, and scores more when boosted -> moved"));
	assertMessage(!chain1[2]->IsMoved(), _T("the second item has a higher weight, and scores more when boosted -> moved"));
}
Esempio n. 2
0
void TestChainElement::TestUseOfMoveWeightingBoost()
{
	ComparisonContext cContext;
	WBP chain1Weights[] = {WBP(2.,1.), WBP(1.5, 2.), WBP(-1,-1)};
	TestChainArray chain1( &cContext, Original, chain1Weights );

	WBP chain2Weights[] = {WBP(1.5, 2.), WBP(2.,1.), WBP(-1,-1)};
	TestChainArray chain2( &cContext, Modified, chain2Weights );

	chain1[0]->Bridge(chain2[1]);
	chain1[1]->Bridge(chain2[0]);

	chain1[0]->FindMoves(chain2[0]);

	assertMessage(chain1[0]->IsMoved(), _T("The higher weighted item should be moved, as it scores lower when boosted"));
	assertMessage(!chain1[1]->IsMoved(), _T("the second item has a lower weight, but scores more when boosted -> no move"));
}
Esempio n. 3
0
void TestChainElement::TestDoesntBoosIfWeightLessThanOne()
{
	ComparisonContext cContext;
	WBP chain1Weights[] = {WBP(2.,1.), WBP(0.75, 4.), WBP(-1,-1)};
	TestChainArray chain1( &cContext, Original, chain1Weights );

	WBP chain2Weights[] = {WBP(0.75, 4.), WBP(2. ,1.), WBP(-1,-1)};
	TestChainArray chain2( &cContext, Modified, chain2Weights );

	chain1[0]->Bridge(chain2[1]);
	chain1[1]->Bridge(chain2[0]);

	chain1[0]->FindMoves(chain2[0]);

	assertMessage(!chain1[0]->IsMoved(), _T("The higher weighted item should not be moved"));
	assertMessage(!chain1[1]->IsMoved(), _T("the second item has a lower weight, and will not be boosted, since it scores less than one without boost"));
	assertMessage(!chain1[1]->GetBridge(), _T("the second item doesn't qualify as a move, so its bridge should be broken"));
}
Esempio n. 4
0
void TestChainElement::TestWeightingBoostForMultipleElementMoves()
{
	ComparisonContext cContext;
	WBP chain1Weights[] = {WBP(2.,1.), WBP(0.75, 4.), WBP(0.5, 4.0), WBP(-1,-1)};
	TestChainArray chain1( &cContext, Original, chain1Weights );

	WBP chain2Weights[] = {WBP(0.75, 4.), WBP(0.5, 4.0), WBP(2. ,1.), WBP(-1,-1)};
	TestChainArray chain2( &cContext, Modified, chain2Weights );

	chain1[0]->Bridge(chain2[2]);
	chain1[1]->Bridge(chain2[0]);
	chain1[2]->Bridge(chain2[1]);

	chain1[0]->FindMoves(chain2[0]);

	assertMessage(chain1[0]->IsMoved(), _T("The higher weighted item should be moved, as it scores lower when boosted"));
	assertMessage(!chain1[1]->IsMoved(), _T("the second item has a lower weight, but scores more when boosted -> no move"));
	assertMessage(chain1[1]->GetBridge(), _T("just checking we haven't lost the bridge"));
	assertMessage(!chain1[2]->IsMoved(), _T("the second item has a lower weight, but scores more when boosted -> no move"));
	assertMessage(chain1[2]->GetBridge(), _T("just checking we haven't lost the bridge"));
}
Esempio n. 5
0
static sample_t diff_resampled(const SRCParams &params, sample_t *buf1, sample_t *buf2, size_t size)
{
  /////////////////////////////////////////////////////////////////////////////
  // After resample only q*nyquist of the bandwidth is preserved. Therefore,
  // to compare output of the resampler with the original signal we must feed
  // the resampler with the bandlimited signal. Bandlimiting filter has a
  // transition band and we must guarantee:
  // passband + transition_band <= q*nyquist.
  //
  // It looks reasonable to make the transition band of the bandlimiting filter
  // to be equal to the transition band of the resampler. In this case we have:
  // passband + (1-q)*nyquist <= q*nyquist
  // passband <= (2q - 1)*nyquist
  //
  // In normalized form nyquist = 0.5, so we have following parameters of the
  // bandlimiting filter: passband = q-0.5, transition band = 0.5*(1-q)

  ParamFIR low_pass(ParamFIR::low_pass, params.q-0.5, 0, 0.5*(1-params.q), params.a + 10, true);

  const FIRInstance *fir = low_pass.make(params.fs);
  BOOST_REQUIRE(fir != 0);
  int trans_len = fir->length * 2;
  delete fir;

  Speakers spk(FORMAT_LINEAR, MODE_MONO, params.fs);
  samples_t s1, s2;
  s1.zero(); s1[0] = buf1;
  s2.zero(); s2[0] = buf2;

  ChunkSource src1(spk, Chunk(s1, size));
  ChunkSource src2(spk, Chunk(s2, size));
  Convolver   conv1(&low_pass);
  Convolver   conv2(&low_pass);
  SliceFilter slice1(trans_len, size - trans_len);
  SliceFilter slice2(trans_len, size - trans_len);
  FilterChain chain1(&conv1, &slice1);
  FilterChain chain2(&conv2, &slice2);
  return calc_diff(&src1, &chain1, &src2, &chain2);
}
Esempio n. 6
0
void TestChainElement::TestMovesInRandomMess()
{
	ComparisonContext cContext;
	double chain1Weights[] = {4.0, 3.1, 2.5, 3.0, 3.5, -1.0};
	TestChainArray chain1( &cContext, Original, chain1Weights );

	double chain2Weights[] = {3.1, 3.5, 4.0, 3.0, 2.5, -1.0};
	TestChainArray chain2( &cContext, Modified, chain2Weights );

	chain1[0]->Bridge(chain2[2]);
	chain1[1]->Bridge(chain2[0]);
	chain1[2]->Bridge(chain2[4]);
	chain1[3]->Bridge(chain2[3]);
	chain1[4]->Bridge(chain2[1]);

	chain1[0]->FindMoves(chain2[0]);

	assertTest(!chain1[0]->IsMoved());
	assertTest(chain1[1]->IsMoved());
	assertTest(chain1[2]->IsMoved());
	assertTest(!chain1[3]->IsMoved());
	assertTest(chain1[4]->IsMoved());
}
Esempio n. 7
0
void TestChainElement::TestMoves_MultiSmallItemsOutweightOneLarge()
{
	ComparisonContext cContext;
	double chain1Weights[] = {0.8, 1.0, 0.9, 0.7, 3.0, -1.0};
	TestChainArray chain1( &cContext, Original, chain1Weights );

	double chain2Weights[] = {3.0, 0.8, 1.0, 0.9, 0.7, -1.0};
	TestChainArray chain2( &cContext, Modified,  chain2Weights );

	chain1[0]->Bridge(chain2[1]);
	chain1[1]->Bridge(chain2[2]);
	chain1[2]->Bridge(chain2[3]);
	chain1[3]->Bridge(chain2[4]);
	chain1[4]->Bridge(chain2[0]);

	chain1[0]->FindMoves(chain2[0]);

	assertTest(!chain1[0]->IsMoved());
	assertTest(!chain1[1]->IsMoved());
	assertTest(!chain1[2]->IsMoved());
	assertTest(!chain1[3]->IsMoved());
	assertTest(chain1[4]->IsMoved());

}