mirror of https://github.com/AxioDL/amuse.git
Added master volume API for entire engine
This commit is contained in:
parent
2dcb9dd1c7
commit
d602fbacd3
|
@ -169,7 +169,7 @@ struct AppCallback : boo::IApplicationCallback
|
||||||
m_seq->kill();
|
m_seq->kill();
|
||||||
}
|
}
|
||||||
m_seq = m_engine->seqPlay(m_groupId, setupId, nullptr);
|
m_seq = m_engine->seqPlay(m_groupId, setupId, nullptr);
|
||||||
m_seq->setVolume(m_volume);
|
m_engine->setVolume(m_volume);
|
||||||
|
|
||||||
if (m_arrData)
|
if (m_arrData)
|
||||||
m_seq->playSong(m_arrData->m_data.get(), false);
|
m_seq->playSong(m_arrData->m_data.get(), false);
|
||||||
|
@ -963,19 +963,13 @@ void EventCallback::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods,
|
||||||
case boo::ESpecialKey::Up:
|
case boo::ESpecialKey::Up:
|
||||||
if (m_app.m_volume < 1.f)
|
if (m_app.m_volume < 1.f)
|
||||||
m_app.m_volume = amuse::clamp(0.f, m_app.m_volume + 0.05f, 1.f);
|
m_app.m_volume = amuse::clamp(0.f, m_app.m_volume + 0.05f, 1.f);
|
||||||
if (m_app.m_vox)
|
m_app.m_engine->setVolume(m_app.m_volume);
|
||||||
m_app.m_vox->setVolume(m_app.m_volume);
|
|
||||||
if (m_app.m_seq)
|
|
||||||
m_app.m_seq->setVolume(m_app.m_volume);
|
|
||||||
m_app.m_updateDisp = true;
|
m_app.m_updateDisp = true;
|
||||||
break;
|
break;
|
||||||
case boo::ESpecialKey::Down:
|
case boo::ESpecialKey::Down:
|
||||||
if (m_app.m_volume > 0.f)
|
if (m_app.m_volume > 0.f)
|
||||||
m_app.m_volume = amuse::clamp(0.f, m_app.m_volume - 0.05f, 1.f);
|
m_app.m_volume = amuse::clamp(0.f, m_app.m_volume - 0.05f, 1.f);
|
||||||
if (m_app.m_vox)
|
m_app.m_engine->setVolume(m_app.m_volume);
|
||||||
m_app.m_vox->setVolume(m_app.m_volume);
|
|
||||||
if (m_app.m_seq)
|
|
||||||
m_app.m_seq->setVolume(m_app.m_volume);
|
|
||||||
m_app.m_updateDisp = true;
|
m_app.m_updateDisp = true;
|
||||||
break;
|
break;
|
||||||
case boo::ESpecialKey::Esc:
|
case boo::ESpecialKey::Esc:
|
||||||
|
|
|
@ -130,6 +130,7 @@ public:
|
||||||
void register5MsCallback(std::function<void(double)>&& callback);
|
void register5MsCallback(std::function<void(double)>&& callback);
|
||||||
AudioChannelSet getAvailableSet();
|
AudioChannelSet getAvailableSet();
|
||||||
void pumpAndMixVoices();
|
void pumpAndMixVoices();
|
||||||
|
void setVolume(float vol);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,9 @@ public:
|
||||||
return seqPlay(groupId, songId, arrData, m_defaultStudio);
|
return seqPlay(groupId, songId, arrData, m_defaultStudio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set total volume of engine */
|
||||||
|
void setVolume(float vol);
|
||||||
|
|
||||||
/** Find voice from VoiceId */
|
/** Find voice from VoiceId */
|
||||||
std::shared_ptr<Voice> findVoice(int vid);
|
std::shared_ptr<Voice> findVoice(int vid);
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ public:
|
||||||
/** Amuse flushes voice samples to the backend this way */
|
/** Amuse flushes voice samples to the backend this way */
|
||||||
virtual void pumpAndMixVoices() = 0;
|
virtual void pumpAndMixVoices() = 0;
|
||||||
|
|
||||||
|
/** Set volume of main mix out */
|
||||||
|
virtual void setVolume(float vol) = 0;
|
||||||
|
|
||||||
/** Amuse may request callbacks 200-updates-per-second virtually */
|
/** Amuse may request callbacks 200-updates-per-second virtually */
|
||||||
virtual void register5MsCallback(std::function<void(double dt)>&& callback) = 0;
|
virtual void register5MsCallback(std::function<void(double dt)>&& callback) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -288,4 +288,6 @@ void BooBackendVoiceAllocator::register5MsCallback(std::function<void(double)>&&
|
||||||
AudioChannelSet BooBackendVoiceAllocator::getAvailableSet() { return AudioChannelSet(m_booEngine.getAvailableSet()); }
|
AudioChannelSet BooBackendVoiceAllocator::getAvailableSet() { return AudioChannelSet(m_booEngine.getAvailableSet()); }
|
||||||
|
|
||||||
void BooBackendVoiceAllocator::pumpAndMixVoices() { m_booEngine.pumpAndMixVoices(); }
|
void BooBackendVoiceAllocator::pumpAndMixVoices() { m_booEngine.pumpAndMixVoices(); }
|
||||||
|
|
||||||
|
void BooBackendVoiceAllocator::setVolume(float vol) { m_booEngine.setVolume(vol); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,6 +384,14 @@ std::shared_ptr<Sequencer> Engine::seqPlay(int groupId, int songId, const unsign
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" const float VolumeLUT[];
|
||||||
|
|
||||||
|
/** Set total volume of engine */
|
||||||
|
void Engine::setVolume(float vol)
|
||||||
|
{
|
||||||
|
m_backend.setVolume(VolumeLUT[int(vol * 65536)]);
|
||||||
|
}
|
||||||
|
|
||||||
/** Find voice from VoiceId */
|
/** Find voice from VoiceId */
|
||||||
std::shared_ptr<Voice> Engine::findVoice(int vid)
|
std::shared_ptr<Voice> Engine::findVoice(int vid)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue