hydrogen 1.2.6
PortAudioDriver.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 PORT_AUDIO_DRIVER_H
24#define PORT_AUDIO_DRIVER_H
25
26#include <core/IO/AudioOutput.h>
27#include <core/IO/NullDriver.h>
28
29#include <unistd.h>
30
31#if defined(H2CORE_HAVE_PORTAUDIO) || _DOXYGEN_
32
33#include <inttypes.h>
34#include <portaudio.h>
35
36namespace H2Core
37{
38
40class PortAudioDriver : public Object<PortAudioDriver>, public AudioOutput
41{
43public:
45 float* m_pOut_L;
46 float* m_pOut_R;
47
48 PortAudioDriver( audioProcessCallback processCallback );
49 virtual ~PortAudioDriver();
50
51 virtual int init( unsigned nBufferSize ) override;
52 virtual int connect() override;
53 virtual void disconnect() override;
54 virtual unsigned getBufferSize() override;
55 virtual int getLatency() override;
56 virtual unsigned getSampleRate() override;
57 virtual float* getOut_L() override;
58 virtual float* getOut_R() override;
59
60 static QStringList getDevices();
61 static QStringList getDevices( QString HostAPI );
62 static QStringList getHostAPIs();
63
64private:
65 PaStream *m_pStream;
66 unsigned m_nSampleRate;
67 QString m_sDevice;
68
69 static bool m_bInitialised;
70
71};
72
73};
74
75#else
76
77namespace H2Core
78{
79
80class PortAudioDriver : public NullDriver
81{
83public:
84 PortAudioDriver( audioProcessCallback processCallback ) : NullDriver( processCallback ) {}
85};
86
87};
88
89#endif
90
91
92#endif
93
int(* audioProcessCallback)(uint32_t, void *)
Definition AudioEngine.h:64
#define H2_OBJECT(name)
Definition Object.h:227
virtual void disconnect() override
virtual float * getOut_L() override
virtual int init(unsigned nBufferSize) override
virtual int getLatency() override
Approximate audio latency (in frames) A reasonable approximation is the buffer time on most audio sys...
virtual float * getOut_R() override
virtual unsigned getBufferSize() override
PortAudioDriver(audioProcessCallback processCallback)
virtual int connect() override
static QStringList getDevices()
audioProcessCallback m_processCallback
virtual unsigned getSampleRate() override
static QStringList getHostAPIs()
int(* audioProcessCallback)(uint32_t, void *)
Definition AudioOutput.h:32