116 |
* Destructor |
* Destructor |
117 |
*/ |
*/ |
118 |
Engine::~Engine() { |
Engine::~Engine() { |
119 |
|
MidiInputPort::RemoveSysexListener(this); |
120 |
if (pDiskThread) { |
if (pDiskThread) { |
121 |
dmsg(1,("Stopping disk thread...")); |
dmsg(1,("Stopping disk thread...")); |
122 |
pDiskThread->StopThread(); |
pDiskThread->StopThread(); |
166 |
|
|
167 |
/** |
/** |
168 |
* Reset all voices and disk thread and clear input event queue and all |
* Reset all voices and disk thread and clear input event queue and all |
169 |
* control and status variables. This method is not thread safe! |
* control and status variables. This method is protected by a mutex. |
170 |
*/ |
*/ |
171 |
void Engine::ResetInternal() { |
void Engine::ResetInternal() { |
172 |
|
ResetInternalMutex.Lock(); |
173 |
|
|
174 |
|
// make sure that the engine does not get any sysex messages |
175 |
|
// while it's reseting |
176 |
|
bool sysexDisabled = MidiInputPort::RemoveSysexListener(this); |
177 |
ActiveVoiceCount = 0; |
ActiveVoiceCount = 0; |
178 |
ActiveVoiceCountMax = 0; |
ActiveVoiceCountMax = 0; |
179 |
|
|
197 |
// delete all input events |
// delete all input events |
198 |
pEventQueue->init(); |
pEventQueue->init(); |
199 |
pSysexBuffer->init(); |
pSysexBuffer->init(); |
200 |
|
if (sysexDisabled) MidiInputPort::AddSysexListener(this); |
201 |
|
ResetInternalMutex.Unlock(); |
202 |
} |
} |
203 |
|
|
204 |
/** |
/** |
1565 |
} |
} |
1566 |
|
|
1567 |
String Engine::Version() { |
String Engine::Version() { |
1568 |
String s = "$Revision: 1.58 $"; |
String s = "$Revision: 1.60 $"; |
1569 |
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 |
1570 |
} |
} |
1571 |
|
|
1572 |
// static constant initializers |
// static constant initializers |
1573 |
const float* Engine::VolumeCurve(InitVolumeCurve()); |
const float* Engine::VolumeCurve(InitVolumeCurve()); |
1574 |
const float* Engine::PanCurve(InitPanCurve()); |
const float* Engine::PanCurve(InitPanCurve()); |
1575 |
|
const float* Engine::CrossfadeCurve(InitCrossfadeCurve()); |
1576 |
|
|
1577 |
float* Engine::InitVolumeCurve() { |
float* Engine::InitVolumeCurve() { |
1578 |
// line-segment approximation |
// line-segment approximation |
1593 |
return InitCurve(segments, 129); |
return InitCurve(segments, 129); |
1594 |
} |
} |
1595 |
|
|
1596 |
|
float* Engine::InitCrossfadeCurve() { |
1597 |
|
// line-segment approximation |
1598 |
|
const float segments[] = { |
1599 |
|
0, 0, 1, 0.03, 10, 0.1, 51, 0.58, 127, 1 |
1600 |
|
}; |
1601 |
|
return InitCurve(segments); |
1602 |
|
} |
1603 |
|
|
1604 |
float* Engine::InitCurve(const float* segments, int size) { |
float* Engine::InitCurve(const float* segments, int size) { |
1605 |
float* y = new float[size]; |
float* y = new float[size]; |
1606 |
for (int x = 0 ; x < size ; x++) { |
for (int x = 0 ; x < size ; x++) { |