mirror of https://github.com/AxioDL/amuse.git
Integrate -10dB volume curve
This commit is contained in:
parent
64ed5e2ea5
commit
e2ee8c550f
|
@ -10,8 +10,6 @@
|
|||
#include <thread>
|
||||
#include <map>
|
||||
|
||||
#define VOL_FACTOR 0.25
|
||||
|
||||
static logvisor::Module Log("amuseplay");
|
||||
|
||||
static amuse::IntrusiveAudioGroupData LoadFromArgs(int argc, const boo::SystemChar** argv,
|
||||
|
@ -210,7 +208,7 @@ struct AppCallback : boo::IApplicationCallback
|
|||
m_seq->kill();
|
||||
}
|
||||
m_seq = m_engine->seqPlay(m_groupId, setupId, nullptr);
|
||||
m_seq->setVolume(m_volume * VOL_FACTOR);
|
||||
m_seq->setVolume(m_volume);
|
||||
|
||||
if (m_arrData)
|
||||
m_seq->playSong(m_arrData.get(), false);
|
||||
|
@ -218,8 +216,7 @@ struct AppCallback : boo::IApplicationCallback
|
|||
UpdateSongDisplay();
|
||||
}
|
||||
|
||||
void SongLoop(const amuse::AudioGroup& group,
|
||||
const amuse::SongGroupIndex& index)
|
||||
void SongLoop(const amuse::SongGroupIndex& index)
|
||||
{
|
||||
printf("░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░\n"
|
||||
"░░░ ████ ████ ┃ ████ ████ ████ ┃ ████ ████ ░░░\n"
|
||||
|
@ -344,8 +341,7 @@ struct AppCallback : boo::IApplicationCallback
|
|||
UpdateSFXDisplay();
|
||||
}
|
||||
|
||||
void SFXLoop(const amuse::AudioGroup& group,
|
||||
const amuse::SFXGroupIndex& index)
|
||||
void SFXLoop(const amuse::SFXGroupIndex& index)
|
||||
{
|
||||
printf("<space>: keyon/keyoff, <left/right>: cycle SFX, <up/down>: volume, <Q>: quit\n");
|
||||
|
||||
|
@ -775,9 +771,9 @@ struct AppCallback : boo::IApplicationCallback
|
|||
|
||||
/* Enter playback loop */
|
||||
if (m_sfxGroup)
|
||||
SFXLoop(*group, *proj.getSFXGroupIndex(m_groupId));
|
||||
SFXLoop(*proj.getSFXGroupIndex(m_groupId));
|
||||
else
|
||||
SongLoop(*group, *proj.getSongGroupIndex(m_groupId));
|
||||
SongLoop(*proj.getSongGroupIndex(m_groupId));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -818,18 +814,18 @@ void EventCallback::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods,
|
|||
if (m_app.m_volume < 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_vox->setVolume(m_app.m_volume * VOL_FACTOR);
|
||||
m_app.m_vox->setVolume(m_app.m_volume);
|
||||
if (m_app.m_seq)
|
||||
m_app.m_seq->setVolume(m_app.m_volume * VOL_FACTOR);
|
||||
m_app.m_seq->setVolume(m_app.m_volume);
|
||||
m_app.m_updateDisp = true;
|
||||
break;
|
||||
case boo::ESpecialKey::Down:
|
||||
if (m_app.m_volume > 0.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_vox->setVolume(m_app.m_volume * VOL_FACTOR);
|
||||
m_app.m_vox->setVolume(m_app.m_volume);
|
||||
if (m_app.m_seq)
|
||||
m_app.m_seq->setVolume(m_app.m_volume * VOL_FACTOR);
|
||||
m_app.m_seq->setVolume(m_app.m_volume);
|
||||
m_app.m_updateDisp = true;
|
||||
break;
|
||||
default: break;
|
||||
|
@ -887,7 +883,7 @@ int main(int argc, const boo::SystemChar** argv)
|
|||
logvisor::RegisterConsoleLogger();
|
||||
AppCallback app(argc, argv);
|
||||
int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto,
|
||||
app, _S("amuseplay"), _S("Amuse Player"), argc, argv);
|
||||
app, _S("amuseplay"), _S("Amuse Player"), argc, argv, false);
|
||||
printf("IM DYING!!\n");
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -114,12 +114,23 @@ BooBackendMIDIReader::BooBackendMIDIReader(Engine& engine, const char* name)
|
|||
{
|
||||
BooBackendVoiceAllocator& voxAlloc = static_cast<BooBackendVoiceAllocator&>(engine.getBackend());
|
||||
if (!name)
|
||||
{
|
||||
auto devices = voxAlloc.m_booEngine.enumerateMIDIDevices();
|
||||
for (const auto& dev : devices)
|
||||
{
|
||||
m_midiIn = voxAlloc.m_booEngine.newRealMIDIIn(dev.first.c_str(),
|
||||
std::bind(&BooBackendMIDIReader::_MIDIReceive, this,
|
||||
std::placeholders::_1));
|
||||
if (m_midiIn)
|
||||
return;
|
||||
}
|
||||
m_midiIn = voxAlloc.m_booEngine.newVirtualMIDIIn(std::bind(&BooBackendMIDIReader::_MIDIReceive, this,
|
||||
std::placeholders::_1));
|
||||
std::placeholders::_1));
|
||||
}
|
||||
else
|
||||
m_midiIn = voxAlloc.m_booEngine.newRealMIDIIn(name,
|
||||
std::bind(&BooBackendMIDIReader::_MIDIReceive, this,
|
||||
std::placeholders::_1));
|
||||
std::bind(&BooBackendMIDIReader::_MIDIReceive, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
void BooBackendMIDIReader::_MIDIReceive(std::vector<uint8_t>&& bytes)
|
||||
|
@ -170,7 +181,7 @@ void BooBackendMIDIReader::noteOn(uint8_t chan, uint8_t key, uint8_t velocity)
|
|||
seq->keyOn(chan, key, velocity);
|
||||
}
|
||||
|
||||
void BooBackendMIDIReader::notePressure(uint8_t chan, uint8_t key, uint8_t pressure)
|
||||
void BooBackendMIDIReader::notePressure(uint8_t /*chan*/, uint8_t /*key*/, uint8_t /*pressure*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -186,7 +197,7 @@ void BooBackendMIDIReader::programChange(uint8_t chan, uint8_t program)
|
|||
seq->setChanProgram(chan, program);
|
||||
}
|
||||
|
||||
void BooBackendMIDIReader::channelPressure(uint8_t chan, uint8_t pressure)
|
||||
void BooBackendMIDIReader::channelPressure(uint8_t /*chan*/, uint8_t /*pressure*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -203,11 +214,11 @@ void BooBackendMIDIReader::allSoundOff(uint8_t chan)
|
|||
seq->allOff(chan, true);
|
||||
}
|
||||
|
||||
void BooBackendMIDIReader::resetAllControllers(uint8_t chan)
|
||||
void BooBackendMIDIReader::resetAllControllers(uint8_t /*chan*/)
|
||||
{
|
||||
}
|
||||
|
||||
void BooBackendMIDIReader::localControl(uint8_t chan, bool on)
|
||||
void BooBackendMIDIReader::localControl(uint8_t /*chan*/, bool /*on*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -217,28 +228,28 @@ void BooBackendMIDIReader::allNotesOff(uint8_t chan)
|
|||
seq->allOff(chan, false);
|
||||
}
|
||||
|
||||
void BooBackendMIDIReader::omniMode(uint8_t chan, bool on)
|
||||
void BooBackendMIDIReader::omniMode(uint8_t /*chan*/, bool /*on*/)
|
||||
{
|
||||
}
|
||||
|
||||
void BooBackendMIDIReader::polyMode(uint8_t chan, bool on)
|
||||
void BooBackendMIDIReader::polyMode(uint8_t /*chan*/, bool /*on*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BooBackendMIDIReader::sysex(const void* data, size_t len)
|
||||
void BooBackendMIDIReader::sysex(const void* /*data*/, size_t /*len*/)
|
||||
{
|
||||
}
|
||||
|
||||
void BooBackendMIDIReader::timeCodeQuarterFrame(uint8_t message, uint8_t value)
|
||||
void BooBackendMIDIReader::timeCodeQuarterFrame(uint8_t /*message*/, uint8_t /*value*/)
|
||||
{
|
||||
}
|
||||
|
||||
void BooBackendMIDIReader::songPositionPointer(uint16_t pointer)
|
||||
void BooBackendMIDIReader::songPositionPointer(uint16_t /*pointer*/)
|
||||
{
|
||||
}
|
||||
|
||||
void BooBackendMIDIReader::songSelect(uint8_t song)
|
||||
void BooBackendMIDIReader::songSelect(uint8_t /*song*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -201,6 +201,13 @@ std::list<std::shared_ptr<Voice>>::iterator Voice::_destroyVoice(Voice* voice)
|
|||
return m_childVoices.erase(voice->m_engineIt);
|
||||
}
|
||||
|
||||
static void ApplyVolume(float vol, int16_t& samp)
|
||||
{
|
||||
/* -10dB to 0dB mapped to full volume range */
|
||||
float factor = (std::pow(10.f, vol - 1.f) - 0.1f) * (1.f / 0.9f);
|
||||
samp *= factor;
|
||||
}
|
||||
|
||||
bool Voice::_advanceSample(int16_t& samp, int32_t& newPitch)
|
||||
{
|
||||
double dt = 1.0 / m_sampleRate;
|
||||
|
@ -251,8 +258,8 @@ bool Voice::_advanceSample(int16_t& samp, int32_t& newPitch)
|
|||
}
|
||||
}
|
||||
|
||||
/* Multiply sample with total volume */
|
||||
samp = ClampFull<int16_t>(samp * totalVol);
|
||||
/* Apple total volume to sample using decibel scale */
|
||||
ApplyVolume(ClampFull<float>(totalVol), samp);
|
||||
|
||||
/* Process active pan-sweep */
|
||||
if (m_panningTime >= 0.f)
|
||||
|
|
Loading…
Reference in New Issue