hydrogen 1.2.6
AudioEngineTests.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef AUDIO_ENGINE_TESTS_H
24#define AUDIO_ENGINE_TESTS_H
25
26#include <core/Object.h>
27#include <core/Basics/Note.h>
29
30#include <memory>
31#include <vector>
32
33namespace H2Core
34{
35
37
42class AudioEngineTests : public H2Core::Object<AudioEngineTests>
43{
45public:
50 static void testFrameToTickConversion();
55 static void testTransportProcessing();
65 static void testTransportRelocation();
70 static void testLoopMode();
76 static void testSongSizeChange();
82 static void testSongSizeChangeInLoopMode();
86 static void testNoteEnqueuing();
87
92 static void testNoteEnqueuingTimeline();
97 static void testHumanization();
98
102 static void testUpdateTransportPosition();
103#ifdef H2CORE_HAVE_JACK
108 static void testTransportProcessingJack();
114 static void testTransportProcessingOffsetsJack();
119 static void testTransportRelocationJack();
125 static void testTransportRelocationOffsetsJack();
126
129 static int jackTestProcessCallback( uint32_t nFrames, void* args );
130
131 static JackAudioDriver* startJackAudioDriver();
132
133 static JackAudioDriver::Timebase m_referenceTimebase;
134#endif
135
136private:
137 static int processTransport( const QString& sContext,
138 int nFrames,
139 long long* nLastLookahead,
140 long long* nLastTransportFrame,
141 long long* nTotalFrames,
142 long* nLastPlayheadTick,
143 double* fLastTickIntervalEnd,
144 bool bCheckLookahead = true );
154 static void checkTransportPosition( std::shared_ptr<TransportPosition> pPos, const QString& sContext );
160 static void checkAudioConsistency( const std::vector<std::shared_ptr<Note>> oldNotes,
161 const std::vector<std::shared_ptr<Note>> newNotes,
162 const QString& sContext,
163 int nPassedFrames,
164 bool bTestAudio = true,
165 float fPassedTicks = 0.0 );
171 static void toggleAndCheckConsistency( int nToggleColumn, int nToggleRow, const QString& sContext );
172
173 static std::vector<std::shared_ptr<Note>> copySongNoteQueue();
178 static void mergeQueues( std::vector<std::shared_ptr<Note>>* noteList,
179 std::vector<std::shared_ptr<Note>> newNotes );
180 static void mergeQueues( std::vector<std::shared_ptr<Note>>* noteList,
181 std::vector<Note*> newNotes );
182 static void resetSampler( const QString& sContext );
183 static void throwException( const QString& sMsg );
184
185#ifdef H2CORE_HAVE_JACK
186 static void stopJackAudioDriver();
187 static void waitForRelocation( JackAudioDriver* pDriver,
188 double fTick, long long nFrame );
189#endif
190};
191};
192
193#endif
#define H2_OBJECT(name)
Definition Object.h:227
Defined in here since it requires access to methods and variables private to the AudioEngine class.
static std::vector< std::shared_ptr< Note > > copySongNoteQueue()
static void testTransportProcessingTimeline()
More detailed test of the transport and playhead integrity in case Timeline/tempo markers are involve...
static void testUpdateTransportPosition()
Checks is reproducible and works even without any song set.
static void testLoopMode()
Unit test checking that loop mode as well as deactivating it works.
static void testSongSizeChange()
Unit test checking consistency of transport position when playback was looped at least once and the s...
static void toggleAndCheckConsistency(int nToggleColumn, int nToggleRow, const QString &sContext)
Toggles the grid cell defined by nToggleColumn and nToggleRow twice and checks whether the transport ...
static void testNoteEnqueuing()
Unit test checking that all notes in a song are picked up once.
static void checkTransportPosition(std::shared_ptr< TransportPosition > pPos, const QString &sContext)
Checks the consistency of the transport position pPos by converting the current tick,...
static void testTransportRelocation()
Unit test checking the relocation of the transport position in audioEngine_process().
static void testTransportProcessing()
Unit test checking the incremental update of the transport position in audioEngine_process().
static void testNoteEnqueuingTimeline()
Checks whether the order of notes enqueued and processed by the Sampler is consistent on tempo change...
static void testSongSizeChangeInLoopMode()
Unit test checking consistency of transport position when playback was looped at least once and the s...
static void resetSampler(const QString &sContext)
static int processTransport(const QString &sContext, int nFrames, long long *nLastLookahead, long long *nLastTransportFrame, long long *nTotalFrames, long *nLastPlayheadTick, double *fLastTickIntervalEnd, bool bCheckLookahead=true)
static void mergeQueues(std::vector< std::shared_ptr< Note > > *noteList, std::vector< std::shared_ptr< Note > > newNotes)
Add every Note in newNotes not yet contained in noteList to the latter.
static void throwException(const QString &sMsg)
static void testFrameToTickConversion()
Unit test checking for consistency when converting frames to ticks and back.
static void testHumanization()
Unit test checking that custom note properties take effect and that humanization works as expected.
static void checkAudioConsistency(const std::vector< std::shared_ptr< Note > > oldNotes, const std::vector< std::shared_ptr< Note > > newNotes, const QString &sContext, int nPassedFrames, bool bTestAudio=true, float fPassedTicks=0.0)
Takes two instances of Sampler::m_playingNotesQueue and checks whether matching notes have exactly nP...
JACK (Jack Audio Connection Kit) server driver.
Timebase
Whether Hydrogen or another program is in Timebase control.
Object holding most of the information about the transport state of the AudioEngine.