29 |
|
|
30 |
#include "Engine.h" |
#include "Engine.h" |
31 |
|
|
32 |
|
#include "../../common/global_private.h" |
33 |
|
|
34 |
namespace LinuxSampler { namespace gig { |
namespace LinuxSampler { namespace gig { |
35 |
|
|
36 |
InstrumentResourceManager Engine::instruments; |
InstrumentResourceManager Engine::instruments; |
191 |
* engine afterwards by calling @c ResumeAll() later on! |
* engine afterwards by calling @c ResumeAll() later on! |
192 |
*/ |
*/ |
193 |
void Engine::SuspendAll() { |
void Engine::SuspendAll() { |
194 |
dmsg(1,("gig::Engine: Suspending all ...\n")); |
dmsg(2,("gig::Engine: Suspending all ...\n")); |
195 |
// stop the engine, so we can safely modify the engine's |
// stop the engine, so we can safely modify the engine's |
196 |
// data structures from this foreign thread |
// data structures from this foreign thread |
197 |
DisableAndLock(); |
DisableAndLock(); |
225 |
if (!iPendingStreamDeletions) break; |
if (!iPendingStreamDeletions) break; |
226 |
usleep(10000); // sleep for 10ms |
usleep(10000); // sleep for 10ms |
227 |
} |
} |
228 |
dmsg(1,("gig::Engine: Everything suspended.\n")); |
dmsg(2,("gig::Engine: Everything suspended.\n")); |
229 |
} |
} |
230 |
|
|
231 |
/** |
/** |
247 |
* @param pRegion - region the engine shall stop using |
* @param pRegion - region the engine shall stop using |
248 |
*/ |
*/ |
249 |
void Engine::Suspend(::gig::Region* pRegion) { |
void Engine::Suspend(::gig::Region* pRegion) { |
250 |
dmsg(1,("gig::Engine: Suspending Region %x ...\n",pRegion)); |
dmsg(2,("gig::Engine: Suspending Region %x ...\n",pRegion)); |
251 |
SuspendedRegionsMutex.Lock(); |
SuspendedRegionsMutex.Lock(); |
252 |
SuspensionChangeOngoing.Set(true); |
SuspensionChangeOngoing.Set(true); |
253 |
pPendingRegionSuspension = pRegion; |
pPendingRegionSuspension = pRegion; |
254 |
SuspensionChangeOngoing.WaitAndUnlockIf(true); |
SuspensionChangeOngoing.WaitAndUnlockIf(true); |
255 |
SuspendedRegionsMutex.Unlock(); |
SuspendedRegionsMutex.Unlock(); |
256 |
dmsg(1,("gig::Engine: Region %x suspended.",pRegion)); |
dmsg(2,("gig::Engine: Region %x suspended.",pRegion)); |
257 |
} |
} |
258 |
|
|
259 |
/** |
/** |
263 |
* @param pRegion - region the engine shall be allowed to use again |
* @param pRegion - region the engine shall be allowed to use again |
264 |
*/ |
*/ |
265 |
void Engine::Resume(::gig::Region* pRegion) { |
void Engine::Resume(::gig::Region* pRegion) { |
266 |
dmsg(1,("gig::Engine: Resuming Region %x ...\n",pRegion)); |
dmsg(2,("gig::Engine: Resuming Region %x ...\n",pRegion)); |
267 |
SuspendedRegionsMutex.Lock(); |
SuspendedRegionsMutex.Lock(); |
268 |
SuspensionChangeOngoing.Set(true); |
SuspensionChangeOngoing.Set(true); |
269 |
pPendingRegionResumption = pRegion; |
pPendingRegionResumption = pRegion; |
270 |
SuspensionChangeOngoing.WaitAndUnlockIf(true); |
SuspensionChangeOngoing.WaitAndUnlockIf(true); |
271 |
SuspendedRegionsMutex.Unlock(); |
SuspendedRegionsMutex.Unlock(); |
272 |
dmsg(1,("gig::Engine: Region %x resumed.\n",pRegion)); |
dmsg(2,("gig::Engine: Region %x resumed.\n",pRegion)); |
273 |
} |
} |
274 |
|
|
275 |
/** |
/** |
571 |
* @returns 0 on success |
* @returns 0 on success |
572 |
*/ |
*/ |
573 |
int Engine::RenderAudio(uint Samples) { |
int Engine::RenderAudio(uint Samples) { |
574 |
dmsg(7,("RenderAudio(Samples=%d)\n", Samples)); |
dmsg(8,("RenderAudio(Samples=%d)\n", Samples)); |
575 |
|
|
576 |
// return if engine disabled |
// return if engine disabled |
577 |
if (EngineDisabled.Pop()) { |
if (EngineDisabled.Pop()) { |
780 |
} |
} |
781 |
} |
} |
782 |
} |
} |
783 |
|
|
784 |
pEngineChannel->SetVoiceCount(voiceCount); |
pEngineChannel->SetVoiceCount(voiceCount); |
785 |
pEngineChannel->SetDiskStreamCount(streamCount); |
pEngineChannel->SetDiskStreamCount(streamCount); |
786 |
} |
} |
1688 |
break; |
break; |
1689 |
} |
} |
1690 |
case 65: { // portamento on / off |
case 65: { // portamento on / off |
1691 |
KillAllVoices(pEngineChannel, itControlChangeEvent); |
const bool bPortamento = itControlChangeEvent->Param.CC.Value >= 64; |
1692 |
pEngineChannel->PortamentoMode = itControlChangeEvent->Param.CC.Value >= 64; |
if (bPortamento != pEngineChannel->PortamentoMode) |
1693 |
|
KillAllVoices(pEngineChannel, itControlChangeEvent); |
1694 |
|
pEngineChannel->PortamentoMode = bPortamento; |
1695 |
break; |
break; |
1696 |
} |
} |
1697 |
case 66: { // sostenuto |
case 66: { // sostenuto |
1761 |
break; |
break; |
1762 |
} |
} |
1763 |
case 126: { // mono mode on |
case 126: { // mono mode on |
1764 |
KillAllVoices(pEngineChannel, itControlChangeEvent); |
if (!pEngineChannel->SoloMode) |
1765 |
|
KillAllVoices(pEngineChannel, itControlChangeEvent); |
1766 |
pEngineChannel->SoloMode = true; |
pEngineChannel->SoloMode = true; |
1767 |
break; |
break; |
1768 |
} |
} |
1769 |
case 127: { // poly mode on |
case 127: { // poly mode on |
1770 |
KillAllVoices(pEngineChannel, itControlChangeEvent); |
if (pEngineChannel->SoloMode) |
1771 |
|
KillAllVoices(pEngineChannel, itControlChangeEvent); |
1772 |
pEngineChannel->SoloMode = false; |
pEngineChannel->SoloMode = false; |
1773 |
break; |
break; |
1774 |
} |
} |
1977 |
} |
} |
1978 |
|
|
1979 |
String Engine::Version() { |
String Engine::Version() { |
1980 |
String s = "$Revision: 1.80 $"; |
String s = "$Revision: 1.84 $"; |
1981 |
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 |
1982 |
} |
} |
1983 |
|
|