From 5e4cb10f72ef69d73fbd2c1bc42465c9111a4c41 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 12 Jan 2012 16:31:36 +0100 Subject: Fix memory leak when unloading a drumkit. --- src/instrument.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/instrument.cc') diff --git a/src/instrument.cc b/src/instrument.cc index 8cfaec7..b10d990 100644 --- a/src/instrument.cc +++ b/src/instrument.cc @@ -34,12 +34,28 @@ Instrument::Instrument() { + printf("new Instrument %p\n", this); mod = 1.0; lastpos = 0; } +Instrument::~Instrument() +{ + printf("delete Instrument %p\n", this); + std::vector::iterator i = audiofiles.begin(); + while(i != audiofiles.end()) { + delete *i; + i++; + } +} + Sample *Instrument::sample(level_t level, size_t pos) { + if(Conf::enable_velocity_modifier == false) { + mod = 1.0; + lastpos = 0; + } + if(Conf::enable_velocity_randomiser) { float r = (float)rand() / (float)RAND_MAX; // random number: [0;1] r -= 0.5; // random number [-0.5;0.5] -- cgit v1.2.3