mirror of
https://github.com/LMMS/lmms.git
synced 2026-02-19 07:34:50 -05:00
* Update ringbuffer submodule to fix includes
* Remove cyclic includes
* Remove Qt include prefixes
* Include C++ versions of C headers
E.g.: assert.h -> cassert
* Move CLIP_BORDER_WIDTH into ClipView
This allows to remove includes to TrackView.h in ClipView cpp files.
* Elliminate useless includes
This improves the include structure by elliminating includes that are
not used. Most of this was done by using `include-what-you-use` with
`CMAKE_C_INCLUDE_WHAT_YOU_USE` and `CMAKE_CXX_INCLUDE_WHAT_YOU_USE`
set to (broken down here):
```
include-what-you-use;
-Xiwyu;--mapping_file=/usr/share/include-what-you-use/qt5_11.imp;
-Xiwyu;--keep=*/xmmintrin.h;
-Xiwyu;--keep=*/lmmsconfig.h;
-Xiwyu;--keep=*/weak_libjack.h;
-Xiwyu;--keep=*/sys/*;
-Xiwyu;--keep=*/debug.h;
-Xiwyu;--keep=*/SDL/*;
-Xiwyu;--keep=*/alsa/*;
-Xiwyu;--keep=*/FL/x.h;
-Xiwyu;--keep=*/MidiApple.h;
-Xiwyu;--keep=*/MidiWinMM.h;
-Xiwyu;--keep=*/AudioSoundIo.h
```
* Fixup: Remove empty #if-#ifdef pairs
* Remove LMMS_HAVE_STD(LIB|INT)_H
160 lines
3.5 KiB
C++
160 lines
3.5 KiB
C++
/*
|
|
* AudioDevice.h - base-class for audio-devices, used by LMMS audio engine
|
|
*
|
|
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
|
*
|
|
* This file is part of LMMS - https://lmms.io
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public
|
|
* License along with this program (see COPYING); if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA.
|
|
*
|
|
*/
|
|
|
|
#ifndef AUDIO_DEVICE_H
|
|
#define AUDIO_DEVICE_H
|
|
|
|
#include <QMutex>
|
|
#include <samplerate.h>
|
|
|
|
#include "lmms_basics.h"
|
|
|
|
|
|
class AudioEngine;
|
|
class AudioPort;
|
|
class QThread;
|
|
|
|
|
|
class AudioDevice
|
|
{
|
|
public:
|
|
AudioDevice( const ch_cnt_t _channels, AudioEngine* audioEngine );
|
|
virtual ~AudioDevice();
|
|
|
|
inline void lock()
|
|
{
|
|
m_devMutex.lock();
|
|
}
|
|
|
|
inline void unlock()
|
|
{
|
|
m_devMutex.unlock();
|
|
}
|
|
|
|
|
|
// if audio-driver supports ports, classes inherting AudioPort
|
|
// (e.g. channel-tracks) can register themselves for making
|
|
// audio-driver able to collect their individual output and provide
|
|
// them at a specific port - currently only supported by JACK
|
|
virtual void registerPort( AudioPort * _port );
|
|
virtual void unregisterPort( AudioPort * _port );
|
|
virtual void renamePort( AudioPort * _port );
|
|
|
|
|
|
inline bool supportsCapture() const
|
|
{
|
|
return m_supportsCapture;
|
|
}
|
|
|
|
inline sample_rate_t sampleRate() const
|
|
{
|
|
return m_sampleRate;
|
|
}
|
|
|
|
ch_cnt_t channels() const
|
|
{
|
|
return m_channels;
|
|
}
|
|
|
|
void processNextBuffer();
|
|
|
|
virtual void startProcessing()
|
|
{
|
|
m_inProcess = true;
|
|
}
|
|
|
|
virtual void stopProcessing();
|
|
|
|
virtual void applyQualitySettings();
|
|
|
|
|
|
|
|
protected:
|
|
// subclasses can re-implement this for being used in conjunction with
|
|
// processNextBuffer()
|
|
virtual void writeBuffer( const surroundSampleFrame * /* _buf*/,
|
|
const fpp_t /*_frames*/,
|
|
const float /*_master_gain*/ )
|
|
{
|
|
}
|
|
|
|
// called by according driver for fetching new sound-data
|
|
fpp_t getNextBuffer( surroundSampleFrame * _ab );
|
|
|
|
// convert a given audio-buffer to a buffer in signed 16-bit samples
|
|
// returns num of bytes in outbuf
|
|
int convertToS16( const surroundSampleFrame * _ab,
|
|
const fpp_t _frames,
|
|
const float _master_gain,
|
|
int_sample_t * _output_buffer,
|
|
const bool _convert_endian = false );
|
|
|
|
// clear given signed-int-16-buffer
|
|
void clearS16Buffer( int_sample_t * _outbuf,
|
|
const fpp_t _frames );
|
|
|
|
// resample given buffer from samplerate _src_sr to samplerate _dst_sr
|
|
fpp_t resample( const surroundSampleFrame * _src,
|
|
const fpp_t _frames,
|
|
surroundSampleFrame * _dst,
|
|
const sample_rate_t _src_sr,
|
|
const sample_rate_t _dst_sr );
|
|
|
|
inline void setSampleRate( const sample_rate_t _new_sr )
|
|
{
|
|
m_sampleRate = _new_sr;
|
|
}
|
|
|
|
AudioEngine* audioEngine()
|
|
{
|
|
return m_audioEngine;
|
|
}
|
|
|
|
bool hqAudio() const;
|
|
|
|
static void stopProcessingThread( QThread * thread );
|
|
|
|
|
|
protected:
|
|
bool m_supportsCapture;
|
|
|
|
|
|
private:
|
|
sample_rate_t m_sampleRate;
|
|
ch_cnt_t m_channels;
|
|
AudioEngine* m_audioEngine;
|
|
bool m_inProcess;
|
|
|
|
QMutex m_devMutex;
|
|
|
|
SRC_DATA m_srcData;
|
|
SRC_STATE * m_srcState;
|
|
|
|
surroundSampleFrame * m_buffer;
|
|
|
|
} ;
|
|
|
|
|
|
#endif
|