From dc5d949af4ae8d80076928f30d1f2ed5de738638 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 6 Jan 2008 12:47:21 +0000 Subject: [PATCH] rewrote effect-framework, changes in plugin-instantiation git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/branches/lmms-mv@656 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 73 +++++ Makefile.am | 17 +- configure.in | 4 +- include/audio_port.h | 14 +- include/automatable_model.h | 5 +- include/dummy_effect.h | 4 +- include/dummy_instrument.h | 2 +- include/dummy_plugin.h | 11 +- include/effect.h | 73 +++-- include/effect_chain.h | 42 ++- include/effect_control_dialog.h | 7 +- include/effect_label.h | 29 +- include/effect_rack_view.h | 77 +++-- include/effect_select_dialog.h | 10 +- include/effect_tab_widget.h | 86 ------ include/effect_view.h | 56 ++-- include/instrument.h | 33 +- include/instrument_track.h | 18 +- include/main_window.h | 6 +- include/mv_base.h | 6 +- include/plugin.h | 22 +- include/sample_track.h | 8 +- include/tab_widget.h | 7 +- include/tool.h | 18 +- .../audio_file_processor.cpp | 4 +- .../audio_file_processor.h | 3 +- plugins/bass_booster/bass_booster.cpp | 10 +- plugins/bass_booster/bass_booster.h | 3 +- plugins/kicker/kicker.cpp | 4 +- plugins/kicker/kicker.h | 3 +- plugins/ladspa_browser/ladspa_browser.cpp | 43 ++- plugins/ladspa_browser/ladspa_browser.h | 26 +- plugins/ladspa_effect/ladspa_effect.cpp | 11 +- plugins/ladspa_effect/ladspa_effect.h | 7 +- plugins/stk/mallets/mallets.cpp | 41 +-- plugins/stk/mallets/mallets.h | 3 +- plugins/vst_effect/vst_effect.cpp | 2 +- src/audio/audio_port.cpp | 7 +- src/core/effect.cpp | 73 ++++- src/core/effect_chain.cpp | 105 ++++++- src/core/effect_control_dialog.cpp | 1 + src/core/effect_select_dialog.cpp | 17 +- src/core/effect_tab_widget.cpp | 154 --------- src/core/import_filter.cpp | 4 +- src/core/instrument.cpp | 20 +- src/core/main_window.cpp | 24 +- src/core/plugin.cpp | 21 +- src/core/sample_play_handle.cpp | 4 +- src/core/surround_area.cpp | 6 +- src/core/tool.cpp | 47 +-- src/tracks/instrument_track.cpp | 48 +-- src/tracks/sample_track.cpp | 13 +- src/widgets/automatable_button.cpp | 7 +- src/widgets/automatable_slider.cpp | 5 +- src/widgets/combobox.cpp | 3 +- src/widgets/effect_label.cpp | 58 +--- src/widgets/effect_rack_view.cpp | 292 ++++++++++-------- src/widgets/effect_view.cpp | 117 ++----- src/widgets/group_box.cpp | 2 +- src/widgets/knob.cpp | 4 +- src/widgets/lcd_spinbox.cpp | 4 +- 61 files changed, 886 insertions(+), 938 deletions(-) delete mode 100644 include/effect_tab_widget.h delete mode 100644 src/core/effect_tab_widget.cpp diff --git a/ChangeLog b/ChangeLog index 3f09c1959..97ec31bc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,76 @@ +2008-01-06 Tobias Doerffel + + * plugins/ladspa_effect/ladspa_effect.cpp: + * plugins/ladspa_effect/ladspa_effect.h: + * plugins/bass_booster/bass_booster.cpp: + * plugins/bass_booster/bass_booster.h: + * plugins/vst_effect/vst_effect.cpp: + changes for making effects work again with new effect-framework + + * plugins/audio_file_processor/audio_file_processor.cpp: + * plugins/audio_file_processor/audio_file_processor.h: + * plugins/stk/mallets/mallets.cpp: + * plugins/stk/mallets/mallets.h: + * plugins/ladspa_browser/ladspa_browser.cpp: + * plugins/ladspa_browser/ladspa_browser.h: + * plugins/kicker/kicker.cpp: + * plugins/kicker/kicker.h: + * include/dummy_plugin.h: + * include/instrument.h: + * include/plugin.h: + * include/tool.h: + * include/main_window.h: + * include/mv_base.h: + * include/dummy_instrument.h: + * src/core/plugin.cpp: + * src/core/tool.cpp: + * src/core/import_filter.cpp: + * src/core/instrument.cpp: + * src/core/surround_area.cpp: + * src/core/main_window.cpp: + moved createView()-functionality from instrument- to plugin-class + + * include/tab_widget.h: + code-formatting stuff + + * include/audio_port.h: + * include/instrument_track.h: + * include/sample_track.h: + * src/audio/audio_port.cpp: + * src/core/sample_play_handle.cpp: + * src/tracks/instrument_track.cpp: + * src/tracks/sample_track.cpp: + integrated new effect-framework + + * Makefile.am: + * include/dummy_effect.h: + * include/effect.h: + * include/effect_chain.h: + * include/effect_control_dialog.h: + * include/effect_label.h: + * include/effect_rack_view.h: + * include/effect_select_dialog.h: + * include/effect_tab_widget.h: + * include/effect_view.h: + * src/core/effect.cpp: + * src/core/effect_chain.cpp: + * src/core/effect_control_dialog.cpp: + * src/core/effect_select_dialog.cpp: + * src/core/effect_tab_widget.cpp: + * src/widgets/effect_label.cpp: + * src/widgets/effect_view.cpp: + * src/widgets/effect_rack_view.cpp: + rewrote view-component of effect-framework and removed effectTabWidget + + * include/automatable_model.h: + * src/widgets/automatable_slider.cpp: + * src/widgets/group_box.cpp: + * src/widgets/lcd_spinbox.cpp: + * src/widgets/combobox.cpp: + * src/widgets/knob.cpp: + * src/widgets/automatable_button.cpp: + pass model-pointer to modelView-constructor + 2008-01-05 Tobias Doerffel * plugins/organic/organic.cpp: diff --git a/Makefile.am b/Makefile.am index 0032df353..02a96d0aa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,7 +63,6 @@ lmms_MOC = \ ./effect_control_dialog.moc \ ./effect_label.moc \ ./effect_select_dialog.moc \ - ./effect_tab_widget.moc \ ./envelope_and_lfo_widget.moc \ ./envelope_tab_widget.moc \ ./export_project_dialog.moc \ @@ -89,8 +88,8 @@ lmms_MOC = \ ./pixmap_button.moc \ ./plugin_browser.moc \ ./project_notes.moc \ - ./rack_plugin.moc \ - ./rack_view.moc \ + ./effect_view.moc \ + ./effect_rack_view.moc \ ./rubberband.moc \ ./rename_dialog.moc \ ./sample_buffer.moc \ @@ -159,7 +158,6 @@ lmms_SOURCES = \ $(srcdir)/src/core/effect_chain.cpp \ $(srcdir)/src/core/effect_control_dialog.cpp \ $(srcdir)/src/core/effect_select_dialog.cpp \ - $(srcdir)/src/core/effect_tab_widget.cpp \ $(srcdir)/src/core/effect.cpp \ $(srcdir)/src/core/engine.cpp \ $(srcdir)/src/core/envelope_and_lfo_widget.cpp \ @@ -221,6 +219,8 @@ lmms_SOURCES = \ $(srcdir)/src/widgets/combobox.cpp \ $(srcdir)/src/widgets/cpuload_widget.cpp \ $(srcdir)/src/widgets/effect_label.cpp \ + $(srcdir)/src/widgets/effect_rack_view.cpp \ + $(srcdir)/src/widgets/effect_view.cpp \ $(srcdir)/src/widgets/fade_button.cpp \ $(srcdir)/src/widgets/group_box.cpp \ $(srcdir)/src/widgets/kmultitabbar.cpp \ @@ -230,8 +230,6 @@ lmms_SOURCES = \ $(srcdir)/src/widgets/nstate_button.cpp \ $(srcdir)/src/widgets/pixmap_button.cpp \ $(srcdir)/src/widgets/project_notes.cpp \ - $(srcdir)/src/widgets/rack_plugin.cpp \ - $(srcdir)/src/widgets/rack_view.cpp \ $(srcdir)/src/widgets/rubberband.cpp \ $(srcdir)/src/widgets/rename_dialog.cpp \ $(srcdir)/src/widgets/side_bar_widget.cpp \ @@ -273,7 +271,9 @@ lmms_SOURCES = \ $(srcdir)/include/panning.h \ $(srcdir)/include/song_editor.h \ $(srcdir)/include/plugin.h \ + $(srcdir)/include/plugin_view.h \ $(srcdir)/include/instrument.h \ + $(srcdir)/include/instrument_view.h \ $(srcdir)/include/bb_editor.h \ $(srcdir)/include/piano_widget.h \ $(srcdir)/include/effect_board.h \ @@ -372,10 +372,9 @@ lmms_SOURCES = \ $(srcdir)/include/effect_chain.h \ $(srcdir)/include/effect_control_dialog.h \ $(srcdir)/include/effect_label.h \ - $(srcdir)/include/effect_tab_widget.h \ - $(srcdir)/include/rack_plugin.h \ - $(srcdir)/include/rack_view.h \ + $(srcdir)/include/effect_rack_view.h \ $(srcdir)/include/effect_select_dialog.h \ + $(srcdir)/include/effect_view.h \ $(srcdir)/include/dummy_effect.h \ $(srcdir)/include/ladspa-1.1.h \ $(srcdir)/include/sweep_oscillator.h \ diff --git a/configure.in b/configure.in index deb308d9c..e47c8f508 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT(lmms, 0.4.0-svn20080104-mv, lmms-devel/at/lists/dot/sf/dot/net) -AM_INIT_AUTOMAKE(lmms, 0.4.0-svn20080104-mv) +AC_INIT(lmms, 0.4.0-svn20080106-mv, lmms-devel/at/lists/dot/sf/dot/net) +AM_INIT_AUTOMAKE(lmms, 0.4.0-svn20080106-mv) AM_CONFIG_HEADER(config.h) diff --git a/include/audio_port.h b/include/audio_port.h index 2fdad2a98..a7177772d 100644 --- a/include/audio_port.h +++ b/include/audio_port.h @@ -1,7 +1,7 @@ /* * audio_port.h - base-class for objects providing sound at a port * - * Copyright (c) 2005-2007 Tobias Doerffel + * Copyright (c) 2005-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -34,7 +34,7 @@ class audioPort { public: - audioPort( const QString & _name ); + audioPort( const QString & _name, track * _track ); ~audioPort(); inline surroundSampleFrame * firstBuffer( void ) @@ -66,7 +66,7 @@ public: inline effectChain * getEffects( void ) { - return( m_effects ); + return( &m_effects ); } void setNextFxChannel( const fx_ch_t _chnl ) @@ -88,7 +88,11 @@ public: NONE, FIRST, BOTH } m_bufferUsage; - inline bool processEffects( void ) { return( m_effects->processAudioBuffer( m_firstBuffer, m_frames ) ); }; + inline bool processEffects( void ) + { + return( m_effects.processAudioBuffer( m_firstBuffer, + m_frames ) ); + } private: surroundSampleFrame * m_firstBuffer; @@ -98,7 +102,7 @@ private: QString m_name; - effectChain * m_effects; + effectChain m_effects; fpp_t m_frames; } ; diff --git a/include/automatable_model.h b/include/automatable_model.h index 7a56e85a0..88249c7cc 100644 --- a/include/automatable_model.h +++ b/include/automatable_model.h @@ -1,7 +1,7 @@ /* * automatable_model.h - declaration of class automatableModel * - * Copyright (c) 2007 Tobias Doerffel + * Copyright (c) 2007-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -247,7 +247,8 @@ public: typedef automatableModel autoModel; typedef automatableModelView autoModelView; - automatableModelView( void ) : modelView() + automatableModelView( ::model * _model ) : + modelView( _model ) { } diff --git a/include/dummy_effect.h b/include/dummy_effect.h index 435b4ae00..3e37ab955 100644 --- a/include/dummy_effect.h +++ b/include/dummy_effect.h @@ -55,8 +55,8 @@ public: class dummyEffect : public effect { public: - inline dummyEffect( void ) : - effect( NULL, NULL ) + inline dummyEffect( model * _parent ) : + effect( NULL, _parent, NULL ) { } diff --git a/include/dummy_instrument.h b/include/dummy_instrument.h index 736d4ee56..b2bb5f8db 100644 --- a/include/dummy_instrument.h +++ b/include/dummy_instrument.h @@ -56,7 +56,7 @@ public: return( "dummyinstrument" ); } - virtual instrumentView * createView( QWidget * _parent ) + virtual pluginView * instantiateView( QWidget * _parent ) { return( new instrumentView( this, _parent ) ); } diff --git a/include/dummy_plugin.h b/include/dummy_plugin.h index 6dcc413d0..1bdc58967 100644 --- a/include/dummy_plugin.h +++ b/include/dummy_plugin.h @@ -2,7 +2,7 @@ * dummy_plugin.h - empty plugin which is used as fallback if a plugin couldn't * be found * - * Copyright (c) 2005-2007 Tobias Doerffel + * Copyright (c) 2005-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -28,13 +28,14 @@ #define _DUMMY_PLUGIN_H #include "plugin.h" +#include "plugin_view.h" class dummyPlugin : public plugin { public: inline dummyPlugin( void ) : - plugin( NULL ) + plugin( NULL, NULL ) { } @@ -56,6 +57,12 @@ public: return( "dummyplugin" ); } +protected: + virtual pluginView * instantiateView( QWidget * _parent ) + { + return( new pluginView( this, _parent ) ); + } + } ; diff --git a/include/effect.h b/include/effect.h index d5e55618c..e7c51aa88 100644 --- a/include/effect.h +++ b/include/effect.h @@ -2,7 +2,7 @@ * effect.h - base class for effects * * Copyright (c) 2006-2007 Danny McRae - * Copyright (c) 2006-2007 Tobias Doerffel + * Copyright (c) 2006-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -39,83 +39,91 @@ #include "automatable_model.h" +class effectChain; class effectControlDialog; class track; -class rackPlugin; class effect : public plugin { public: effect( const plugin::descriptor * _desc, + model * _parent, const descriptor::subPluginFeatures::key * _key ); virtual ~effect(); + + virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); + virtual void loadSettings( const QDomElement & _this ); + + inline virtual QString nodeName( void ) const + { + return( "effect" ); + } + - virtual bool FASTCALL processAudioBuffer( + virtual bool processAudioBuffer( surroundSampleFrame * _buf, const fpp_t _frames ); - + inline ch_cnt_t getProcessorCount( void ) const { return( m_processors ); } - + inline void setProcessorCount( ch_cnt_t _processors ) { m_processors = _processors; } - + inline bool isOkay( void ) const { return( m_okay ); } - + inline void setOkay( bool _state ) { m_okay = _state; } - - + + inline bool isRunning( void ) const { return( m_running ); } - + inline void startRunning( void ) { m_bufferCount = 0; m_running = TRUE; } - + inline void stopRunning( void ) { m_running = FALSE; } - + inline bool isEnabled( void ) const { return( m_enabledModel.value() ); } - - inline Uint32 getTimeout( void ) const + + inline f_cnt_t getTimeout( void ) const { - return( m_silenceTimeout ); + const float samples = engine::getMixer()->sampleRate() * + m_autoQuitModel.value() / 1000.0f; + return( 1 + ( static_cast( samples ) / + engine::getMixer()->framesPerPeriod() ) ); } - - inline void setTimeout( Uint32 _time_out ) - { - m_silenceTimeout = _time_out; - } - + inline float getWetLevel( void ) const { return( m_wetDryModel.value() ); } - + inline float getDryLevel( void ) const { return( 1.0f - m_wetDryModel.value() ); } - + inline float getGate( void ) const { const float level = m_gateModel.value(); @@ -123,7 +131,7 @@ public: engine::getMixer()->framesPerPeriod() ); } - inline Uint32 getBufferCount( void ) const + inline f_cnt_t getBufferCount( void ) const { return( m_bufferCount ); } @@ -135,7 +143,7 @@ public: inline void incrementBufferCount( void ) { - m_bufferCount++; + ++m_bufferCount; } inline bool dontRun( void ) const @@ -156,9 +164,14 @@ public: virtual effectControlDialog * createControlDialog( track * _track ) = 0; static effect * instantiate( const QString & _plugin_name, + model * _parent, descriptor::subPluginFeatures::key * _key ); +protected: + virtual pluginView * instantiateView( QWidget * ); + + private: descriptor::subPluginFeatures::key m_key; @@ -167,16 +180,16 @@ private: bool m_okay; bool m_noRun; bool m_running; + f_cnt_t m_bufferCount; + boolModel m_enabledModel; - - Uint32 m_bufferCount; - Uint32 m_silenceTimeout; - floatModel m_wetDryModel; floatModel m_gateModel; + floatModel m_autoQuitModel; - friend class rackPlugin; + friend class effectView; + friend class effectChain; } ; diff --git a/include/effect_chain.h b/include/effect_chain.h index c0acf4155..0c88d8104 100644 --- a/include/effect_chain.h +++ b/include/effect_chain.h @@ -2,6 +2,7 @@ * effect_chain.h - class for processing and effects chain * * Copyright (c) 2006-2008 Danny McRae + * Copyright (c) 2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -28,37 +29,48 @@ #include "effect.h" -typedef QVector effect_list_t; - - -class effectChain +class effectChain : public journallingObject, public model { public: - effectChain( void ); + effectChain( audioPort * _port, track * _track ); virtual ~effectChain(); - - void FASTCALL appendEffect( effect * _effect ); - void FASTCALL removeEffect( effect * _effect ); - void FASTCALL moveDown( effect * _effect ); - void FASTCALL moveUp( effect * _effect ); - bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf, + + virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); + virtual void loadSettings( const QDomElement & _this ); + + inline virtual QString nodeName( void ) const + { + return( "fxchain" ); + } + + void appendEffect( effect * _effect ); + void removeEffect( effect * _effect ); + void moveDown( effect * _effect ); + void moveUp( effect * _effect ); + bool processAudioBuffer( surroundSampleFrame * _buf, const fpp_t _frames ); void startRunning( void ); bool isRunning( void ); - inline const effect_list_t & getEffects( void ) +/* inline const effect_list_t & getEffects( void ) { return( m_effects ); - } + }*/ + + void deleteAllPlugins( void ); private: - effect_list_t m_effects; + typedef QVector effectList; + effectList m_effects; + + audioPort * m_port; + track * m_track; boolModel m_enabledModel; - friend class effectTabWidget; + friend class effectRackView; } ; diff --git a/include/effect_control_dialog.h b/include/effect_control_dialog.h index 9e3746584..1d95eb488 100644 --- a/include/effect_control_dialog.h +++ b/include/effect_control_dialog.h @@ -2,7 +2,7 @@ * effect_control_dialog.h - base-class for effect-dialogs for displaying and * editing control port values * - * Copyright (c) 2006-2007 Tobias Doerffel + * Copyright (c) 2006-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -28,14 +28,15 @@ #include -#include "journalling_object.h" +#include "mv_base.h" +#include "types.h" class effect; class track; -class effectControlDialog : public QWidget, public journallingObject +class effectControlDialog : public QWidget, public modelView { Q_OBJECT public: diff --git a/include/effect_label.h b/include/effect_label.h index 1403e9e16..6b8c8121e 100644 --- a/include/effect_label.h +++ b/include/effect_label.h @@ -3,6 +3,7 @@ * offers access to an effect rack * * Copyright (c) 2006-2007 Danny McRae + * Copyright (c) 2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -28,18 +29,15 @@ #include -#include "journalling_object.h" - class QLabel; class QPushButton; -class effectTabWidget; +class effectRackView; class sampleTrack; -class tabWidget; -class effectLabel: public QWidget, public journallingObject +class effectLabel: public QWidget { Q_OBJECT public: @@ -48,22 +46,14 @@ public: virtual ~effectLabel(); QString text( void ) const; - void FASTCALL setText( const QString & _text ); - - virtual void FASTCALL saveSettings( QDomDocument & _doc, - QDomElement & _parent ); - virtual void FASTCALL loadSettings( const QDomElement & _this ); - inline virtual QString nodeName( void ) const - { - return( "sample_track" ); - } + void setText( const QString & _text ); + - public slots: void showEffects( void ); void rename( void ); - + signals: void clicked( void ); void nameChanged( void ); @@ -78,13 +68,12 @@ protected: private: sampleTrack * m_track; - + QLabel * m_label; QPushButton * m_effectBtn; - tabWidget * m_tabWidget; - effectTabWidget * m_effWidget; QWidget * m_effWindow; + effectRackView * m_effectRack; -}; +} ; #endif diff --git a/include/effect_rack_view.h b/include/effect_rack_view.h index c83fea3ab..ea98a68c4 100644 --- a/include/effect_rack_view.h +++ b/include/effect_rack_view.h @@ -1,7 +1,8 @@ /* - * right_frame.h - provides the display for the rackInsert instances + * effect_rack_view.h - view for effectChain-model * * Copyright (c) 2006-2007 Danny McRae + * Copyright (c) 2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -22,63 +23,61 @@ * */ -#ifndef _RACK_VIEW_H -#define _RACK_VIEW_H +#ifndef _EFFECT_RACK_VIEW_H +#define _EFFECT_RACK_VIEW_H #include -#include -#include -#include - +#include "effect_chain.h" #include "types.h" -#include "journalling_object.h" + +class QPushButton; +class QScrollArea; +class QVBoxLayout; + +class effectView; +class groupBox; -class audioPort; -class effect; -class rackPlugin; -class track; - - -class rackView: public QWidget, public journallingObject +class effectRackView : public QWidget, public modelView { Q_OBJECT - public: - rackView( QWidget * _parent, track * _track, audioPort * _port ); - ~rackView(); - - void addEffect( effect * _e ); - - virtual void FASTCALL saveSettings( QDomDocument & _doc, - QDomElement & _parent ); - virtual void FASTCALL loadSettings( const QDomElement & _this ); - inline virtual QString nodeName( void ) const - { - return( "rack" ); - } - - void deleteAllPlugins( void ); + effectRackView( effectChain * _model, QWidget * _parent ); + virtual ~effectRackView(); public slots: - void moveUp( rackPlugin * _plugin ); - void moveDown( rackPlugin * _plugin ); - void deletePlugin( rackPlugin * _plugin ); + void moveUp( effectView * _view ); + void moveDown( effectView * _view ); + void deletePlugin( effectView * _view ); + + +private slots: + void updateView( void ); + void addEffect( void ); private: - void redraw(); + virtual void modelChanged( void ); + + inline effectChain * fxChain( void ) + { + return( castModel() ); + } + + inline const effectChain * fxChain( void ) const + { + return( castModel() ); + } - QVector m_rackInserts; - + QVector m_effectViews; + QVBoxLayout * m_mainLayout; + groupBox * m_effectsGroupBox; QScrollArea * m_scrollArea; - - track * m_track; - audioPort * m_port; + QPushButton * m_addButton; Uint32 m_lastY; diff --git a/include/effect_select_dialog.h b/include/effect_select_dialog.h index 87bbd08f3..acad866a7 100644 --- a/include/effect_select_dialog.h +++ b/include/effect_select_dialog.h @@ -29,7 +29,7 @@ #include #include -#include "effect.h" +#include "effect_chain.h" class effectSelectDialog : public QDialog @@ -39,7 +39,7 @@ public: effectSelectDialog( QWidget * _parent ); virtual ~effectSelectDialog(); - effect * instantiateSelectedPlugin( void ); + effect * instantiateSelectedPlugin( effectChain * _parent ); public slots: void showPorts( void ); @@ -53,13 +53,13 @@ private: -class effectList : public QWidget +class effectListWidget : public QWidget { Q_OBJECT public: - effectList( QWidget * _parent ); + effectListWidget( QWidget * _parent ); - virtual ~effectList(); + virtual ~effectListWidget(); inline effectKey getSelected( void ) { diff --git a/include/effect_tab_widget.h b/include/effect_tab_widget.h deleted file mode 100644 index a64a454c0..000000000 --- a/include/effect_tab_widget.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * effect_tab_widget.h - tab-widget in channel-track-window for setting up - * effects - * - * Copyright (c) 2006-2008 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 _EFFECT_TAB_WIDGET_H -#define _EFFECT_TAB_WIDGET_H - -#include - -#include "journalling_object.h" -#include "rack_view.h" - - -class QPushButton; - -class audioPort; -class groupBox; -class instrumentTrack; -class sampleTrack; -class track; - - -class effectTabWidget : public QWidget, public journallingObject -{ - Q_OBJECT -public: - effectTabWidget( instrumentTrack * _track, audioPort * _port ); - effectTabWidget( QWidget * _parent, sampleTrack * _track, - audioPort * _port ); - virtual ~effectTabWidget(); - - - virtual void FASTCALL saveSettings( QDomDocument & _doc, - QDomElement & _parent ); - virtual void FASTCALL loadSettings( const QDomElement & _this ); - inline virtual QString nodeName( void ) const - { - return( "fx" ); - } - - void setupWidget( void ); - - inline void deleteAllEffects( void ) - { - m_rack->deleteAllPlugins(); - } - - -private slots: - void addEffect( void ); - - -private: - track * m_track; - audioPort * m_port; - - groupBox * m_effectsGroupBox; - QPushButton * m_addButton; - - rackView * m_rack; - -} ; - -#endif diff --git a/include/effect_view.h b/include/effect_view.h index 7334a3482..58d3d6ddb 100644 --- a/include/effect_view.h +++ b/include/effect_view.h @@ -1,8 +1,8 @@ /* - * rack_plugin.h - tab-widget in channel-track-window for setting up - * effects + * effect_view.h - view-component for an effect * * Copyright (c) 2006-2007 Danny McRae + * Copyright (c) 2007-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -23,13 +23,11 @@ * */ -#ifndef _RACK_PLUGIN_H -#define _RACK_PLUGIN_H - -#include +#ifndef _EFFECT_VIEW_H +#define _EFFECT_VIEW_H #include "automatable_model.h" - +#include "plugin_view.h" class QGroupBox; class QLabel; @@ -45,51 +43,44 @@ class tempoSyncKnob; class track; -class rackPlugin: public QWidget, public journallingObject +class effectView : public pluginView { Q_OBJECT - public: - rackPlugin( QWidget * _parent, effect * _eff, track * _track, - audioPort * _port ); - virtual ~rackPlugin(); + effectView( effect * _model, QWidget * _parent ); + virtual ~effectView(); - inline effect * getEffect() + inline effect * getEffect( void ) { - return( m_effect ); + return( castModel() ); + } + inline const effect * getEffect( void ) const + { + return( castModel() ); } - virtual void FASTCALL saveSettings( QDomDocument & _doc, - QDomElement & _parent ); - virtual void FASTCALL loadSettings( const QDomElement & _this ); - inline virtual QString nodeName( void ) const - { - return( "effect" ); - } public slots: void editControls( void ); - void updateAutoQuit( void ); -/* void bypassChanged( void ); - void updateWetDry( void ); - void updateGate( void );*/ void moveUp( void ); void moveDown( void ); void deletePlugin( void ); void displayHelp( void ); void closeEffects( void ); + signals: - void moveUp( rackPlugin * _plugin ); - void moveDown( rackPlugin * _plugin ); - void deletePlugin( rackPlugin * _plugin ); + void moveUp( effectView * _plugin ); + void moveDown( effectView * _plugin ); + void deletePlugin( effectView * _plugin ); + protected: void contextMenuEvent( QContextMenuEvent * _me ); - -private: - floatModel m_autoQuitModel; + virtual void modelChanged( void ); + +private: ledCheckBox * m_bypass; knob * m_wetDry; tempoSyncKnob * m_autoQuit; @@ -99,10 +90,7 @@ private: QLabel * m_label; QPushButton * m_editButton; QMdiSubWindow * m_subWindow; - effect * m_effect; effectControlDialog * m_controlView; - track * m_track; - audioPort * m_port; bool m_show; } ; diff --git a/include/instrument.h b/include/instrument.h index 55f823cbc..a17226499 100644 --- a/include/instrument.h +++ b/include/instrument.h @@ -31,7 +31,6 @@ #include "plugin.h" #include "mixer.h" -#include "mv_base.h" // forward-declarations @@ -43,7 +42,7 @@ class notePlayHandle; class track; -class instrument : public plugin, public model +class instrument : public plugin { public: instrument( instrumentTrack * _instrument_track, @@ -117,8 +116,6 @@ public: virtual bool isFromTrack( const track * _track ) const; - instrumentView * createEditor( QWidget * _parent ); - protected: inline instrumentTrack * getInstrumentTrack( void ) const @@ -131,38 +128,10 @@ protected: // desiredReleaseFrames() frames are left void applyRelease( sampleFrame * buf, const notePlayHandle * _n ); - // instruments have to implement this to create an according view for - // themselves - virtual instrumentView * createView( QWidget * _parent ) = 0; - - private: instrumentTrack * m_instrumentTrack; } ; - -class instrumentView : public QWidget, public modelView -{ -public: - instrumentView( instrument * _instrument, QWidget * _parent ); - virtual ~instrumentView(); - - instrument * model( void ) - { - return( castModel() ); - } - - const instrument * model( void ) const - { - return( castModel() ); - } - - virtual void setModel( ::model * _model, bool = FALSE ); - -} ; - - - #endif diff --git a/include/instrument_track.h b/include/instrument_track.h index 7f2f9dd43..3bf047f23 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -2,7 +2,7 @@ * instrument_track.h - declaration of class instrumentTrack, a track + window * which holds an instrument-plugin * - * Copyright (c) 2004-2007 Tobias Doerffel + * Copyright (c) 2004-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -30,18 +30,20 @@ #include #include +#include "audio_port.h" #include "automatable_model.h" #include "lcd_spinbox.h" #include "midi_event_processor.h" #include "mixer.h" +#include "effect_chain.h" #include "surround_area.h" #include "tab_widget.h" #include "track.h" + class QLineEdit; class arpAndChordsTabWidget; -class audioPort; -class effectTabWidget; +class effectRackView; class envelopeTabWidget; class fadeButton; class instrument; @@ -158,7 +160,7 @@ public: inline audioPort * getAudioPort( void ) { - return( m_audioPort ); + return( &m_audioPort ); } intModel * baseNoteModel( void ) @@ -207,7 +209,7 @@ private: midiPort * m_midiPort; - audioPort * m_audioPort; + audioPort m_audioPort; notePlayHandle * m_notes[NOTES_PER_OCTAVE * OCTAVES]; @@ -237,7 +239,11 @@ private: envelopeTabWidget * m_envWidget; arpAndChordsTabWidget * m_arpWidget; midiTabWidget * m_midiWidget; - effectTabWidget * m_effWidget; + + pluginView * m_instrumentView; + effectRackView * m_effectRack; + +// effectChain m_effects; // test-piano at the bottom of every instrument-settings-window pianoWidget * m_pianoWidget; diff --git a/include/main_window.h b/include/main_window.h index 4c906c9b7..a9550e584 100644 --- a/include/main_window.h +++ b/include/main_window.h @@ -37,7 +37,7 @@ class QMdiArea; class QSplashScreen; class configManager; -class tool; +class pluginView; class toolButton; @@ -155,8 +155,8 @@ private: bool m_alt; } m_keyMods; - QMenu * m_tools_menu; - QList m_tools; + QMenu * m_toolsMenu; + QList m_tools; bool m_modified; diff --git a/include/mv_base.h b/include/mv_base.h index 281b3fef3..7e38aa73e 100644 --- a/include/mv_base.h +++ b/include/mv_base.h @@ -28,6 +28,8 @@ #include +class modelView; + class model : public QObject { @@ -71,8 +73,8 @@ signals: class modelView { public: - modelView() : - m_model( NULL ) + modelView( model * _model ) : + m_model( _model ) { } diff --git a/include/plugin.h b/include/plugin.h index 385589c47..e92ef9fdf 100644 --- a/include/plugin.h +++ b/include/plugin.h @@ -32,6 +32,7 @@ #include #include "journalling_object.h" +#include "mv_base.h" #include "base64.h" @@ -42,8 +43,10 @@ class QPixmap; class QWidget; +class pluginView; -class plugin : public journallingObject + +class plugin : public journallingObject, public model { public: enum pluginTypes @@ -150,7 +153,7 @@ public: } ; // contructor of a plugin - plugin( const descriptor * _descriptor ); + plugin( const descriptor * _descriptor, model * _parent ); virtual ~plugin(); // returns public-name out of descriptor @@ -184,6 +187,7 @@ public: // returns an instance of a plugin whose name matches to given one // if specified plugin couldn't be loaded, it creates a dummy-plugin static plugin * FASTCALL instantiate( const QString & _plugin_name, + model * _parent, void * _data ); // some plugins run external programs for doing their actual work @@ -194,21 +198,29 @@ public: // of course isn't that efficient virtual bool supportsParallelizing( void ) const; - // plugins supporting parallelizing, should re-implement that as the + // plugins supporting parallelization, should re-implement that as the // mixer will call this at the end of processing according chain // of plugins virtual void waitForWorkerThread( void ); - // fills given vector with descriptors of all available plugins static void FASTCALL getDescriptorsOfAvailPlugins( QVector & _plugin_descs ); + // create a view for the model + pluginView * createView( QWidget * _parent ); + + +protected: + // create a view for the model + virtual pluginView * instantiateView( QWidget * ) = 0; + + private: const descriptor * m_descriptor; // pointer to instantiation-function in plugin - typedef plugin * ( * instantiationHook )( void * ); + typedef plugin * ( * instantiationHook )( model *, void * ); } ; diff --git a/include/sample_track.h b/include/sample_track.h index e430f9627..507f5e332 100644 --- a/include/sample_track.h +++ b/include/sample_track.h @@ -2,7 +2,7 @@ * sample_track.h - class sampleTrack, a track which provides arrangement of * samples * - * Copyright (c) 2005-2007 Tobias Doerffel + * Copyright (c) 2005-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -29,11 +29,11 @@ #include +#include "audio_port.h" #include "track.h" #include "volume_knob.h" class QLabel; -class audioPort; class effectLabel; class sampleBuffer; @@ -133,7 +133,7 @@ public: inline audioPort * getAudioPort( void ) { - return( m_audioPort ); + return( &m_audioPort ); } virtual QString nodeName( void ) const @@ -144,7 +144,7 @@ public: private: effectLabel * m_trackLabel; - audioPort * m_audioPort; + audioPort m_audioPort; volumeKnob * m_volumeKnob; knobModel m_volumeModel; diff --git a/include/tab_widget.h b/include/tab_widget.h index cb3b67e16..c06756d0a 100644 --- a/include/tab_widget.h +++ b/include/tab_widget.h @@ -1,7 +1,7 @@ /* * tab_widget.h - LMMS-tabwidget * - * Copyright (c) 2005-2007 Tobias Doerffel + * Copyright (c) 2005-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -35,10 +35,9 @@ class tabWidget : public QWidget Q_OBJECT public: tabWidget( const QString & _caption, QWidget * _parent ); - ~tabWidget(); + virtual ~tabWidget(); - void addTab( QWidget * _w, const QString & _name, - int _idx = -1 ); + void addTab( QWidget * _w, const QString & _name, int _idx = -1 ); void setActiveTab( int _idx ); diff --git a/include/tool.h b/include/tool.h index 7baa2cfab..e4c0d5e9b 100644 --- a/include/tool.h +++ b/include/tool.h @@ -2,6 +2,7 @@ * tool.h - declaration of class tool, standard interface for all tool plugins * * Copyright (c) 2006-2007 Javier Serrano Polo + * Copyright (c) 2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -26,24 +27,31 @@ #ifndef _TOOL_H #define _TOOL_H -#include - #include "plugin.h" +#include "plugin_view.h" -class tool : public QWidget, public plugin +class tool : public plugin { public: - tool( const descriptor * _descriptor ); + tool( const descriptor * _descriptor, model * _parent ); virtual ~tool(); // instantiate tool-plugin with given name or return NULL // on failure - static tool * FASTCALL instantiate( const QString & _plugin_name ); + static tool * FASTCALL instantiate( const QString & _plugin_name, + model * _parent ); } ; +class toolView : public pluginView +{ +public: + toolView( tool * _tool, QWidget * _parent ); + +} ; + #endif diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index b8c519d05..d66d55dee 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -216,7 +216,7 @@ Uint32 audioFileProcessor::getBeatLen( notePlayHandle * _n ) const -instrumentView * audioFileProcessor::createView( QWidget * _parent ) +pluginView * audioFileProcessor::instantiateView( QWidget * _parent ) { return( new audioFileProcessorView( this, _parent ) ); } @@ -600,7 +600,7 @@ extern "C" { // neccessary for getting instance out of shared lib -plugin * lmms_plugin_main( void * _data ) +plugin * lmms_plugin_main( model *, void * _data ) { return( new audioFileProcessor( static_cast( _data ) ) ); diff --git a/plugins/audio_file_processor/audio_file_processor.h b/plugins/audio_file_processor/audio_file_processor.h index 39c982226..ce6b6f2eb 100644 --- a/plugins/audio_file_processor/audio_file_processor.h +++ b/plugins/audio_file_processor/audio_file_processor.h @@ -30,6 +30,7 @@ #include #include "instrument.h" +#include "instrument_view.h" #include "sample_buffer.h" #include "volume_knob.h" #include "pixmap_button.h" @@ -73,7 +74,7 @@ public: return( 128 ); } - virtual instrumentView * createView( QWidget * _parent ); + virtual pluginView * instantiateView( QWidget * _parent ); public slots: diff --git a/plugins/bass_booster/bass_booster.cpp b/plugins/bass_booster/bass_booster.cpp index 59cbf0472..e8c9f4bce 100644 --- a/plugins/bass_booster/bass_booster.cpp +++ b/plugins/bass_booster/bass_booster.cpp @@ -51,9 +51,9 @@ plugin::descriptor bassbooster_plugin_descriptor = -bassBoosterEffect::bassBoosterEffect( +bassBoosterEffect::bassBoosterEffect( model * _parent, const descriptor::subPluginFeatures::key * _key ) : - effect( &bassbooster_plugin_descriptor, _key ), + effect( &bassbooster_plugin_descriptor, _parent, _key ), m_bbFX( effectLib::fastBassBoost<>( 70.0f, 1.0f, 2.8f ) ) { } @@ -71,7 +71,7 @@ bassBoosterEffect::~bassBoosterEffect() bool FASTCALL bassBoosterEffect::processAudioBuffer( surroundSampleFrame * _buf, const fpp_t _frames ) { - if( isBypassed() || !isRunning () ) + if( !isEnabled() || !isRunning () ) { return( FALSE ); } @@ -114,9 +114,9 @@ extern "C" { // neccessary for getting instance out of shared lib -plugin * lmms_plugin_main( void * _data ) +plugin * lmms_plugin_main( model * _parent, void * _data ) { - return( new bassBoosterEffect( + return( new bassBoosterEffect( _parent, static_cast( _data ) ) ); } diff --git a/plugins/bass_booster/bass_booster.h b/plugins/bass_booster/bass_booster.h index e520cccc1..108db8fa1 100644 --- a/plugins/bass_booster/bass_booster.h +++ b/plugins/bass_booster/bass_booster.h @@ -40,7 +40,8 @@ class bassBoosterEffect : public effect { public: - bassBoosterEffect( const descriptor::subPluginFeatures::key * _key ); + bassBoosterEffect( model * _parent, + const descriptor::subPluginFeatures::key * _key ); virtual ~bassBoosterEffect(); virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf, const fpp_t _frames ); diff --git a/plugins/kicker/kicker.cpp b/plugins/kicker/kicker.cpp index 1e2a498b5..27904b3e9 100644 --- a/plugins/kicker/kicker.cpp +++ b/plugins/kicker/kicker.cpp @@ -178,7 +178,7 @@ void kickerInstrument::deleteNotePluginData( notePlayHandle * _n ) -instrumentView * kickerInstrument::createView( QWidget * _parent ) +pluginView * kickerInstrument::instantiateView( QWidget * _parent ) { return( new kickerInstrumentView( this, _parent ) ); } @@ -255,7 +255,7 @@ extern "C" { // neccessary for getting instance out of shared lib -plugin * lmms_plugin_main( void * _data ) +plugin * lmms_plugin_main( model *, void * _data ) { return( new kickerInstrument( static_cast( _data ) ) ); diff --git a/plugins/kicker/kicker.h b/plugins/kicker/kicker.h index 152a5c746..0338ffca2 100644 --- a/plugins/kicker/kicker.h +++ b/plugins/kicker/kicker.h @@ -27,6 +27,7 @@ #define _KICKER_H #include "instrument.h" +#include "instrument_view.h" #include "knob.h" @@ -56,7 +57,7 @@ public: return( 512 ); } - virtual instrumentView * createView( QWidget * _parent ); + virtual pluginView * instantiateView( QWidget * _parent ); private: diff --git a/plugins/ladspa_browser/ladspa_browser.cpp b/plugins/ladspa_browser/ladspa_browser.cpp index e71baef46..4ce460ed0 100644 --- a/plugins/ladspa_browser/ladspa_browser.cpp +++ b/plugins/ladspa_browser/ladspa_browser.cpp @@ -2,7 +2,7 @@ * ladspa_browser.cpp - dialog to display information about installed LADSPA * plugins * - * Copyright (c) 2006-2007 Danny McRae + * Copyright (c) 2006-2008 Danny McRae * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -73,7 +73,32 @@ plugin * lmms_plugin_main( void * _data ) ladspaBrowser::ladspaBrowser( void ) : - tool( &ladspa_browser_plugin_descriptor ) + tool( &ladspa_browser_plugin_descriptor, NULL ) +{ +} + + + + +ladspaBrowser::~ladspaBrowser() +{ +} + + + + +QString ladspaBrowser::nodeName( void ) const +{ + return( ladspa_browser_plugin_descriptor.name ); +} + + + + + + +ladspaBrowserView::ladspaBrowserView( tool * _tool, QWidget * _parent ) : + toolView( _tool, _parent ) { QHBoxLayout * hlayout = new QHBoxLayout( this ); hlayout->setSpacing( 0 ); @@ -160,22 +185,14 @@ ladspaBrowser::ladspaBrowser( void ) : -ladspaBrowser::~ladspaBrowser() +ladspaBrowserView::~ladspaBrowserView() { } -QString ladspaBrowser::nodeName( void ) const -{ - return( ladspa_browser_plugin_descriptor.name ); -} - - - - -QWidget * ladspaBrowser::createTab( QWidget * _parent, const QString & _txt, +QWidget * ladspaBrowserView::createTab( QWidget * _parent, const QString & _txt, ladspaPluginType _type ) { QWidget * tab = new QWidget( _parent ); @@ -205,7 +222,7 @@ QWidget * ladspaBrowser::createTab( QWidget * _parent, const QString & _txt, -void ladspaBrowser::showPorts( const ladspa_key_t & _key ) +void ladspaBrowserView::showPorts( const ladspa_key_t & _key ) { ladspaPortDialog ports( _key ); ports.exec(); diff --git a/plugins/ladspa_browser/ladspa_browser.h b/plugins/ladspa_browser/ladspa_browser.h index 0f357ce92..db27616ce 100644 --- a/plugins/ladspa_browser/ladspa_browser.h +++ b/plugins/ladspa_browser/ladspa_browser.h @@ -2,7 +2,7 @@ * ladspa_browser.h - dialog to display information about installed LADSPA * plugins * - * Copyright (c) 2006-2007 Danny McRae + * Copyright (c) 2006-2008 Danny McRae * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -35,14 +35,12 @@ class tabBar; -class ladspaBrowser : public tool +class ladspaBrowserView : public toolView { Q_OBJECT public: - ladspaBrowser( void ); - virtual ~ladspaBrowser(); - - virtual QString nodeName( void ) const; + ladspaBrowserView( tool * _tool, QWidget * _parent ); + virtual ~ladspaBrowserView(); public slots: @@ -59,4 +57,20 @@ private: } ; +class ladspaBrowser : public tool +{ +public: + ladspaBrowser( void ); + virtual ~ladspaBrowser(); + + virtual pluginView * instantiateView( QWidget * _parent ) + { + return( new ladspaBrowserView( this, _parent ) ); + } + + virtual QString nodeName( void ) const; + +} ; + + #endif diff --git a/plugins/ladspa_effect/ladspa_effect.cpp b/plugins/ladspa_effect/ladspa_effect.cpp index 200235393..152e96e10 100644 --- a/plugins/ladspa_effect/ladspa_effect.cpp +++ b/plugins/ladspa_effect/ladspa_effect.cpp @@ -59,8 +59,9 @@ plugin::descriptor ladspaeffect_plugin_descriptor = } -ladspaEffect::ladspaEffect( const descriptor::subPluginFeatures::key * _key ) : - effect( &ladspaeffect_plugin_descriptor, _key ), +ladspaEffect::ladspaEffect( model * _parent, + const descriptor::subPluginFeatures::key * _key ) : + effect( &ladspaeffect_plugin_descriptor, _parent, _key ), m_effName( "none" ), m_key( ladspaSubPluginFeatures::subPluginKeyToLadspaKey( _key ) /* ladspa_key_t( _cdata->settings.attribute( "label" ), @@ -464,15 +465,13 @@ void FASTCALL ladspaEffect::setControl( Uint16 _control, LADSPA_Data _value ) } -#undef indexOf - extern "C" { // neccessary for getting instance out of shared lib -plugin * lmms_plugin_main( void * _data ) +plugin * lmms_plugin_main( model * _parent, void * _data ) { - return( new ladspaEffect( + return( new ladspaEffect( _parent, static_cast( _data ) ) ); } diff --git a/plugins/ladspa_effect/ladspa_effect.h b/plugins/ladspa_effect/ladspa_effect.h index 2cdb0aaf4..610813a1f 100644 --- a/plugins/ladspa_effect/ladspa_effect.h +++ b/plugins/ladspa_effect/ladspa_effect.h @@ -1,7 +1,7 @@ /* * ladspa_effect.h - class for handling LADSPA effect plugins * - * Copyright (c) 2006-2007 Danny McRae + * Copyright (c) 2006-2008 Danny McRae * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -41,7 +41,8 @@ typedef QVector multi_proc_t; class ladspaEffect : public effect { public: - ladspaEffect( const descriptor::subPluginFeatures::key * _key ); + ladspaEffect( model * _parent, + const descriptor::subPluginFeatures::key * _key ); virtual ~ladspaEffect(); virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf, @@ -84,7 +85,7 @@ private: Uint16 m_effectChannels; Uint16 m_portCount; fpp_t m_bufferSize; - + const LADSPA_Descriptor * m_descriptor; QVector m_handles; diff --git a/plugins/stk/mallets/mallets.cpp b/plugins/stk/mallets/mallets.cpp index 662fdd956..a58665b6a 100644 --- a/plugins/stk/mallets/mallets.cpp +++ b/plugins/stk/mallets/mallets.cpp @@ -58,8 +58,8 @@ plugin::descriptor malletsstk_plugin_descriptor = } -malletsInstrument::malletsInstrument( instrumentTrack * _channel_track ): - instrument( _channel_track, &malletsstk_plugin_descriptor ), +malletsInstrument::malletsInstrument( instrumentTrack * _instrument_track ): + instrument( _instrument_track, &malletsstk_plugin_descriptor ), m_hardnessModel(64.0f, 0.0f, 128.0f, 0.1f, this), m_positionModel(64.0f, 0.0f, 128.0f, 0.1f, this), m_vibratoGainModel(64.0f, 0.0f, 128.0f, 0.1f, this), @@ -77,21 +77,21 @@ malletsInstrument::malletsInstrument( instrumentTrack * _channel_track ): m_presetsModel(this), m_spreadModel(0, 0, 255, 1, this) { - m_hardnessModel.setTrack( _channel_track ); - m_positionModel.setTrack( _channel_track ); - m_vibratoGainModel.setTrack( _channel_track ); - m_vibratoFreqModel.setTrack( _channel_track ); - m_stickModel.setTrack( _channel_track ); - m_modulatorModel.setTrack( _channel_track ); - m_crossfadeModel.setTrack( _channel_track ); - m_lfoSpeedModel.setTrack( _channel_track ); - m_lfoDepthModel.setTrack( _channel_track ); - m_adsrModel.setTrack( _channel_track ); - m_pressureModel.setTrack( _channel_track ); - m_motionModel.setTrack( _channel_track ); - m_velocityModel.setTrack( _channel_track ); - m_strikeModel.setTrack( _channel_track ); - m_spreadModel.setTrack( _channel_track ); + m_hardnessModel.setTrack( _instrument_track ); + m_positionModel.setTrack( _instrument_track ); + m_vibratoGainModel.setTrack( _instrument_track ); + m_vibratoFreqModel.setTrack( _instrument_track ); + m_stickModel.setTrack( _instrument_track ); + m_modulatorModel.setTrack( _instrument_track ); + m_crossfadeModel.setTrack( _instrument_track ); + m_lfoSpeedModel.setTrack( _instrument_track ); + m_lfoDepthModel.setTrack( _instrument_track ); + m_adsrModel.setTrack( _instrument_track ); + m_pressureModel.setTrack( _instrument_track ); + m_motionModel.setTrack( _instrument_track ); + m_velocityModel.setTrack( _instrument_track ); + m_strikeModel.setTrack( _instrument_track ); + m_spreadModel.setTrack( _instrument_track ); // ModalBar m_presetsModel.addItem( tr( "Marimba" ) ); @@ -299,7 +299,7 @@ void malletsInstrument::deleteNotePluginData( notePlayHandle * _n ) -instrumentView * malletsInstrument::createView( QWidget * _parent ) +pluginView * malletsInstrument::instantiateView( QWidget * _parent ) { return( new malletsInstrumentView( this, _parent ) ); } @@ -307,7 +307,8 @@ instrumentView * malletsInstrument::createView( QWidget * _parent ) -malletsInstrumentView::malletsInstrumentView( malletsInstrument * _instrument, QWidget * _parent ) : +malletsInstrumentView::malletsInstrumentView( malletsInstrument * _instrument, + QWidget * _parent ) : instrumentView( _instrument, _parent ) { _instrument->m_filesMissing = @@ -673,7 +674,7 @@ extern "C" { // neccessary for getting instance out of shared lib -plugin * lmms_plugin_main( void * _data ) +plugin * lmms_plugin_main( model *, void * _data ) { return( new malletsInstrument( static_cast( _data ) ) ); } diff --git a/plugins/stk/mallets/mallets.h b/plugins/stk/mallets/mallets.h index 31a396642..f0f18a32e 100644 --- a/plugins/stk/mallets/mallets.h +++ b/plugins/stk/mallets/mallets.h @@ -31,6 +31,7 @@ #include "combobox.h" #include "instrument.h" +#include "instrument_view.h" #include "knob.h" #include "note_play_handle.h" #include "led_checkbox.h" @@ -133,7 +134,7 @@ public: virtual QString nodeName( void ) const; - virtual instrumentView * createView( QWidget * _parent ); + virtual pluginView * instantiateView( QWidget * _parent ); private: knobModel m_hardnessModel; diff --git a/plugins/vst_effect/vst_effect.cpp b/plugins/vst_effect/vst_effect.cpp index 31f5d09d3..22b3f46d6 100644 --- a/plugins/vst_effect/vst_effect.cpp +++ b/plugins/vst_effect/vst_effect.cpp @@ -82,7 +82,7 @@ vstEffect::~vstEffect() bool FASTCALL vstEffect::processAudioBuffer( surroundSampleFrame * _buf, const fpp_t _frames ) { - if( isBypassed() || !isRunning () ) + if( !isEnabled() || !isRunning () ) { return( FALSE ); } diff --git a/src/audio/audio_port.cpp b/src/audio/audio_port.cpp index faa1b31f6..d4cc53c84 100644 --- a/src/audio/audio_port.cpp +++ b/src/audio/audio_port.cpp @@ -3,7 +3,7 @@ /* * audio_port.cpp - base-class for objects providing sound at a port * - * Copyright (c) 2004-2007 Tobias Doerffel + * Copyright (c) 2004-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -33,7 +33,7 @@ #include "engine.h" -audioPort::audioPort( const QString & _name ) : +audioPort::audioPort( const QString & _name, track * _track ) : m_bufferUsage( NONE ), m_firstBuffer( new surroundSampleFrame[ engine::getMixer()->framesPerPeriod()] ), @@ -42,7 +42,7 @@ audioPort::audioPort( const QString & _name ) : m_extOutputEnabled( FALSE ), m_nextFxChannel( -1 ), m_name( "unnamed port" ), - m_effects( new effectChain ), + m_effects( this, _track ), m_frames( engine::getMixer()->framesPerPeriod() ) { engine::getMixer()->clearAudioBuffer( m_firstBuffer, @@ -62,7 +62,6 @@ audioPort::~audioPort() engine::getMixer()->removeAudioPort( this ); delete[] m_firstBuffer; delete[] m_secondBuffer; - delete m_effects; } diff --git a/src/core/effect.cpp b/src/core/effect.cpp index 57dd9b1ea..522414c6e 100644 --- a/src/core/effect.cpp +++ b/src/core/effect.cpp @@ -25,25 +25,27 @@ * */ -#include #include "effect.h" #include "engine.h" #include "dummy_effect.h" +#include "effect_chain.h" +#include "effect_view.h" effect::effect( const plugin::descriptor * _desc, + model * _parent, const descriptor::subPluginFeatures::key * _key ) : - plugin( _desc ), + plugin( _desc, _parent ), m_key( _key ? *_key : descriptor::subPluginFeatures::key() ), m_okay( TRUE ), m_noRun( FALSE ), m_running( FALSE ), - m_enabledModel( FALSE, FALSE, TRUE ), m_bufferCount( 0 ), - m_silenceTimeout( 10 ), - m_wetDryModel( 1.0f, 0.0f, 1.0f, 0.01f ), - m_gateModel( 0.0f, 0.0f, 1.0f, 0.01f ) + m_enabledModel( TRUE, FALSE, TRUE, boolModel::defaultRelStep(), this ), + m_wetDryModel( 1.0f, 0.0f, 1.0f, 0.01f, this ), + m_gateModel( 0.0f, 0.0f, 1.0f, 0.01f, this ), + m_autoQuitModel( 1.0f, 1.0f, 8000.0f, 100.0f, this ) { } @@ -57,7 +59,45 @@ effect::~effect() -bool FASTCALL effect::processAudioBuffer( surroundSampleFrame * _buf, +void effect::saveSettings( QDomDocument & _doc, QDomElement & _this ) +{ + _this.setAttribute( "on", m_enabledModel.value() ); + _this.setAttribute( "wet", m_wetDryModel.value() ); + _this.setAttribute( "autoquit", m_autoQuitModel.value() ); + _this.setAttribute( "gate", m_gateModel.value() ); +// m_controlView->saveState( _doc, _this ); +} + + + + +void effect::loadSettings( const QDomElement & _this ) +{ + m_enabledModel.setValue( _this.attribute( "on" ).toInt() ); + m_wetDryModel.setValue( _this.attribute( "wet" ).toFloat() ); + m_autoQuitModel.setValue( _this.attribute( "autoquit" ).toFloat() ); + m_gateModel.setValue( _this.attribute( "gate" ).toFloat() ); +/* + QDomNode node = _this.firstChild(); + while( !node.isNull() ) + { + if( node.isElement() ) + { + if( m_controlView->nodeName() == node.nodeName() ) + { + m_controlView->restoreState( + node.toElement() ); + } + } + node = node.nextSibling(); + }*/ +} + + + + + +bool effect::processAudioBuffer( surroundSampleFrame * _buf, const fpp_t _frames ) { return( FALSE ); @@ -65,18 +105,12 @@ bool FASTCALL effect::processAudioBuffer( surroundSampleFrame * _buf, -/* -void FASTCALL effect::setGate( float _level ) -{ - m_gate = _level * _level * m_processors * - engine::getMixer()->framesPerPeriod(); -} -*/ effect * effect::instantiate( const QString & _plugin_name, + model * _parent, descriptor::subPluginFeatures::key * _key ) { - plugin * p = plugin::instantiate( _plugin_name, _key ); + plugin * p = plugin::instantiate( _plugin_name, _parent, _key ); // check whether instantiated plugin is an instrument if( dynamic_cast( p ) != NULL ) { @@ -86,9 +120,16 @@ effect * effect::instantiate( const QString & _plugin_name, // not quite... so delete plugin and return dummy instrument delete p; - return( new dummyEffect() ); + return( new dummyEffect( _parent ) ); } + +pluginView * effect::instantiateView( QWidget * _parent ) +{ + return( new effectView( this, _parent ) ); +} + + #endif diff --git a/src/core/effect_chain.cpp b/src/core/effect_chain.cpp index 0ea0f4261..085dab678 100644 --- a/src/core/effect_chain.cpp +++ b/src/core/effect_chain.cpp @@ -4,6 +4,7 @@ * effect_chain.cpp - class for processing and effects chain * * Copyright (c) 2006-2008 Danny McRae + * Copyright (c) 2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -31,7 +32,10 @@ -effectChain::effectChain( void ) : +effectChain::effectChain( audioPort * _port, track * _track ) : + model( /*_track*/ NULL ), + m_port( _port ), + m_track( _track ), m_enabledModel( FALSE, FALSE, TRUE ) { } @@ -41,26 +45,89 @@ effectChain::effectChain( void ) : effectChain::~effectChain() { - for( effect_list_t::size_type eff = 0; eff < m_effects.count(); eff++ ) + deleteAllPlugins(); +} + + + + +void effectChain::saveSettings( QDomDocument & _doc, QDomElement & _this ) +{ + _this.setAttribute( "fxenabled", m_enabledModel.value() ); + _this.setAttribute( "numofeffects", m_effects.count() ); + for( effectList::iterator it = m_effects.begin(); + it != m_effects.end(); it++ ) { - delete m_effects[eff]; + QDomElement ef = ( *it )->saveState( _doc, _this ); + ef.setAttribute( "name", ( *it )->getDescriptor()->name ); + ef.setAttribute( "key", ( *it )->getKey().dumpBase64() ); + } +} + + + + +void effectChain::loadSettings( const QDomElement & _this ) +{ +// deleteAllPlugins(); + for( int i = 0; i < m_effects.count(); ++i ) + { + delete m_effects[i]; } m_effects.clear(); + + m_enabledModel.setValue( _this.attribute( "fxenabled" ).toInt() ); + + const int plugin_cnt = _this.attribute( "numofeffects" ).toInt(); + + QDomNode node = _this.firstChild(); + for( int i = 0; i < plugin_cnt; i++ ) + { + if( node.isElement() && node.nodeName() == "effect" ) + { + QDomElement cn = node.toElement(); + const QString name = cn.attribute( "name" ); + // we have this really convenient key-ctor + // which takes a QString and decodes the + // base64-data inside :-) + effectKey key( cn.attribute( "key" ) ); + effect * e = effect::instantiate( name, this, &key ); + m_effects.push_back( e ); + // TODO: somehow detect if effect is sub-plugin-capable + // but couldn't load sub-plugin with requsted key + if( node.isElement() ) + { + if( e->nodeName() == node.nodeName() ) + { + e->restoreState( node.toElement() ); + } + } + } + node = node.nextSibling(); + } + + emit dataChanged(); } -void FASTCALL effectChain::appendEffect( effect * _effect ) + +void effectChain::appendEffect( effect * _effect ) { engine::getMixer()->lock(); + _effect->m_enabledModel.setTrack( m_track ); + _effect->m_wetDryModel.setTrack( m_track ); + _effect->m_gateModel.setTrack( m_track ); + _effect->m_autoQuitModel.setTrack( m_track ); m_effects.append( _effect ); engine::getMixer()->unlock(); + emit dataChanged(); } -void FASTCALL effectChain::removeEffect( effect * _effect ) +void effectChain::removeEffect( effect * _effect ) { engine::getMixer()->lock(); m_effects.erase( qFind( m_effects.begin(), m_effects.end(), _effect ) ); @@ -70,12 +137,12 @@ void FASTCALL effectChain::removeEffect( effect * _effect ) -void FASTCALL effectChain::moveDown( effect * _effect ) +void effectChain::moveDown( effect * _effect ) { if( _effect != m_effects.last() ) { int i = 0; - for( effect_list_t::iterator it = m_effects.begin(); + for( effectList::iterator it = m_effects.begin(); it != m_effects.end(); it++, i++ ) { if( *it == _effect ) @@ -93,12 +160,12 @@ void FASTCALL effectChain::moveDown( effect * _effect ) -void FASTCALL effectChain::moveUp( effect * _effect ) +void effectChain::moveUp( effect * _effect ) { if( _effect != m_effects.first() ) { int i = 0; - for( effect_list_t::iterator it = m_effects.begin(); + for( effectList::iterator it = m_effects.begin(); it != m_effects.end(); it++, i++ ) { if( *it == _effect ) @@ -116,7 +183,7 @@ void FASTCALL effectChain::moveUp( effect * _effect ) -bool FASTCALL effectChain::processAudioBuffer( surroundSampleFrame * _buf, +bool effectChain::processAudioBuffer( surroundSampleFrame * _buf, const fpp_t _frames ) { if( m_enabledModel.value() == FALSE ) @@ -124,7 +191,7 @@ bool FASTCALL effectChain::processAudioBuffer( surroundSampleFrame * _buf, return( FALSE ); } bool more_effects = FALSE; - for( effect_list_t::iterator it = m_effects.begin(); + for( effectList::iterator it = m_effects.begin(); it != m_effects.end(); it++ ) { more_effects |= ( *it )->processAudioBuffer( _buf, _frames ); @@ -142,7 +209,7 @@ void effectChain::startRunning( void ) return; } - for( effect_list_t::iterator it = m_effects.begin(); + for( effectList::iterator it = m_effects.begin(); it != m_effects.end(); it++ ) { ( *it )->startRunning(); @@ -161,7 +228,7 @@ bool effectChain::isRunning( void ) bool running = FALSE; - for( effect_list_t::iterator it = m_effects.begin(); + for( effectList::iterator it = m_effects.begin(); it != m_effects.end() || !running; it++ ) { running = ( *it )->isRunning() && running; @@ -170,4 +237,16 @@ bool effectChain::isRunning( void ) } + + +void effectChain::deleteAllPlugins( void ) +{ + for( int i = 0; i < m_effects.count(); ++i ) + { + delete m_effects[i]; + } + m_effects.clear(); +} + + #endif diff --git a/src/core/effect_control_dialog.cpp b/src/core/effect_control_dialog.cpp index 42f17f664..175844ee4 100644 --- a/src/core/effect_control_dialog.cpp +++ b/src/core/effect_control_dialog.cpp @@ -35,6 +35,7 @@ effectControlDialog::effectControlDialog( QWidget * _parent, effect * _eff ) : QWidget( _parent ), + modelView( _eff ), m_effect( _eff ) { setWindowTitle( m_effect->publicName() ); diff --git a/src/core/effect_select_dialog.cpp b/src/core/effect_select_dialog.cpp index 3c058fee6..5d716d2b0 100644 --- a/src/core/effect_select_dialog.cpp +++ b/src/core/effect_select_dialog.cpp @@ -47,7 +47,7 @@ effectSelectDialog::effectSelectDialog( QWidget * _parent ) : vlayout->setSpacing( 10 ); vlayout->setMargin( 10 ); - effectList * elist = new effectList( this ); + effectListWidget * elist = new effectListWidget( this ); elist->setMinimumSize( 500, 400 ); connect( elist, SIGNAL( doubleClicked( const effectKey & ) ), this, SLOT( selectPlugin() ) ); @@ -107,11 +107,12 @@ effectSelectDialog::~effectSelectDialog() -effect * effectSelectDialog::instantiateSelectedPlugin( void ) +effect * effectSelectDialog::instantiateSelectedPlugin( effectChain * _parent ) { if( !m_currentSelection.name.isEmpty() && m_currentSelection.desc ) { return( effect::instantiate( m_currentSelection.desc->name, + _parent, &m_currentSelection ) ); } return( NULL ); @@ -148,7 +149,7 @@ void effectSelectDialog::selectPlugin( void ) -effectList::effectList( QWidget * _parent ) : +effectListWidget::effectListWidget( QWidget * _parent ) : QWidget( _parent ), m_descriptionWidget( NULL ) { @@ -226,14 +227,14 @@ effectList::effectList( QWidget * _parent ) : -effectList::~effectList() +effectListWidget::~effectListWidget() { } -void effectList::rowChanged( int _pluginIndex ) +void effectListWidget::rowChanged( int _pluginIndex ) { delete m_descriptionWidget; m_descriptionWidget = NULL; @@ -268,7 +269,7 @@ void effectList::rowChanged( int _pluginIndex ) -void effectList::onDoubleClicked( QListWidgetItem * _item ) +void effectListWidget::onDoubleClicked( QListWidgetItem * _item ) { emit( doubleClicked( m_currentSelection ) ); } @@ -276,7 +277,7 @@ void effectList::onDoubleClicked( QListWidgetItem * _item ) -void effectList::onAddButtonReleased() +void effectListWidget::onAddButtonReleased() { emit( addPlugin( m_currentSelection ) ); } @@ -284,7 +285,7 @@ void effectList::onAddButtonReleased() -void effectList::resizeEvent( QResizeEvent * ) +void effectListWidget::resizeEvent( QResizeEvent * ) { //m_descriptionWidget->setFixedWidth( width() - 40 ); } diff --git a/src/core/effect_tab_widget.cpp b/src/core/effect_tab_widget.cpp deleted file mode 100644 index f6ef459d7..000000000 --- a/src/core/effect_tab_widget.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef SINGLE_SOURCE_COMPILE - -/* - * effect_tab_widget.cpp - tab-widget in channel-track-window for setting up - * effects - * - * Copyright (c) 2006-2008 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 "effect_tab_widget.h" - - -#include -#include - - -#include "audio_port.h" -#include "effect_select_dialog.h" -#include "embed.h" -#include "group_box.h" -#include "instrument_track.h" -#include "rack_plugin.h" -#include "rack_view.h" -#include "sample_track.h" -#include "tooltip.h" -#include "automatable_model_templates.h" - - - -effectTabWidget::effectTabWidget( instrumentTrack * _track, - audioPort * _port ) : - QWidget( _track->tabWidgetParent() ), - m_track( dynamic_cast( _track ) ), - m_port( _port ) -{ - m_port->getEffects()->m_enabledModel.setTrack( m_track ); - setupWidget(); -} - - - - -effectTabWidget::effectTabWidget( QWidget * _parent, - sampleTrack * _track, - audioPort * _port ) : - QWidget( _parent ), - m_track( dynamic_cast( _track ) ), - m_port( _port ) -{ - m_port->getEffects()->m_enabledModel.setTrack( m_track ); - setupWidget(); -} - - - - -effectTabWidget::~effectTabWidget() -{ -} - - - - -void effectTabWidget::setupWidget( void ) -{ - m_effectsGroupBox = new groupBox( tr( "EFFECTS CHAIN" ), this ); - m_effectsGroupBox->setModel( &m_port->getEffects()->m_enabledModel ); - m_effectsGroupBox->setGeometry( 2, 2, 242, 244 ); - - m_rack = new rackView( m_effectsGroupBox, m_track, m_port ); - m_rack->move( 6, 22 ); - - m_addButton = new QPushButton( m_effectsGroupBox/*, "Add Effect"*/ ); - m_addButton->setText( tr( "Add" ) ); - m_addButton->move( 75, 210 ); - connect( m_addButton, SIGNAL( clicked( void ) ), - this, SLOT( addEffect( void ) ) ); -} - - - - -void effectTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _this ) -{ - _this.setAttribute( "fxenabled", - m_port->getEffects()->m_enabledModel.value() ); - m_rack->saveState( _doc, _this ); - -} - - - - -void effectTabWidget::loadSettings( const QDomElement & _this ) -{ - m_port->getEffects()->m_enabledModel.setValue( - _this.attribute( "fxenabled" ).toInt() ); - - QDomNode node = _this.firstChild(); - while( !node.isNull() ) - { - if( node.isElement() ) - { - if( m_rack->nodeName() == node.nodeName() ) - { - m_rack->restoreState( node.toElement() ); - } - } - node = node.nextSibling(); - } -} - - - - -void effectTabWidget::addEffect( void ) -{ - effectSelectDialog esd( this ); - esd.exec(); - - if( esd.result() == QDialog::Rejected ) - { - return; - } - - effect * e = esd.instantiateSelectedPlugin(); - m_rack->addEffect( e ); -} - - - - -#include "effect_tab_widget.moc" - -#endif diff --git a/src/core/import_filter.cpp b/src/core/import_filter.cpp index c97c9b853..ed23273ca 100644 --- a/src/core/import_filter.cpp +++ b/src/core/import_filter.cpp @@ -36,7 +36,7 @@ importFilter::importFilter( const QString & _file_name, const descriptor * _descriptor ) : - plugin( _descriptor ), + plugin( _descriptor, NULL ), m_file( _file_name ) { } @@ -70,7 +70,7 @@ void importFilter::import( const QString & _file_to_import, { if( it->type == plugin::ImportFilter ) { - plugin * p = plugin::instantiate( it->name, s ); + plugin * p = plugin::instantiate( it->name, NULL, s ); if( dynamic_cast( p ) != NULL && dynamic_cast( p )->tryImport( _tc ) == TRUE ) diff --git a/src/core/instrument.cpp b/src/core/instrument.cpp index 48c0312eb..aedb4fb9d 100644 --- a/src/core/instrument.cpp +++ b/src/core/instrument.cpp @@ -26,6 +26,7 @@ #include "instrument.h" +#include "instrument_view.h" #include "automatable_model_templates.h" #include "instrument_track.h" #include "dummy_instrument.h" @@ -34,8 +35,7 @@ instrument::instrument( instrumentTrack * _instrument_track, const descriptor * _descriptor ) : - plugin( _descriptor ), - model( /* _instrument_track */ NULL ), + plugin( _descriptor, NULL/* _instrument_track*/ ), m_instrumentTrack( _instrument_track ) { } @@ -82,7 +82,8 @@ f_cnt_t instrument::beatLen( notePlayHandle * ) const instrument * instrument::instantiate( const QString & _plugin_name, instrumentTrack * _instrument_track ) { - plugin * p = plugin::instantiate( _plugin_name, _instrument_track ); + plugin * p = plugin::instantiate( _plugin_name, /*_instrument_track*/ NULL, + _instrument_track ); // check whether instantiated plugin is an instrument if( dynamic_cast( p ) != NULL ) { @@ -105,16 +106,6 @@ bool instrument::isFromTrack( const track * _track ) const -instrumentView * instrument::createEditor( QWidget * _parent ) -{ - instrumentView * i = createView( _parent ); - i->setModel( this ); - return( i ); -} - - - - void instrument::applyRelease( sampleFrame * buf, const notePlayHandle * _n ) { const fpp_t frames = _n->framesLeftForCurrentPeriod(); @@ -144,8 +135,7 @@ void instrument::applyRelease( sampleFrame * buf, const notePlayHandle * _n ) instrumentView::instrumentView( instrument * _instrument, QWidget * _parent ) : - QWidget( _parent ), - modelView() + pluginView( _instrument, _parent ) { setModel( _instrument ); setFixedSize( 250, 250 ); diff --git a/src/core/main_window.cpp b/src/core/main_window.cpp index f8ce51b99..443a34823 100644 --- a/src/core/main_window.cpp +++ b/src/core/main_window.cpp @@ -57,6 +57,7 @@ #include "side_bar.h" #include "config_mgr.h" #include "mixer.h" +#include "plugin_view.h" #include "project_notes.h" #include "setup_dialog.h" #include "audio_dummy.h" @@ -76,7 +77,7 @@ mainWindow::mainWindow( void ) : m_workspace( NULL ), m_templatesMenu( NULL ), m_recentlyOpenedProjectsMenu( NULL ), - m_tools_menu( NULL ), + m_toolsMenu( NULL ), m_modified( FALSE ) { setAttribute( Qt::WA_DeleteOnClose ); @@ -421,7 +422,7 @@ void mainWindow::finalize( void ) configManager::inst(), SLOT( exec() ) ); - m_tools_menu = new QMenu( this ); + m_toolsMenu = new QMenu( this ); QVector pluginDescriptors; plugin::getDescriptorsOfAvailPlugins( pluginDescriptors ); for( QVector::iterator it = @@ -430,14 +431,15 @@ void mainWindow::finalize( void ) { if( it->type == plugin::Tool ) { - m_tools_menu->addAction( *it->logo, it->public_name ); - m_tools.push_back( tool::instantiate( it->name ) ); + m_toolsMenu->addAction( *it->logo, it->public_name ); + m_tools.push_back( tool::instantiate( it->name, + /*this*/NULL )->createView( this ) ); } } - if( !m_tools_menu->isEmpty() ) + if( !m_toolsMenu->isEmpty() ) { - menuBar()->addMenu( m_tools_menu )->setText( tr( "&Tools" ) ); - connect( m_tools_menu, SIGNAL( triggered( QAction * ) ), + menuBar()->addMenu( m_toolsMenu )->setText( tr( "&Tools" ) ); + connect( m_toolsMenu, SIGNAL( triggered( QAction * ) ), this, SLOT( showTool( QAction * ) ) ); } @@ -954,13 +956,13 @@ void mainWindow::fillTemplatesMenu( void ) void mainWindow::showTool( QAction * _idx ) { - tool * t = m_tools[m_tools_menu->actions().indexOf( _idx )]; - t->show(); + pluginView * p = m_tools[m_toolsMenu->actions().indexOf( _idx )]; + p->show(); if( m_workspace ) { - t->parentWidget()->show(); + p->parentWidget()->show(); } - t->setFocus(); + p->setFocus(); } diff --git a/src/core/plugin.cpp b/src/core/plugin.cpp index ad4a863ff..aa8070432 100644 --- a/src/core/plugin.cpp +++ b/src/core/plugin.cpp @@ -53,7 +53,9 @@ static plugin::descriptor dummy_plugin_descriptor = -plugin::plugin( const descriptor * _descriptor ) : +plugin::plugin( const descriptor * _descriptor, model * _parent ) : + journallingObject(), + model( _parent ), m_descriptor( _descriptor ) { if( dummy_plugin_descriptor.logo == NULL ) @@ -92,7 +94,8 @@ QString plugin::getParameter( const QString & ) -plugin * plugin::instantiate( const QString & _plugin_name, void * _data ) +plugin * plugin::instantiate( const QString & _plugin_name, model * _parent, + void * _data ) { QLibrary plugin_lib( configManager::inst()->pluginDir() + _plugin_name ); @@ -118,7 +121,7 @@ plugin * plugin::instantiate( const QString & _plugin_name, void * _data ) QMessageBox::Default ); return( new dummyPlugin() ); } - plugin * inst = inst_hook( _data ); + plugin * inst = inst_hook( _parent, _data ); return( inst ); } @@ -175,5 +178,17 @@ void plugin::getDescriptorsOfAvailPlugins( QVector & _plugin_descs ) +pluginView * plugin::createView( QWidget * _parent ) +{ + pluginView * pv = instantiateView( _parent ); + if( pv != NULL ) + { + pv->setModel( this ); + } + return( pv ); +} + + + #endif diff --git a/src/core/sample_play_handle.cpp b/src/core/sample_play_handle.cpp index a1b3aa820..6e5bbdd8d 100644 --- a/src/core/sample_play_handle.cpp +++ b/src/core/sample_play_handle.cpp @@ -42,7 +42,7 @@ samplePlayHandle::samplePlayHandle( const QString & _sample_file ) : m_sampleBuffer( new sampleBuffer( _sample_file ) ), m_doneMayReturnTrue( TRUE ), m_frame( 0 ), - m_audioPort( new audioPort( "samplePlayHandle" ) ), + m_audioPort( new audioPort( "samplePlayHandle", NULL ) ), m_ownAudioPort( TRUE ), m_defaultVolumeModel( 1.0f, 0.0f, 4.0f, 0.001f/* this*/ ), m_volumeModel( &m_defaultVolumeModel ), @@ -59,7 +59,7 @@ samplePlayHandle::samplePlayHandle( sampleBuffer * _sample_buffer ) : m_sampleBuffer( sharedObject::ref( _sample_buffer ) ), m_doneMayReturnTrue( TRUE ), m_frame( 0 ), - m_audioPort( new audioPort( "samplePlayHandle" ) ), + m_audioPort( new audioPort( "samplePlayHandle", NULL ) ), m_ownAudioPort( TRUE ), m_defaultVolumeModel( 1.0f, 0.0f, 4.0f, 0.001f/* this*/ ), m_volumeModel( &m_defaultVolumeModel ), diff --git a/src/core/surround_area.cpp b/src/core/surround_area.cpp index b44ae48c5..303a4bf28 100644 --- a/src/core/surround_area.cpp +++ b/src/core/surround_area.cpp @@ -4,7 +4,7 @@ * surround_area.cpp - a widget for setting position of a channel + * calculation of volume for each speaker * - * Copyright (c) 2004-2007 Tobias Doerffel + * Copyright (c) 2004-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -50,10 +50,8 @@ QPixmap * surroundArea::s_backgroundArtwork = NULL; surroundArea::surroundArea( QWidget * _parent, const QString & _name ) : QWidget( _parent ), - modelView() + modelView( new surroundAreaModel( NULL, NULL, TRUE ) ) { - setModel( new surroundAreaModel( NULL, NULL, TRUE ) ); - if( s_backgroundArtwork == NULL ) { s_backgroundArtwork = new QPixmap( embed::getIconPixmap( diff --git a/src/core/tool.cpp b/src/core/tool.cpp index c755a75f6..eaf6ce80a 100644 --- a/src/core/tool.cpp +++ b/src/core/tool.cpp @@ -36,23 +36,9 @@ -tool::tool( const descriptor * _descriptor ) : - plugin( _descriptor ) +tool::tool( const descriptor * _descriptor, model * _parent ) : + plugin( _descriptor, _parent ) { - QWidget * window; - if( engine::getMainWindow()->workspace() ) - { - engine::getMainWindow()->workspace()->addSubWindow( this ); - window = parentWidget(); - window->setAttribute( Qt::WA_DeleteOnClose, FALSE ); - } - else - { - window = this; - } - - window->setWindowTitle( _descriptor->public_name ); - window->setWindowIcon( *_descriptor->logo ); } @@ -65,11 +51,11 @@ tool::~tool() -tool * tool::instantiate( const QString & _plugin_name ) +tool * tool::instantiate( const QString & _plugin_name, model * _parent ) { - plugin * p = plugin::instantiate( _plugin_name, NULL ); - // check whether instantiated plugin is an instrument - if( dynamic_cast( p ) != NULL ) + plugin * p = plugin::instantiate( _plugin_name, _parent, NULL ); + // check whether instantiated plugin is a tool + if( p->type() == Tool ) { // everything ok, so return pointer return( dynamic_cast( p ) ); @@ -83,4 +69,25 @@ tool * tool::instantiate( const QString & _plugin_name ) + +toolView::toolView( tool * _tool, QWidget * _parent ) : + pluginView( _tool, _parent ) +{ + QWidget * window; + if( engine::getMainWindow()->workspace() ) + { + engine::getMainWindow()->workspace()->addSubWindow( this ); + window = parentWidget(); + window->setAttribute( Qt::WA_DeleteOnClose, FALSE ); + } + else + { + window = this; + } + + window->setWindowTitle( _tool->publicName() ); + window->setWindowIcon( *_tool->getDescriptor()->logo ); +} + + #endif diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index ca5a1344e..d2bb1c1f6 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -50,7 +50,7 @@ #include "debug.h" #include "effect_board.h" #include "effect_chain.h" -#include "effect_tab_widget.h" +#include "effect_rack_view.h" #include "embed.h" #include "engine.h" #include "envelope_tab_widget.h" @@ -66,6 +66,7 @@ #include "note_play_handle.h" #include "pattern.h" #include "piano_widget.h" +#include "plugin_view.h" #include "sample_play_handle.h" #include "song_editor.h" #include "string_pair_drag.h" @@ -100,7 +101,7 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : m_trackType( INSTRUMENT_TRACK ), m_midiPort( engine::getMixer()->getMIDIClient()->addPort( this, tr( "unnamed_channel" ) ) ), - m_audioPort( new audioPort( tr( "unnamed_channel" ) ) ), + m_audioPort( tr( "unnamed_channel" ), this ), m_notes(), m_baseNoteModel( 0, 0, NOTES_PER_OCTAVE * OCTAVES - 1, 1/* this */ ), m_volumeModel( DEFAULT_VOLUME, MIN_VOLUME, MAX_VOLUME, @@ -109,7 +110,9 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : m_effectChannelModel( DEFAULT_EFFECT_CHANNEL, MIN_EFFECT_CHANNEL, MAX_EFFECT_CHANNEL /* this */ ), +// m_effects( /* this */ NULL ), m_instrument( NULL ), + m_instrumentView( NULL ), m_midiInputAction( NULL ), m_midiOutputAction( NULL ) { @@ -248,10 +251,11 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : m_envWidget = new envelopeTabWidget( this ); m_arpWidget = new arpAndChordsTabWidget( this ); m_midiWidget = new midiTabWidget( this, m_midiPort ); - m_effWidget = new effectTabWidget( this, m_audioPort ); + m_effectRack = new effectRackView( m_audioPort.getEffects(), + m_tabWidget ); m_tabWidget->addTab( m_envWidget, tr( "ENV/LFO/FILTER" ), 1 ); m_tabWidget->addTab( m_arpWidget, tr( "ARP/CHORD" ), 2 ); - m_tabWidget->addTab( m_effWidget, tr( "FX" ), 3 ); + m_tabWidget->addTab( m_effectRack, tr( "FX" ), 3 ); m_tabWidget->addTab( m_midiWidget, tr( "MIDI" ), 4 ); // setup piano-widget @@ -323,8 +327,7 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : instrumentTrack::~instrumentTrack() { engine::getMixer()->removePlayHandles( this ); - delete m_effWidget; - delete m_audioPort; + delete m_effectRack; engine::getMixer()->getMIDIClient()->removePort( m_midiPort ); if( engine::getMainWindow()->workspace() ) @@ -450,7 +453,7 @@ void instrumentTrack::processAudioBuffer( sampleFrame * _buf, } float v_scale = (float) getVolume() / DEFAULT_VOLUME; - m_audioPort->getEffects()->startRunning(); + m_audioPort.getEffects()->startRunning(); // instruments using instrument-play-handles will call this method // without any knowledge about notes, so they pass NULL for _n, which @@ -465,7 +468,7 @@ void instrumentTrack::processAudioBuffer( sampleFrame * _buf, engine::getMixer()->bufferToPort( _buf, ( _n != NULL ) ? tMin( _n->framesLeftForCurrentPeriod(), _frames ) : _frames, - ( _n != NULL ) ? _n->offset() : 0, v, m_audioPort ); + ( _n != NULL ) ? _n->offset() : 0, v, &m_audioPort ); } @@ -664,7 +667,7 @@ void instrumentTrack::playNote( notePlayHandle * _n, bool _try_parallelizing ) // in last period and have // to clear parts of it _n->noteOff(); - engine::getMixer()->clearAudioBuffer( m_audioPort->firstBuffer(), + engine::getMixer()->clearAudioBuffer( m_audioPort.firstBuffer(), engine::getMixer()->framesPerPeriod() - ( *youngest_note )->offset(), ( *youngest_note )->offset() ); @@ -749,7 +752,7 @@ void instrumentTrack::setName( const QString & _new_name ) #endif m_tswInstrumentTrackButton->setText( m_name ); m_midiPort->setName( m_name ); - m_audioPort->setName( m_name ); + m_audioPort.setName( m_name ); } @@ -969,7 +972,7 @@ void instrumentTrack::saveTrackSpecificSettings( QDomDocument & _doc, m_envWidget->saveState( _doc, _this ); m_arpWidget->saveState( _doc, _this ); m_midiWidget->saveState( _doc, _this ); - m_effWidget->saveState( _doc, _this ); + m_audioPort.getEffects()->saveState( _doc, _this ); } @@ -990,7 +993,8 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this ) if( _this.hasAttribute( "baseoct" ) ) { // TODO: move this compat code to mmp.cpp -> upgrade() - m_baseNoteModel.setInitValue( _this.attribute( "baseoct" ).toInt() + m_baseNoteModel.setInitValue( _this. + attribute( "baseoct" ).toInt() * NOTES_PER_OCTAVE + _this.attribute( "basetone" ).toInt() ); } @@ -1020,9 +1024,11 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this ) { m_midiWidget->restoreState( node.toElement() ); } - else if( m_effWidget->nodeName() == node.nodeName() ) + else if( m_audioPort.getEffects()->nodeName() == + node.nodeName() ) { - m_effWidget->restoreState( node.toElement() ); + m_audioPort.getEffects()->restoreState( + node.toElement() ); had_fx = TRUE; } else if( automationPattern::classNodeName() @@ -1031,6 +1037,7 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this ) // if node-name doesn't match any known one, // we assume that it is an instrument-plugin // which we'll try to load + delete m_instrumentView; delete m_instrument; m_instrument = instrument::instantiate( node.nodeName(), this ); @@ -1040,16 +1047,18 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this ) m_instrument->restoreState( node.toElement() ); } - m_tabWidget->addTab( m_instrument-> - createEditor( m_tabWidget ), + m_instrumentView = m_instrument-> + createView( m_tabWidget ); + m_tabWidget->addTab( m_instrumentView, tr( "PLUGIN" ), 0 ); } } node = node.nextSibling(); } + // TODO: why not move above without any condition?? if( !had_fx ) { - m_effWidget->deleteAllEffects(); + m_audioPort.getEffects()->deleteAllPlugins(); } engine::getMixer()->unlock(); @@ -1072,12 +1081,13 @@ instrument * instrumentTrack::loadInstrument( const QString & _plugin_name ) invalidateAllMyNPH(); engine::getMixer()->lock(); + delete m_instrumentView; delete m_instrument; m_instrument = instrument::instantiate( _plugin_name, this ); engine::getMixer()->unlock(); - m_tabWidget->addTab( m_instrument->createEditor( m_tabWidget ), - tr( "PLUGIN" ), 0 ); + m_instrumentView = m_instrument->createView( m_tabWidget ); + m_tabWidget->addTab( m_instrumentView, tr( "PLUGIN" ), 0 ); m_tabWidget->setActiveTab( 0 ); m_tswInstrumentTrackButton->update(); diff --git a/src/tracks/sample_track.cpp b/src/tracks/sample_track.cpp index 41f2606e6..204c99f4f 100644 --- a/src/tracks/sample_track.cpp +++ b/src/tracks/sample_track.cpp @@ -330,7 +330,7 @@ void sampleTCOSettingsDialog::setSampleFile( const QString & _f ) sampleTrack::sampleTrack( trackContainer * _tc ) : track( _tc ), - m_audioPort( new audioPort( tr( "Sample track" ) ) ), + m_audioPort( tr( "Sample track" ), this ), m_volumeModel( DEFAULT_VOLUME, MIN_VOLUME, MAX_VOLUME, 1/*, this*/ ) { m_volumeModel.setTrack( this ); @@ -372,7 +372,6 @@ sampleTrack::~sampleTrack() } engine::getMixer()->removePlayHandles( this ); - delete m_audioPort; } @@ -393,7 +392,7 @@ bool FASTCALL sampleTrack::play( const midiTime & _start, { sendMidiTime( _start ); - m_audioPort->getEffects()->startRunning(); + m_audioPort.getEffects()->startRunning(); bool played_a_note = FALSE; // will be return variable for( int i = 0; i < numOfTCOs(); ++i ) @@ -436,7 +435,7 @@ void sampleTrack::saveTrackSpecificSettings( QDomDocument & _doc, QDomElement & _this ) { _this.setAttribute( "name", m_trackLabel->text() ); - m_trackLabel->saveState( _doc, _this ); + m_audioPort.getEffects()->saveState( _doc, _this ); #if 0 _this.setAttribute( "icon", m_trackLabel->pixmapFile() ); #endif @@ -454,9 +453,11 @@ void sampleTrack::loadTrackSpecificSettings( const QDomElement & _this ) { if( node.isElement() ) { - if( m_trackLabel->nodeName() == node.nodeName() ) + if( m_audioPort.getEffects()->nodeName() == + node.nodeName() ) { - m_trackLabel->restoreState( node.toElement() ); + m_audioPort.getEffects()->restoreState( + node.toElement() ); } } node = node.nextSibling(); diff --git a/src/widgets/automatable_button.cpp b/src/widgets/automatable_button.cpp index 98c77816c..7b04d089d 100644 --- a/src/widgets/automatable_button.cpp +++ b/src/widgets/automatable_button.cpp @@ -41,10 +41,10 @@ automatableButton::automatableButton( QWidget * _parent, const QString & _name ) : QPushButton( _parent ), - autoModelView(), + autoModelView( new autoModel( FALSE, FALSE, TRUE, + autoModel::defaultRelStep(), NULL, TRUE ) ), m_group( NULL ) { - setModel( new autoModel( FALSE, FALSE, TRUE, 1, NULL, TRUE ) ); setAccessibleName( _name ); } @@ -165,9 +165,8 @@ void automatableButton::toggle( void ) automatableButtonGroup::automatableButtonGroup( QWidget * _parent, const QString & _name ) : QWidget( _parent ), - autoModelView() + autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ) { - setModel( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ); hide(); setAccessibleName( _name ); } diff --git a/src/widgets/automatable_slider.cpp b/src/widgets/automatable_slider.cpp index e17bcb072..b98dfcf8d 100644 --- a/src/widgets/automatable_slider.cpp +++ b/src/widgets/automatable_slider.cpp @@ -4,7 +4,7 @@ * automatable_slider.cpp - implementation of class automatableSlider * * Copyright (c) 2006-2007 Javier Serrano Polo - * Copyright (c) 2007 Tobias Doerffel + * Copyright (c) 2007-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -41,10 +41,9 @@ automatableSlider::automatableSlider( QWidget * _parent, const QString & _name ) : QSlider( _parent ), - autoModelView(), + autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ), m_showStatus( FALSE ) { - setModel( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ); setAccessibleName( _name ); connect( this, SIGNAL( valueChanged( int ) ), diff --git a/src/widgets/combobox.cpp b/src/widgets/combobox.cpp index 3400d3641..dadf702de 100644 --- a/src/widgets/combobox.cpp +++ b/src/widgets/combobox.cpp @@ -47,11 +47,10 @@ const int CB_ARROW_BTN_WIDTH = 20; comboBox::comboBox( QWidget * _parent, const QString & _name ) : QWidget( _parent ), - autoModelView(), + autoModelView( new comboBoxModel ), m_menu( this ), m_pressed( FALSE ) { - setModel( new comboBoxModel ); if( s_background == NULL ) { s_background = new QPixmap( embed::getIconPixmap( diff --git a/src/widgets/effect_label.cpp b/src/widgets/effect_label.cpp index ce7a19e03..17d574b2e 100644 --- a/src/widgets/effect_label.cpp +++ b/src/widgets/effect_label.cpp @@ -5,6 +5,7 @@ * offers access to an effect rack * * Copyright (c) 2006-2007 Danny McRae + * Copyright (c) 2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -29,12 +30,13 @@ #include "effect_label.h" #include +#include #include #include #include #include -#include "effect_tab_widget.h" +#include "effect_rack_view.h" #include "embed.h" #include "engine.h" #include "gui_templates.h" @@ -55,33 +57,33 @@ effectLabel::effectLabel( const QString & _initial_name, QWidget * _parent, m_effectBtn->setGeometry( 6, 1, 28, 28 ); connect( m_effectBtn, SIGNAL( clicked() ), this, SLOT( showEffects() ) ); - + m_label = new QLabel( this ); m_label->setText( _initial_name ); QFont f = m_label->font(); m_label->setFont( pointSize<8>( f ) ); m_label->setGeometry( 38, 1, 200, 28 ); - - m_effWidget = new effectTabWidget( engine::getMainWindow()->workspace(), - m_track, - m_track->getAudioPort() ); + + m_effectRack = new effectRackView( + m_track->getAudioPort()->getEffects(), + engine::getMainWindow()->workspace() ); if( engine::getMainWindow()->workspace() ) { engine::getMainWindow()->workspace()->addSubWindow( - m_effWidget ); - m_effWindow = m_effWidget->parentWidget(); + m_effectRack ); + m_effWindow = m_effectRack->parentWidget(); m_effWindow->setAttribute( Qt::WA_DeleteOnClose, FALSE ); m_effWindow->layout()->setSizeConstraint( QLayout::SetFixedSize ); } else { - m_effWindow = m_effWidget; + m_effWindow = m_effectRack; } m_effWindow->setWindowTitle( _initial_name ); - m_effWidget->setFixedSize( 240, 242 ); + m_effectRack->setFixedSize( 240, 242 ); m_effWindow->hide(); } @@ -104,7 +106,7 @@ QString effectLabel::text( void ) const -void FASTCALL effectLabel::setText( const QString & _text ) +void effectLabel::setText( const QString & _text ) { m_label->setText( _text ); m_effWindow->setWindowTitle( _text ); @@ -117,8 +119,8 @@ void effectLabel::showEffects( void ) { if( m_effWindow->isHidden() ) { - m_effWidget->show(); - if( m_effWindow != m_effWidget ) + m_effectRack->show(); + if( m_effWindow != m_effectRack ) { m_effWindow->show(); } @@ -133,36 +135,6 @@ void effectLabel::showEffects( void ) -void effectLabel::saveSettings( QDomDocument & _doc, QDomElement & _this ) -{ -// _this.setAttribute( "name", m_label->text() ); - m_effWidget->saveState( _doc, _this ); - -} - - - - -void effectLabel::loadSettings( const QDomElement & _this ) -{ -// m_label->setText( _this.attribute( "name" ) ); - - QDomNode node = _this.firstChild(); - while( !node.isNull() ) - { - if( node.isElement() ) - { - if( m_effWidget->nodeName() == node.nodeName() ) - { - m_effWidget->restoreState( node.toElement() ); - } - } - node = node.nextSibling(); - } -} - - - void effectLabel::rename( void ) { diff --git a/src/widgets/effect_rack_view.cpp b/src/widgets/effect_rack_view.cpp index 39ab64f7e..bbf4d6feb 100644 --- a/src/widgets/effect_rack_view.cpp +++ b/src/widgets/effect_rack_view.cpp @@ -1,9 +1,10 @@ #ifndef SINGLE_SOURCE_COMPILE /* - * rack_view.cpp - provides the display for the rackInsert instances + * effect_rack_view.cpp - view for effectChain-model * * Copyright (c) 2006-2007 Danny McRae + * Copyright (c) 2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -26,218 +27,239 @@ #include +#include +#include +#include +#include -#include "rack_view.h" -#include "audio_port.h" -#include "rack_plugin.h" +#include "effect_rack_view.h" +#include "effect_select_dialog.h" +#include "effect_view.h" +#include "group_box.h" -rackView::rackView( QWidget * _parent, track * _track, audioPort * _port ) : +effectRackView::effectRackView( effectChain * _model, QWidget * _parent ) : QWidget( _parent ), - m_track( _track ), - m_port( _port ) + modelView( NULL ) { setFixedSize( 230, 184 ); - m_mainLayout = new QVBoxLayout( this ); +/* m_mainLayout = new QVBoxLayout( this ); m_mainLayout->setMargin( 0 ); - m_mainLayout->setSpacing( 0 ); - m_scrollArea = new QScrollArea( this ); + m_mainLayout->setSpacing( 0 );*/ + + m_effectsGroupBox = new groupBox( tr( "EFFECTS CHAIN" ), this ); + m_effectsGroupBox->setGeometry( 2, 2, 242, 244 ); + + m_scrollArea = new QScrollArea( m_effectsGroupBox ); m_scrollArea->setFixedSize( 230, 184 ); m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); m_scrollArea->setPalette( QApplication::palette( m_scrollArea ) ); + m_scrollArea->move( 6, 22 ); + + m_addButton = new QPushButton( m_effectsGroupBox/*, "Add Effect"*/ ); + m_addButton->setText( tr( "Add" ) ); + m_addButton->move( 75, 210 ); + connect( m_addButton, SIGNAL( clicked( void ) ), + this, SLOT( addEffect( void ) ) ); - m_mainLayout->addWidget( m_scrollArea ); + //m_mainLayout->addWidget( m_scrollArea ); + + QWidget * w = new QWidget; + m_scrollArea->setWidget( w ); + w->show(); m_lastY = 0; + + setModel( _model ); } -rackView::~rackView() +effectRackView::~effectRackView() { - deleteAllPlugins(); + //deleteAllPlugins(); } -void rackView::addEffect( effect * _e ) +/* +void effectRackView::deleteAllPlugins( void ) { - if( !m_scrollArea->widget() ) - { - QWidget * w = new QWidget; - m_scrollArea->setWidget( w ); - w->show(); - } - QWidget * w = m_scrollArea->widget(); - rackPlugin * plugin = new rackPlugin( w, _e, m_track, m_port ); - connect( plugin, SIGNAL( moveUp( rackPlugin * ) ), - this, SLOT( moveUp( rackPlugin * ) ) ); - connect( plugin, SIGNAL( moveDown( rackPlugin * ) ), - this, SLOT( moveDown( rackPlugin * ) ) ); - connect( plugin, SIGNAL( deletePlugin( rackPlugin * ) ), - this, SLOT( deletePlugin( rackPlugin * ) ) ); - plugin->move( 0, m_lastY ); - plugin->show(); - m_lastY += plugin->height(); - m_scrollArea->widget()->setFixedSize( 210, m_lastY ); - m_rackInserts.append( plugin ); -} - - - - -void FASTCALL rackView::saveSettings( QDomDocument & _doc, - QDomElement & _this ) -{ - _this.setAttribute( "numofeffects", m_rackInserts.count() ); - for( QVector::iterator it = m_rackInserts.begin(); - it != m_rackInserts.end(); it++ ) - { - QDomElement ef = ( *it )->saveState( _doc, _this ); - ef.setAttribute( "name", - ( *it )->getEffect()->getDescriptor()->name ); - ef.setAttribute( "key", - ( *it )->getEffect()->getKey().dumpBase64() ); - } -} - - - - -void FASTCALL rackView::loadSettings( const QDomElement & _this ) -{ - deleteAllPlugins(); - - const int plugin_cnt = _this.attribute( "numofeffects" ).toInt(); - - QDomNode node = _this.firstChild(); - for( int i = 0; i < plugin_cnt; i++ ) - { - if( node.isElement() && node.nodeName() == "effect" ) - { - QDomElement cn = node.toElement(); - const QString name = cn.attribute( "name" ); - // we have this really convenient key-ctor - // which takes a QString and decodes the - // base64-data inside :-) - effectKey key( cn.attribute( "key" ) ); - addEffect( effect::instantiate( name, &key ) ); - // TODO: somehow detect if effect is sub-plugin-capable - // but couldn't load sub-plugin with requsted key - if( node.isElement() ) - { - if( m_rackInserts.last()->nodeName() == - node.nodeName() ) - { - m_rackInserts.last()->restoreState( - node.toElement() ); - } - } - } - node = node.nextSibling(); - } - -} - - - - -void rackView::deleteAllPlugins( void ) -{ - for( QVector::iterator it = m_rackInserts.begin(); - it != m_rackInserts.end(); ++it ) + for( QVector::iterator it = m_effectViews.begin(); + it != m_effectViews.end(); ++it ) { delete *it; } - m_rackInserts.clear(); + m_effectViews.clear(); } +*/ - -void rackView::moveUp( rackPlugin * _plugin ) +void effectRackView::moveUp( effectView * _view ) { - if( _plugin != m_rackInserts.first() ) + fxChain()->moveUp( _view->getEffect() ); + if( _view != m_effectViews.first() ) { int i = 0; - for( QVector::iterator it = - m_rackInserts.begin(); - it != m_rackInserts.end(); it++, i++ ) + for( QVector::iterator it = + m_effectViews.begin(); + it != m_effectViews.end(); it++, i++ ) { - if( *it == _plugin ) + if( *it == _view ) { break; } } - rackPlugin * temp = m_rackInserts[ i - 1 ]; + effectView * temp = m_effectViews[ i - 1 ]; - m_rackInserts[i - 1] = _plugin; - m_rackInserts[i] = temp; + m_effectViews[i - 1] = _view; + m_effectViews[i] = temp; - redraw(); + updateView(); } } -void rackView::moveDown( rackPlugin * _plugin ) +void effectRackView::moveDown( effectView * _view ) { - m_port->getEffects()->moveDown( _plugin->getEffect() ); - if( _plugin != m_rackInserts.last() ) + if( _view != m_effectViews.last() ) + { + // moving next effect up is the same + moveUp( *( qFind( m_effectViews.begin(), m_effectViews.end(), + _view ) + 1 ) ); + } +/* + fxChain()->moveDown( _view->getEffect() ); + if( _view != m_effectViews.last() ) { int i = 0; - for( QVector::iterator it = - m_rackInserts.begin(); - it != m_rackInserts.end(); it++, i++ ) + for( QVector::iterator it = + m_effectViews.begin(); + it != m_effectViews.end(); it++, i++ ) { - if( *it == _plugin ) + if( *it == _view ) { break; } } - rackPlugin * temp = m_rackInserts.at( i + 1 ); + effectView * temp = m_effectViews.at( i + 1 ); - m_rackInserts[i + 1] = _plugin; - m_rackInserts[i] = temp; + m_effectViews[i + 1] = _view; + m_effectViews[i] = temp; redraw(); - } + }*/ } -void rackView::deletePlugin( rackPlugin * _plugin ) +void effectRackView::deletePlugin( effectView * _view ) { - m_rackInserts.erase( qFind( m_rackInserts.begin(), m_rackInserts.end(), - _plugin ) ); - delete _plugin; - redraw(); + effect * e = _view->getEffect(); + m_effectViews.erase( qFind( m_effectViews.begin(), m_effectViews.end(), + _view ) ); + delete _view; + fxChain()->m_effects.erase( qFind( fxChain()->m_effects.begin(), + fxChain()->m_effects.end(), + e ) ); + delete e; + updateView(); } -void rackView::redraw() +void effectRackView::updateView( void ) { - m_lastY = 0; - for( QVector::iterator it = m_rackInserts.begin(); - it != m_rackInserts.end(); it++ ) + QWidget * w = m_scrollArea->widget(); + QVector view_map( fxChain()->m_effects.size(), FALSE ); + + for( QVector::iterator it = fxChain()->m_effects.begin(); + it != fxChain()->m_effects.end(); ++it ) { - ( *it )->move( 0, m_lastY ); - m_lastY += ( *it )->height(); + int i = 0; + for( QVector::iterator vit = + m_effectViews.begin(); + vit != m_effectViews.end(); ++vit, ++i ) + { + if( ( *vit )->getEffect() == *it ) + { + view_map[i] = TRUE; + break; + } + } + if( i >= m_effectViews.size() ) + { + effectView * view = new effectView( *it, w ); + connect( view, SIGNAL( moveUp( effectView * ) ), + this, SLOT( moveUp( effectView * ) ) ); + connect( view, SIGNAL( moveDown( effectView * ) ), + this, SLOT( moveDown( effectView * ) ) ); + connect( view, SIGNAL( deletePlugin( effectView * ) ), + this, SLOT( deletePlugin( effectView * ) ) ); + view->show(); + m_effectViews.append( view ); + view_map[i] = TRUE; + + } } - m_scrollArea->widget()->setFixedSize( 210, m_lastY ); -} + + int i = m_lastY = 0; + for( QVector::iterator it = m_effectViews.begin(); + it != m_effectViews.end(); ) + { + if( i < view_map.size() && view_map[i] == FALSE ) + { + delete m_effectViews[i]; + m_effectViews.erase( it ); + } + else + { + ( *it )->move( 0, m_lastY ); + m_lastY += ( *it )->height(); + ++it; + ++i; + } + } + w->setFixedSize( 210, m_lastY ); +} -#include "rack_view.moc" +void effectRackView::addEffect( void ) +{ + effectSelectDialog esd( this ); + esd.exec(); + + if( esd.result() == QDialog::Rejected ) + { + return; + } + + fxChain()->appendEffect( esd.instantiateSelectedPlugin( fxChain() ) ); + updateView(); +} + + + + +void effectRackView::modelChanged( void ) +{ + m_effectsGroupBox->setModel( &fxChain()->m_enabledModel ); + updateView(); +} + + + +#include "effect_rack_view.moc" #endif diff --git a/src/widgets/effect_view.cpp b/src/widgets/effect_view.cpp index ab7ad8c4f..50977e600 100644 --- a/src/widgets/effect_view.cpp +++ b/src/widgets/effect_view.cpp @@ -1,10 +1,10 @@ #ifndef SINGLE_SOURCE_COMPILE /* - * effect_tab_widget.cpp - tab-widget in channel-track-window for setting up - * effects + * effect_view.cpp - view-component for an effect * * Copyright (c) 2006-2007 Danny McRae + * Copyright (c) 2007-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -26,7 +26,7 @@ */ -#include "rack_plugin.h" +#include "effect_view.h" #include #include @@ -46,15 +46,8 @@ #include "tooltip.h" -rackPlugin::rackPlugin( QWidget * _parent, - effect * _eff, - track * _track, - audioPort * _port ) : - QWidget( _parent ), - m_autoQuitModel( 1.0f, 1.0f, 8000.0f, 100.0f /* this */ ), - m_effect( _eff ), - m_track( _track ), - m_port( _port ), +effectView::effectView( effect * _model, QWidget * _parent ) : + pluginView( _model, _parent ), m_show( TRUE ) { setFixedSize( 210, 60 ); @@ -66,18 +59,13 @@ rackPlugin::rackPlugin( QWidget * _parent, pal.setBrush( backgroundRole(), bg ); setPalette( pal ); - m_effect->m_enabledModel.setTrack( m_track ); - m_effect->m_enabledModel.setValue( TRUE ); m_bypass = new ledCheckBox( "", this, tr( "Turn the effect off" ) ); - m_bypass->setModel( &m_effect->m_enabledModel ); m_bypass->move( 3, 3 ); m_bypass->setWhatsThis( tr( "Toggles the effect on or off." ) ); toolTip::add( m_bypass, tr( "On/Off" ) ); - m_effect->m_wetDryModel.setTrack( m_track ); m_wetDry = new knob( knobBright_26, this, tr( "Wet/Dry mix" ) ); - m_wetDry->setModel( &m_effect->m_wetDryModel ); m_wetDry->setLabel( tr( "W/D" ) ); m_wetDry->move( 27, 5 ); m_wetDry->setHintText( tr( "Wet Level:" ) + " ", "" ); @@ -86,12 +74,7 @@ rackPlugin::rackPlugin( QWidget * _parent, "shows up in the output." ) ); - m_autoQuitModel.setTrack( m_track ); - m_autoQuitModel.setInitValue( 1.0f ); - connect( &m_autoQuitModel, SIGNAL( dataChanged( void ) ), - this, SLOT( updateAutoQuit( void ) ) ); m_autoQuit = new tempoSyncKnob( knobBright_26, this, tr( "Decay" ) ); - m_autoQuit->setModel( &m_autoQuitModel ); m_autoQuit->setLabel( tr( "Decay" ) ); m_autoQuit->move( 60, 5 ); m_autoQuit->setHintText( tr( "Time:" ) + " ", "ms" ); @@ -101,9 +84,7 @@ rackPlugin::rackPlugin( QWidget * _parent, "run the risk of clipping the tail on delay effects." ) ); - m_effect->m_gateModel.setTrack( m_track ); m_gate = new knob( knobBright_26, this, tr( "Gate" ) ); - m_gate->setModel( &m_effect->m_gateModel ); m_gate->setLabel( tr( "Gate" ) ); m_gate->move( 93, 5 ); m_gate->setHintText( tr( "Gate:" ) + " ", "" ); @@ -120,7 +101,7 @@ rackPlugin::rackPlugin( QWidget * _parent, this, SLOT( editControls() ) ); m_label = new QLabel( this ); - m_label->setText( m_effect->publicName() ); + m_label->setText( getEffect()->publicName() ); f = m_label->font(); f.setBold( TRUE ); m_label->setFont( pointSize<7>( f ) ); @@ -131,7 +112,7 @@ rackPlugin::rackPlugin( QWidget * _parent, bg.toImage().copy( 5, 44, 195, 10 ) ) ); m_label->setPalette( pal ); - m_controlView = m_effect->createControlDialog( m_track ); + m_controlView = getEffect()->createControlDialog( NULL ); m_subWindow = engine::getMainWindow()->workspace()->addSubWindow( m_controlView ); connect( m_controlView, SIGNAL( closed() ), @@ -173,23 +154,24 @@ rackPlugin::rackPlugin( QWidget * _parent, "Right clicking will bring up a context menu where you can change the order " "in which the effects are processed or delete an effect altogether." ) ); - m_port->getEffects()->appendEffect( m_effect ); +// m_port->getEffects()->appendEffect( m_effect ); + setModel( _model ); } -rackPlugin::~rackPlugin() +effectView::~effectView() { - m_port->getEffects()->removeEffect( m_effect ); - delete m_effect; +// m_port->getEffects()->removeEffect( m_effect ); +// delete m_effect; m_controlView->deleteLater(); } -void rackPlugin::editControls( void ) +void effectView::editControls( void ) { if( m_show ) { @@ -207,22 +189,10 @@ void rackPlugin::editControls( void ) -void rackPlugin::updateAutoQuit( void ) -{ - float samples = engine::getMixer()->sampleRate() * - m_autoQuitModel.value() / 1000.0f; - Uint32 buffers = 1 + ( static_cast( samples ) / - engine::getMixer()->framesPerPeriod() ); - m_effect->setTimeout( buffers ); -} - - - - -void rackPlugin::contextMenuEvent( QContextMenuEvent * ) +void effectView::contextMenuEvent( QContextMenuEvent * ) { QPointer contextMenu = new captionMenu( - m_effect->publicName() ); + getEffect()->publicName() ); contextMenu->addAction( embed::getIconPixmap( "arp_up_on" ), tr( "Move &up" ), this, SLOT( moveUp() ) ); @@ -244,7 +214,7 @@ void rackPlugin::contextMenuEvent( QContextMenuEvent * ) -void rackPlugin::moveUp() +void effectView::moveUp() { emit( moveUp( this ) ); } @@ -252,14 +222,14 @@ void rackPlugin::moveUp() -void rackPlugin::moveDown() +void effectView::moveDown() { emit( moveDown( this ) ); } -void rackPlugin::deletePlugin() +void effectView::deletePlugin() { emit( deletePlugin( this ) ); } @@ -267,7 +237,7 @@ void rackPlugin::deletePlugin() -void rackPlugin::displayHelp( void ) +void effectView::displayHelp( void ) { QWhatsThis::showText( mapToGlobal( rect().bottomRight() ), whatsThis() ); @@ -276,53 +246,22 @@ void rackPlugin::displayHelp( void ) -void FASTCALL rackPlugin::saveSettings( QDomDocument & _doc, - QDomElement & _this ) -{ - _this.setAttribute( "on", m_effect->m_enabledModel.value() ); - _this.setAttribute( "wet", m_effect->m_wetDryModel.value() ); - _this.setAttribute( "autoquit", m_autoQuitModel.value() ); - _this.setAttribute( "gate", m_effect->m_gateModel.value() ); - m_controlView->saveState( _doc, _this ); -} - - - - -void FASTCALL rackPlugin::loadSettings( const QDomElement & _this ) -{ - m_effect->m_enabledModel.setValue( _this.attribute( "on" ).toInt() ); - m_effect->m_wetDryModel.setValue( _this.attribute( "wet" ).toFloat() ); - m_autoQuitModel.setValue( _this.attribute( "autoquit" ).toFloat() ); - m_effect->m_gateModel.setValue( _this.attribute( "gate" ).toFloat() ); - - QDomNode node = _this.firstChild(); - while( !node.isNull() ) - { - if( node.isElement() ) - { - if( m_controlView->nodeName() == node.nodeName() ) - { - m_controlView->restoreState( - node.toElement() ); - } - } - node = node.nextSibling(); - } -} - - - - -void rackPlugin::closeEffects( void ) +void effectView::closeEffects( void ) { m_subWindow->hide(); m_show = TRUE; } +void effectView::modelChanged( void ) +{ + m_bypass->setModel( &getEffect()->m_enabledModel ); + m_wetDry->setModel( &getEffect()->m_wetDryModel ); + m_autoQuit->setModel( &getEffect()->m_autoQuitModel ); + m_gate->setModel( &getEffect()->m_gateModel ); +} -#include "rack_plugin.moc" +#include "effect_view.moc" #endif diff --git a/src/widgets/group_box.cpp b/src/widgets/group_box.cpp index 25c3a1e42..76c825490 100644 --- a/src/widgets/group_box.cpp +++ b/src/widgets/group_box.cpp @@ -49,7 +49,7 @@ QPixmap * groupBox::s_ledBg = NULL; groupBox::groupBox( const QString & _caption, QWidget * _parent ) : QWidget( _parent ), - autoModelView(), + autoModelView( NULL ), m_caption( _caption ) { if( s_ledBg == NULL ) diff --git a/src/widgets/knob.cpp b/src/widgets/knob.cpp index 88b6046a1..569a2145e 100644 --- a/src/widgets/knob.cpp +++ b/src/widgets/knob.cpp @@ -65,7 +65,7 @@ textFloat * knob::s_textFloat = NULL; knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) : QWidget( _parent ), - autoModelView(), + autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ), m_mouseOffset( 0.0f ), m_buttonPressed( FALSE ), m_hintTextBeforeValue( "" ), @@ -73,8 +73,6 @@ knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) : m_knobNum( _knob_num ), m_label( "" ) { - setModel( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ); - if( s_textFloat == NULL ) { s_textFloat = new textFloat( this ); diff --git a/src/widgets/lcd_spinbox.cpp b/src/widgets/lcd_spinbox.cpp index 1fbd43446..6a8105909 100644 --- a/src/widgets/lcd_spinbox.cpp +++ b/src/widgets/lcd_spinbox.cpp @@ -41,7 +41,7 @@ lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent, const QString & _name ) : QWidget( _parent ), - autoModelView(), + autoModelView( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ), m_number( new QLCDNumber( _num_digits, this ) ), m_label( NULL ), m_origMousePos() @@ -50,8 +50,6 @@ lcdSpinBox::lcdSpinBox( int _num_digits, QWidget * _parent, m_number->setFrameShadow( QFrame::Sunken ); m_number->setSegmentStyle( QLCDNumber::Flat ); - setModel( new autoModel( 0, 0, 0, 1, NULL, TRUE ) ); - QPalette pal; pal.setColor( QPalette::Light, Qt::gray ); pal.setColor( QPalette::Mid, Qt::darkGray );