2
2
* mixer.h - audio-device-independent mixer for LMMS
4
* Linux MultiMedia Studio
5
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox@users.sourceforge.net>
4
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
7
8
* This program is free software; you can redistribute it and/or
8
9
* modify it under the terms of the GNU General Public
52
51
#include "panning.h"
54
53
#include "play_handle.h"
54
#include "effect_board.h"
62
64
const int DEFAULT_BUFFER_SIZE = 512;
64
const Uint16 MAX_SAMPLE_PACKETS = 256; // how many parallel audio-samples-
65
// buffers shall be maximal exist and
68
66
const Uint8 DEFAULT_CHANNELS = 2;
70
68
const Uint8 SURROUND_CHANNELS =
78
76
const Uint32 DEFAULT_QUALITY_LEVEL = 0;
79
77
const Uint32 HIGH_QUALITY_LEVEL = DEFAULT_QUALITY_LEVEL+1;
80
78
extern Uint32 SAMPLE_RATES[QUALITY_LEVELS];
81
const Uint32 DEFAULT_SAMPLE_RATE = 44100;//SAMPLE_RATES[DEFAULT_QUALITY_LEVEL];
79
const Uint32 DEFAULT_SAMPLE_RATE = 44100;
84
82
typedef sampleType sampleFrame[DEFAULT_CHANNELS];
125
void FASTCALL addBuffer( sampleFrame * _buf, Uint32 _frames,
119
void FASTCALL bufferToPort( sampleFrame * _buf, Uint32 _frames,
126
120
Uint32 _framesAhead,
127
volumeVector & _volumeVector );
121
volumeVector & _volumeVector,
128
123
inline Uint32 framesPerAudioBuffer( void ) const
130
125
return( m_framesPerAudioBuffer );
128
inline Uint8 cpuLoad( void ) const
134
133
inline bool highQuality( void ) const
151
150
void FASTCALL setAudioDevice( audioDevice * _dev, bool _hq );
152
151
void restoreAudioDevice( void );
156
inline const QString & midiDevName( void ) const
158
return( m_midiDevName );
161
inline midiDevice * getMIDIDevice( void )
152
inline audioDevice * audioDev( void )
154
return( m_audioDev );
159
inline void addAudioPort( audioPort * _port )
162
m_audioPorts.push_back( _port );
166
inline void removeAudioPort( audioPort * _port )
168
vvector<audioPort *>::iterator it = qFind( m_audioPorts.begin(),
171
if( it != m_audioPorts.end() )
173
m_audioPorts.erase( it );
178
inline const QString & midiClientName( void ) const
180
return( m_midiClientName );
183
inline midiClient * getMIDIClient( void )
185
return( m_midiClient );
174
196
m_playHandlesToRemove.push_back( _ph );
177
void FASTCALL checkValidityOfPlayHandles( void );
180
inline int sampleRate( void )
199
void checkValidityOfPlayHandles( void );
203
inline Uint32 sampleRate( void )
182
205
return( SAMPLE_RATES[m_qualityLevel] );
186
inline float masterOutput( void ) const
209
inline float masterGain( void ) const
188
return( m_masterOutput );
211
return( m_masterGain );
191
inline void setMasterOutput( float _mo )
214
inline void setMasterGain( float _mo )
193
m_masterOutput = _mo;
249
surroundSampleFrame * m_buffer; // actual buffer for
253
Uint32 m_framesAhead; // number of frames, the buffer
254
// should be mixed ahead
257
enum samplePacketStates
259
READY, FILLING, UNUSED
264
273
static mixer * s_instanceOfMe;
269
void quitThread( void );
278
void stopProcessing( void );
272
281
// we don't allow to create mixer by using copy-ctor
273
mixer( const mixer & ) :
278
m_curBuf( m_buffer1 ),
279
m_nextBuf( m_buffer2 )
282
mixer( const mixer & )
283
virtual void run( void );
286
void FASTCALL mixSamplePacket( samplePacket * _sp );
289
288
audioDevice * tryAudioDevices( void );
290
midiDevice * tryMIDIDevices( void );
294
sampleFrame * m_silence;
295
#ifndef DISABLE_SURROUND
296
surroundSampleFrame * m_surroundSilence;// cool, silence in surround ;-)
300
samplePacket m_samplePackets[MAX_SAMPLE_PACKETS];
289
midiClient * tryMIDIClients( void );
291
void processBuffer( surroundSampleFrame * _buf, fxChnl _fx_chnl );
295
vvector<audioPort *> m_audioPorts;
302
297
Uint32 m_framesPerAudioBuffer;
304
surroundSampleFrame * m_buffer1;
305
surroundSampleFrame * m_buffer2;
307
299
surroundSampleFrame * m_curBuf;
308
300
surroundSampleFrame * m_nextBuf;
310
bool m_discardCurBuf;
313
304
playHandleVector m_playHandles;
314
305
playHandleVector m_playHandlesToRemove;
316
307
Uint8 m_qualityLevel;
317
volatile float m_masterOutput;
319
volatile bool m_quit;
323
311
audioDevice * m_audioDev;