hydrogen 1.2.3
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-2024 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>
28
29#include <memory>
30#include <vector>
31
32namespace H2Core
33{
34
35 class TransportPosition;
36
41class AudioEngineTests : public H2Core::Object<AudioEngineTests>
42{
44public:
49 static void testFrameToTickConversion();
54 static void testTransportProcessing();
64 static void testTransportRelocation();
69 static void testLoopMode();
75 static void testSongSizeChange();
81 static void testSongSizeChangeInLoopMode();
85 static void testNoteEnqueuing();
86
91 static void testNoteEnqueuingTimeline();
96 static void testHumanization();
97
98private:
99 static int processTransport( const QString& sContext,
100 int nFrames,
101 long long* nLastLookahead,
102 long long* nLastTransportFrame,
103 long long* nTotalFrames,
104 long* nLastPlayheadTick,
105 double* fLastTickIntervalEnd,
106 bool bCheckLookahead = true );
116 static void checkTransportPosition( std::shared_ptr<TransportPosition> pPos, const QString& sContext );
122 static void checkAudioConsistency( const std::vector<std::shared_ptr<Note>> oldNotes,
123 const std::vector<std::shared_ptr<Note>> newNotes,
124 const QString& sContext,
125 int nPassedFrames,
126 bool bTestAudio = true,
127 float fPassedTicks = 0.0 );
133 static void toggleAndCheckConsistency( int nToggleColumn, int nToggleRow, const QString& sContext );
134
135 static std::vector<std::shared_ptr<Note>> copySongNoteQueue();
140 static void mergeQueues( std::vector<std::shared_ptr<Note>>* noteList,
141 std::vector<std::shared_ptr<Note>> newNotes );
142 static void mergeQueues( std::vector<std::shared_ptr<Note>>* noteList,
143 std::vector<Note*> newNotes );
144 static void resetSampler( const QString& sContext );
145 static void throwException( const QString& sMsg );
146};
147};
148
149#endif
#define H2_OBJECT(name)
Definition Object.h:224
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 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...