diff --git a/.gitmodules b/.gitmodules index 61363a48fd1..000a2dffb91 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,6 @@ [submodule "plugins/FreeBoy/game-music-emu"] path = plugins/FreeBoy/game-music-emu url = https://bitbucket.org/mpyne/game-music-emu.git -[submodule "plugins/opl2/adplug"] - path = plugins/opl2/adplug +[submodule "plugins/OpulenZ/adplug"] + path = plugins/OpulenZ/adplug url = https://github.com/adplug/adplug.git diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 7d962406aee..399fb7279a3 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -60,7 +60,7 @@ IF("${PLUGIN_LIST}" STREQUAL "") MultitapEcho monstro nes - opl2 + OpulenZ organic FreeBoy patman diff --git a/plugins/opl2/CMakeLists.txt b/plugins/OpulenZ/CMakeLists.txt similarity index 84% rename from plugins/opl2/CMakeLists.txt rename to plugins/OpulenZ/CMakeLists.txt index 46ef740f965..f4efc374a02 100644 --- a/plugins/opl2/CMakeLists.txt +++ b/plugins/OpulenZ/CMakeLists.txt @@ -9,14 +9,14 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable") INCLUDE_DIRECTORIES(adplug/src) -BUILD_PLUGIN(OPL2 - opl2instrument.cpp - opl2instrument.h +BUILD_PLUGIN(opulenz + OpulenZ.cpp + OpulenZ.h adplug/src/opl.h adplug/src/fmopl.c adplug/src/fmopl.h adplug/src/temuopl.cpp adplug/src/temuopl.h - MOCFILES opl2instrument.h + MOCFILES OpulenZ.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png" ) diff --git a/plugins/opl2/opl2instrument.cpp b/plugins/OpulenZ/OpulenZ.cpp similarity index 93% rename from plugins/opl2/opl2instrument.cpp rename to plugins/OpulenZ/OpulenZ.cpp index 9546bf2cfc9..7913a4cbb32 100644 --- a/plugins/opl2/opl2instrument.cpp +++ b/plugins/OpulenZ/OpulenZ.cpp @@ -1,5 +1,5 @@ /* - * OPL2 FM synth + * OpulenZ.cpp - AdLib OPL2 FM synth based instrument * * Copyright (c) 2014 Raine M. Ekman * @@ -33,9 +33,7 @@ // - Portamento (needs mono mode?) // - Pre-bend/post-bend in poly mode could use portamento speed? -#include "opl2instrument.h" -#include "mididata.h" -#include "debug.h" +#include "OpulenZ.h" #include "Instrument.h" #include "Engine.h" #include "InstrumentPlayHandle.h" @@ -46,13 +44,14 @@ #include #include #include +#include +#include #include "opl.h" #include "temuopl.h" +#include "mididata.h" -#include #include "embed.h" -#include "math.h" #include "debug.h" #include "Knob.h" @@ -63,7 +62,7 @@ extern "C" { -Plugin::Descriptor PLUGIN_EXPORT OPL2_plugin_descriptor = +Plugin::Descriptor PLUGIN_EXPORT opulenz_plugin_descriptor = { STRINGIFY( PLUGIN_NAME ), "OpulenZ", @@ -80,20 +79,20 @@ Plugin::Descriptor PLUGIN_EXPORT OPL2_plugin_descriptor = // necessary for getting instance out of shared lib Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data ) { - return( new opl2instrument( static_cast( _data ) ) ); + return( new OpulenzInstrument( static_cast( _data ) ) ); } } // I'd much rather do without a mutex, but it looks like // the emulator code isn't really ready for threads -QMutex opl2instrument::emulatorMutex; +QMutex OpulenzInstrument::emulatorMutex; // Weird ordering of voice parameters const unsigned int adlib_opadd[OPL2_VOICES] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12}; -opl2instrument::opl2instrument( InstrumentTrack * _instrument_track ) : - Instrument( _instrument_track, &OPL2_plugin_descriptor ), +OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) : + Instrument( _instrument_track, &opulenz_plugin_descriptor ), m_patchModel( 0, 0, 127, this, tr( "Patch" ) ), op1_a_mdl(14.0, 0.0, 15.0, 1.0, this, tr( "Op 1 Attack" ) ), op1_d_mdl(14.0, 0.0, 15.0, 1.0, this, tr( "Op 1 Decay" ) ), @@ -217,7 +216,7 @@ opl2instrument::opl2instrument( InstrumentTrack * _instrument_track ) : Engine::mixer()->addPlayHandle( iph ); } -opl2instrument::~opl2instrument() { +OpulenzInstrument::~OpulenzInstrument() { delete theEmulator; Engine::mixer()->removePlayHandlesOfTypes( instrumentTrack(), PlayHandle::TypeNotePlayHandle @@ -226,7 +225,7 @@ opl2instrument::~opl2instrument() { } // Samplerate changes when choosing oversampling, so this is more or less mandatory -void opl2instrument::reloadEmulator() { +void OpulenzInstrument::reloadEmulator() { delete theEmulator; emulatorMutex.lock(); theEmulator = new CTemuopl(Engine::mixer()->processingSampleRate(), true, false); @@ -241,7 +240,7 @@ void opl2instrument::reloadEmulator() { } // This shall only be called from code protected by the holy Mutex! -void opl2instrument::setVoiceVelocity(int voice, int vel) { +void OpulenzInstrument::setVoiceVelocity(int voice, int vel) { int vel_adjusted; // Velocity calculation, some kind of approximation // Only calculate for operator 1 if in adding mode, don't want to change timbre @@ -263,7 +262,7 @@ void opl2instrument::setVoiceVelocity(int voice, int vel) { } // Pop least recently used voice -int opl2instrument::popVoice() { +int OpulenzInstrument::popVoice() { int tmp = voiceLRU[0]; for( int i=0; i0; --i) { @@ -292,7 +291,7 @@ int opl2instrument::pushVoice(int v) { return i; } -bool opl2instrument::handleMidiEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset ) +bool OpulenzInstrument::handleMidiEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset ) { emulatorMutex.lock(); int key, vel, voice, tmp_pb; @@ -386,18 +385,18 @@ bool opl2instrument::handleMidiEvent( const MidiEvent& event, const MidiTime& ti return true; } -QString opl2instrument::nodeName() const +QString OpulenzInstrument::nodeName() const { - return( OPL2_plugin_descriptor.name ); + return( opulenz_plugin_descriptor.name ); } -PluginView * opl2instrument::instantiateView( QWidget * _parent ) +PluginView * OpulenzInstrument::instantiateView( QWidget * _parent ) { - return( new opl2instrumentView( this, _parent ) ); + return( new OpulenzInstrumentView( this, _parent ) ); } -void opl2instrument::play( sampleFrame * _working_buffer ) +void OpulenzInstrument::play( sampleFrame * _working_buffer ) { emulatorMutex.lock(); theEmulator->update(renderbuffer, frameCount); @@ -418,7 +417,7 @@ void opl2instrument::play( sampleFrame * _working_buffer ) } -void opl2instrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) +void OpulenzInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) { op1_a_mdl.saveSettings( _doc, _this, "op1_a" ); op1_d_mdl.saveSettings( _doc, _this, "op1_d" ); @@ -452,7 +451,7 @@ void opl2instrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) trem_depth_mdl.saveSettings( _doc, _this, "trem_depth" ); } -void opl2instrument::loadSettings( const QDomElement & _this ) +void OpulenzInstrument::loadSettings( const QDomElement & _this ) { op1_a_mdl.loadSettings( _this, "op1_a" ); op1_d_mdl.loadSettings( _this, "op1_d" ); @@ -488,7 +487,7 @@ void opl2instrument::loadSettings( const QDomElement & _this ) } // Load a patch into the emulator -void opl2instrument::loadPatch(const unsigned char inst[14]) { +void OpulenzInstrument::loadPatch(const unsigned char inst[14]) { emulatorMutex.lock(); for(int v=0; vwrite(0x20+adlib_opadd[v],inst[0]); // op1 AM/VIB/EG/KSR/Multiplier @@ -506,7 +505,7 @@ void opl2instrument::loadPatch(const unsigned char inst[14]) { emulatorMutex.unlock(); } -void opl2instrument::tuneEqual(int center, float Hz) { +void OpulenzInstrument::tuneEqual(int center, float Hz) { float tmp; for(int n=0; n<128; ++n) { tmp = Hz*pow( 2.0, ( n - center ) * ( 1.0 / 12.0 ) + pitchbend * ( 1.0 / 1200.0 ) ); @@ -515,7 +514,7 @@ void opl2instrument::tuneEqual(int center, float Hz) { } // Find suitable F number in lowest possible block -int opl2instrument::Hz2fnum(float Hz) { +int OpulenzInstrument::Hz2fnum(float Hz) { for(int block=0; block<8; ++block) { unsigned int fnum = Hz * pow( 2.0, 20.0 - (double)block ) * ( 1.0 / 49716.0 ); if(fnum<1023) { @@ -526,13 +525,13 @@ int opl2instrument::Hz2fnum(float Hz) { } // Load one of the default patches -void opl2instrument::loadGMPatch() { +void OpulenzInstrument::loadGMPatch() { unsigned char *inst = midi_fm_instruments[m_patchModel.value()]; loadPatch(inst); } // Update patch from the models to the chip emulation -void opl2instrument::updatePatch() { +void OpulenzInstrument::updatePatch() { unsigned char inst[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; inst[0] = ( op1_trem_mdl.value() ? 128 : 0 ) + ( op1_vib_mdl.value() ? 64 : 0 ) + @@ -586,7 +585,7 @@ void opl2instrument::updatePatch() { } // Load an SBI file into the knob models -void opl2instrument::loadFile( const QString& file ) { +void OpulenzInstrument::loadFile( const QString& file ) { // http://cd.textfiles.com/soundsensations/SYNTH/SBINS/ // http://cd.textfiles.com/soundsensations/SYNTH/SBI1198/1198SBI.ZIP if( !file.isEmpty() && QFileInfo( file ).exists() ) @@ -678,7 +677,7 @@ void opl2instrument::loadFile( const QString& file ) { -opl2instrumentView::opl2instrumentView( Instrument * _instrument, +OpulenzInstrumentView::OpulenzInstrumentView( Instrument * _instrument, QWidget * _parent ) : InstrumentView( _instrument, _parent ) { @@ -694,8 +693,8 @@ opl2instrumentView::opl2instrumentView( Instrument * _instrument, #define BUTTON_GEN(buttname, tooltip, xpos, ypos) \ buttname = new PixmapButton( this, NULL );\ - buttname->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "opl2_led_on" ) );\ - buttname->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "opl2_led_off" ) );\ + buttname->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "led_on" ) );\ + buttname->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "led_off" ) );\ buttname->setCheckable( true );\ ToolTip::add( buttname, tr( tooltip ) );\ buttname->move( xpos, ypos ); @@ -760,13 +759,13 @@ opl2instrumentView::opl2instrumentView( Instrument * _instrument, "artwork" ) ); setPalette( pal ); } -opl2instrumentView::~opl2instrumentView() { +OpulenzInstrumentView::~OpulenzInstrumentView() { // Knobs are QWidgets and our children, so they're // destroyed automagically } // Returns text for time knob formatted nicely -inline QString opl2instrumentView::knobHintHelper(float n) { +inline QString OpulenzInstrumentView::knobHintHelper(float n) { if(n>1000) { return QString::number(n/1000, 'f', 0)+ " s"; } else if(n>10) { @@ -776,7 +775,7 @@ inline QString opl2instrumentView::knobHintHelper(float n) { } } -void opl2instrumentView::updateKnobHints() +void OpulenzInstrumentView::updateKnobHints() { // Envelope times in ms: t[0] = 0, t[n] = ( 1<(); + OpulenzInstrument * m = castModel(); op1_a_kn->setHintText( tr( "Attack" ), @@ -817,9 +816,9 @@ void opl2instrumentView::updateKnobHints() " (" + QString::number(fmultipliers[(int)m->op2_mul_mdl.value()]) + " semitones)"); } -void opl2instrumentView::modelChanged() +void OpulenzInstrumentView::modelChanged() { - opl2instrument * m = castModel(); + OpulenzInstrument * m = castModel(); // m_patch->setModel( &m->m_patchModel ); op1_a_kn->setModel( &m->op1_a_mdl ); diff --git a/plugins/opl2/opl2instrument.h b/plugins/OpulenZ/OpulenZ.h similarity index 92% rename from plugins/opl2/opl2instrument.h rename to plugins/OpulenZ/OpulenZ.h index f60ab32c5a7..e69c278efc9 100644 --- a/plugins/opl2/opl2instrument.h +++ b/plugins/OpulenZ/OpulenZ.h @@ -1,5 +1,5 @@ /* - * OPL2 FM synth + * OpulenZ.h - AdLib OPL2 FM synth based instrument * * Copyright (c) 2013 Raine M. Ekman * @@ -22,8 +22,8 @@ * */ -#ifndef _OPL2_H -#define _OPL2_H +#ifndef OPULENZ_H +#define OPULENZ_H #include "Instrument.h" #include "InstrumentView.h" @@ -41,12 +41,12 @@ // The "normal" range for LMMS pitchbends #define DEFAULT_BEND_CENTS 100 -class opl2instrument : public Instrument +class OpulenzInstrument : public Instrument { Q_OBJECT public: - opl2instrument( InstrumentTrack * _instrument_track ); - virtual ~opl2instrument(); + OpulenzInstrument( InstrumentTrack * _instrument_track ); + virtual ~OpulenzInstrument(); virtual QString nodeName() const; virtual PluginView * instantiateView( QWidget * _parent ); @@ -142,12 +142,12 @@ private slots: -class opl2instrumentView : public InstrumentView +class OpulenzInstrumentView : public InstrumentView { Q_OBJECT public: - opl2instrumentView( Instrument * _instrument, QWidget * _parent ); - virtual ~opl2instrumentView(); + OpulenzInstrumentView( Instrument * _instrument, QWidget * _parent ); + virtual ~OpulenzInstrumentView(); LcdSpinBox *m_patch; void modelChanged(); diff --git a/plugins/opl2/adplug b/plugins/OpulenZ/adplug similarity index 100% rename from plugins/opl2/adplug rename to plugins/OpulenZ/adplug diff --git a/plugins/opl2/artwork.png b/plugins/OpulenZ/artwork.png similarity index 100% rename from plugins/opl2/artwork.png rename to plugins/OpulenZ/artwork.png diff --git a/plugins/opl2/opl2_led_off.png b/plugins/OpulenZ/led_off.png similarity index 100% rename from plugins/opl2/opl2_led_off.png rename to plugins/OpulenZ/led_off.png diff --git a/plugins/opl2/opl2_led_on.png b/plugins/OpulenZ/led_on.png similarity index 100% rename from plugins/opl2/opl2_led_on.png rename to plugins/OpulenZ/led_on.png diff --git a/plugins/opl2/logo.png b/plugins/OpulenZ/logo.png similarity index 100% rename from plugins/opl2/logo.png rename to plugins/OpulenZ/logo.png diff --git a/plugins/opl2/wave1_off.png b/plugins/OpulenZ/wave1_off.png similarity index 100% rename from plugins/opl2/wave1_off.png rename to plugins/OpulenZ/wave1_off.png diff --git a/plugins/opl2/wave1_on.png b/plugins/OpulenZ/wave1_on.png similarity index 100% rename from plugins/opl2/wave1_on.png rename to plugins/OpulenZ/wave1_on.png diff --git a/plugins/opl2/wave2_off.png b/plugins/OpulenZ/wave2_off.png similarity index 100% rename from plugins/opl2/wave2_off.png rename to plugins/OpulenZ/wave2_off.png diff --git a/plugins/opl2/wave2_on.png b/plugins/OpulenZ/wave2_on.png similarity index 100% rename from plugins/opl2/wave2_on.png rename to plugins/OpulenZ/wave2_on.png diff --git a/plugins/opl2/wave3_off.png b/plugins/OpulenZ/wave3_off.png similarity index 100% rename from plugins/opl2/wave3_off.png rename to plugins/OpulenZ/wave3_off.png diff --git a/plugins/opl2/wave3_on.png b/plugins/OpulenZ/wave3_on.png similarity index 100% rename from plugins/opl2/wave3_on.png rename to plugins/OpulenZ/wave3_on.png diff --git a/plugins/opl2/wave4_off.png b/plugins/OpulenZ/wave4_off.png similarity index 100% rename from plugins/opl2/wave4_off.png rename to plugins/OpulenZ/wave4_off.png diff --git a/plugins/opl2/wave4_on.png b/plugins/OpulenZ/wave4_on.png similarity index 100% rename from plugins/opl2/wave4_on.png rename to plugins/OpulenZ/wave4_on.png diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 9a1d150642e..cd73be05dc4 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -984,6 +984,16 @@ void DataFile::upgrade_1_3_0() child.setTagName( "freeboy" ); } } + else if( el.attribute( "name" ) == "OPL2" ) + { + el.setAttribute( "name", "opulenz" ); + QDomNodeList children = el.elementsByTagName( "OPL2" ); + for( int j = 0; !children.item( j ).isNull(); ++j ) + { + QDomElement child = children.item( j ).toElement(); + child.setTagName( "opulenz" ); + } + } } }