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 |
|
this->MIDIKey = MIDIKey; |
40 |
pRegion = Instrument->GetRegion(MIDIKey); |
pRegion = Instrument->GetRegion(MIDIKey); |
41 |
PlaybackState = playback_state_ram; // we always start playback from RAM cache and switch then to disk if needed |
PlaybackState = playback_state_ram; // we always start playback from RAM cache and switch then to disk if needed |
42 |
Pos = 0; |
Pos = 0; |
70 |
if (DiskVoice) { |
if (DiskVoice) { |
71 |
MaxRAMPos = cachedsamples - (OutputBufferSize << MAX_PITCH) / pSample->Channels; |
MaxRAMPos = cachedsamples - (OutputBufferSize << MAX_PITCH) / pSample->Channels; |
72 |
pDiskThread->OrderNewStream(&DiskStreamRef, pSample, MaxRAMPos); |
pDiskThread->OrderNewStream(&DiskStreamRef, pSample, MaxRAMPos); |
73 |
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)); |
74 |
} |
} |
75 |
else { |
else { |
76 |
MaxRAMPos = cachedsamples; |
MaxRAMPos = cachedsamples; |
77 |
dmsg(("RAM only voice launched\n")); |
dmsg(5,("RAM only voice launched\n")); |
78 |
} |
} |
79 |
|
|
80 |
CurrentPitch = pow(2, (double) (MIDIKey - (int) pSample->MIDIUnityNote) / (double) 12); |
CurrentPitch = pow(2, (double) (MIDIKey - (int) pSample->MIDIUnityNote) / (double) 12); |
93 |
if (DiskVoice) { |
if (DiskVoice) { |
94 |
// check if we reached the allowed limit of the sample RAM cache |
// check if we reached the allowed limit of the sample RAM cache |
95 |
if (Pos > MaxRAMPos) { |
if (Pos > MaxRAMPos) { |
96 |
dmsg(("Voice: switching to disk playback (Pos=%f)\n", Pos)); |
dmsg(5,("Voice: switching to disk playback (Pos=%f)\n", Pos)); |
97 |
this->PlaybackState = playback_state_disk; |
this->PlaybackState = playback_state_disk; |
98 |
} |
} |
99 |
} |
} |