hydrogen 1.2.3
FakeDriver.cpp
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#include <core/IO/FakeDriver.h>
25#include <core/Hydrogen.h>
27
28namespace H2Core
29{
30
32 : AudioOutput()
33 , m_processCallback( processCallback )
34 , m_pOut_L( nullptr )
35 , m_pOut_R( nullptr )
36 , m_nBufferSize( 0 )
37 , m_nSampleRate( 44100 ) {
38}
39
40
43
44
45int FakeDriver::init( unsigned nBufferSize )
46{
47 INFOLOG( QString( "Init, %1 samples" ).arg( nBufferSize ) );
48
49 m_nBufferSize = nBufferSize;
51 m_pOut_L = new float[nBufferSize];
52 m_pOut_R = new float[nBufferSize];
53
54 return 0;
55}
56
57
59{
60 INFOLOG( "connect" );
61
62 // always rolling, no user interaction
64
65 return 0;
66}
67
68
70{
71 INFOLOG( "disconnect" );
72
73 delete[] m_pOut_L;
74 m_pOut_L = nullptr;
75
76 delete[] m_pOut_R;
77 m_pOut_R = nullptr;
78}
79
80
82{
83 return m_nSampleRate;
84}
85
87{
88 return m_pOut_L;
89}
90
91
93{
94 return m_pOut_R;
95}
96
97
99{
100 while ( m_processCallback( m_nBufferSize, nullptr ) == 0 ) {
101 // process...
102 }
103}
104
105
106};
#define INFOLOG(x)
Definition Object.h:237
void setNextState(State state)
@ Playing
Transport is rolling.
Base abstract class for audio output classes.
Definition AudioOutput.h:39
virtual void disconnect() override
FakeDriver(audioProcessCallback processCallback)
virtual float * getOut_L() override
virtual int init(unsigned nBufferSize) override
unsigned m_nSampleRate
Definition FakeDriver.h:59
virtual float * getOut_R() override
virtual int connect() override
audioProcessCallback m_processCallback
Definition FakeDriver.h:57
virtual unsigned getSampleRate() override
unsigned m_nBufferSize
Definition FakeDriver.h:58
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
Definition Hydrogen.h:83
AudioEngine * getAudioEngine() const
Definition Hydrogen.h:649
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
unsigned m_nSampleRate
Sample rate of the audio.
int(* audioProcessCallback)(uint32_t, void *)
Definition AudioOutput.h:32