Skip to content

Commit 9483dae

Browse files
Merge branch 'develop' into f/AUD-217_LV2_Worker_Thread_Extension
2 parents 394da0b + 6465173 commit 9483dae

File tree

7 files changed

+28
-21
lines changed

7 files changed

+28
-21
lines changed

src/plugins/step_sequencer_plugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ void StepSequencerPlugin::process_audio(const ChunkSampleBuffer& in_buffer, Chun
131131
return;
132132
}
133133

134-
double start_beat = _host_control.transport()->current_bar_beats() * MULTIPLIER_8TH_NOTE;
135-
double end_beat = _host_control.transport()->current_bar_beats(AUDIO_CHUNK_SIZE) * MULTIPLIER_8TH_NOTE;
134+
float start_beat = _host_control.transport()->current_bar_beats() * MULTIPLIER_8TH_NOTE;
135+
float end_beat = _host_control.transport()->current_bar_beats(AUDIO_CHUNK_SIZE) * MULTIPLIER_8TH_NOTE;
136136

137137
/* New 8th note during this chunk */
138138
if (static_cast<int>(end_beat) - static_cast<int>(start_beat) != 0)

test/unittests/engine/event_timer_test.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ TEST_F(TestEventTimer, TestToOffsetConversion)
4646
ASSERT_EQ(0, offset);
4747

4848
/* Create a timestamp in the middle of the chunk, note we must add
49-
* chunk time here because the EventTimer is 1 chunk ahead internally */
49+
* chunk time here because the EventTimer is 1 chunk ahead internally,
50+
* Because of rounding errors, the resulting sample offset could be
51+
* both AUDIO_CHUNK_SIZE / 2 and AUDIO_CHUNK_SIZE / 2 -1 */
5052
auto chunk_time = calc_chunk_time(TEST_SAMPLE_RATE);
5153
Time timestamp = 1s + chunk_time + chunk_time / 2;
5254
std::tie(send_now, offset) = _module_under_test.sample_offset_from_realtime(timestamp);
5355
ASSERT_TRUE(send_now);
54-
ASSERT_EQ(AUDIO_CHUNK_SIZE / 2 - 1, offset);
56+
ASSERT_GE(offset, AUDIO_CHUNK_SIZE / 2 - 1);
57+
ASSERT_LE(offset, AUDIO_CHUNK_SIZE / 2);
5558
}
5659

5760
TEST_F(TestEventTimer, TestToRealTimesConversion)

test/unittests/engine/transport_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ TEST_F(TestTransport, TestTimeline68Time)
8484
_module_under_test.set_sample_rate(TEST_SAMPLERATE);
8585
_module_under_test.set_tempo(180, false);
8686
_module_under_test.set_time_signature({6, 8}, false);
87-
constexpr float precision = 3.0f * AUDIO_CHUNK_SIZE / TEST_SAMPLERATE;
87+
constexpr float precision = 4.0f * AUDIO_CHUNK_SIZE / TEST_SAMPLERATE;
8888

8989
/* Check that the starting point is 0 */
9090
_module_under_test.set_playing_mode(PlayingMode::PLAYING, false);

test/unittests/library/processor_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ TEST_F(TestBypassManager, TestCrossfade)
250250

251251
_module_under_test.crossfade_output(bypass_buffer, buffer, 2, 2);
252252

253-
EXPECT_LT(buffer.channel(1)[AUDIO_CHUNK_SIZE - 1], 2.0f);
254-
EXPECT_GT(buffer.channel(1)[AUDIO_CHUNK_SIZE - 1], 1.0f);
253+
EXPECT_LE(buffer.channel(1)[AUDIO_CHUNK_SIZE - 1], 2.0f);
254+
EXPECT_GE(buffer.channel(1)[AUDIO_CHUNK_SIZE - 1], 1.0f);
255255

