/[svn]/linuxsampler/trunk/src/voice.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/voice.cpp

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  Voice::~Voice() { Line 35  Voice::~Voice() {
35  }  }
36    
37  void Voice::Trigger(int MIDIKey, uint8_t Velocity, gig::Instrument* Instrument) {  void Voice::Trigger(int MIDIKey, uint8_t Velocity, gig::Instrument* Instrument) {
38      Active        = true;      Active          = true;
39      pRegion       = Instrument->GetRegion(MIDIKey);      this->MIDIKey   = MIDIKey;
40      PlaybackState = playback_state_ram; // we always start playback from RAM cache and switch then to disk if needed      pRegion         = Instrument->GetRegion(MIDIKey);
41      Pos           = 0;      PlaybackState   = playback_state_ram; // we always start playback from RAM cache and switch then to disk if needed
42        Pos             = 0;
43        ReleaseVelocity = 127; // default release velocity value
44    
45      if (!pRegion) {      if (!pRegion) {
46          std::cerr << "Audio Thread: No Region defined for MIDI key " << MIDIKey << std::endl << std::flush;          std::cerr << "Audio Thread: No Region defined for MIDI key " << MIDIKey << std::endl << std::flush;
# Line 69  void Voice::Trigger(int MIDIKey, uint8_t Line 71  void Voice::Trigger(int MIDIKey, uint8_t
71      if (DiskVoice) {      if (DiskVoice) {
72          MaxRAMPos = cachedsamples - (OutputBufferSize << MAX_PITCH) / pSample->Channels;          MaxRAMPos = cachedsamples - (OutputBufferSize << MAX_PITCH) / pSample->Channels;
73          pDiskThread->OrderNewStream(&DiskStreamRef, pSample, MaxRAMPos);          pDiskThread->OrderNewStream(&DiskStreamRef, pSample, MaxRAMPos);
74          dmsg(("Disk voice launched (cached samples: %d, total Samples: %d, MaxRAMPos: %d\n", cachedsamples, pSample->SamplesTotal, MaxRAMPos));          dmsg(5,("Disk voice launched (cached samples: %d, total Samples: %d, MaxRAMPos: %d\n", cachedsamples, pSample->SamplesTotal, MaxRAMPos));
75      }      }
76      else {      else {
77          MaxRAMPos = cachedsamples;          MaxRAMPos = cachedsamples;
78          dmsg(("RAM only voice launched\n"));          dmsg(5,("RAM only voice launched\n"));
79      }      }
80    
81      CurrentPitch = pow(2, (double) (MIDIKey - (int) pSample->MIDIUnityNote) / (double) 12);      CurrentPitch = pow(2, (double) (MIDIKey - (int) pSample->MIDIUnityNote) / (double) 12);
# Line 92  void Voice::RenderAudio() { Line 94  void Voice::RenderAudio() {
94                  if (DiskVoice) {                  if (DiskVoice) {
95                      // check if we reached the allowed limit of the sample RAM cache                      // check if we reached the allowed limit of the sample RAM cache
96                      if (Pos > MaxRAMPos) {                      if (Pos > MaxRAMPos) {
97                          dmsg(("Voice: switching to disk playback (Pos=%f)\n", Pos));                          dmsg(5,("Voice: switching to disk playback (Pos=%f)\n", Pos));
98                          this->PlaybackState = playback_state_disk;                          this->PlaybackState = playback_state_disk;
99                      }                      }
100                  }                  }
# Line 130  void Voice::RenderAudio() { Line 132  void Voice::RenderAudio() {
132              break;              break;
133    
134          case playback_state_end:          case playback_state_end:
135              this->Active = false; // free voice              Kill(); // free voice
136              break;              break;
137      }      }
138  }  }

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

  ViewVC Help
Powered by ViewVC