45 |
Voice::Voice() { |
Voice::Voice() { |
46 |
pEngine = NULL; |
pEngine = NULL; |
47 |
pDiskThread = NULL; |
pDiskThread = NULL; |
48 |
Active = false; |
PlaybackState = playback_state_end; |
49 |
pEG1 = NULL; |
pEG1 = NULL; |
50 |
pEG2 = NULL; |
pEG2 = NULL; |
51 |
pEG3 = NULL; |
pEG3 = NULL; |
117 |
} |
} |
118 |
|
|
119 |
Type = type_normal; |
Type = type_normal; |
|
Active = true; |
|
120 |
MIDIKey = itNoteOnEvent->Param.Note.Key; |
MIDIKey = itNoteOnEvent->Param.Note.Key; |
121 |
pRegion = pInstrument->GetRegion(MIDIKey); |
pRegion = pInstrument->GetRegion(MIDIKey); |
122 |
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 |
123 |
Delay = itNoteOnEvent->FragmentPos(); |
Delay = itNoteOnEvent->FragmentPos(); |
124 |
itTriggerEvent = itNoteOnEvent; |
itTriggerEvent = itNoteOnEvent; |
125 |
itKillEvent = Pool<Event>::Iterator(); |
itKillEvent = Pool<Event>::Iterator(); |
126 |
|
itChildVoice = Pool<Voice>::Iterator(); |
127 |
|
|
128 |
if (!pRegion) { |
if (!pRegion) { |
129 |
std::cerr << "gig::Voice: No Region defined for MIDI key " << MIDIKey << std::endl << std::flush; |
std::cerr << "gig::Voice: No Region defined for MIDI key " << MIDIKey << std::endl << std::flush; |
146 |
// if this is the 1st layer then spawn further voices for all the other layers |
// if this is the 1st layer then spawn further voices for all the other layers |
147 |
if (iLayer == 0) |
if (iLayer == 0) |
148 |
for (int iNewLayer = 1; iNewLayer < pRegion->pDimensionDefinitions[i].zones; iNewLayer++) |
for (int iNewLayer = 1; iNewLayer < pRegion->pDimensionDefinitions[i].zones; iNewLayer++) |
149 |
pEngine->LaunchVoice(itNoteOnEvent, iNewLayer, ReleaseTriggerVoice); |
itChildVoice = pEngine->LaunchVoice(itNoteOnEvent, iNewLayer, ReleaseTriggerVoice); |
150 |
break; |
break; |
151 |
case ::gig::dimension_velocity: |
case ::gig::dimension_velocity: |
152 |
DimValues[i] = itNoteOnEvent->Param.Note.Velocity; |
DimValues[i] = itNoteOnEvent->Param.Note.Velocity; |
701 |
break; |
break; |
702 |
|
|
703 |
case playback_state_end: |
case playback_state_end: |
704 |
KillImmediately(); // free voice |
std::cerr << "gig::Voice::Render(): entered with playback_state_end, this is a bug!\n" << std::flush; |
705 |
break; |
break; |
706 |
} |
} |
707 |
|
|
718 |
|
|
719 |
itTriggerEvent = Pool<Event>::Iterator(); |
itTriggerEvent = Pool<Event>::Iterator(); |
720 |
|
|
721 |
// If release stage finished, let the voice be killed |
// If sample stream or release stage finished, kill the voice |
722 |
if (pEG1->GetStage() == EGADSR::stage_end) this->PlaybackState = playback_state_end; |
if (PlaybackState == playback_state_end || pEG1->GetStage() == EGADSR::stage_end) KillImmediately(); |
723 |
} |
} |
724 |
|
|
725 |
/** |
/** |
734 |
DiskStreamRef.hStream = 0; |
DiskStreamRef.hStream = 0; |
735 |
DiskStreamRef.State = Stream::state_unused; |
DiskStreamRef.State = Stream::state_unused; |
736 |
DiskStreamRef.OrderID = 0; |
DiskStreamRef.OrderID = 0; |
737 |
Active = false; |
PlaybackState = playback_state_end; |
738 |
|
itTriggerEvent = Pool<Event>::Iterator(); |
739 |
|
itKillEvent = Pool<Event>::Iterator(); |
740 |
} |
} |
741 |
|
|
742 |
/** |
/** |