256256
for (int i = 0; i < chunks_in_ramp - 1; ++i)
257257
{

test/unittests/library/vst2x_wrapper_test.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "test_utils/test_utils.h"
66
#include "test_utils/host_control_mockup.h"
77

8-
#include "test_utils/engine_mockup.h"
98
#include "library/vst2x_wrapper.cpp"
109

1110
using namespace sushi;
@@ -202,11 +201,14 @@ TEST_F(TestVst2xWrapper, TestTimeInfo)
202201
_host_control._transport.set_playing_mode(PlayingMode::PLAYING, false);
203202
_host_control._transport.set_tempo(60, false);
204203
_host_control._transport.set_time_signature({4, 4}, false);
205-
_host_control._transport.set_time(std::chrono::seconds(1), static_cast<int64_t>(TEST_SAMPLE_RATE));
204+
_host_control._transport.set_time(std::chrono::seconds(2), static_cast<int64_t>(TEST_SAMPLE_RATE) * 2);
206205
auto time_info = _module_under_test->time_info();
207-
EXPECT_EQ(static_cast<int64_t>(TEST_SAMPLE_RATE), time_info->samplePos);
208-
EXPECT_EQ(1'000'000'000, time_info->nanoSeconds);
209-
EXPECT_FLOAT_EQ(1.0f, time_info->ppqPos);
206+
/* For these numbers to match exactly, we need to choose a time interval which
207+
* is an integer multiple of AUDIO_CHUNK_SIZE, hence 2 seconds at 48000, which
208+
* is good up to AUDIO_CHUNK_SIZE = 256 */
209+
EXPECT_EQ(static_cast<int64_t>(TEST_SAMPLE_RATE) * 2, time_info->samplePos);
210+
EXPECT_EQ(2'000'000'000, time_info->nanoSeconds);
211+
EXPECT_FLOAT_EQ(2.0f, time_info->ppqPos);
210212
EXPECT_FLOAT_EQ(60.0f, time_info->tempo);
211213
EXPECT_FLOAT_EQ(0.0f, time_info->barStartPos);
212214
EXPECT_EQ(4, time_info->timeSigNumerator);

test/unittests/library/vst3x_wrapper_test.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,19 @@ TEST_F(TestVst3xWrapper, TestTimeInfo)
210210
_host_control._transport.set_playing_mode(PlayingMode::PLAYING, false);
211211
_host_control._transport.set_tempo(120, false);
212212
_host_control._transport.set_time_signature({3, 4}, false);
213-
_host_control._transport.set_time(std::chrono::seconds(1), static_cast<int64_t>(TEST_SAMPLE_RATE));
213+
_host_control._transport.set_time(std::chrono::seconds(2), static_cast<int64_t>(TEST_SAMPLE_RATE) * 2);
214214

215215
_module_under_test->_fill_processing_context();
216216
auto context = _module_under_test->_process_data.processContext;
217-
217+
/* For these numbers to match exactly, we need to choose a time interval which
218+
* is an integer multiple of AUDIO_CHUNK_SIZE, hence 2 seconds at 48000, which
219+
* is good up to AUDIO_CHUNK_SIZE = 256 */
218220
EXPECT_FLOAT_EQ(TEST_SAMPLE_RATE, context->sampleRate);
219-
EXPECT_EQ(static_cast<int64_t>(TEST_SAMPLE_RATE), context->projectTimeSamples);
220-
EXPECT_EQ(1'000'000'000, context->systemTime);
221-
EXPECT_EQ(static_cast<int64_t>(TEST_SAMPLE_RATE), context->continousTimeSamples);
222-
EXPECT_FLOAT_EQ(2.0f, context->projectTimeMusic);
223-
EXPECT_FLOAT_EQ(0.0f, context->barPositionMusic);
221+
EXPECT_EQ(static_cast<int64_t>(TEST_SAMPLE_RATE) * 2, context->projectTimeSamples);
222+
EXPECT_EQ(2'000'000'000, context->systemTime);
223+
EXPECT_EQ(static_cast<int64_t>(TEST_SAMPLE_RATE) * 2, context->continousTimeSamples);
224+
EXPECT_FLOAT_EQ(4.0f, context->projectTimeMusic);
225+
EXPECT_FLOAT_EQ(3.0f, context->barPositionMusic);
224226
EXPECT_FLOAT_EQ(120.0f, context->tempo);
225227
EXPECT_EQ(3, context->timeSigNumerator);
226228
EXPECT_EQ(4, context->timeSigDenominator);

test/unittests/plugins/step_sequencer_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ TEST_F(TestStepSequencerPlugin, TestOutput)
3838

3939
ASSERT_TRUE(_fifo.empty());
4040
/* 1/8 notes at 120 bpm equals 4 notes/sec, @48000 results having an
41-
* 18 note at 12000, so fast forward the time so directly before this time */
42-
_host_control._transport.set_time(std::chrono::milliseconds(249), 11990);
41+
* 8th note at 12000, so fast forward the time so directly before this time */
42+
_host_control._transport.set_time(std::chrono::microseconds(249'500), 11'990);
4343
_module_under_test.process_audio(buffer, buffer);
4444
RtEvent e;
4545
bool got_event = _fifo.pop(e);

0 commit comments

Comments
 (0)