3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005-2009 Christian Schoenebeck * |
* Copyright (C) 2005-2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 Grigor Iliev * |
* Copyright (C) 2009-2010 Christian Schoenebeck and Grigor Iliev * |
8 |
* * |
* * |
9 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
10 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
35 |
D* pDiskThread; ///< Pointer to the disk thread, to be able to order a disk stream and later to delete the stream again |
D* pDiskThread; ///< Pointer to the disk thread, to be able to order a disk stream and later to delete the stream again |
36 |
int RealSampleWordsLeftToRead; ///< Number of samples left to read, not including the silence added for the interpolator |
int RealSampleWordsLeftToRead; ///< Number of samples left to read, not including the silence added for the interpolator |
37 |
|
|
38 |
VoiceBase() { |
VoiceBase(SignalUnitRack* pRack = NULL): AbstractVoice(pRack) { |
39 |
pRegion = NULL; |
pRegion = NULL; |
40 |
pDiskThread = NULL; |
pDiskThread = NULL; |
41 |
} |
} |
79 |
|
|
80 |
virtual int OrderNewStream() { |
virtual int OrderNewStream() { |
81 |
int res = pDiskThread->OrderNewStream ( |
int res = pDiskThread->OrderNewStream ( |
82 |
&DiskStreamRef, pRegion, MaxRAMPos, !RAMLoop |
&DiskStreamRef, pRegion, MaxRAMPos + GetRAMCacheOffset(), !RAMLoop |
83 |
); |
); |
84 |
|
|
85 |
if (res < 0) { |
if (res < 0) { |
90 |
|
|
91 |
return 0; |
return 0; |
92 |
} |
} |
93 |
|
|
94 |
|
/** The offset of the RAM cache from the sample start (in sample units). */ |
95 |
|
virtual int GetRAMCacheOffset() { return 0; } |
96 |
|
|
97 |
/** |
/** |
98 |
* Renders the audio data for this voice for the current audio fragment. |
* Renders the audio data for this voice for the current audio fragment. |
124 |
if (DiskVoice) { |
if (DiskVoice) { |
125 |
// check if we reached the allowed limit of the sample RAM cache |
// check if we reached the allowed limit of the sample RAM cache |
126 |
if (finalSynthesisParameters.dPos > MaxRAMPos) { |
if (finalSynthesisParameters.dPos > MaxRAMPos) { |
127 |
dmsg(5,("Voice: switching to disk playback (Pos=%f)\n", finalSynthesisParameters.dPos)); |
dmsg(5,("VoiceBase: switching to disk playback (Pos=%f)\n", finalSynthesisParameters.dPos)); |
128 |
this->PlaybackState = Voice::playback_state_disk; |
this->PlaybackState = Voice::playback_state_disk; |
129 |
} |
} |
130 |
} else if (finalSynthesisParameters.dPos >= pSample->GetCache().Size / SmplInfo.FrameSize) { |
} else if (finalSynthesisParameters.dPos >= pSample->GetCache().Size / SmplInfo.FrameSize) { |
178 |
break; |
break; |
179 |
|
|
180 |
case Voice::playback_state_end: |
case Voice::playback_state_end: |
181 |
std::cerr << "gig::Voice::Render(): entered with playback_state_end, this is a bug!\n" << std::flush; |
std::cerr << "VoiceBase::Render(): entered with playback_state_end, this is a bug!\n" << std::flush; |
182 |
break; |
break; |
183 |
} |
} |
184 |
|
|
188 |
itTriggerEvent = Pool<Event>::Iterator(); |
itTriggerEvent = Pool<Event>::Iterator(); |
189 |
|
|
190 |
// If sample stream or release stage finished, kill the voice |
// If sample stream or release stage finished, kill the voice |
191 |
if ( |
if (PlaybackState == Voice::playback_state_end || EG1Finished()) { |
192 |
PlaybackState == Voice::playback_state_end || |
KillImmediately(); |
193 |
EG1.getSegmentType() == gig::EGADSR::segment_end |
} |
|
) KillImmediately(); |
|
194 |
} |
} |
195 |
|
|
196 |
/** |
/** |
229 |
S* pSample; ///< Pointer to the sample to be played back |
S* pSample; ///< Pointer to the sample to be played back |
230 |
R* pRegion; ///< Pointer to the articulation information of current region of this voice |
R* pRegion; ///< Pointer to the articulation information of current region of this voice |
231 |
|
|
232 |
|
virtual MidiKeyBase* GetMidiKeyInfo(int MIDIKey) { |
233 |
|
EC* pChannel = static_cast<EC*>(pEngineChannel); |
234 |
|
return &pChannel->pMIDIKeyInfo[MIDIKey]; |
235 |
|
} |
236 |
|
|
237 |
virtual unsigned long GetNoteOnTime(int MIDIKey) { |
virtual unsigned long GetNoteOnTime(int MIDIKey) { |
238 |
EC* pChannel = static_cast<EC*>(pEngineChannel); |
EC* pChannel = static_cast<EC*>(pEngineChannel); |
239 |
return pChannel->pMIDIKeyInfo[MIDIKey].NoteOnTime; |
return pChannel->pMIDIKeyInfo[MIDIKey].NoteOnTime; |