/[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 12 by schoenebeck, Sun Nov 16 19:01:50 2003 UTC revision 30 by schoenebeck, Sun Jan 11 16:43:54 2004 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"  #include "rtelmemorypool.h"
39    #include "modulationsystem.h"
40    
 #define DEBUG                   0  
41  #define PITCHBEND_SEMITONES     12  #define PITCHBEND_SEMITONES     12
42  #define MAX_AUDIO_VOICES        64  #define MAX_AUDIO_VOICES        64
43    
# Line 47  Line 46 
46    
47  class AudioThread : public Thread {  class AudioThread : public Thread {
48      public:      public:
49          int ActiveVoiceCount;  ///< number of currently active voices          double Volume;               ///< overall volume (a value < 1.0 means attenuation, a value > 1.0 means amplification)
50            int    ActiveVoiceCount;     ///< number of currently active voices
51            int    ActiveVoiceCountMax;  ///< the maximum voice usage since application start
52    
53          AudioThread(AudioIO* pAudioIO, DiskThread* pDiskThread, gig::Instrument* pInstrument);          AudioThread(AudioIO* pAudioIO, DiskThread* pDiskThread, gig::Instrument* pInstrument);
54         ~AudioThread();         ~AudioThread();
55          void ProcessNoteOn(uint8_t Pitch, uint8_t Velocity);          void SendNoteOn(uint8_t Pitch, uint8_t Velocity);
56          void ProcessNoteOff(uint8_t Pitch, uint8_t Velocity);          void SendNoteOff(uint8_t Pitch, uint8_t Velocity);
57          void ProcessContinuousController(uint8_t Channel, uint8_t Number, uint8_t Value);          void SendControlChange(uint8_t Channel, uint8_t Number, uint8_t Value);
58      protected:      protected:
59          int Main(); ///< Implementation of virtual method from class Thread          int Main(); ///< Implementation of virtual method from class Thread
60      private:      private:
# Line 70  class AudioThread : public Thread { Line 71  class AudioThread : public Thread {
71              uint8_t        number;              uint8_t        number;
72              uint8_t        value;              uint8_t        value;
73          } command;          } command;
74          struct sustained_key_t {          struct midi_key_info_t {
75              int midikey;              RTEList<Voice*>*             pActiveVoices;      ///< Contains the active voices associated with the MIDI key.
76              int velocity;              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)
77                bool                         Sustained;          ///< Is true if the MIDI key is currently sustained, thus if Note-off arrived while sustain pedal pressed.
78                bool                         KeyPressed;         ///< Is true if the respective MIDI key is currently pressed.
79                uint*                        pSustainPoolNode;   ///< FIXME: hack to allow fast deallocation of the key from the sustained key pool
80          };          };
81    
82          RingBuffer<command_t>*           pCommandQueue;          RingBuffer<command_t>*           pCommandQueue;
83          float*                           pAudioSumBuffer;    ///< Audio sum of all voices (32 bit)          float*                           pAudioSumBuffer;    ///< Audio sum of all voices (32 bit)
84          Voice**                          pVoices;            ///< The voice pool, containing all Voices (active and inactice voices) in unsorted order          Voice**                          pVoices;            ///< The voice pool, containing all Voices (active and inactice voices) in unsorted order
85          RTEList<Voice *>*                pActiveVoices[128]; ///< Contains all active voices sorted by MIDI key number          midi_key_info_t                  pMIDIKeyInfo[128];  ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key
86          /* ActiveVoicePool is a memory pool of limited size (size=MAX VOICES) of active voices.          /* ActiveVoicePool is a memory pool of limited size (size=MAX VOICES) of active voices.
87             it can be allocated dynamically in real time and the allocated elements can be added to             it can be allocated dynamically in real time and the allocated elements can be added to
88             the linked lists represented by ActiveVoices[MIDIKey]. This means we can have unlimited             the linked lists represented by ActiveVoices[MIDIKey]. This means we can have unlimited
89             active voices per key. This if for example useful to manage the sustain pedal messages             active voices per key. This if for example useful to manage the sustain pedal messages
90           */           */
91          RTELMemoryPool<Voice *>*         ActiveVoicePool;          RTELMemoryPool<Voice*>*          ActiveVoicePool;
92          /* SustainedVoicePool is a dynamically allocated pool (size=MAX VOICES) and list of notes          RTELMemoryPool<uint>*            SustainedKeyPool;   ///< Contains the MIDI key numbers of all currently sustained keys.
            notes that were sustained and where the corresponding MIDI note-off arrived  
            but cannot processed yet. Basically when the sustain pedal is pressed and the  
            note-off on a certain midi key arrives. notes are not deleted from the  
            ActiveVoices[MIDIKey] list but an element is added in the SustainedVoicePool,  
            which is a dynamically allocated pool with a builtin list.  
            Then the pedal is finally released, this list is traversed and all elements  
            in the lists ActiveVoices[MIDIKey] ( where MIDIKey is contained in the list of  
            sustained voices) are processed (voices are released)  
         */  
         RTELMemoryPool<sustained_key_t>* SustainedKeyPool;  
93          AudioIO*                         pAudioIO;          AudioIO*                         pAudioIO;
94          DiskThread*                      pDiskThread;          DiskThread*                      pDiskThread;
95          gig::Instrument*                 pInstrument;          gig::Instrument*                 pInstrument;
96          bool                             SustainPedal;  ///< true if sustain pedal is down          bool                             SustainPedal;       ///< true if sustain pedal is down
97          uint8_t                          PrevHoldCCValue;          uint8_t                          PrevHoldCCValue;
98    
99          void ActivateVoice(uint8_t MIDIKey, uint8_t Velocity);          void ProcessNoteOn(uint8_t MIDIKey, uint8_t Velocity);
100          void ReleaseVoice(uint8_t MIDIKey, uint8_t Velocity);          void ProcessNoteOff(uint8_t MIDIKey, uint8_t Velocity);
101          void ReleaseVoice(Voice* pVoice);          void ProcessControlChange(uint8_t Channel, uint8_t Number, uint8_t Value);
102          void ContinuousController(uint8_t Channel, uint8_t Number, uint8_t Value);          void KillVoice(Voice* pVoice);
103          void CacheInitialSamples(gig::Sample* pSample);          void CacheInitialSamples(gig::Sample* pSample);
104  };  };
105    

Legend:
Removed from v.12  
changed lines
  Added in v.30

  ViewVC Help
Powered by ViewVC