mirror of
https://github.com/AxioDL/amuse.git
synced 2025-12-08 21:17:49 +00:00
All relevant SoundMacros implemented, voice and engine tweaks
This commit is contained in:
@@ -15,12 +15,22 @@ Engine::Engine(IBackendVoiceAllocator& backend)
|
||||
|
||||
Voice* Engine::_allocateVoice(const AudioGroup& group, double sampleRate, bool dynamicPitch, bool emitter)
|
||||
{
|
||||
m_activeVoices.emplace_back(*this, group, m_nextVid++, emitter);
|
||||
auto it = m_activeVoices.emplace(m_activeVoices.end(), *this, group, m_nextVid++, emitter);
|
||||
m_activeVoices.back().m_backendVoice =
|
||||
m_backend.allocateVoice(m_activeVoices.back(), sampleRate, dynamicPitch);
|
||||
m_activeVoices.back().m_engineIt = it;
|
||||
return &m_activeVoices.back();
|
||||
}
|
||||
|
||||
std::list<Voice>::iterator Engine::_destroyVoice(Voice* voice)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
assert(this == &voice->getEngine());
|
||||
#endif
|
||||
voice->_destroy();
|
||||
return m_activeVoices.erase(voice->m_engineIt);
|
||||
}
|
||||
|
||||
AudioGroup* Engine::_findGroupFromSfxId(int sfxId, const AudioGroupSampleDirectory::Entry*& entOut) const
|
||||
{
|
||||
for (const auto& grp : m_audioGroups)
|
||||
@@ -147,4 +157,30 @@ Voice* Engine::findVoice(int vid)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** Stop all voices in `kg`, stops immediately (no KeyOff) when `flag` set */
|
||||
void Engine::killKeygroup(uint8_t kg, uint8_t flag)
|
||||
{
|
||||
for (auto it = m_activeVoices.begin() ; it != m_activeVoices.end() ;)
|
||||
{
|
||||
if (it->m_keygroup == kg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
it = _destroyVoice(&*it);
|
||||
continue;
|
||||
}
|
||||
it->keyOff();
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
/** Send all voices using `macroId` the message `val` */
|
||||
void Engine::sendMacroMessage(ObjectId macroId, int32_t val)
|
||||
{
|
||||
for (auto it = m_activeVoices.begin() ; it != m_activeVoices.end() ; ++it)
|
||||
if (it->getObjectId() == macroId)
|
||||
it->message(val);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user