diff --git a/src/sampler.cpp b/src/sampler.cpp index d1efebc2..f3380d85 100644 --- a/src/sampler.cpp +++ b/src/sampler.cpp @@ -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 */