12SoundFx::SoundVar::SoundVar(
const zenkit::ISoundEffect& sfx, Tempest::Sound &&snd)
13 :snd(std::move(snd)),vol(float(sfx.vol)/127.f),loop(sfx.loop){
16SoundFx::SoundVar::SoundVar(
const float vol, Tempest::Sound &&snd)
17 :snd(std::move(snd)),vol(vol/127.f){
25 std::string name = std::string(s);
27 i =
char(std::toupper(i));
33 if(name.rfind(
".WAV")==name.size()-4) {
36 Tempest::Log::d(
"unable to load sound fx: ",name);
else
37 inst.emplace_back(1.f,std::move(snd));
41 Tempest::Log::d(
"unable to load sound fx: ",name);
46 inst.emplace_back(127.f,std::move(snd));
49Tempest::SoundEffect
SoundFx::load(Tempest::SoundDevice &dev,
bool& loop)
const {
51 return Tempest::SoundEffect();
52 auto& var = inst[size_t(std::rand())%inst.size()];
53 Tempest::SoundEffect effect = dev.load(var.snd);
54 effect.setVolume(var.vol);
59void SoundFx::implLoad(std::string_view s) {
64 inst.emplace_back(sfx,std::move(snd));
68void SoundFx::loadVariants(std::string_view s) {
69 for(
int i=1;i<100;++i) {
75 inst.emplace_back(sfx,std::move(snd));
static const SoundDefinitions & sfx()
static Tempest::Sound loadSoundBuffer(std::string_view name)
Tempest::SoundEffect load(Tempest::SoundDevice &dev, bool &loop) const
SoundFx(std::string_view tagname)