26 |
#include <math.h> |
#include <math.h> |
27 |
#include <unistd.h> |
#include <unistd.h> |
28 |
#include <fcntl.h> |
#include <fcntl.h> |
29 |
|
#include <pthread.h> |
30 |
|
#include <sstream> |
31 |
|
|
32 |
#include "global.h" |
#include "global.h" |
33 |
#include "thread.h" |
#include "thread.h" |
37 |
#include "gig.h" |
#include "gig.h" |
38 |
#include "rtelmemorypool.h" |
#include "rtelmemorypool.h" |
39 |
#include "modulationsystem.h" |
#include "modulationsystem.h" |
40 |
|
#include "network/lscp.h" |
41 |
|
|
42 |
#define PITCHBEND_SEMITONES 12 |
#define PITCHBEND_SEMITONES 12 |
43 |
#define MAX_AUDIO_VOICES 64 |
#define MAX_AUDIO_VOICES 64 |
51 |
//FIXME: Class name "AudioThread" is now misleading, because there is no thread anymore, but the name will change soon to "Engine" when we restructure the source tree |
//FIXME: Class name "AudioThread" is now misleading, because there is no thread anymore, but the name will change soon to "Engine" when we restructure the source tree |
52 |
class AudioThread { |
class AudioThread { |
53 |
public: |
public: |
54 |
double Volume; ///< overall volume (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
double Volume; ///< overall volume (a value < 1.0 means attenuation, a value > 1.0 means amplification) |
55 |
int ActiveVoiceCount; ///< number of currently active voices |
int ActiveVoiceCount; ///< number of currently active voices |
56 |
int ActiveVoiceCountMax; ///< the maximum voice usage since application start |
int ActiveVoiceCountMax; ///< the maximum voice usage since application start |
57 |
|
DiskThread* pDiskThread; |
58 |
|
|
59 |
AudioThread(AudioIO* pAudioIO, DiskThread* pDiskThread, gig::Instrument* pInstrument); |
AudioThread(AudioIO* pAudioIO); |
60 |
~AudioThread(); |
~AudioThread(); |
61 |
|
result_t LoadInstrument(const char* FileName, uint Instrument); |
62 |
|
void Reset(); |
63 |
void SendNoteOn(uint8_t Key, uint8_t Velocity); |
void SendNoteOn(uint8_t Key, uint8_t Velocity); |
64 |
void SendNoteOff(uint8_t Key, uint8_t Velocity); |
void SendNoteOff(uint8_t Key, uint8_t Velocity); |
65 |
void SendPitchbend(int Pitch); |
void SendPitchbend(int Pitch); |
86 |
RTEList<ModulationSystem::Event>* pEvents; ///< All events for the current audio fragment. |
RTEList<ModulationSystem::Event>* pEvents; ///< All events for the current audio fragment. |
87 |
RTEList<ModulationSystem::Event>* pCCEvents[ModulationSystem::destination_count]; ///< Control change events for the current audio fragment. |
RTEList<ModulationSystem::Event>* pCCEvents[ModulationSystem::destination_count]; ///< Control change events for the current audio fragment. |
88 |
AudioIO* pAudioIO; |
AudioIO* pAudioIO; |
89 |
DiskThread* pDiskThread; |
RIFF::File* pRIFF; |
90 |
|
gig::File* pGig; |
91 |
gig::Instrument* pInstrument; |
gig::Instrument* pInstrument; |
92 |
bool SustainPedal; ///< true if sustain pedal is down |
bool SustainPedal; ///< true if sustain pedal is down |
93 |
uint8_t PrevHoldCCValue; |
uint8_t PrevHoldCCValue; |
94 |
int Pitch; ///< Current (absolute) MIDI pitch value. |
int Pitch; ///< Current (absolute) MIDI pitch value. |
95 |
|
bool SuspensionRequested; |
96 |
|
pthread_mutex_t __render_state_mutex; |
97 |
|
pthread_cond_t __render_exit_condition; |
98 |
|
|
99 |
void ProcessNoteOn(ModulationSystem::Event* pNoteOnEvent); |
void ProcessNoteOn(ModulationSystem::Event* pNoteOnEvent); |
100 |
void ProcessNoteOff(ModulationSystem::Event* pNoteOffEvent); |
void ProcessNoteOff(ModulationSystem::Event* pNoteOffEvent); |
102 |
void ProcessControlChange(ModulationSystem::Event* pControlChangeEvent); |
void ProcessControlChange(ModulationSystem::Event* pControlChangeEvent); |
103 |
void KillVoice(Voice* pVoice); |
void KillVoice(Voice* pVoice); |
104 |
void CacheInitialSamples(gig::Sample* pSample); |
void CacheInitialSamples(gig::Sample* pSample); |
105 |
|
void ResetInternal(); |
106 |
|
|
107 |
friend class Voice; |
friend class Voice; |
108 |
}; |
}; |