Browse Source

sampler: add a few sanity checks to sampler.

undefined
Sam Hocevar 9 years ago
parent
commit
0566c16b69
1 changed files with 17 additions and 7 deletions
  1. +17
    -7
      src/sampler.cpp

+ 17
- 7
src/sampler.cpp View File

@@ -47,25 +47,35 @@ int Sampler::Register(char const *path)

void Sampler::Deregister(int id)
{
data->samples.RemoveSlot(id - 1); /* ID 0 is for the empty sample */
if (id > 0)
data->samples.RemoveSlot(id - 1); /* ID 0 is for the empty sample */
}

void Sampler::PlaySample(int id)
{
Sample *sample = (Sample *)data->samples.GetEntity(id - 1);
sample->Play();
if (id > 0)
{
Sample *sample = (Sample *)data->samples.GetEntity(id - 1);
sample->Play();
}
}

void Sampler::LoopSample(int id)
{
Sample *sample = (Sample *)data->samples.GetEntity(id - 1);
sample->Loop();
if (id > 0)
{
Sample *sample = (Sample *)data->samples.GetEntity(id - 1);
sample->Loop();
}
}

void Sampler::StopSample(int id)
{
Sample *sample = (Sample *)data->samples.GetEntity(id - 1);
sample->Stop();
if (id > 0)
{
Sample *sample = (Sample *)data->samples.GetEntity(id - 1);
sample->Stop();
}
}

} /* namespace lol */


Loading…
Cancel
Save