diff --git a/ChangeLog b/ChangeLog index 6a43c9fb8..432f51235 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2006-09-08 Danny McRae + * configure.in: + * plugins/Makefile.am: + * plugins/stk/Makefile.am: + began work on supporting STK instruments + + * plugins/stk/mallets/Makefile.am: + * plugins/stk/mallets/artwork.png: + * plugins/stk/mallets/logo.png: + * plugins/stk/mallets/mallets.h: + * plugins/stk/mallets/mallets.cpp: + added mallets instrument + + * include/config_mgr.h: + * src/core/config_mgr.cpp: + * include/setup_dialog.h: + * src/core/setup_dialog.cpp: + added STK rawwave to directory selector + 2006-09-03 Thomas Girard * src/core/file_browser.cpp: diff --git a/configure.in b/configure.in index 3b8392b2b..a39605346 100644 --- a/configure.in +++ b/configure.in @@ -214,6 +214,24 @@ if test ! -z "$HAVE_LADSPA_H" ; then fi #AM_CONDITIONAL(HAVE_LADSPA_H, test ! -z "$HAVE_LADSPA_H") + +# check for STK +AC_ARG_WITH(stk, + AS_HELP_STRING([--with-stk], [enable support for STK plugins]), [ with_stk=yes ], [ with_stk=no ]) +AH_TEMPLATE(HAVE_STK_H, [Define to 1 if you have the header file.]) +#if test "x$with_stk" = "xyes" ; then +# AC_CHECK_HEADER(stk/Stk.h, HAVE_STK_H="true") +# AC_CHECK_LIB([stk], [], HAVE_STK="true", HAVE_STK_H="") +#fi +if test "x$with_stk" = "xyes" ; then + HAVE_STK_H="true" +fi +if test ! -z "$HAVE_STK_H" ; then + AC_DEFINE(HAVE_STK_H) +fi +AM_CONDITIONAL(STK_SUPPORT, test ! -z "$HAVE_STK_H") + + # check for vorbis-lib AC_ARG_WITH(vorbis, AS_HELP_STRING([--without-vorbis], @@ -484,6 +502,8 @@ AC_CONFIG_FILES([Makefile plugins/midi_import/Makefile plugins/organic/Makefile plugins/plucked_string_synth/Makefile + plugins/stk/Makefile + plugins/stk/mallets/Makefile plugins/triple_oscillator/Makefile plugins/vestige/Makefile plugins/vibed/Makefile diff --git a/include/config_mgr.h b/include/config_mgr.h index 9ba0ea34f..5c5f96221 100644 --- a/include/config_mgr.h +++ b/include/config_mgr.h @@ -166,6 +166,13 @@ public: } #endif +#ifdef HAVE_STK_H + const QString & stkDir( void ) const + { + return( m_stkDir ); + } +#endif + const QString & value( const QString & _class, const QString & _attribute ) const; void setValue( const QString & _class, const QString & _attribute, @@ -181,6 +188,7 @@ public slots: void setArtworkDir( const QString & _ad ); void setFLDir( const QString & _fd ); void setLADSPADir( const QString & _fd ); + void setSTKDir( const QString & _fd ); protected slots: @@ -222,6 +230,9 @@ private: #ifdef LADSPA_SUPPORT QString m_ladDir; #endif +#ifdef HAVE_STK_H + QString m_stkDir; +#endif typedef vvector > stringPairVector; typedef QMap settingsMap; diff --git a/include/setup_dialog.h b/include/setup_dialog.h index 234bdd2d4..362db7c4e 100644 --- a/include/setup_dialog.h +++ b/include/setup_dialog.h @@ -85,7 +85,8 @@ private slots: void setArtworkDir( const QString & _ad ); void setFLDir( const QString & _fd ); void setLADSPADir( const QString & _fd ); - + void setSTKDir( const QString & _fd ); + // audio settings widget void audioInterfaceChanged( const QString & _driver ); void displayAudioHelp( void ); @@ -107,7 +108,7 @@ private slots: void openArtworkDir( void ); void openFLDir( void ); void openLADSPADir( void ); - + void openSTKDir( void ); void toggleDisableChActInd( bool _disabled ); void toggleManualChPiano( bool _enabled ); @@ -135,6 +136,9 @@ private: #ifdef LADSPA_SUPPORT QLineEdit * m_ladLineEdit; #endif +#ifdef HAVE_STK_H + QLineEdit * m_stkLineEdit; +#endif QString m_workingDir; QString m_vstDir; @@ -143,6 +147,9 @@ private: #ifdef LADSPA_SUPPORT QString m_ladDir; #endif +#ifdef HAVE_STK_H + QString m_stkDir; +#endif bool m_disableChActInd; bool m_manualChPiano; diff --git a/plugins/Makefile.am b/plugins/Makefile.am index deaf18444..d0ceedd34 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -2,5 +2,9 @@ if VST_SUPPORT VESTIGE_SUBDIR=vestige endif -SUBDIRS = audio_file_processor bit_invader flp_import midi_import organic plucked_string_synth triple_oscillator $(VESTIGE_SUBDIR) vibed +if STK_SUPPORT +STK_DIR=stk +endif + +SUBDIRS = audio_file_processor bit_invader flp_import midi_import organic plucked_string_synth $(STK_DIR) triple_oscillator $(VESTIGE_SUBDIR) vibed diff --git a/plugins/stk/Makefile.am b/plugins/stk/Makefile.am new file mode 100644 index 000000000..c615d3acf --- /dev/null +++ b/plugins/stk/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = mallets \ No newline at end of file diff --git a/plugins/stk/mallets/Makefile.am b/plugins/stk/mallets/Makefile.am new file mode 100644 index 000000000..03b386a60 --- /dev/null +++ b/plugins/stk/mallets/Makefile.am @@ -0,0 +1,34 @@ +AUTOMAKE_OPTIONS = foreign 1.4 + + +INCLUDES = -I/usr/include/stk -I$(top_srcdir)/include -I$(top_srcdir)/src/lib -I. + + +AM_CXXFLAGS := $(AM_CXXFLAGS) $(QT_CXXFLAGS) -DPLUGIN_NAME="malletsstk" + + +%.moc: ./%.h + $(MOC) -o $@ $< + + +MOC_FILES = ./mallets.moc + +BUILT_SOURCES = $(MOC_FILES) ./embedded_resources.h +EMBEDDED_RESOURCES = $(wildcard *png) + +./embedded_resources.h: $(EMBEDDED_RESOURCES) + $(top_builddir)/buildtools/bin2res $(EMBEDDED_RESOURCES) > $@ + +EXTRA_DIST = $(EMBEDDED_RESOURCES) + + +CLEANFILES = $(MOC_FILES) ./embedded_resources.h + + + +pkglib_LTLIBRARIES= libmalletsstk.la + +libmalletsstk_la_SOURCES = mallets.cpp mallets.h +libmalletsstk_la_LDFLAGS = -L/usr/lib -lstk + +$(libmalletsstk_la_SOURCES): ./embedded_resources.h diff --git a/plugins/stk/mallets/artwork.png b/plugins/stk/mallets/artwork.png new file mode 100644 index 000000000..ed24a16b1 Binary files /dev/null and b/plugins/stk/mallets/artwork.png differ diff --git a/plugins/stk/mallets/logo.png b/plugins/stk/mallets/logo.png new file mode 100644 index 000000000..c9a8a0451 Binary files /dev/null and b/plugins/stk/mallets/logo.png differ diff --git a/plugins/stk/mallets/mallets.cpp b/plugins/stk/mallets/mallets.cpp new file mode 100644 index 000000000..1bd258f96 --- /dev/null +++ b/plugins/stk/mallets/mallets.cpp @@ -0,0 +1,658 @@ +/* + * mallets.h - tuned instruments that one would bang upon + * + * Copyright (c) 2006 Danny McRae + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + + +#include "qt3support.h" + +#ifdef QT4 + +#include + +#else + +#include + +#endif + +#include "BandedWG.h" +#include "ModalBar.h" +#include "TubeBell.h" + +#include "mallets.h" +#include "instrument_track.h" +#include "note_play_handle.h" +#include "templates.h" +#include "knob.h" + +#undef SINGLE_SOURCE_COMPILE +#include "embed.cpp" + + +extern "C" +{ + +plugin::descriptor malletsstk_plugin_descriptor = +{ + STRINGIFY_PLUGIN_NAME( PLUGIN_NAME ), + "Mallets", + QT_TRANSLATE_NOOP( "pluginBrowser", + "Tuneful things to bang on" ), + "Danny McRae ", + 0x0100, + plugin::INSTRUMENT, + new QPixmap( PLUGIN_NAME::getIconPixmap( "logo" ) ) +} ; + +} + + +mallets::mallets( instrumentTrack * _channel_track ) : + instrument( _channel_track, &malletsstk_plugin_descriptor ) +{ + m_modalBarWidget = setupModalBarControls( this, _channel_track ); + setWidgetBackground( m_modalBarWidget, "artwork" ); + + m_tubeBellWidget = setupTubeBellControls( this, _channel_track ); + setWidgetBackground( m_tubeBellWidget, "artwork" ); + m_tubeBellWidget->hide(); + + m_bandedWGWidget = setupBandedWGControls( this, _channel_track ); + setWidgetBackground( m_bandedWGWidget, "artwork" ); + m_bandedWGWidget->hide(); + + m_presets = setupPresets( this, _channel_track ); + + m_spread = new knob( knobBright_26, this, tr( "Spread" ), + eng(), _channel_track ); + m_spread->setLabel( tr( "Spread" ) ); + m_spread->setRange( 0, 255, 1 ); + m_spread->setInitValue( 0 ); + m_spread->move( 178, 173 ); + m_spread->setHintText( tr( "Spread:" ) + " ", "" ); + + m_buffer = bufferAllocator::alloc( + eng()->getMixer()->framesPerAudioBuffer() ); +} + + + + +mallets::~mallets() +{ + bufferAllocator::free( m_buffer ); +} + + + + +void mallets::setWidgetBackground( QWidget * _widget, const QString & _pic ) +{ +#ifdef QT4 + _widget->setAutoFillBackground( TRUE ); + _widget->QPalette pal; + _widget->pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( + _pic ) ); + _widget->setPalette( pal ); +#else + _widget->setErasePixmap( PLUGIN_NAME::getIconPixmap( _pic ) ); +#endif +} + + + + +QWidget * mallets::setupModalBarControls( QWidget * _parent, track * _track ) +{ + QWidget * widget = new QWidget( _parent, "ModalBar" ); + widget->setFixedSize( 250, 250 ); + + m_hardness = new knob( knobBright_26, widget, tr( "Hardness" ), + eng(), _track ); + m_hardness->setLabel( tr( "Hardness" ) ); + m_hardness->setRange( 0.0, 128.0, 0.1 ); + m_hardness->setInitValue( 64.0 ); + m_hardness->move( 145, 24 ); + m_hardness->setHintText( tr( "Hardness:" ) + " ", "" ); + + m_position = new knob( knobBright_26, widget, tr( "Position" ), + eng(), _track ); + m_position->setLabel( tr( "Position" ) ); + m_position->setRange( 0.0, 128.0, 0.1 ); + m_position->setInitValue( 64.0 ); + m_position->move( 195, 24 ); + m_position->setHintText( tr( "Position:" ) + " ", "" ); + + m_vibratoGain = new knob( knobBright_26, widget, tr( "Vibrato Gain" ), + eng(), _track ); + m_vibratoGain->setLabel( tr( "Vib Gain" ) ); + m_vibratoGain->setRange( 0.0, 128.0, 0.1 ); + m_vibratoGain->setInitValue( 64.0 ); + m_vibratoGain->move( 56, 86 ); + m_vibratoGain->setHintText( tr( "Vib Gain:" ) + " ", "" ); + + m_vibratoFreq = new knob( knobBright_26, widget, tr( "Vibrato Freq" ), + eng(), _track ); + m_vibratoFreq->setLabel( tr( "Vib Freq" ) ); + m_vibratoFreq->setRange( 0.0, 128.0, 0.1 ); + m_vibratoFreq->setInitValue( 64.0 ); + m_vibratoFreq->move( 117, 86 ); + m_vibratoFreq->setHintText( tr( "Vib Freq:" ) + " ", "" ); + + m_stick = new knob( knobBright_26, widget, tr( "Stick Mix" ), + eng(), _track ); + m_stick->setLabel( tr( "Stick Mix" ) ); + m_stick->setRange( 0.0, 128.0, 0.1 ); + m_stick->setInitValue( 64.0 ); + m_stick->move( 178, 86 ); + m_stick->setHintText( tr( "Stick Mix:" ) + " ", "" ); + + return( widget ); +} + + + + +QWidget * mallets::setupTubeBellControls( QWidget * _parent, track * _track ) +{ + QWidget * widget = new QWidget( _parent, "TubeBellWidget" ); + widget->setFixedSize( 250, 250 ); + + m_modulator = new knob( knobBright_26, widget, tr( "Modulator" ), + eng(), _track ); + m_modulator->setLabel( tr( "Modulator" ) ); + m_modulator->setRange( 0.0, 128.0, 0.1 ); + m_modulator->setInitValue( 100.0 ); + m_modulator->move( 145, 24 ); + m_modulator->setHintText( tr( "Modulator:" ) + " ", "" ); + + m_crossfade = new knob( knobBright_26, widget, tr( "Crossfade" ), + eng(), _track ); + m_crossfade->setLabel( tr( "Crossfade" ) ); + m_crossfade->setRange( 0.0, 128.0, 0.1 ); + m_crossfade->setInitValue( 0.0 ); + m_crossfade->move( 195, 24 ); + m_crossfade->setHintText( tr( "Crossfade:" ) + " ", "" ); + + m_lfoSpeed = new knob( knobBright_26, widget, tr( "LFO Speed" ), + eng(), _track ); + m_lfoSpeed->setLabel( tr( "LFO Speed" ) ); + m_lfoSpeed->setRange( 0.0, 128.0, 0.1 ); + m_lfoSpeed->setInitValue( 20.0 ); + m_lfoSpeed->move( 56, 86 ); + m_lfoSpeed->setHintText( tr( "LFO Speed:" ) + " ", "" ); + + m_lfoDepth = new knob( knobBright_26, widget, tr( "LFO Depth" ), + eng(), _track ); + m_lfoDepth->setLabel( tr( "LFO Depth" ) ); + m_lfoDepth->setRange( 0.0, 128.0, 0.1 ); + m_lfoDepth->setInitValue( 10.0 ); + m_lfoDepth->move( 117, 86 ); + m_lfoDepth->setHintText( tr( "LFO Depth:" ) + " ", "" ); + + m_adsr = new knob( knobBright_26, widget, tr( "ADSR" ), + eng(), _track ); + m_adsr->setLabel( tr( "ADSR" ) ); + m_adsr->setRange( 0.0, 128.0, 0.1 ); + m_adsr->setInitValue( 0.0 ); + m_adsr->move( 178, 86 ); + m_adsr->setHintText( tr( "ADSR:" ) + " ", "" ); + + return( widget ); +} + + + + +QWidget * mallets::setupBandedWGControls( QWidget * _parent, track * _track ) +{ + // BandedWG + QWidget * widget = new QWidget( _parent, "BandedWGWidget" ); + widget->setFixedSize( 250, 250 ); + + m_strike = new ledCheckBox( tr( "Bowed" ), widget, tr( "Bowed" ), + eng(), _track ); + m_strike->move( 165, 30 ); + + m_pressure = new knob( knobBright_26, widget, tr( "Pressure" ), + eng(), _track ); + m_pressure->setLabel( tr( "Pressure" ) ); + m_pressure->setRange( 0.0, 128.0, 0.1 ); + m_pressure->setInitValue( 64.0 ); + m_pressure->move( 56, 86 ); + m_pressure->setHintText( tr( "Pressure:" ) + " ", "" ); + + m_motion = new knob( knobBright_26, widget, tr( "Motion" ), + eng(), _track ); + m_motion->setLabel( tr( "Motion" ) ); + m_motion->setRange( 0.0, 128.0, 0.1 ); + m_motion->setInitValue( 64.0 ); + m_motion->move( 117, 86 ); + m_motion->setHintText( tr( "Motion:" ) + " ", "" ); + + m_velocity = new knob( knobBright_26, widget, tr( "Speed" ), + eng(), _track ); + m_velocity->setLabel( tr( "Speed" ) ); + m_velocity->setRange( 0.0, 128.0, 0.1 ); + m_velocity->setInitValue( 74.5 ); + m_velocity->move( 178, 86 ); + m_velocity->setHintText( tr( "Speed:" ) + " ", "" ); + + m_vibrato = new knob( knobBright_26, widget, tr( "Vibrato" ), + eng(), _track ); + m_vibrato->setLabel( tr( "Vibrato" ) ); + m_vibrato->setRange( 0.0, 128.0, 0.1 ); + m_vibrato->setInitValue( 64.0 ); + m_vibrato->move( 178, 129 ); + m_vibrato->setHintText( tr( "Vibrato:" ) + " ", "" ); + + return( widget ); +} + + + + +comboBox * mallets::setupPresets( QWidget * _parent, track * _track ) +{ + comboBox * presets = new comboBox( _parent, tr( "Instrument" ), + eng(), _track ); + presets->setGeometry( 64, 157, 99, 22 ); + presets->setFont( pointSize<8>( presets->font() ) ); + + connect( presets, SIGNAL( valueChanged( int ) ), + _parent, SLOT( changePreset( int ) ) ); + + // ModalBar + presets->addItem( tr( "Marimba" ) ); + m_scalers.append( 4.0 ); + presets->addItem( tr( "Vibraphone" ) ); + m_scalers.append( 4.0 ); + presets->addItem( tr( "Agogo" ) ); + m_scalers.append( 5.0 ); + presets->addItem( tr( "Wood1" ) ); + m_scalers.append( 4.0 ); + presets->addItem( tr( "Reso" ) ); + m_scalers.append( 2.5 ); + presets->addItem( tr( "Wood2" ) ); + m_scalers.append( 5.0 ); + presets->addItem( tr( "Beats" ) ); + m_scalers.append( 20.0 ); + presets->addItem( tr( "Two Fixed" ) ); + m_scalers.append( 5.0 ); + presets->addItem( tr( "Clump" ) ); + m_scalers.append( 4.0 ); + + // TubeBell + presets->addItem( tr( "Tubular Bells" ) ); + m_scalers.append( 1.8 ); + + // BandedWG + presets->addItem( tr( "Uniform Bar" ) ); + m_scalers.append( 25.0 ); + presets->addItem( tr( "Tuned Bar" ) ); + m_scalers.append( 10.0 ); + presets->addItem( tr( "Glass" ) ); + m_scalers.append( 16.0 ); + presets->addItem( tr( "Tibetan Bowl" ) ); + m_scalers.append( 7.0 ); + + return( presets ); +} + + + + +void mallets::saveSettings( QDomDocument & _doc, QDomElement & _this ) +{ + // ModalBar + m_hardness->saveSettings( _doc, _this, "hardness" ); + m_position->saveSettings( _doc, _this, "position" ); + m_vibratoGain->saveSettings( _doc, _this, "vib_gain" ); + m_vibratoFreq->saveSettings( _doc, _this, "vib_freq" ); + m_stick->saveSettings( _doc, _this, "stick_mix" ); + + // TubeBell + m_modulator->saveSettings( _doc, _this, "modulator" ); + m_crossfade->saveSettings( _doc, _this, "crossfade" ); + m_lfoSpeed->saveSettings( _doc, _this, "lfo_speed" ); + m_lfoDepth->saveSettings( _doc, _this, "lfo_depth" ); + m_adsr->saveSettings( _doc, _this, "adsr" ); + + // BandedWG + m_pressure->saveSettings( _doc, _this, "pressure" ); + m_motion->saveSettings( _doc, _this, "motion" ); + m_vibrato->saveSettings( _doc, _this, "vibrato" ); + m_velocity->saveSettings( _doc, _this, "velocity" ); + m_strike->saveSettings( _doc, _this, "strike" ); + + m_presets->saveSettings( _doc, _this, "preset" ); + m_spread->saveSettings( _doc, _this, "spread" ); +} + + + + +void mallets::loadSettings( const QDomElement & _this ) +{ + // ModalBar + m_hardness->loadSettings( _this, "hardness" ); + m_position->loadSettings( _this, "position" ); + m_vibratoGain->loadSettings( _this, "vib_gain" ); + m_vibratoFreq->loadSettings( _this, "vib_freq" ); + m_stick->loadSettings( _this, "stick_mix" ); + + // TubeBell + m_modulator->loadSettings( _this, "modulator" ); + m_crossfade->loadSettings( _this, "crossfade" ); + m_lfoSpeed->loadSettings( _this, "lfo_speed" ); + m_lfoDepth->loadSettings( _this, "lfo_depth" ); + m_adsr->loadSettings( _this, "adsr" ); + + // BandedWG + m_pressure->loadSettings( _this, "pressure" ); + m_motion->loadSettings( _this, "motion" ); + m_vibrato->loadSettings( _this, "vibrato" ); + m_velocity->loadSettings( _this, "velocity" ); + m_strike->loadSettings( _this, "strike" ); + + m_presets->loadSettings( _this, "preset" ); + m_spread->loadSettings( _this, "spread" ); +} + + + + +QString mallets::nodeName( void ) const +{ + return( malletsstk_plugin_descriptor.name ); +} + + + + +void mallets::playNote( notePlayHandle * _n ) +{ + int p = m_presets->value(); + + float freq = getInstrumentTrack()->frequency( _n ); + if ( _n->totalFramesPlayed() == 0 ) + { + float vel = static_cast( _n->getVolume() ) / 100.0f; + + if( p < 9 ) + { + _n->m_pluginData = new malletsSynth( + freq, + vel, + m_vibratoGain->value(), + m_hardness->value(), + m_position->value(), + m_stick->value(), + m_vibratoFreq->value(), + p, + (Uint8) m_spread->value(), + eng()->getMixer()->sampleRate() ); + } + else if( p == 9 ) + { + _n->m_pluginData = new malletsSynth( + freq, + vel, + p, + m_lfoDepth->value(), + m_modulator->value(), + m_crossfade->value(), + m_lfoSpeed->value(), + m_adsr->value(), + (Uint8) m_spread->value(), + eng()->getMixer()->sampleRate() ); + } + else + { + _n->m_pluginData = new malletsSynth( + freq, + vel, + m_pressure->value(), + m_motion->value(), + m_vibrato->value(), + p - 10, + m_strike->value() * 128.0, + m_velocity->value(), + (Uint8) m_spread->value(), + eng()->getMixer()->sampleRate() ); + } + } + + const Uint32 frames = eng()->getMixer()->framesPerAudioBuffer(); + + malletsSynth * ps = static_cast( _n->m_pluginData ); + sample_t add_scale = 0.0f; + if( p == 10 ) + { + add_scale = + static_cast( m_strike->value() ) * freq * 2.5f; + } + for( Uint32 frame = 0; frame < frames; ++frame ) + { + const sample_t left = ps->nextSampleLeft() * + ( m_scalers[m_presets->value()] + add_scale ); + const sample_t right = ps->nextSampleRight() * + ( m_scalers[m_presets->value()] + add_scale ); + for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS / 2; ++chnl ) + { + m_buffer[frame][chnl * DEFAULT_CHANNELS / 2] = left; + m_buffer[frame][( chnl + 1 ) * DEFAULT_CHANNELS / 2] = + right; + } + } + + getInstrumentTrack()->processAudioBuffer( m_buffer, frames, _n ); +} + + + + +void mallets::deleteNotePluginData( notePlayHandle * _n ) +{ + delete static_cast( _n->m_pluginData ); +} + + + + +void mallets::changePreset( int _preset ) +{ + if( _preset < 9 ) + { + m_tubeBellWidget->hide(); + m_bandedWGWidget->hide(); + m_modalBarWidget->show(); + } + else if( _preset == 9 ) + { + m_modalBarWidget->hide(); + m_bandedWGWidget->hide(); + m_tubeBellWidget->show(); + } + else + { + m_modalBarWidget->hide(); + m_tubeBellWidget->hide(); + m_bandedWGWidget->show(); + } +} + + + +// ModalBar +malletsSynth::malletsSynth( const StkFloat _pitch, + const StkFloat _velocity, + const StkFloat _control1, + const StkFloat _control2, + const StkFloat _control4, + const StkFloat _control8, + const StkFloat _control11, + const int _control16, + const Uint8 _delay, + const sample_rate_t _sample_rate ) +{ + try + { + Stk::setSampleRate( _sample_rate ); + Stk::setRawwavePath( configManager::inst()->stkDir() ); + + m_voice = new ModalBar(); + + m_voice->controlChange( 1, _control1 ); + m_voice->controlChange( 2, _control2 ); + m_voice->controlChange( 4, _control4 ); + m_voice->controlChange( 8, _control8 ); + m_voice->controlChange( 11, _control11 ); + m_voice->controlChange( 16, _control16 ); + m_voice->controlChange( 128, 128.0f ); + + m_voice->noteOn( _pitch, _velocity ); + } + catch( ... ) + { + m_voice = NULL; + } + + m_delay = bufferAllocator::alloc( 256 ); + m_delayRead = 0; + m_delayWrite = _delay; + for( Uint16 i = 0; i < 256; i++ ) + { + m_delay[i] = 0.0; + } +} + + + + +// TubeBell +malletsSynth::malletsSynth( const StkFloat _pitch, + const StkFloat _velocity, + const int _preset, + const StkFloat _control1, + const StkFloat _control2, + const StkFloat _control4, + const StkFloat _control11, + const StkFloat _control128, + const Uint8 _delay, + const sample_rate_t _sample_rate ) +{ + try + { + Stk::setSampleRate( _sample_rate ); + Stk::setRawwavePath( configManager::inst()->stkDir() ); + + m_voice = new TubeBell(); + + m_voice->controlChange( 1, _control1 ); + m_voice->controlChange( 2, _control2 ); + m_voice->controlChange( 4, _control4 ); + m_voice->controlChange( 11, _control11 ); + m_voice->controlChange( 128, _control128 ); + + m_voice->noteOn( _pitch, _velocity ); + } + catch( ... ) + { + m_voice = NULL; + } + + m_delay = bufferAllocator::alloc( 256 ); + m_delayRead = 0; + m_delayWrite = _delay; + for( Uint16 i = 0; i < 256; i++ ) + { + m_delay[i] = 0.0; + } +} + + + + +// BandedWG +malletsSynth::malletsSynth( const StkFloat _pitch, + const StkFloat _velocity, + const StkFloat _control2, + const StkFloat _control4, + const StkFloat _control11, + const int _control16, + const StkFloat _control64, + const StkFloat _control128, + const Uint8 _delay, + const sample_rate_t _sample_rate ) +{ + try + { + Stk::setSampleRate( _sample_rate ); + Stk::setRawwavePath( configManager::inst()->stkDir() ); + + m_voice = new BandedWG(); + + m_voice->controlChange( 1, 128.0 ); + m_voice->controlChange( 2, _control2 ); + m_voice->controlChange( 4, _control4 ); + m_voice->controlChange( 11, _control11 ); + m_voice->controlChange( 16, _control16 ); + m_voice->controlChange( 64, _control64 ); + m_voice->controlChange( 128, _control128 ); + + m_voice->noteOn( _pitch, _velocity ); + } + catch( ... ) + { + m_voice = NULL; + } + + m_delay = bufferAllocator::alloc( 256 ); + m_delayRead = 0; + m_delayWrite = _delay; + for( Uint16 i = 0; i < 256; i++ ) + { + m_delay[i] = 0.0; + } +} + + + + +extern "C" +{ + +// neccessary for getting instance out of shared lib +plugin * lmms_plugin_main( void * _data ) +{ + return( new mallets( static_cast( _data ) ) ); +} + + +} + + +#include "mallets.moc" + + diff --git a/plugins/stk/mallets/mallets.h b/plugins/stk/mallets/mallets.h new file mode 100644 index 000000000..a9586ef92 --- /dev/null +++ b/plugins/stk/mallets/mallets.h @@ -0,0 +1,180 @@ +/* + * mallets.h - tuned instruments that one would bang upon + * + * Copyright (c) 2006 Danny McRae + * + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + + +#ifndef _MALLET_H +#define _MALLET_H + +#include "Instrmnt.h" + +#include "instrument.h" +#include "combobox.h" +#include "led_checkbox.h" +#include "track.h" +#include "buffer_allocator.h" + +class knob; +class notePlayHandle; + + +class malletsSynth +{ +public: + // ModalBar + malletsSynth( const StkFloat _pitch, + const StkFloat _velocity, + const StkFloat _control1, + const StkFloat _control2, + const StkFloat _control4, + const StkFloat _control8, + const StkFloat _control11, + const int _control16, + const Uint8 _delay, + const sample_rate_t _sample_rate ); + + // TubeBell + malletsSynth( const StkFloat _pitch, + const StkFloat _velocity, + const int _preset, + const StkFloat _control1, + const StkFloat _control2, + const StkFloat _control4, + const StkFloat _control11, + const StkFloat _control128, + const Uint8 _delay, + const sample_rate_t _sample_rate ); + + // BandedWG + malletsSynth( const StkFloat _pitch, + const StkFloat _velocity, + const StkFloat _control2, + const StkFloat _control4, + const StkFloat _control11, + const int _control16, + const StkFloat _control64, + const StkFloat _control128, + const Uint8 _delay, + const sample_rate_t _sample_rate ); + + inline ~malletsSynth( void ) + { + m_voice->noteOff( 0.0 ); + bufferAllocator::free( m_delay ); + delete m_voice; + } + + inline sample_t nextSampleLeft( void ) + { + if( m_voice == NULL ) + { + return( 0.0f ); + } + else + { + StkFloat s = m_voice->tick(); + m_delay[m_delayWrite] = s; + m_delayWrite++; + m_delayWrite %= 256; + return( s ); + } + } + + inline sample_t nextSampleRight( void ) + { + StkFloat s = m_delay[m_delayRead]; + m_delayRead++; + m_delayRead %= 256; + return( s ); + } + + +protected: + Instrmnt * m_voice; + + StkFloat * m_delay; + Uint8 m_delayRead; + Uint8 m_delayWrite; +}; + + + + +class mallets : public instrument +{ + Q_OBJECT +public: + mallets( instrumentTrack * _channel_track ); + virtual ~mallets(); + + virtual void FASTCALL playNote( notePlayHandle * _n ); + virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n ); + + + virtual void FASTCALL saveSettings( QDomDocument & _doc, + QDomElement & _parent ); + virtual void FASTCALL loadSettings( const QDomElement & _this ); + + virtual QString nodeName( void ) const; + +public slots: + void changePreset( int _preset ); + +private: + void setWidgetBackground( QWidget * _widget, const QString & _pic ); + QWidget * setupModalBarControls( QWidget * _parent, track * _track ); + QWidget * setupTubeBellControls( QWidget * _parent, track * _track ); + QWidget * setupBandedWGControls( QWidget * _parent, track * _track ); + comboBox * setupPresets( QWidget * _parent, track * _track ); + + QWidget * m_modalBarWidget; + knob * m_hardness; + knob * m_position; + knob * m_vibratoGain; + knob * m_vibratoFreq; + knob * m_stick; + + QWidget * m_tubeBellWidget; + knob * m_modulator; + knob * m_crossfade; + knob * m_lfoSpeed; + knob * m_lfoDepth; + knob * m_adsr; + + QWidget * m_bandedWGWidget; + knob * m_pressure; + knob * m_motion; + knob * m_vibrato; + knob * m_velocity; + ledCheckBox * m_strike; + + comboBox * m_presets; + knob * m_spread; + + vvector m_scalers; + sampleFrame * m_buffer; +}; + + +#endif diff --git a/src/core/config_mgr.cpp b/src/core/config_mgr.cpp index 924c6836c..6c9bfceac 100644 --- a/src/core/config_mgr.cpp +++ b/src/core/config_mgr.cpp @@ -576,6 +576,16 @@ void configManager::setLADSPADir( const QString & _fd ) +void configManager::setSTKDir( const QString & _fd ) +{ +#ifdef HAVE_STK_H + m_stkDir = _fd; +#endif +} + + + + void configManager::accept( void ) { if( m_workingDir.right( 1 ) != "/" ) @@ -848,6 +858,9 @@ bool configManager::loadConfigFile( void ) #ifdef LADSPA_SUPPORT m_ladDir = value( "paths", "laddir" ); #endif +#ifdef HAVE_STK_H + m_stkDir = value( "paths", "stkdir" ); +#endif if( m_vstDir == "" ) { @@ -861,9 +874,16 @@ bool configManager::loadConfigFile( void ) #ifdef LADSPA_SUPPORT if( m_ladDir == "" ) - { - m_ladDir = "/usr/lib/ladspa/:/usr/local/lib/ladspa/"; - } +{ + m_ladDir = "/usr/lib/ladspa/:/usr/local/lib/ladspa/"; +} +#endif + +#ifdef HAVE_STK_H + if( m_stkDir == "" ) +{ + m_stkDir = "/usr/share/stk/rawwaves/"; +} #endif if( root.isElement() ) @@ -915,6 +935,9 @@ void configManager::saveConfigFile( void ) #ifdef LADSPA_SUPPORT setValue( "paths", "laddir", m_ladDir ); #endif +#ifdef HAVE_STK_H + setValue( "paths", "stkdir", m_stkDir ); +#endif QDomDocument doc( "lmms-config-file" ); diff --git a/src/core/setup_dialog.cpp b/src/core/setup_dialog.cpp index 1dadd2c63..eea02ad3e 100644 --- a/src/core/setup_dialog.cpp +++ b/src/core/setup_dialog.cpp @@ -119,6 +119,9 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) : m_flDir( configManager::inst()->flDir() ), #ifdef LADSPA_SUPPORT m_ladDir( configManager::inst()->ladspaDir() ), +#endif +#ifdef HAVE_STK_H + m_stkDir( configManager::inst()->stkDir() ), #endif m_disableChActInd( configManager::inst()->value( "ui", "disablechannelactivityindicators" ).toInt() ), @@ -144,7 +147,11 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) : QWidget * ws = new QWidget( settings ); #ifdef LADSPA_SUPPORT +#ifdef HAVE_STK_H + ws->setFixedSize( 360, 412 ); +#else ws->setFixedSize( 360, 356 ); +#endif #else ws->setFixedSize( 360, 300 ); #endif @@ -263,7 +270,11 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) : QWidget * directories = new QWidget( ws ); #ifdef LADSPA_SUPPORT +#ifdef HAVE_STK_H + directories->setFixedSize( 360, 362 ); +#else directories->setFixedSize( 360, 316 ); +#endif #else directories->setFixedSize( 360, 260 ); #endif @@ -368,6 +379,26 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) : SLOT( openLADSPADir() ) ); #endif +#ifdef HAVE_STK_H + // STK-dir + tabWidget * stk_tw = new tabWidget( tr( + "STK rawwave directory" ).toUpper(), + directories ); + stk_tw->setFixedHeight( 56 ); + + m_stkLineEdit = new QLineEdit( m_stkDir, stk_tw ); + m_stkLineEdit->setGeometry( 10, 20, 300, 16 ); + connect( m_stkLineEdit, SIGNAL( textChanged( const QString & ) ), this, + SLOT( setSTKDir( const QString & ) ) ); + + QPushButton * stkdir_select_btn = new QPushButton( + embed::getIconPixmap( "project_open", 16, 16 ), + "", stk_tw ); + stkdir_select_btn->setFixedSize( 24, 24 ); + stkdir_select_btn->move( 320, 20 ); + connect( stkdir_select_btn, SIGNAL( clicked() ), this, + SLOT( openSTKDir() ) ); +#endif dir_layout->addWidget( lmms_wd_tw ); dir_layout->addSpacing( 10 ); @@ -380,6 +411,10 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) : dir_layout->addSpacing( 10 ); dir_layout->addWidget( lad_tw ); #endif +#ifdef HAVE_STK_H + dir_layout->addSpacing( 10 ); + dir_layout->addWidget( stk_tw ); +#endif dir_layout->addStretch(); @@ -694,6 +729,9 @@ void setupDialog::accept( void ) #ifdef LADSPA_SUPPORT configManager::inst()->setLADSPADir( m_ladDir ); #endif +#ifdef HAVE_STK_H + configManager::inst()->setSTKDir( m_stkDir ); +#endif // tell all audio-settings-widget to save their settings for( aswMap::iterator it = m_audioIfaceSetupWidgets.begin(); @@ -974,6 +1012,27 @@ void setupDialog::openLADSPADir( void ) +void setupDialog::openSTKDir( void ) +{ +#ifdef HAVE_STK_H +#ifdef QT4 + QString new_dir = QFileDialog::getExistingDirectory( this, + tr( "Choose STK rawwave directory" ), + m_ladDir ); +#else + QString new_dir = QFileDialog::getExistingDirectory( m_ladDir, 0, 0, + tr( "Choose STK rawwave directory" ), TRUE ); +#endif + if( new_dir != QString::null ) + { + m_stkLineEdit->setText( new_dir ); + } +#endif +} + + + + void setupDialog::setFLDir( const QString & _fd ) { m_flDir = _fd; @@ -992,6 +1051,16 @@ void setupDialog::setLADSPADir( const QString & _fd ) +void setupDialog::setSTKDir( const QString & _fd ) +{ +#ifdef HAVE_STK_H + m_stkDir = _fd; +#endif +} + + + + void setupDialog::audioInterfaceChanged( const QString & _iface ) { for( aswMap::iterator it = m_audioIfaceSetupWidgets.begin();