Example #1
0
	void testPatterns()
	{
		FloatModel model;

		auto song = Engine::getSong();
		AutomationTrack track(song);

		AutomationPattern p1(&track);
		p1.setProgressionType(AutomationPattern::LinearProgression);
		p1.putValue(0, 0.0, false);
		p1.putValue(10, 1.0, false);
		p1.movePosition(0);
		p1.addObject(&model);

		AutomationPattern p2(&track);
		p2.setProgressionType(AutomationPattern::LinearProgression);
		p2.putValue(0, 0.0, false);
		p2.putValue(100, 1.0, false);
		p2.movePosition(100);
		p2.addObject(&model);

		AutomationPattern p3(&track);
		p3.addObject(&model);
		//XXX: Why is this even necessary?
		p3.clear();

		QCOMPARE(song->automatedValuesAt(  0)[&model], 0.0f);
		QCOMPARE(song->automatedValuesAt(  5)[&model], 0.5f);
		QCOMPARE(song->automatedValuesAt( 10)[&model], 1.0f);
		QCOMPARE(song->automatedValuesAt( 50)[&model], 1.0f);
		QCOMPARE(song->automatedValuesAt(100)[&model], 0.0f);
		QCOMPARE(song->automatedValuesAt(150)[&model], 0.5f);
	}
	void testLengthRespected()
	{
		FloatModel model;

		auto song = Engine::getSong();
		AutomationTrack track(song);

		AutomationPattern p(&track);
		p.setProgressionType(AutomationPattern::LinearProgression);
		p.addObject(&model);

		p.putValue(0, 0.0, false);
		p.putValue(100, 1.0, false);

		p.changeLength(100);
		QCOMPARE(song->automatedValuesAt(  0)[&model], 0.0f);
		QCOMPARE(song->automatedValuesAt( 50)[&model], 0.5f);
		QCOMPARE(song->automatedValuesAt(100)[&model], 1.0f);

		p.changeLength(50);
		QCOMPARE(song->automatedValuesAt(  0)[&model], 0.0f);
		QCOMPARE(song->automatedValuesAt( 50)[&model], 0.5f);
		QCOMPARE(song->automatedValuesAt(100)[&model], 0.5f);
	}
	void testGlobalAutomation()
	{
		// Global automation should not have priority, see https://github.com/LMMS/lmms/issues/4268
		// Tests regression caused by 75077f6200a5aee3a5821aae48a3b8466ed8714a
		auto song = Engine::getSong();

		auto globalTrack = song->globalAutomationTrack();
		AutomationPattern globalPattern(globalTrack);

		AutomationTrack localTrack(song);
		AutomationPattern localPattern(&localTrack);

		FloatModel model;
		globalPattern.setProgressionType(AutomationPattern::DiscreteProgression);
		localPattern.setProgressionType(AutomationPattern::DiscreteProgression);
		globalPattern.addObject(&model);
		localPattern.addObject(&model);
		globalPattern.putValue(0, 100.0f, false);
		localPattern.putValue(0, 50.0f, false);

		QCOMPARE(song->automatedValuesAt(0)[&model], 50.0f);
	}
Example #4
0
	void testBBTrack()
	{
		auto song = Engine::getSong();
		auto bbContainer = Engine::getBBTrackContainer();
		BBTrack bbTrack(song);
		AutomationTrack automationTrack(bbContainer);
		bbTrack.createTCOsForBB(bbTrack.index());

		QVERIFY(automationTrack.numOfTCOs());
		AutomationPattern* p1 = dynamic_cast<AutomationPattern*>(automationTrack.getTCO(0));
		QVERIFY(p1);

		FloatModel model;

		p1->setProgressionType(AutomationPattern::LinearProgression);
		p1->putValue(0, 0.0, false);
		p1->putValue(10, 1.0, false);
		p1->addObject(&model);

		QCOMPARE(bbContainer->automatedValuesAt( 0, bbTrack.index())[&model], 0.0f);
		QCOMPARE(bbContainer->automatedValuesAt( 5, bbTrack.index())[&model], 0.5f);
		QCOMPARE(bbContainer->automatedValuesAt(10, bbTrack.index())[&model], 1.0f);
		QCOMPARE(bbContainer->automatedValuesAt(50, bbTrack.index())[&model], 1.0f);

		BBTrack bbTrack2(song);
		bbTrack.createTCOsForBB(bbTrack2.index());

		QCOMPARE(bbContainer->automatedValuesAt(5, bbTrack.index())[&model], 0.5f);
		QVERIFY(! bbContainer->automatedValuesAt(5, bbTrack2.index()).size());

		BBTCO tco(&bbTrack);
		tco.changeLength(MidiTime::ticksPerTact() * 2);
		tco.movePosition(0);

		QCOMPARE(song->automatedValuesAt(0)[&model], 0.0f);
		QCOMPARE(song->automatedValuesAt(5)[&model], 0.5f);
		QCOMPARE(song->automatedValuesAt(MidiTime::ticksPerTact() + 5)[&model], 0.5f);
	}