From 5816a2ae5d10c962a006029398999e96e6bb15ee Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Sun, 26 Jan 2014 13:29:52 +0800 Subject: [PATCH 1/3] Fixed OpulenZ segfault bug when it is dropped on another instrument. --- plugins/opl2/opl2instrument.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/opl2/opl2instrument.cpp b/plugins/opl2/opl2instrument.cpp index 2288e0d32..9b7f188a5 100644 --- a/plugins/opl2/opl2instrument.cpp +++ b/plugins/opl2/opl2instrument.cpp @@ -148,6 +148,13 @@ opl2instrument::opl2instrument( InstrumentTrack * _instrument_track ) : emulatorMutex.lock(); theEmulator = new CTemuopl(engine::mixer()->processingSampleRate(), true, false); theEmulator->init(); + + //Initialize voice values + for(int i=0; i<9; ++i) { + voiceNote[i] = OPL2_VOICE_FREE; + voiceLRU[i] = i; + } + // Enable waveform selection theEmulator->write(0x01,0x20); emulatorMutex.unlock(); @@ -162,11 +169,6 @@ opl2instrument::opl2instrument( InstrumentTrack * _instrument_track ) : pitchbend = 0; tuneEqual(69, 440); - for(int i=1; i<9; ++i) { - voiceNote[i] = OPL2_VOICE_FREE; - voiceLRU[i] = i; - } - connect( engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( reloadEmulator() ) ); // Connect knobs From b15942d12021a01d7b549a736ae00a660e5a097b Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Sun, 26 Jan 2014 14:19:33 +0800 Subject: [PATCH 2/3] Amended initialize code --- plugins/opl2/opl2instrument.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/opl2/opl2instrument.cpp b/plugins/opl2/opl2instrument.cpp index 9b7f188a5..50ea98b0a 100644 --- a/plugins/opl2/opl2instrument.cpp +++ b/plugins/opl2/opl2instrument.cpp @@ -150,7 +150,9 @@ opl2instrument::opl2instrument( InstrumentTrack * _instrument_track ) : theEmulator->init(); //Initialize voice values - for(int i=0; i<9; ++i) { + voiceNote[0] = 0; + voiceLRU[0] = 0; + for(int i=1; i<9; ++i) { voiceNote[i] = OPL2_VOICE_FREE; voiceLRU[i] = i; } From b502ae9da484ffa2f685f45f08c87400bf25c9d6 Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Sun, 26 Jan 2014 14:23:32 +0800 Subject: [PATCH 3/3] Changed the placement of code --- plugins/opl2/opl2instrument.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/opl2/opl2instrument.cpp b/plugins/opl2/opl2instrument.cpp index 50ea98b0a..3c8b425b0 100644 --- a/plugins/opl2/opl2instrument.cpp +++ b/plugins/opl2/opl2instrument.cpp @@ -148,6 +148,9 @@ opl2instrument::opl2instrument( InstrumentTrack * _instrument_track ) : emulatorMutex.lock(); theEmulator = new CTemuopl(engine::mixer()->processingSampleRate(), true, false); theEmulator->init(); + // Enable waveform selection + theEmulator->write(0x01,0x20); + emulatorMutex.unlock(); //Initialize voice values voiceNote[0] = 0; @@ -157,10 +160,6 @@ opl2instrument::opl2instrument( InstrumentTrack * _instrument_track ) : voiceLRU[i] = i; } - // Enable waveform selection - theEmulator->write(0x01,0x20); - emulatorMutex.unlock(); - updatePatch(); // Can the buffer size change suddenly? I bet that would break lots of stuff