1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#include "../src/core/sampleChannel.h"
#include "../src/core/sampleChannelRec.h"
#include <catch.hpp>
using namespace giada;
using namespace giada::m;
TEST_CASE("sampleChannelRec")
{
const int BUFFER_SIZE = 1024;
SampleChannel ch(false, BUFFER_SIZE);
SECTION("start reading actions, don't treat recs as loop")
{
sampleChannelRec::startReadingActions(&ch, /*treatRecsAsLoops=*/false,
/*recsStopOnChanHalt=*/false);
REQUIRE(ch.recStatus == ChannelStatus::OFF);
REQUIRE(ch.readActions == true);
}
SECTION("start reading actions, do treat recs as loop")
{
sampleChannelRec::startReadingActions(&ch, /*treatRecsAsLoops=*/true,
/*recsStopOnChanHalt=*/false);
REQUIRE(ch.recStatus == ChannelStatus::WAIT);
REQUIRE(ch.readActions == false);
}
SECTION("stop reading actions")
{
/* First state: PLAY */
ch.recStatus = ChannelStatus::PLAY;
sampleChannelRec::stopReadingActions(&ch, /*clockRunning=*/true,
/*treatRecsAsLoops=*/false, /*recsStopOnChanHalt=*/false);
REQUIRE(ch.readActions == false);
REQUIRE(ch.recStatus == ChannelStatus::PLAY);
/* Second state: WAIT */
ch.recStatus = ChannelStatus::WAIT;
sampleChannelRec::stopReadingActions(&ch, /*clockRunning=*/true,
/*treatRecsAsLoops=*/false, /*recsStopOnChanHalt=*/false);
REQUIRE(ch.readActions == false);
REQUIRE(ch.recStatus == ChannelStatus::OFF);
/* Third state: WAIT */
ch.recStatus = ChannelStatus::ENDING;
sampleChannelRec::stopReadingActions(&ch, /*clockRunning=*/true,
/*treatRecsAsLoops=*/false, /*recsStopOnChanHalt=*/false);
REQUIRE(ch.readActions == false);
REQUIRE(ch.recStatus == ChannelStatus::PLAY);
/* Fourth state: any, but with clockRunning == false. */
sampleChannelRec::stopReadingActions(&ch, /*clockRunning=*/false,
/*treatRecsAsLoops=*/false, /*recsStopOnChanHalt=*/false);
REQUIRE(ch.readActions == false);
REQUIRE(ch.recStatus == ChannelStatus::OFF);
}
SECTION("set read actions status to false with recsStopOnChanHalt")
{
ch.status = ChannelStatus::PLAY;
ch.tracker = 1024;
sampleChannelRec::setReadActions(&ch, false, /*recsStopOnChanHalt=*/true);
REQUIRE(ch.readActions == false);
REQUIRE(ch.status == ChannelStatus::OFF);
REQUIRE(ch.tracker == 0);
}
}
|