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-2009 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 Grigor Iliev * |
* Copyright (C) 2009-2010 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 * |
79 |
int bend = pChannel->Pitch; |
int bend = pChannel->Pitch; |
80 |
uint8_t chanaft = pChannel->ControllerTable[128]; |
uint8_t chanaft = pChannel->ControllerTable[128]; |
81 |
uint8_t* cc = pChannel->ControllerTable; |
uint8_t* cc = pChannel->ControllerTable; |
82 |
::sfz::trigger_t trig = TRIGGER_ATTACK; |
::sfz::trigger_t trig = TRIGGER_ATTACK | |
83 |
|
((pChannel->LastKey != -1 && |
84 |
|
pChannel->PressedKeys[pChannel->LastKey] && |
85 |
|
pChannel->LastKey != key) ? |
86 |
|
TRIGGER_LEGATO : TRIGGER_FIRST); |
87 |
|
|
88 |
pChannel->regionsTemp = pChannel->pInstrument->GetRegionsOnKey ( |
pChannel->regionsTemp = pChannel->pInstrument->GetRegionsOnKey ( |
89 |
chan, key, vel, bend, 0, chanaft, 0, 0, 0, trig, cc, |
chan, key, vel, bend, 0, chanaft, 0, 0, Random(), trig, cc, |
90 |
0.0f, 1, pChannel->PressedKeys, pChannel->LastKeySwitch, pChannel->LastKey |
0.0f, pChannel->PressedKeys, pChannel->LastKeySwitch, pChannel->LastKey |
91 |
); |
); |
92 |
|
|
93 |
for (int i = 0; i < pChannel->regionsTemp.size(); i++) { |
for (int i = 0; i < pChannel->regionsTemp.size(); i++) { |
104 |
EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel); |
EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel); |
105 |
uint8_t chan = pChannel->MidiChannel(); |
uint8_t chan = pChannel->MidiChannel(); |
106 |
int key = itNoteOffEvent->Param.Note.Key; |
int key = itNoteOffEvent->Param.Note.Key; |
107 |
uint8_t vel = itNoteOffEvent->Param.Note.Velocity; |
|
108 |
|
// MIDI note-on velocity is used instead of note-off velocity |
109 |
|
uint8_t vel = pChannel->pMIDIKeyInfo[key].Velocity; |
110 |
|
itNoteOffEvent->Param.Note.Velocity = vel; |
111 |
|
|
112 |
int bend = pChannel->Pitch; |
int bend = pChannel->Pitch; |
113 |
uint8_t chanaft = pChannel->ControllerTable[128]; |
uint8_t chanaft = pChannel->ControllerTable[128]; |
114 |
uint8_t* cc = pChannel->ControllerTable; |
uint8_t* cc = pChannel->ControllerTable; |
115 |
::sfz::trigger_t trig = TRIGGER_RELEASE; |
::sfz::trigger_t trig = TRIGGER_RELEASE; |
116 |
|
|
117 |
pChannel->regionsTemp = pChannel->pInstrument->GetRegionsOnKey ( |
pChannel->regionsTemp = pChannel->pInstrument->GetRegionsOnKey ( |
118 |
chan, key, vel, bend, 0, chanaft, 0, 0, 0, trig, cc, 0.0f, 0, NULL, 0, 0 |
chan, key, vel, bend, 0, chanaft, 0, 0, Random(), trig, cc, |
119 |
|
0.0f, pChannel->PressedKeys, pChannel->LastKeySwitch, pChannel->LastKey |
120 |
); |
); |
121 |
|
|
122 |
// now launch the required amount of voices |
// now launch the required amount of voices |
136 |
EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel); |
EngineChannel* pChannel = static_cast<EngineChannel*>(pEngineChannel); |
137 |
int key = itNoteOnEvent->Param.Note.Key; |
int key = itNoteOnEvent->Param.Note.Key; |
138 |
EngineChannel::MidiKey* pKey = &pChannel->pMIDIKeyInfo[key]; |
EngineChannel::MidiKey* pKey = &pChannel->pMIDIKeyInfo[key]; |
139 |
Voice::type_t VoiceType = Voice::type_normal; |
Voice::type_t VoiceType = (ReleaseTriggerVoice) ? Voice::type_release_trigger : (!iLayer) ? Voice::type_release_trigger_required : Voice::type_normal; |
140 |
|
|
141 |
Pool<Voice>::Iterator itNewVoice; |
Pool<Voice>::Iterator itNewVoice; |
142 |
::sfz::Region* pRgn = pChannel->regionsTemp[iLayer]; |
::sfz::Region* pRgn = pChannel->regionsTemp[iLayer]; |
147 |
// only mark the first voice of a layered voice (group) to be in a |
// only mark the first voice of a layered voice (group) to be in a |
148 |
// key group, so the layered voices won't kill each other |
// key group, so the layered voices won't kill each other |
149 |
int iKeyGroup = (iLayer == 0 && !ReleaseTriggerVoice) ? pRgn->group : 0; |
int iKeyGroup = (iLayer == 0 && !ReleaseTriggerVoice) ? pRgn->group : 0; |
150 |
if (HandleKeyGroupConflicts) pChannel->HandleKeyGroupConflicts(iKeyGroup, itNoteOnEvent); |
if (HandleKeyGroupConflicts) pChannel->HandleKeyGroupConflicts(iKeyGroup, itNoteOnEvent, pRgn->off_mode == ::sfz::OFF_NORMAL); |
151 |
|
|
152 |
// allocate a new voice for the key |
// allocate a new voice for the key |
153 |
itNewVoice = pKey->pActiveVoices->allocAppend(); |
itNewVoice = pKey->pActiveVoices->allocAppend(); |
174 |
} |
} |
175 |
|
|
176 |
String Engine::Version() { |
String Engine::Version() { |
177 |
String s = "$Revision: 1.2 $"; |
String s = "$Revision: 1.7 $"; |
178 |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
179 |
} |
} |
180 |
|
|