/[svn]/linuxsampler/tags/v0_1_0/src/audiothread.h
ViewVC logotype

Diff of /linuxsampler/tags/v0_1_0/src/audiothread.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9 by schoenebeck, Wed Nov 5 14:47:10 2003 UTC revision 15 by schoenebeck, Sun Nov 23 21:16:49 2003 UTC
# Line 35  Line 35 
35  #include "voice.h"  #include "voice.h"
36  #include "audioio.h"  #include "audioio.h"
37  #include "gig.h"  #include "gig.h"
38    #include "rtelmemorypool.h"
39    
 #define DEBUG                   0  
40  #define PITCHBEND_SEMITONES     12  #define PITCHBEND_SEMITONES     12
41  #define MAX_AUDIO_VOICES        64  #define MAX_AUDIO_VOICES        64
42    
43  // preload 64k samples = 128kB of data in RAM for 16 bit mono samples  // preload 64k samples = 128kB of data in RAM for 16 bit mono samples
44  #define NUM_RAM_PRELOAD_SAMPLES 65536  #define NUM_RAM_PRELOAD_SAMPLES 32768
45    
46  class AudioThread : public Thread {  class AudioThread : public Thread {
47      public:      public:
48            int ActiveVoiceCount;     ///< number of currently active voices
49            int ActiveVoiceCountMax;  ///< the maximum voice usage since application start
50    
51          AudioThread(AudioIO* pAudioIO, DiskThread* pDiskThread, gig::Instrument* pInstrument);          AudioThread(AudioIO* pAudioIO, DiskThread* pDiskThread, gig::Instrument* pInstrument);
52         ~AudioThread();         ~AudioThread();
53          void ProcessNoteOn(uint8_t Pitch, uint8_t Velocity);          void ProcessNoteOn(uint8_t Pitch, uint8_t Velocity);
54          void ProcessNoteOff(uint8_t Pitch, uint8_t Velocity);          void ProcessNoteOff(uint8_t Pitch, uint8_t Velocity);
55            void ProcessContinuousController(uint8_t Channel, uint8_t Number, uint8_t Value);
56      protected:      protected:
57          int Main(); ///< Implementation of virtual method from class Thread          int Main(); ///< Implementation of virtual method from class Thread
58      private:      private:
59          enum command_type_t {          enum command_type_t {
60              command_type_note_on,              command_type_note_on,
61              command_type_note_off              command_type_note_off,
62                command_type_continuous_controller
63          };          };
64          struct command_t {          struct command_t {
65              command_type_t type;              command_type_t type;
66                uint8_t        channel;
67              uint8_t        pitch;              uint8_t        pitch;
68              uint8_t        velocity;              uint8_t        velocity;
69                uint8_t        number;
70                uint8_t        value;
71          } command;          } command;
72          RingBuffer<command_t>* pCommandQueue;          struct midi_key_info_t {
73          float*                 pAudioSumBuffer;    ///< Audio sum of all voices (32 bit)              RTEList<Voice*>*             pActiveVoices; ///< Contains the active voices associated with the MIDI key.
74          Voice**                pVoices;            ///< The voice pool, containing all Voices (active and inactice voices) in unsorted order              RTEList<Voice*>::NodeHandle  hSustainPtr;   ///< Points to the voice element in the active voice list which has not received a note-off yet (this pointer is needed for sustain pedal handling)
75          Voice*                 ActiveVoices[128];  ///< Contains all active voices sorted by MIDI key number              bool                         Sustained;     ///< Is true if the MIDI key is currently sustained, thus if Note-off arrived while sustain pedal pressed.
76          AudioIO*               pAudioIO;          };
77          DiskThread*            pDiskThread;  
78          gig::Instrument*       pInstrument;          RingBuffer<command_t>*           pCommandQueue;
79            float*                           pAudioSumBuffer;    ///< Audio sum of all voices (32 bit)
80            Voice**                          pVoices;            ///< The voice pool, containing all Voices (active and inactice voices) in unsorted order
81            midi_key_info_t                  pMIDIKeyInfo[128];  ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key
82            /* ActiveVoicePool is a memory pool of limited size (size=MAX VOICES) of active voices.
83               it can be allocated dynamically in real time and the allocated elements can be added to
84               the linked lists represented by ActiveVoices[MIDIKey]. This means we can have unlimited
85               active voices per key. This if for example useful to manage the sustain pedal messages
86             */
87            RTELMemoryPool<Voice*>*          ActiveVoicePool;
88            RTELMemoryPool<uint>*            SustainedKeyPool;   ///< Contains the MIDI key numbers of all currently sustained keys.
89            AudioIO*                         pAudioIO;
90            DiskThread*                      pDiskThread;
91            gig::Instrument*                 pInstrument;
92            bool                             SustainPedal;       ///< true if sustain pedal is down
93            uint8_t                          PrevHoldCCValue;
94    
95          void ActivateVoice(uint8_t MIDIKey, uint8_t Velocity);          void ActivateVoice(uint8_t MIDIKey, uint8_t Velocity);
96          void ReleaseVoice(uint8_t MIDIKey, uint8_t Velocity);          void ReleaseVoice(uint8_t MIDIKey, uint8_t Velocity);
97            void ReleaseVoice(Voice* pVoice);
98            void ContinuousController(uint8_t Channel, uint8_t Number, uint8_t Value);
99          void CacheInitialSamples(gig::Sample* pSample);          void CacheInitialSamples(gig::Sample* pSample);
100  };  };
101    

Legend:
Removed from v.9  
changed lines
  Added in v.15

  ViewVC Help
Powered by ViewVC