Skip to content

Commit 6ebb96b

Browse files
committed
WIP fix errors in test
1 parent c1dc568 commit 6ebb96b

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

tests/objects/patternal.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ TEST_CASE("Compare two MIDI notes", "[advanced][patternal]")
6666
TEST_CASE("MIDI messages are output properly", "[advanced][patternal]")
6767
{
6868
// Our sampling rate is 48kHz and the buffer size is 512
69-
static const double samplingRate = 48000;
70-
static const int bufferSize = 512;
71-
static const double tickDuration = samplingRate / bufferSize; // seconds
72-
static const double ticksPerSecond = 1.0 / tickDuration;
73-
static const double testDuration = 3.0; // seconds
69+
static constexpr double samplingRate = 48000;
70+
static constexpr int bufferSize = 512;
71+
static constexpr double tickDuration = samplingRate / bufferSize; // seconds
72+
static constexpr double ticksPerSecond = 1.0 / tickDuration;
73+
static constexpr double testDuration = 3.0; // seconds
74+
static constexpr double NS_PER_S = 1000000;
7475

7576
Processor patternalProcessor;
7677
patternalProcessor.inputs.patterns.value = {
@@ -81,15 +82,23 @@ TEST_CASE("MIDI messages are output properly", "[advanced][patternal]")
8182

8283
// Check the output on each tick:
8384
const int totalNumberOfTicks = (int) ticksPerSecond * testDuration;
85+
int64_t pos_in_frames = 0;
86+
double pos_in_ns = 0;
8487
for (int tickIndex = 0; tickIndex < totalNumberOfTicks; tickIndex++) {
8588

8689
INFO("tick number " << tickIndex << " / " << totalNumberOfTicks);
8790
// INFO("Test tick " << tickIndex);
91+
pos_in_frames += bufferSize;
92+
pos_in_ns += tickDuration / NS_PER_S;
8893
tick_musical tk;
94+
// TODO tk.start_position_quarter =
95+
// TODO tk.end_position_quarter =
8996
tk.tempo = 120; // 120 BPM. One beat lasts 500 ms.
9097
tk.signature.num = 4;
9198
tk.signature.denom = 4;
9299
tk.frames = bufferSize;
100+
tk.position_in_nanoseconds = pos_in_ns;
101+
tk.position_in_frames = pos_in_frames;
93102
double timeNow = tickIndex * tickDuration;
94103
patternalProcessor(tk);
95104

0 commit comments

Comments
 (0)