mirror of
https://github.com/LMMS/lmms.git
synced 2026-01-02 11:38:05 -05:00
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@23 0778d3d1-df1d-0410-868b-ea421aaaa00d
144 lines
2.9 KiB
C++
144 lines
2.9 KiB
C++
/*
|
|
* audio_device.h - base-class for audio-devices, used by LMMS-mixer
|
|
*
|
|
* Linux MultiMedia Studio
|
|
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
|
*
|
|
* 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., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*
|
|
*/
|
|
|
|
|
|
#ifndef _AUDIO_DEVICE_H
|
|
#define _AUDIO_DEVICE_H
|
|
|
|
#include "qt3support.h"
|
|
|
|
#ifdef QT4
|
|
|
|
#include <QMutex>
|
|
|
|
#else
|
|
|
|
#include <qmutex.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include <config.h>
|
|
#endif
|
|
|
|
#ifdef HAVE_SAMPLERATE_H
|
|
#include <samplerate.h>
|
|
#endif
|
|
|
|
|
|
#include "mixer.h"
|
|
#include "tab_widget.h"
|
|
|
|
|
|
class audioDevice
|
|
{
|
|
public:
|
|
audioDevice( Uint32 _sample_rate, Uint8 _channels );
|
|
virtual ~audioDevice();
|
|
|
|
inline void lock( void )
|
|
{
|
|
m_devMutex.lock();
|
|
}
|
|
|
|
inline void unlock( void )
|
|
{
|
|
m_devMutex.unlock();
|
|
}
|
|
|
|
void FASTCALL writeBuffer( surroundSampleFrame * _ab, Uint32 _frames,
|
|
Uint32 _src_sample_rate,
|
|
float _master_gain );
|
|
|
|
inline Uint32 sampleRate( void ) const
|
|
{
|
|
return( m_sampleRate );
|
|
}
|
|
|
|
Uint8 channels( void ) const
|
|
{
|
|
return( m_channels );
|
|
}
|
|
|
|
|
|
|
|
class setupWidget : public tabWidget
|
|
{
|
|
public:
|
|
setupWidget( const QString & _caption, QWidget * _parent ) :
|
|
tabWidget( tabWidget::tr( "Settings for %1" ).arg(
|
|
_caption ), _parent )
|
|
{
|
|
}
|
|
|
|
virtual ~setupWidget()
|
|
{
|
|
}
|
|
|
|
virtual void saveSettings( void ) = 0;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
protected:
|
|
virtual void FASTCALL writeBufferToDev( surroundSampleFrame * _ab,
|
|
Uint32 _frames,
|
|
float _master_gain ) = 0;
|
|
|
|
// convert a given audio-buffer to a buffer in signed 16-bit samples
|
|
// returns num of bytes in outbuf
|
|
int FASTCALL convertToS16( surroundSampleFrame * _ab, Uint32 _frames,
|
|
float _master_gain,
|
|
outputSampleType * _output_buffer,
|
|
bool _convert_endian = FALSE );
|
|
|
|
// clear given signed-int-16-buffer
|
|
void FASTCALL clearS16Buffer( outputSampleType * _outbuf,
|
|
Uint32 _frames );
|
|
|
|
// resample given buffer from samplerate _src_src to samplerate _dst_src
|
|
void FASTCALL resample( surroundSampleFrame * _src, Uint32 _frames,
|
|
surroundSampleFrame * _dst,
|
|
Uint32 _src_sr, Uint32 _dst_sr );
|
|
inline void setSampleRate( Uint32 _new_sr )
|
|
{
|
|
m_sampleRate = _new_sr;
|
|
}
|
|
|
|
|
|
private:
|
|
Uint32 m_sampleRate;
|
|
Uint8 m_channels;
|
|
QMutex m_devMutex;
|
|
|
|
#ifdef HAVE_SAMPLERATE_H
|
|
SRC_DATA m_srcData;
|
|
SRC_STATE * m_srcState;
|
|
#endif
|
|
|
|
} ;
|
|
|
|
|
|
#endif
|