RemoteVstPlugin: fixed too short arrays for preset names
[lmms.git] / include / AudioBackend.h
blob10d17c2da1290aa7402364c2014e8cccb82cc235
1 /*
2 * AudioBackend.h - base-class for audio-devices, used by LMMS-mixer
4 * Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
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 GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
25 #ifndef _AUDIO_DEVICE_H
26 #define _AUDIO_DEVICE_H
28 #include <QtCore/QPair>
29 #include <QtCore/QThread>
31 #include "Mixer.h"
32 #include "tab_widget.h"
35 class AudioPort;
37 /*! \brief The AudioBackend class is the base class for all kinds of AudioBackends.
39 * All classes derived from AudioBackend receive audio data so they can output
40 * it.
42 class AudioBackend
44 public:
45 /*! \brief Constructs an AudioBackend object for the given AudioOutputContext. */
46 AudioBackend( const ch_cnt_t _channels, AudioOutputContext * context );
47 virtual ~AudioBackend();
49 /*! If the audio backend supports ports, classes creating an AudioPort
50 * (e.g. InstrumentTrack) can register themselves for making
51 * audio backend able to collect their individual output and provide
52 * them at a specific port - currently only supported by JACK
54 virtual void registerPort( AudioPort * _port );
55 virtual void unregisterPort( AudioPort * _port );
56 virtual void renamePort( AudioPort * _port );
59 inline bool supportsCapture() const
61 return m_supportsCapture;
64 inline sample_rate_t sampleRate() const
66 return m_sampleRate;
69 ch_cnt_t channels() const
71 return m_channels;
74 /*! \brief Fetches one buffer and writes it to output device.
76 * \return Number of frames processed
78 int processNextBuffer();
80 virtual void startProcessing()
84 virtual void stopProcessing();
86 virtual void applyQualitySettings();
90 class setupWidget : public tabWidget
92 public:
93 setupWidget( const QString & _caption, QWidget * _parent ) :
94 tabWidget( tabWidget::tr( "Settings for %1" ).arg(
95 tabWidget::tr( _caption.toAscii() ) ).
96 toUpper(), _parent )
100 virtual ~setupWidget()
104 virtual void saveSettings() = 0;
106 virtual void show()
108 parentWidget()->show();
109 QWidget::show();
115 /*! \brief Returns const pointer to AudioOutputContext this AudioBackend acts for. */
116 const AudioOutputContext * outputContext() const
118 return m_context;
121 /*! \brief Returns const pointer to Mixer this AudioBackend acts for. */
122 const Mixer * mixer() const;
125 protected:
126 /*! \brief Writes given buffer to actual device.
128 * Subclasses can reimplement this for being used in conjunction with
129 * processNextBuffer()
131 virtual void writeBuffer( const sampleFrameA * /* _buf*/,
132 const fpp_t /*_frames*/,
133 const float /*_master_gain*/ )
137 /*! \brief Called by according backend for fetching new audio data. */
138 int getNextBuffer( sampleFrameA * _ab );
140 /*! \brief Clears given signed-int-16-buffer. */
141 void clearS16Buffer( intSampleFrameA * _outbuf, const fpp_t _frames );
143 inline void setSampleRate( const sample_rate_t _new_sr )
145 m_sampleRate = _new_sr;
148 bool hqAudio() const;
150 AudioOutputContext * outputContext()
152 return m_context;
155 Mixer * mixer();
158 protected:
159 bool m_supportsCapture;
162 private:
163 AudioOutputContext * m_context;
164 sample_rate_t m_sampleRate;
165 ch_cnt_t m_channels;
167 sampleFrameA * m_buffer;
172 #endif