/[svn]/linuxsampler/trunk/src/audiothread.h
ViewVC logotype

Diff of /linuxsampler/trunk/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 10 by senoner, Tue Nov 11 23:30:47 2003 UTC
# Line 36  Line 36 
36  #include "audioio.h"  #include "audioio.h"
37  #include "gig.h"  #include "gig.h"
38    
39    #include "rtelmemorypool.h"
40    
41  #define DEBUG                   0  #define DEBUG                   0
42  #define PITCHBEND_SEMITONES     12  #define PITCHBEND_SEMITONES     12
43  #define MAX_AUDIO_VOICES        64  #define MAX_AUDIO_VOICES        64
44    
45  // 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
46  #define NUM_RAM_PRELOAD_SAMPLES 65536  #define NUM_RAM_PRELOAD_SAMPLES 32768
47    
48  class AudioThread : public Thread {  class AudioThread : public Thread {
49      public:      public:
# Line 49  class AudioThread : public Thread { Line 51  class AudioThread : public Thread {
51         ~AudioThread();         ~AudioThread();
52          void ProcessNoteOn(uint8_t Pitch, uint8_t Velocity);          void ProcessNoteOn(uint8_t Pitch, uint8_t Velocity);
53          void ProcessNoteOff(uint8_t Pitch, uint8_t Velocity);          void ProcessNoteOff(uint8_t Pitch, uint8_t Velocity);
54            void ProcessContinuousController(uint8_t Channel, uint8_t Number, uint8_t Value);
55    
56            // the number of currently active streams
57            // printed on the console the main thread (along with the active streams count)
58            int ActiveVoiceCount;
59    
60      protected:      protected:
61          int Main(); ///< Implementation of virtual method from class Thread          int Main(); ///< Implementation of virtual method from class Thread
62      private:      private:
63          enum command_type_t {          enum command_type_t {
64              command_type_note_on,              command_type_note_on,
65              command_type_note_off              command_type_note_off,
66                command_type_continuous_controller
67          };          };
68          struct command_t {          struct command_t {
69              command_type_t type;              command_type_t type;
70                uint8_t        channel;
71              uint8_t        pitch;              uint8_t        pitch;
72              uint8_t        velocity;              uint8_t        velocity;
73                uint8_t        number;
74                uint8_t        value;
75          } command;          } command;
76          RingBuffer<command_t>* pCommandQueue;          RingBuffer<command_t>* pCommandQueue;
77          float*                 pAudioSumBuffer;    ///< Audio sum of all voices (32 bit)          float*                 pAudioSumBuffer;    ///< Audio sum of all voices (32 bit)
78          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
79          Voice*                 ActiveVoices[128];  ///< Contains all active voices sorted by MIDI key number  
80            RTEList<Voice *> *pActiveVoices[128];  ///< Contains all active voices sorted by MIDI key number
81            /* ActiveVoicePool is a memory pool of limited size (size=MAX VOICES) of active voices.
82               it can be allocated dynamically in real time and the allocated elements can be added to
83               the linked lists represented by ActiveVoices[MIDIKey]. This means we can have unlimited
84               active voices per key. This if for example useful to manage the sustain pedal messages
85             */
86            RTELMemoryPool<Voice *> *ActiveVoicePool;
87            /* SustainedVoicePool is a dynamically allocated pool (size=MAX VOICES) and list of notes
88               notes that were sustained and where the corresponding MIDI note-off arrived
89               but cannot processed yet. Basically when the sustain pedal is pressed and the
90               note-off on a certain midi key arrives. notes are not deleted from the
91               ActiveVoices[MIDIKey] list but an element is added in the SustainedVoicePool,
92               which is a dynamically allocated pool with a builtin list.
93               Then the pedal is finally released, this list is traversed and all elements
94               in the lists ActiveVoices[MIDIKey] ( where MIDIKey is contained in the list of
95               sustained voices) are processed (voices are released)
96            */
97    
98            typedef struct {
99                             int midikey;
100                             int velocity;
101                           } sustained_key_t;
102    
103            RTELMemoryPool<sustained_key_t> *SustainedKeyPool;
104    
105            uint8_t PrevHoldCCValue;
106            // SustainPedal = 1 if the sustain pedal is down, otherwise it is 0
107            uint8_t SustainPedal;
108    
109    
110    
111          AudioIO*               pAudioIO;          AudioIO*               pAudioIO;
112          DiskThread*            pDiskThread;          DiskThread*            pDiskThread;
113          gig::Instrument*       pInstrument;          gig::Instrument*       pInstrument;
114    
115          void ActivateVoice(uint8_t MIDIKey, uint8_t Velocity);          void ActivateVoice(uint8_t MIDIKey, uint8_t Velocity);
116          void ReleaseVoice(uint8_t MIDIKey, uint8_t Velocity);          void ReleaseVoice(uint8_t MIDIKey, uint8_t Velocity);
117            void ContinuousController(uint8_t Channel, uint8_t Number, uint8_t Value);
118          
119          void CacheInitialSamples(gig::Sample* pSample);          void CacheInitialSamples(gig::Sample* pSample);
120  };  };
121    

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

  ViewVC Help
Powered by ViewVC