From f63c4b35ef69a5ab31edcd064157f997b300cf9f Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 9 Nov 2017 07:23:16 +0000 Subject: [PATCH] Revert "Fixes for dynamic memory allocation." Seem to be buggy... This reverts commit 3a9568fa1ac2a1eb5bf565098c94d29e7289dd4b. --- src/dexed.cpp | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/dexed.cpp b/src/dexed.cpp index 90bcf15..899f3ce 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -49,27 +49,27 @@ Dexed::Dexed(double rate) : lvtk::Synth(p_n_ports, p_midi_in) Env::init_sr(rate); fx.init(rate); - engineMkI=new EngineMkI; - if(!engineMkI) + if((engineMkI=new EngineMkI)==NULL) { TRACE("Cannot not create engine EngineMkI"); + exit(400); } - engineOpl=new EngineOpl; - if(!engineOpl) + if((engineOpl=new EngineOpl)==NULL) { TRACE("Cannot not create engine EngineOpl"); + exit(401); } - engineMsfa=new FmCore; - if(!engineMsfa) + if((engineMsfa=new FmCore)==NULL) { TRACE("Cannot create engine FmCore"); + exit(402); } for(i=0; i(p_n_ports, p_midi_in) bufsize_=256; - outbuf_=new float[bufsize_]; - if(outbuf_) + if((outbuf_=new float[bufsize_])==NULL) { TRACE("Cannot create outbuf_ buffer"); + exit(404); } lfo.reset(data+137); + setMonoMode(false); sustain = false; @@ -126,22 +127,23 @@ Dexed::~Dexed() { TRACE("Hi"); - if(outbuf_) + if(outbuf_!=NULL) delete [] outbuf_; - for(uint8_t note = 0; note < MAX_ACTIVE_NOTES; ++note) + currentNote = -1; + + for (uint8_t note = 0; note < MAX_ACTIVE_NOTES; ++note) { - if(voices[note].dx7_note) + if ( voices[note].dx7_note != NULL ) + { delete voices[note].dx7_note; + voices[note].dx7_note = NULL; + } + voices[note].keydown = false; + voices[note].sustained = false; + voices[note].live = false; } - if(engineMkI) - delete(engineMkI); - if(engineOpl) - delete(engineOpl); - if(engineMsfa) - delete(engineMsfa); - TRACE("Bye"); TRACE("--------------------------------------------------------------------------------"); }