From 5fd05b16e466c98ebb38e3398fa5c6018761429e Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Fri, 10 Feb 2006 10:48:27 +0000 Subject: [PATCH] introduced engine-technology git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@81 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 26 +- Makefile.am | 7 +- configure.in | 4 +- include/arp_and_chords_tab_widget.h | 4 +- include/audio_alsa.h | 5 +- include/audio_device.h | 9 +- include/audio_dummy.h | 12 +- include/audio_file_device.h | 3 +- include/audio_file_ogg.h | 9 +- include/audio_file_wave.h | 9 +- include/audio_jack.h | 11 +- include/audio_oss.h | 3 +- include/audio_port.h | 4 +- include/audio_sample_recorder.h | 5 +- include/audio_sdl.h | 3 +- include/bb_editor.h | 42 +- include/bb_track.h | 7 +- include/buffer_allocator.h | 8 +- include/config_mgr.h | 8 +- include/cpuload_widget.h | 11 +- include/dummy_plugin.h | 4 +- include/engine.h | 37 +- include/envelope_and_lfo_widget.h | 47 +- include/envelope_tab_widget.h | 12 +- include/export.h | 4 +- include/export_project_dialog.h | 13 +- include/fade_button.h | 2 +- include/file_browser.h | 14 +- include/instrument.h | 4 +- include/instrument_play_handle.h | 6 +- include/knob.h | 10 +- include/main_window.h | 165 ++++ include/micro_timer.h | 2 +- include/midi_alsa_raw.h | 6 +- include/midi_alsa_seq.h | 8 +- include/midi_client.h | 7 +- include/midi_dummy.h | 8 +- include/midi_oss.h | 6 +- include/midi_port.h | 2 +- include/midi_tab_widget.h | 5 +- include/midi_time.h | 8 +- include/mixer.h | 98 +- include/name_label.h | 9 +- include/note_play_handle.h | 40 +- include/oscillator.h | 5 +- include/pattern.h | 11 +- include/piano_roll.h | 22 +- include/play_handle.h | 8 +- include/plugin.h | 5 +- include/plugin_browser.h | 11 +- include/preset_preview_play_handle.h | 32 +- include/project_notes.h | 9 +- include/sample_buffer.h | 21 +- include/sample_play_handle.h | 13 +- include/sample_track.h | 13 +- include/setup_dialog.h | 5 +- include/song_editor.h | 48 +- include/string_pair_drag.h | 12 +- include/tempo_sync_knob.h | 7 +- include/timeline.h | 6 +- include/track.h | 15 +- include/track_container.h | 12 +- include/visualization_widget.h | 10 +- .../audio_file_processor.cpp | 33 +- plugins/bit_invader/bit_invader.cpp | 32 +- plugins/bit_invader/bit_invader.h | 2 +- plugins/bit_invader/graph.cpp | 12 +- plugins/bit_invader/graph.h | 9 +- .../plucked_string_synth.cpp | 17 +- .../plucked_string_synth.h | 3 +- .../triple_oscillator/triple_oscillator.cpp | 95 +- plugins/triple_oscillator/triple_oscillator.h | 4 +- plugins/vestige/lvsl_client.cpp | 25 +- plugins/vestige/lvsl_client.h | 7 +- plugins/vestige/vestige.cpp | 19 +- plugins/vestige/vestige.h | 2 +- src/audio/audio_alsa.cpp | 14 +- src/audio/audio_device.cpp | 17 +- src/audio/audio_file_device.cpp | 5 +- src/audio/audio_file_ogg.cpp | 5 +- src/audio/audio_file_wave.cpp | 5 +- src/audio/audio_jack.cpp | 14 +- src/audio/audio_oss.cpp | 14 +- src/audio/audio_port.cpp | 33 +- src/audio/audio_sample_recorder.cpp | 14 +- src/audio/audio_sdl.cpp | 14 +- src/core/arp_and_chords_tab_widget.cpp | 31 +- src/core/bb_editor.cpp | 42 +- src/core/envelope_and_lfo_widget.cpp | 149 +-- src/core/envelope_tab_widget.cpp | 72 +- src/core/export_project_dialog.cpp | 38 +- src/core/file_browser.cpp | 52 +- src/core/instrument.cpp | 6 +- src/core/main.cpp | 47 +- src/core/main_window.cpp | 864 ++++++++++++++++++ src/core/midi_tab_widget.cpp | 21 +- src/core/mixer.cpp | 69 +- src/core/name_label.cpp | 7 +- src/core/note.cpp | 2 +- src/core/note_play_handle.cpp | 40 +- src/core/piano_roll.cpp | 92 +- src/core/plugin.cpp | 3 +- src/core/plugin_browser.cpp | 15 +- src/core/preset_preview_play_handle.cpp | 145 +-- src/core/sample_play_handle.cpp | 35 +- src/core/setup_dialog.cpp | 19 +- src/core/song_editor.cpp | 168 ++-- src/core/timeline.cpp | 21 +- src/core/track.cpp | 38 +- src/core/track_container.cpp | 30 +- src/lib/buffer_allocator.cpp | 3 +- src/lib/oscillator.cpp | 32 +- src/lib/sample_buffer.cpp | 23 +- src/lib/string_pair_drag.cpp | 12 +- src/midi/midi_alsa_raw.cpp | 6 +- src/midi/midi_alsa_seq.cpp | 18 +- src/midi/midi_client.cpp | 10 +- src/midi/midi_oss.cpp | 6 +- src/tracks/bb_track.cpp | 60 +- src/tracks/pattern.cpp | 62 +- src/tracks/sample_track.cpp | 39 +- src/widgets/cpuload_widget.cpp | 7 +- src/widgets/group_box.cpp | 2 +- src/widgets/knob.cpp | 29 +- src/widgets/pixmap_button.cpp | 2 +- src/widgets/project_notes.cpp | 51 +- src/widgets/tempo_sync_knob.cpp | 25 +- src/widgets/text_float.cpp | 7 +- src/widgets/tool_button.cpp | 2 +- src/widgets/visualization_widget.cpp | 19 +- 130 files changed, 2528 insertions(+), 1260 deletions(-) create mode 100644 include/main_window.h create mode 100644 src/core/main_window.cpp diff --git a/ChangeLog b/ChangeLog index 608c271335..174c1caa12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2006-02-09 Tobias Doerffel + + * plugins/triple_oscillator/triple_oscillator.cpp: + per default set volume of each osc to 33% + + * allmost all files: + use engine-technology + + * include/engine.h: + * src/core/engine.cpp: + added engine- and engineObject-class providing new "engine-technology" + which makes singleton-classes obsoletes and offers a lot of new + possibilities like GUI-data-separation and having several projects + open at the same time + 2006-02-06 Tobias Doerffel * include/mixer.h: @@ -9,15 +24,14 @@ 2006-02-06 Andreas Brandmaier - * plugins/bitinvader/bitinvader.cpp - * plugins/bitinvader/bitinvader.h - * plugins/bitinvader/graph.cpp - * plugins/bitinvader/graph.h + * plugins/bitinvader/bitinvader.cpp: + * plugins/bitinvader/bitinvader.h: + * plugins/bitinvader/graph.cpp: + * plugins/bitinvader/graph.h: - code cleanup - added drag&drop support to wavegraph - added new BitInvader presets and improved old ones - - + 2006-02-05 Tobias Doerffel * include/basic_filters.h: diff --git a/Makefile.am b/Makefile.am index 6193590f60..08e8957454 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,7 +63,7 @@ lmms_MOC = \ ./knob.moc \ ./lcd_spinbox.moc \ ./led_checkbox.moc \ - ./lmms_main_win.moc \ + ./main_window.moc \ ./mixer.moc \ ./name_label.moc \ ./nstate_button.moc \ @@ -121,12 +121,13 @@ lmms_SOURCES = \ $(srcdir)/src/core/arp_and_chords_tab_widget.cpp \ $(srcdir)/src/core/bb_editor.cpp \ $(srcdir)/src/core/config_mgr.cpp \ + $(srcdir)/src/core/engine.cpp \ $(srcdir)/src/core/envelope_and_lfo_widget.cpp \ $(srcdir)/src/core/envelope_tab_widget.cpp \ $(srcdir)/src/core/export_project_dialog.cpp \ $(srcdir)/src/core/file_browser.cpp \ $(srcdir)/src/core/instrument.cpp \ - $(srcdir)/src/core/lmms_main_win.cpp \ + $(srcdir)/src/core/main_window.cpp \ $(srcdir)/src/core/main.cpp \ $(srcdir)/src/core/midi_tab_widget.cpp \ $(srcdir)/src/core/mixer.cpp \ @@ -189,7 +190,7 @@ lmms_SOURCES = \ $(srcdir)/src/widgets/visualization_widget.cpp \ $(srcdir)/include/pch.h \ $(srcdir)/include/debug.h \ - $(srcdir)/include/lmms_main_win.h \ + $(srcdir)/include/main_window.h \ $(srcdir)/include/audio_alsa.h \ $(srcdir)/include/audio_device.h \ $(srcdir)/include/audio_dummy.h \ diff --git a/configure.in b/configure.in index b1f7cec2e8..651279d8c8 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.1.4-cvs20060206, tobydox/at/users/dot/sourceforge/dot/net) -AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060206) +AC_INIT(lmms, 0.1.4-cvs20060209, tobydox/at/users/dot/sourceforge/dot/net) +AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060209) AM_CONFIG_HEADER(config.h) diff --git a/include/arp_and_chords_tab_widget.h b/include/arp_and_chords_tab_widget.h index 8764c18b37..85061978cf 100644 --- a/include/arp_and_chords_tab_widget.h +++ b/include/arp_and_chords_tab_widget.h @@ -45,6 +45,7 @@ #include "settings.h" #include "types.h" +#include "engine.h" class QPixmap; @@ -62,7 +63,8 @@ class tempoSyncKnob; const int MAX_CHORD_POLYPHONY = 10; -class arpAndChordsTabWidget : public QWidget, public settings +class arpAndChordsTabWidget : public QWidget, public settings, + public engineObject { Q_OBJECT public: diff --git a/include/audio_alsa.h b/include/audio_alsa.h index 0e1cead6ed..0cab60874a 100644 --- a/include/audio_alsa.h +++ b/include/audio_alsa.h @@ -51,8 +51,9 @@ class QLineEdit; class audioALSA : public audioDevice, public QThread { public: - audioALSA( const sample_rate_t _sample_rate, bool & _success_ful ); - ~audioALSA(); + audioALSA( const sample_rate_t _sample_rate, bool & _success_ful, + mixer * _mixer ); + virtual ~audioALSA(); inline static QString name( void ) { diff --git a/include/audio_device.h b/include/audio_device.h index 179f0a68a1..8c6c9e4d01 100644 --- a/include/audio_device.h +++ b/include/audio_device.h @@ -64,7 +64,7 @@ class audioDevice { public: audioDevice( const sample_rate_t _sample_rate, - const ch_cnt_t _channels ); + const ch_cnt_t _channels, mixer * _mixer ); virtual ~audioDevice(); inline void lock( void ) @@ -163,10 +163,17 @@ protected: m_sampleRate = _new_sr; } + mixer * getMixer( void ) + { + return( m_mixer ); + } + private: sample_rate_t m_sampleRate; ch_cnt_t m_channels; + mixer * m_mixer; + QMutex m_devMutex; #ifdef HAVE_SAMPLERATE_H diff --git a/include/audio_dummy.h b/include/audio_dummy.h index 63b355ec88..7c3a9ac248 100644 --- a/include/audio_dummy.h +++ b/include/audio_dummy.h @@ -1,7 +1,7 @@ /* * audio_dummy.h - dummy-audio-device * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -33,8 +33,9 @@ class audioDummy : public audioDevice, public QThread { public: - audioDummy( Uint32 _sample_rate, bool & _success_ful ) : - audioDevice( _sample_rate, DEFAULT_CHANNELS ), + audioDummy( const sample_rate_t _sample_rate, bool & _success_ful, + mixer * _mixer ) : + audioDevice( _sample_rate, DEFAULT_CHANNELS, _mixer ), m_quit( FALSE ) { _success_ful = TRUE; @@ -94,9 +95,8 @@ private: timer.reset(); processNextBuffer(); const Sint32 microseconds = static_cast( - mixer::inst()->framesPerAudioBuffer() * - 1000000.0f / - mixer::inst()->sampleRate() - + getMixer()->framesPerAudioBuffer() * + 1000000.0f / getMixer()->sampleRate() - timer.elapsed() ); if( microseconds > 0 ) { diff --git a/include/audio_file_device.h b/include/audio_file_device.h index 588c5f65b7..55a47fe448 100644 --- a/include/audio_file_device.h +++ b/include/audio_file_device.h @@ -52,7 +52,8 @@ public: const bool _use_vbr, const bitrate_t _nom_bitrate, const bitrate_t _min_bitrate, - const bitrate_t _max_bitrate ); + const bitrate_t _max_bitrate, + mixer * _mixer ); virtual ~audioFileDevice(); diff --git a/include/audio_file_ogg.h b/include/audio_file_ogg.h index b1b3a579ec..0ce4c67cc4 100644 --- a/include/audio_file_ogg.h +++ b/include/audio_file_ogg.h @@ -49,7 +49,8 @@ public: const bool _use_vbr, const bitrate_t _nom_bitrate, const bitrate_t _min_bitrate, - const bitrate_t _max_bitrate ); + const bitrate_t _max_bitrate, + mixer * _mixer ); virtual ~audioFileOgg(); static audioFileDevice * getInst( const sample_rate_t _sample_rate, @@ -59,11 +60,13 @@ public: const bool _use_vbr, const bitrate_t _nom_bitrate, const bitrate_t _min_bitrate, - const bitrate_t _max_bitrate ) + const bitrate_t _max_bitrate, + mixer * _mixer ) { return( new audioFileOgg( _sample_rate, _channels, _success_ful, _file, _use_vbr, _nom_bitrate, - _min_bitrate, _max_bitrate ) ); + _min_bitrate, _max_bitrate, + _mixer ) ); } diff --git a/include/audio_file_wave.h b/include/audio_file_wave.h index 04cfae8a50..e76be3ca2e 100644 --- a/include/audio_file_wave.h +++ b/include/audio_file_wave.h @@ -42,7 +42,8 @@ public: const bool _use_vbr, const bitrate_t _nom_bitrate, const bitrate_t _min_bitrate, - const bitrate_t _max_bitrate ); + const bitrate_t _max_bitrate, + mixer * _mixer ); virtual ~audioFileWave(); static audioFileDevice * getInst( const sample_rate_t _sample_rate, @@ -52,12 +53,14 @@ public: const bool _use_vbr, const bitrate_t _nom_bitrate, const bitrate_t _min_bitrate, - const bitrate_t _max_bitrate ) + const bitrate_t _max_bitrate, + mixer * _mixer ) { return( new audioFileWave( _sample_rate, _channels, _success_ful, _file, _use_vbr, _nom_bitrate, _min_bitrate, - _max_bitrate ) ); + _max_bitrate, + _mixer ) ); } diff --git a/include/audio_jack.h b/include/audio_jack.h index 6e2635e83f..e159b0b091 100644 --- a/include/audio_jack.h +++ b/include/audio_jack.h @@ -1,7 +1,7 @@ /* * audio_jack.h - support for JACK-transport * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -67,8 +67,9 @@ class lcdSpinBox; class audioJACK : public audioDevice { public: - audioJACK( Uint32 _sample_rate, bool & _success_ful ); - ~audioJACK(); + audioJACK( const sample_rate_t _sample_rate, bool & _success_ful, + mixer * _mixer ); + virtual ~audioJACK(); inline static QString name( void ) { @@ -113,8 +114,8 @@ private: surroundSampleFrame * m_outBuf; - Uint32 m_framesDoneInCurBuf; - Uint32 m_framesToDoInCurBuf; + f_cnt_t m_framesDoneInCurBuf; + f_cnt_t m_framesToDoInCurBuf; struct stereoPort diff --git a/include/audio_oss.h b/include/audio_oss.h index faeb8e81ef..3c94bc0e73 100644 --- a/include/audio_oss.h +++ b/include/audio_oss.h @@ -47,7 +47,8 @@ class QLineEdit; class audioOSS : public audioDevice, public QThread { public: - audioOSS( const sample_rate_t _sample_rate, bool & _success_ful ); + audioOSS( const sample_rate_t _sample_rate, bool & _success_ful, + mixer * _mixer ); virtual ~audioOSS(); inline static QString name( void ) diff --git a/include/audio_port.h b/include/audio_port.h index c925480890..24ca45ca1a 100644 --- a/include/audio_port.h +++ b/include/audio_port.h @@ -43,10 +43,10 @@ #include "effect_board.h" -class audioPort +class audioPort : public engineObject { public: - audioPort( const QString & _name ); + audioPort( const QString & _name, engine * _engine ); ~audioPort(); inline surroundSampleFrame * firstBuffer( void ) diff --git a/include/audio_sample_recorder.h b/include/audio_sample_recorder.h index 10d2a5ebc7..b93e298b4d 100644 --- a/include/audio_sample_recorder.h +++ b/include/audio_sample_recorder.h @@ -54,11 +54,12 @@ class audioSampleRecorder : public audioDevice { public: audioSampleRecorder( const sample_rate_t _sample_rate, - const ch_cnt_t _channels, bool & _success_ful ); + const ch_cnt_t _channels, bool & _success_ful, + mixer * _mixer ); virtual ~audioSampleRecorder(); f_cnt_t framesRecorded( void ) const; - void FASTCALL createSampleBuffer( sampleBuffer * * _sample_buf ) const; + void FASTCALL createSampleBuffer( sampleBuffer * * _sample_buf ); private: diff --git a/include/audio_sdl.h b/include/audio_sdl.h index 65bebe75aa..addcef1f21 100644 --- a/include/audio_sdl.h +++ b/include/audio_sdl.h @@ -51,7 +51,8 @@ class QLineEdit; class audioSDL : public audioDevice { public: - audioSDL( const sample_rate_t _sample_rate, bool & _success_ful ); + audioSDL( const sample_rate_t _sample_rate, bool & _success_ful, + mixer * _mixer ); virtual ~audioSDL(); inline static QString name( void ) diff --git a/include/bb_editor.h b/include/bb_editor.h index 9ee11db650..d559b619c3 100644 --- a/include/bb_editor.h +++ b/include/bb_editor.h @@ -27,16 +27,12 @@ #define _BB_EDITOR_H #include "qt3support.h" - - #include "track_container.h" -#include "lmms_main_win.h" class QPixmap; class comboBox; -class songEditor; class toolButton; @@ -44,17 +40,9 @@ class bbEditor : public trackContainer { Q_OBJECT public: - static inline bbEditor * inst( void ) - { - if( s_instanceOfMe == NULL ) - { - s_instanceOfMe = new bbEditor(); - } - return( s_instanceOfMe ); - } - - virtual bool FASTCALL play( midiTime _start, Uint32 _start_frame, - Uint32 _frames, Uint32 _frame_base, + virtual bool FASTCALL play( midiTime _start, const f_cnt_t _start_frame, + const f_cnt_t _frames, + const f_cnt_t _frame_base, Sint16 _tco_num = -1 ); virtual void FASTCALL saveSettings( QDomDocument & _doc, @@ -73,20 +61,22 @@ public: } csize currentBB( void ) const; - tact FASTCALL lengthOfBB( csize _bb ); + tact FASTCALL lengthOfBB( const csize _bb ); inline tact lengthOfCurrentBB( void ) { return( lengthOfBB( currentBB() ) ); } - void FASTCALL removeBB( csize _bb ); + void FASTCALL removeBB( const csize _bb ); csize numOfBBs( void ) const; - void FASTCALL swapBB( csize _bb1, csize _bb2 ); + void FASTCALL swapBB( const csize _bb1, const csize _bb2 ); void updateBBTrack( trackContentObject * _tco ); public slots: + void play( void ); + void stop( void ); void updateComboBox( void ); void setCurrentBB( int _bb ); @@ -99,21 +89,14 @@ protected: virtual QRect scrollAreaRect( void ) const; -protected slots: - void play( void ); - void stop( void ); - - private: - bbEditor(); + bbEditor( engine * _engine ); //bbEditor( const bbEditor & ); - ~bbEditor(); + virtual ~bbEditor(); - void FASTCALL createTCOsForBB( csize _bb ); + void FASTCALL createTCOsForBB( const csize _bb ); - static bbEditor * s_instanceOfMe; - QWidget * m_toolBar; toolButton * m_playButton; @@ -122,8 +105,7 @@ private: comboBox * m_bbComboBox; - friend class songEditor; - friend lmmsMainWin::~lmmsMainWin(); + friend class engine; } ; diff --git a/include/bb_track.h b/include/bb_track.h index c8f5c8c985..8b25f39441 100644 --- a/include/bb_track.h +++ b/include/bb_track.h @@ -100,8 +100,9 @@ public: virtual trackTypes type( void ) const; virtual bool FASTCALL play( const midiTime & _start, - Uint32 _start_frame, Uint32 _frames, - Uint32 _frame_base, + const f_cnt_t _start_frame, + const fpab_t _frames, + const f_cnt_t _frame_base, Sint16 _tco_num = -1 ); virtual trackContentObject * FASTCALL createTCO( const midiTime & _pos ); @@ -111,7 +112,7 @@ public: virtual void FASTCALL loadTrackSpecificSettings( const QDomElement & _this ); - static bbTrack * FASTCALL findBBTrack( csize _bb_num ); + static bbTrack * FASTCALL findBBTrack( csize _bb_num, engine * _engine ); static csize FASTCALL numOfBBTrack( track * _track ); static void FASTCALL swapBBTracks( track * _track1, track * _track2 ); diff --git a/include/buffer_allocator.h b/include/buffer_allocator.h index e30e80474e..15b8206b93 100644 --- a/include/buffer_allocator.h +++ b/include/buffer_allocator.h @@ -38,10 +38,10 @@ namespace bufferAllocator { - void * FASTCALL allocBytes( Uint32 _bytes ); + void * FASTCALL allocBytes( const Uint32 _bytes ); template - inline T * FASTCALL alloc( Uint32 _n ) + inline T * FASTCALL alloc( const Uint32 _n ) { return( (T *) allocBytes( sizeof( T ) * _n ) ); } @@ -50,10 +50,10 @@ namespace bufferAllocator void FASTCALL free( void * _buf ); // try to cleanup _level unused buffers - void FASTCALL cleanUp( Uint16 _level ); + void FASTCALL cleanUp( const Uint16 _level ); // disable autocleanup-mechanisms - void FASTCALL disableAutoCleanup( bool _disabled ); + void FASTCALL disableAutoCleanup( const bool _disabled ); // simple class for automatically freeing buffer in complex functions diff --git a/include/config_mgr.h b/include/config_mgr.h index 01e0900e77..ad11b9dbb4 100644 --- a/include/config_mgr.h +++ b/include/config_mgr.h @@ -51,9 +51,6 @@ #endif -#include "lmms_main_win.h" - - class QLineEdit; class QLabel; class QRadioButton; @@ -61,6 +58,8 @@ class QHBoxLayout; class QVBoxLayout; class QFrame; +class engine; + const QString PROJECTS_PATH = "projects/"; const QString PRESETS_PATH = "presets/"; @@ -207,8 +206,7 @@ private: QVBoxLayout * m_contentLayout; - // lmmsMainWin-dtor is allowed to destroy us... - friend lmmsMainWin::~lmmsMainWin(); + friend class engine; } ; diff --git a/include/cpuload_widget.h b/include/cpuload_widget.h index 42ce339c4b..cfe6e364b4 100644 --- a/include/cpuload_widget.h +++ b/include/cpuload_widget.h @@ -2,7 +2,7 @@ * cpuload_widget.h - widget for displaying CPU-load (partly based on * Hydrogen's CPU-load-widget) * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -44,18 +44,19 @@ #endif #include "types.h" +#include "engine.h" -class cpuloadWidget : public QWidget +class cpuloadWidget : public QWidget, public engineObject { Q_OBJECT public: - cpuloadWidget( QWidget * _parent ); - ~cpuloadWidget(); + cpuloadWidget( QWidget * _parent, engine * _engine ); + virtual ~cpuloadWidget(); protected: - void paintEvent( QPaintEvent * _ev ); + virtual void paintEvent( QPaintEvent * _ev ); protected slots: diff --git a/include/dummy_plugin.h b/include/dummy_plugin.h index c620c5efa9..fadad4da73 100644 --- a/include/dummy_plugin.h +++ b/include/dummy_plugin.h @@ -33,8 +33,8 @@ class dummyPlugin : public plugin { public: - inline dummyPlugin( void ) : - plugin( NULL ) + inline dummyPlugin( engine * _engine = NULL ) : + plugin( NULL, _engine ) { } diff --git a/include/engine.h b/include/engine.h index c67603d8f1..4d9ed94ff0 100644 --- a/include/engine.h +++ b/include/engine.h @@ -26,17 +26,21 @@ #ifndef _ENGINE_H #define _ENGINE_H -class mixer; -class lmmsMainWin; -class songEditor; +#include "qt3support.h" + + class bbEditor; +class mainWindow; +class mixer; class pianoRoll; +class projectNotes; +class songEditor; class engine { public: - engine( bool _has_gui = TRUE ); + engine( const bool _has_gui = TRUE ); engine( const engine & _engine ); ~engine(); @@ -55,7 +59,12 @@ public: return( m_mixer ); } - inline lmmsMainWin * getMainWindow( void ) + inline const mixer * getMixer( void ) const + { + return( m_mixer ); + } + + inline mainWindow * getMainWindow( void ) { return( m_mainWindow ); } @@ -65,6 +74,11 @@ public: return( m_songEditor ); } + inline const songEditor * getSongEditor( void ) const + { + return( m_songEditor ); + } + inline bbEditor * getBBEditor( void ) { return( m_bbEditor ); @@ -75,15 +89,21 @@ public: return( m_pianoRoll ); } + inline projectNotes * getProjectNotes( void ) + { + return( m_projectNotes ); + } + private: bool m_hasGUI; mixer * m_mixer; - lmmsMainWin * m_mainWindow; + mainWindow * m_mainWindow; songEditor * m_songEditor; bbEditor * m_bbEditor; pianoRoll * m_pianoRoll; + projectNotes * m_projectNotes; } ; @@ -100,6 +120,11 @@ public: return( m_engine ); } + inline const engine * eng( void ) const + { + return( m_engine ); + } + inline bool hasGUI( void ) const { return( m_engine->hasGUI() ); diff --git a/include/envelope_and_lfo_widget.h b/include/envelope_and_lfo_widget.h index 80070dbe2e..815e117c52 100644 --- a/include/envelope_and_lfo_widget.h +++ b/include/envelope_and_lfo_widget.h @@ -3,7 +3,7 @@ * is used by envelope/lfo/filter-tab of * channel-window * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -37,10 +37,14 @@ #ifdef QT4 #include +#include +#include #else #include +#include +#include #endif @@ -63,22 +67,26 @@ class tempoSyncKnob; class envelopeAndLFOWidget : public QWidget, public settings, - public specialBgHandlingWidget + public specialBgHandlingWidget, + public engineObject { Q_OBJECT public: - envelopeAndLFOWidget( float _value_for_zero_amount, QWidget * _parent ); - ~envelopeAndLFOWidget(); + envelopeAndLFOWidget( float _value_for_zero_amount, QWidget * _parent, + engine * _engine ); + virtual ~envelopeAndLFOWidget(); static inline float expKnobVal( float val ) { return( ( ( val < 0 ) ? -1 : 1 ) * val*val ); } - static void triggerLFO( void ); - static void resetLFO( void ); - float FASTCALL level( Uint32 _frame, Uint32 _release_begin, - Uint32 _frame_offset ) const; + static void triggerLFO( engine * _engine ); + static void resetLFO( engine * _engine ); + + float FASTCALL level( f_cnt_t _frame, + const f_cnt_t _release_begin, + const f_cnt_t _frame_offset ) const; inline bool used( void ) const { @@ -105,7 +113,8 @@ protected: virtual void mousePressEvent( QMouseEvent * _me ); virtual void paintEvent( QPaintEvent * _pe ); - float FASTCALL lfoLevel( Uint32 _frame, Uint32 _frame_offset ) const; + float FASTCALL lfoLevel( f_cnt_t _frame, + const f_cnt_t _frame_offset ) const; protected slots: @@ -122,10 +131,11 @@ private: static QPixmap * s_envGraph; static QPixmap * s_lfoGraph; - static Uint32 s_lfoFrame; + static QMap > s_EaLWidgets; bool m_used; + // envelope-stuff knob * m_predelayKnob; knob * m_attackKnob; @@ -139,10 +149,10 @@ private: float m_amount; float m_valueForZeroAmount; float m_amountAdd; - Uint32 m_pahdFrames; - Uint32 m_rFrames; - float * m_pahdEnv; - float * m_rEnv; + f_cnt_t m_pahdFrames; + f_cnt_t m_rFrames; + sample_t * m_pahdEnv; + sample_t * m_rEnv; // LFO-stuff knob * m_lfoPredelayKnob; @@ -158,12 +168,13 @@ private: ledCheckBox * m_x100Cb; ledCheckBox * m_controlEnvAmountCb; - Uint32 m_lfoPredelayFrames; - Uint32 m_lfoAttackFrames; - Uint32 m_lfoOscillationFrames; + f_cnt_t m_lfoPredelayFrames; + f_cnt_t m_lfoAttackFrames; + f_cnt_t m_lfoOscillationFrames; + f_cnt_t m_lfoFrame; float m_lfoAmount; bool m_lfoAmountIsZero; - float * m_lfoShapeData; + sample_t * m_lfoShapeData; sampleBuffer m_userWave; enum lfoShapes diff --git a/include/envelope_tab_widget.h b/include/envelope_tab_widget.h index 7e2eb48c6c..5c6bccb27e 100644 --- a/include/envelope_tab_widget.h +++ b/include/envelope_tab_widget.h @@ -57,14 +57,16 @@ class pixmapButton; class tabWidget; -class envelopeTabWidget : public QWidget, public settings +class envelopeTabWidget : public QWidget, public settings, + public engineObject { Q_OBJECT public: envelopeTabWidget( channelTrack * _channel_track ); virtual ~envelopeTabWidget(); - void FASTCALL processAudioBuffer( sampleFrame * _ab, Uint32 _frames, + void FASTCALL processAudioBuffer( sampleFrame * _ab, + const fpab_t _frames, notePlayHandle * _n ); enum targets @@ -77,10 +79,10 @@ public: TARGET_COUNT } ; - Uint32 envFrames( void ); - Uint32 releaseFrames( void ); + f_cnt_t envFrames( void ); + f_cnt_t releaseFrames( void ); - float FASTCALL volumeLevel( notePlayHandle * _n, Uint32 _frame ); + float FASTCALL volumeLevel( notePlayHandle * _n, const f_cnt_t _frame ); virtual void FASTCALL saveSettings( QDomDocument & _doc, diff --git a/include/export.h b/include/export.h index a5f896a33a..6426a8bc1f 100644 --- a/include/export.h +++ b/include/export.h @@ -29,6 +29,7 @@ class audioFileDevice; +class mixer; typedef audioFileDevice * ( * getDeviceInst)( const sample_rate_t _sample_rate, @@ -38,7 +39,8 @@ typedef audioFileDevice * ( * getDeviceInst)( const sample_rate_t _sample_rate, const bool _use_vbr, const bitrate_t _nom_bitrate, const bitrate_t _min_bitrate, - const bitrate_t _max_bitrate ); + const bitrate_t _max_bitrate, + mixer * _mixer ); enum fileTypes diff --git a/include/export_project_dialog.h b/include/export_project_dialog.h index 3d4584fae9..6800541eb1 100644 --- a/include/export_project_dialog.h +++ b/include/export_project_dialog.h @@ -44,6 +44,7 @@ #endif #include "export.h" +#include "engine.h" class QLabel; @@ -55,12 +56,13 @@ class ledCheckBox; class pixmapButton; -class exportProjectDialog : public QDialog +class exportProjectDialog : public QDialog, public engineObject { Q_OBJECT public: - exportProjectDialog( const QString & _file_name, QWidget * _parent ); - ~exportProjectDialog(); + exportProjectDialog( const QString & _file_name, QWidget * _parent, + engine * _engine ); + virtual ~exportProjectDialog(); public slots: @@ -68,8 +70,8 @@ public slots: protected: - void keyPressEvent( QKeyEvent * _ke ); - void closeEvent( QCloseEvent * _ce ); + virtual void keyPressEvent( QKeyEvent * _ke ); + virtual void closeEvent( QCloseEvent * _ce ); private slots: @@ -85,6 +87,7 @@ private: _ext ); static Sint16 s_availableBitrates[]; + QString m_fileName; QLabel * m_typeLbl; comboBox * m_typeCombo; diff --git a/include/fade_button.h b/include/fade_button.h index 40d320a327..45d9db3de8 100644 --- a/include/fade_button.h +++ b/include/fade_button.h @@ -1,7 +1,7 @@ /* * fade_button.h - declaration of class fadeButton * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * diff --git a/include/file_browser.h b/include/file_browser.h index 25a90a6501..617d3582b3 100644 --- a/include/file_browser.h +++ b/include/file_browser.h @@ -1,7 +1,7 @@ /* * file_browser.h - include file for fileBrowser * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -46,7 +46,7 @@ #include "side_bar_widget.h" - +#include "engine.h" class fileItem; @@ -57,13 +57,13 @@ class trackContainer; -class fileBrowser : public sideBarWidget +class fileBrowser : public sideBarWidget, public engineObject { Q_OBJECT public: fileBrowser( const QString & _path, const QString & _filter, const QString & _title, const QPixmap & _pm, - QWidget * _parent ); + QWidget * _parent, engine * _engine ); virtual ~fileBrowser(); @@ -100,12 +100,12 @@ private: -class listView : public Q3ListView +class listView : public Q3ListView, public engineObject { Q_OBJECT public: - listView( QWidget * _parent ); - ~listView(); + listView( QWidget * _parent, engine * _engine ); + virtual ~listView(); protected: diff --git a/include/instrument.h b/include/instrument.h index ed5a2bbe89..f12ea53707 100644 --- a/include/instrument.h +++ b/include/instrument.h @@ -82,7 +82,7 @@ public: // (note with unspecified length) // Per default this function returns 0. In this case, channel is using // the length of the longest envelope (if one active). - virtual Uint32 FASTCALL beatLen( notePlayHandle * _n ) const; + virtual f_cnt_t FASTCALL beatLen( notePlayHandle * _n ) const; // instrument-play-handles use this for checking whether they can mark @@ -110,7 +110,7 @@ protected: inline void invalidate( void ) { m_valid = FALSE; - mixer::inst()->checkValidityOfPlayHandles(); + eng()->getMixer()->checkValidityOfPlayHandles(); } diff --git a/include/instrument_play_handle.h b/include/instrument_play_handle.h index 19c4e02793..834e96483d 100644 --- a/include/instrument_play_handle.h +++ b/include/instrument_play_handle.h @@ -1,7 +1,7 @@ /* * instrument_play_handle.h - play-handle for playing an instrument * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -33,8 +33,8 @@ class instrumentPlayHandle : public playHandle { public: - inline instrumentPlayHandle( instrument * _instrument ) : - playHandle( INSTRUMENT_PLAY_HANDLE ), + inline instrumentPlayHandle( instrument * _instrument ) FASTCALL : + playHandle( INSTRUMENT_PLAY_HANDLE, _instrument->eng() ), m_instrument( _instrument ) { } diff --git a/include/knob.h b/include/knob.h index 640547edf9..7d32f76b08 100644 --- a/include/knob.h +++ b/include/knob.h @@ -4,7 +4,7 @@ * This file is based on the knob-widget of the Qwt Widget Library by * Josef Wilgen * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -44,6 +44,9 @@ #endif +#include "engine.h" + + class QPixmap; class textFloat; @@ -55,11 +58,12 @@ enum knobTypes -class knob : public QWidget +class knob : public QWidget, public engineObject { Q_OBJECT public: - knob( int _knob_num, QWidget * _parent, const QString & _name ); + knob( int _knob_num, QWidget * _parent, const QString & _name, + engine * _engine ); virtual ~knob(); diff --git a/include/main_window.h b/include/main_window.h new file mode 100644 index 0000000000..9e4243efb2 --- /dev/null +++ b/include/main_window.h @@ -0,0 +1,165 @@ +/* + * main_window.h - declaration of class mainWindow, the main window of LMMS + * + * Copyright (c) 2004-2006 Tobias Doerffel + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + + +#ifndef _MAIN_WINDOW_H +#define _MAIN_WINDOW_H + +#include "qt3support.h" + +#ifdef QT4 + +#include +#include +#include + +#else + +#include +#include +#include + +#endif + + +#ifdef HAVE_CONFIG_H +#include +#endif + + +#include "types.h" +#include "engine.h" + + +class QGridLayout; +class QSplashScreen; + +class configManager; +class toolButton; + + + +class mainWindow : public QMainWindow, public engineObject +{ + Q_OBJECT +public: + inline QWorkspace * workspace( void ) + { + return( m_workspace ); + } + + inline QWidget * toolBar( void ) + { + return( m_toolBar ); + } + + int addWidgetToToolBar( QWidget * _w, int _row = -1, int _col = -1 ); + void addSpacingToToolBar( int _size ); + + void FASTCALL resetWindowTitle( const QString & _add = "" ); + + void clearKeyModifiers( void ); + + inline bool isCtrlPressed( void ) + { + return( m_keyMods.m_ctrl ); + } + + inline bool isShiftPressed( void ) + { + return( m_keyMods.m_shift ); + } + + inline bool isAltPressed( void ) + { + return( m_keyMods.m_alt ); + } + + static QSplashScreen * s_splashScreen; + + +public slots: + inline void emptySlot( void ) + { + } + inline void enterWhatsThisMode( void ) + { + QWhatsThis::enterWhatsThisMode(); + } + void createNewProject( void ); + void createNewProjectFromTemplate( int _idx ); + void openProject( void ); + bool saveProject( void ); + bool saveProjectAs( void ); + void showSettingsDialog( void ); + void aboutLMMS( void ); + void help( void ); + void toggleBBEditorWin( void ); + void toggleSongEditorWin( void ); + void toggleProjectNotesWin( void ); + void togglePianoRollWin( void ); + + +protected: + virtual void closeEvent( QCloseEvent * _ce ); + virtual void focusOutEvent( QFocusEvent * _fe ); + virtual void keyPressEvent( QKeyEvent * _ke ); + virtual void keyReleaseEvent( QKeyEvent * _ke ); + + +private: + mainWindow( engine * _engine ); + mainWindow( const mainWindow & ); + virtual ~mainWindow(); + + void finalize( void ); + + + QWorkspace * m_workspace; + + QWidget * m_toolBar; + QGridLayout * m_toolBarLayout; + + QMenu * m_templatesMenu; + + struct keyModifiers + { + keyModifiers() : + m_ctrl( FALSE ), + m_shift( FALSE ), + m_alt( FALSE ) + { + } + bool m_ctrl; + bool m_shift; + bool m_alt; + } m_keyMods; + + + friend class engine; + +} ; + +#endif + diff --git a/include/micro_timer.h b/include/micro_timer.h index c4e25762bc..3fe49d89c0 100644 --- a/include/micro_timer.h +++ b/include/micro_timer.h @@ -1,7 +1,7 @@ /* * micro_timer.h - simple high-precision timer * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * diff --git a/include/midi_alsa_raw.h b/include/midi_alsa_raw.h index 37775bee24..bd9052dbc8 100644 --- a/include/midi_alsa_raw.h +++ b/include/midi_alsa_raw.h @@ -1,7 +1,7 @@ /* * midi_alsa_raw.h - midi-client for RawMIDI via ALSA * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -61,8 +61,8 @@ class QLineEdit; class midiALSARaw : public midiClientRaw, public QThread { public: - midiALSARaw( void ); - ~midiALSARaw(); + midiALSARaw( engine * _engine ); + virtual ~midiALSARaw(); static QString probeDevice( void ); diff --git a/include/midi_alsa_seq.h b/include/midi_alsa_seq.h index 968e371ed1..9dd9fa1da6 100644 --- a/include/midi_alsa_seq.h +++ b/include/midi_alsa_seq.h @@ -1,7 +1,7 @@ /* * midi_alsa_seq.h - ALSA-sequencer-client * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -71,8 +71,8 @@ class midiALSASeq : { Q_OBJECT public: - midiALSASeq( void ); - ~midiALSASeq(); + midiALSASeq( engine * _engine ); + virtual ~midiALSASeq(); static QString probeDevice( void ); @@ -143,7 +143,7 @@ public: private slots: - void changeQueueTempo( int _bpm ); + void changeQueueTempo( bpm_t _bpm ); void updatePortList( void ); diff --git a/include/midi_client.h b/include/midi_client.h index fbd3d9c641..9724433ab3 100644 --- a/include/midi_client.h +++ b/include/midi_client.h @@ -44,16 +44,17 @@ #include "midi.h" #include "midi_event_processor.h" #include "tab_widget.h" +#include "engine.h" class midiPort; // base-class for all MIDI-clients -class midiClient +class midiClient : public engineObject { public: - midiClient( void ); + midiClient( engine * _engine ); virtual ~midiClient(); // to be implemented by sub-classes @@ -143,7 +144,7 @@ const Uint8 RAW_MIDI_PARSE_BUF_SIZE = 16; class midiClientRaw : public midiClient { public: - midiClientRaw( void ); + midiClientRaw( engine * _engine ); virtual ~midiClientRaw(); // we are raw-clients for sure! diff --git a/include/midi_dummy.h b/include/midi_dummy.h index 01dac7d09e..9bb28cb636 100644 --- a/include/midi_dummy.h +++ b/include/midi_dummy.h @@ -1,7 +1,7 @@ /* * midi_dummy.h - dummy MIDI-driver * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -35,11 +35,11 @@ class midiDummy : public midiClientRaw { public: - midiDummy() : - midiClientRaw() + midiDummy( engine * _engine ) : + midiClientRaw( _engine ) { } - ~midiDummy() + virtual ~midiDummy() { } diff --git a/include/midi_oss.h b/include/midi_oss.h index ebbdde4e34..52f18d22f5 100644 --- a/include/midi_oss.h +++ b/include/midi_oss.h @@ -1,7 +1,7 @@ /* * midi_oss.h - OSS-raw-midi-client * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -43,8 +43,8 @@ class QLineEdit; class midiOSS : public midiClientRaw, public QThread { public: - midiOSS( void ); - ~midiOSS(); + midiOSS( engine * _engine ); + virtual ~midiOSS(); static QString probeDevice( void ); diff --git a/include/midi_port.h b/include/midi_port.h index fe56e707be..23a5763eba 100644 --- a/include/midi_port.h +++ b/include/midi_port.h @@ -2,7 +2,7 @@ * midi_port.h - abstraction of MIDI-ports which are part of LMMS's MIDI- * sequencing system * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * diff --git a/include/midi_tab_widget.h b/include/midi_tab_widget.h index 2d9c4030b1..b8841c01c3 100644 --- a/include/midi_tab_widget.h +++ b/include/midi_tab_widget.h @@ -44,6 +44,7 @@ #endif #include "settings.h" +#include "engine.h" class QMenu; @@ -57,12 +58,12 @@ class lcdSpinBox; class midiPort; -class midiTabWidget : public QWidget, public settings +class midiTabWidget : public QWidget, public settings, public engineObject { Q_OBJECT public: midiTabWidget( channelTrack * _channel_track, midiPort * _port ); - ~midiTabWidget(); + virtual ~midiTabWidget(); virtual void FASTCALL saveSettings( QDomDocument & _doc, diff --git a/include/midi_time.h b/include/midi_time.h index c47336ede5..a282889be7 100644 --- a/include/midi_time.h +++ b/include/midi_time.h @@ -2,7 +2,7 @@ * midi_time.h - declaration of class midiTime which provides data-type for * position- and length-variables * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -98,11 +98,11 @@ public: } // calculate number of frame that are needed this time - inline Uint32 frames( const float _frames_per_tact ) const + inline f_cnt_t frames( const float _frames_per_tact ) const { if( m_tact >= 0 ) { - return( static_cast( m_tact * + return( static_cast( m_tact * _frames_per_tact + m_tact64th * _frames_per_tact / @@ -111,7 +111,7 @@ public: return( 0 ); } - static inline midiTime fromFrames( Uint32 _frames, + static inline midiTime fromFrames( const f_cnt_t _frames, const float _frames_per_tact ) { return( midiTime( static_cast( _frames * 64.0f / diff --git a/include/mixer.h b/include/mixer.h index 5f379d67f3..624530b4cb 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -52,12 +52,11 @@ #include "note.h" #include "play_handle.h" #include "effect_board.h" +#include "engine.h" class audioDevice; class midiClient; -class lmmsMainWin; -class plugin; class audioPort; @@ -107,47 +106,14 @@ const octaves BASE_OCTAVE = OCTAVE_4; -class mixer : public QObject +class mixer : public QObject, public engineObject { Q_OBJECT public: - static inline mixer * inst( void ) - { - if( s_instanceOfMe == NULL ) - { - s_instanceOfMe = new mixer(); - } - return( s_instanceOfMe ); - } + void initDevices( void ); + void FASTCALL clear( const bool _everything = FALSE ); - void FASTCALL bufferToPort( const sampleFrame * _buf, - const fpab_t _frames, - const fpab_t _framesAhead, - const volumeVector & _volumeVector, - audioPort * _port ); - - inline fpab_t framesPerAudioBuffer( void ) const - { - return( m_framesPerAudioBuffer ); - } - - inline Uint8 cpuLoad( void ) const - { - return( m_cpuLoad ); - } - - inline bool highQuality( void ) const - { - return( m_qualityLevel > DEFAULT_QUALITY_LEVEL ); - } - - - inline const surroundSampleFrame * currentAudioBuffer( void ) const - { - return( m_curBuf ); - } - // audio-device-stuff inline const QString & audioDevName( void ) const { @@ -181,6 +147,7 @@ public: } } + // MIDI-client-stuff inline const QString & midiClientName( void ) const { @@ -193,6 +160,7 @@ public: } + // play-handle stuff inline void addPlayHandle( playHandle * _ph ) { if( criticalXRuns() == FALSE ) @@ -217,9 +185,36 @@ public: void checkValidityOfPlayHandles( void ); + inline bool haveNoRunningNotes( void ) const + { + return( m_playHandles.size() == 0 ); + } - inline sample_rate_t sampleRate( void ) + // methods providing information for other classes + inline fpab_t framesPerAudioBuffer( void ) const + { + return( m_framesPerAudioBuffer ); + } + + inline const surroundSampleFrame * currentAudioBuffer( void ) const + { + return( m_curBuf ); + } + + + inline Uint8 cpuLoad( void ) const + { + return( m_cpuLoad ); + } + + inline bool highQuality( void ) const + { + return( m_qualityLevel > DEFAULT_QUALITY_LEVEL ); + } + + + inline sample_rate_t sampleRate( void ) const { return( SAMPLE_RATES[m_qualityLevel] ); } @@ -250,6 +245,7 @@ public: } + // methods for controlling mixer-state void pause( void ) { if( m_mixMutexLockLevel == 0 ) @@ -269,8 +265,12 @@ public: } - void FASTCALL clear( const bool _everything = FALSE ); - + // audio-buffer-mgm + void FASTCALL bufferToPort( const sampleFrame * _buf, + const fpab_t _frames, + const fpab_t _framesAhead, + const volumeVector & _volumeVector, + audioPort * _port ); void FASTCALL clearAudioBuffer( sampleFrame * _ab, const f_cnt_t _frames ); @@ -279,11 +279,6 @@ public: const f_cnt_t _frames ); #endif - inline bool haveNoRunningNotes( void ) const - { - return( m_playHandles.size() == 0 ); - } - bool criticalXRuns( void ) const; const surroundSampleFrame * renderNextBuffer( void ); @@ -300,17 +295,16 @@ signals: private: - - static mixer * s_instanceOfMe; - - mixer(); + mixer( engine * _engine ); ~mixer(); + void startProcessing( void ); void stopProcessing( void ); // we don't allow to create mixer by using copy-ctor - mixer( const mixer & ) + mixer( const mixer & ) : + engineObject( NULL ) { } @@ -353,7 +347,7 @@ private: Uint8 m_mixMutexLockLevel; - friend class lmmsMainWin; + friend class engine; } ; diff --git a/include/name_label.h b/include/name_label.h index e940500bfd..8a6f65f8fc 100644 --- a/include/name_label.h +++ b/include/name_label.h @@ -41,13 +41,16 @@ #endif +#include "engine.h" -class nameLabel : public QLabel + +class nameLabel : public QLabel, public engineObject { Q_OBJECT public: - nameLabel( const QString & _initial_name, QWidget * _parent ); - ~nameLabel(); + nameLabel( const QString & _initial_name, QWidget * _parent, + engine * _engine ); + virtual ~nameLabel(); const QPixmap & pixmap( void ) const { diff --git a/include/note_play_handle.h b/include/note_play_handle.h index b4802161ff..b8b5abc5e4 100644 --- a/include/note_play_handle.h +++ b/include/note_play_handle.h @@ -27,8 +27,6 @@ #ifndef _NOTE_PLAY_HANDLE_H #define _NOTE_PLAY_HANDLE_H -#include - #include "play_handle.h" #include "basic_filters.h" #include "note.h" @@ -47,10 +45,10 @@ public: void * m_pluginData; basicFilters<> * m_filter; - notePlayHandle( channelTrack * _chnl_trk, const Uint32 _frames_ahead, - const Uint32 _frames, note * _n, + notePlayHandle( channelTrack * _chnl_trk, const f_cnt_t _frames_ahead, + const f_cnt_t _frames, note * _n, const bool _arp_note = FALSE ) FASTCALL; - ~notePlayHandle(); + virtual ~notePlayHandle(); virtual void play( void ); @@ -65,34 +63,34 @@ public: virtual void checkValidity( void ); - void FASTCALL noteOff( Uint32 _s = 0 ); + void FASTCALL noteOff( const f_cnt_t _s = 0 ); - inline Uint32 framesBeforeRelease( void ) const + inline f_cnt_t framesBeforeRelease( void ) const { return( m_framesBeforeRelease ); } - inline Uint32 releaseFramesDone( void ) const + inline f_cnt_t releaseFramesDone( void ) const { return( m_releaseFramesDone ); } - Uint32 actualReleaseFramesToDo( void ) const; + f_cnt_t actualReleaseFramesToDo( void ) const; // returns how many samples this note is aligned ahead, i.e. // at which position it is inserted in the according buffer - inline Uint32 framesAhead( void ) const + inline f_cnt_t framesAhead( void ) const { return ( m_framesAhead ); } // returns total numbers of frames to play - inline Uint32 frames( void ) const + inline f_cnt_t frames( void ) const { return( m_frames ); } - void setFrames( Uint32 _frames ); + void setFrames( const f_cnt_t _frames ); // returns whether note was released inline bool released( void ) const @@ -101,13 +99,13 @@ public: } // returns total numbers of played frames - inline Uint32 totalFramesPlayed( void ) const + inline f_cnt_t totalFramesPlayed( void ) const { return( m_totalFramesPlayed ); } // returns volume-level at frame _frame (envelope/LFO) - float FASTCALL volumeLevel( Uint32 _frame ); + float FASTCALL volumeLevel( const f_cnt_t _frame ); // adds note-play-handle _n as subnote inline void addSubNote( notePlayHandle * _n ) @@ -139,7 +137,7 @@ public: return( m_arpNote ); } - inline void setArpNote( bool _on ) + inline void setArpNote( const bool _on ) { m_arpNote = _on; } @@ -172,17 +170,17 @@ public: private: channelTrack * m_channelTrack; // needed for calling // channelTrack::playNote - Uint32 m_frames; // total frames to play - Uint32 m_framesAhead; // numbers of frames ahead in buffer + f_cnt_t m_frames; // total frames to play + f_cnt_t m_framesAhead; // numbers of frames ahead in buffer // to mix in - Uint32 m_totalFramesPlayed; // total frame-counter - used for + f_cnt_t m_totalFramesPlayed; // total frame-counter - used for // figuring out whether a whole note // has been played - Uint32 m_framesBeforeRelease; // number of frames after which note + f_cnt_t m_framesBeforeRelease; // number of frames after which note // is released - Uint32 m_releaseFramesToDo; // total numbers of frames to be + f_cnt_t m_releaseFramesToDo; // total numbers of frames to be // played after release - Uint32 m_releaseFramesDone; // number of frames done after + f_cnt_t m_releaseFramesDone; // number of frames done after // release of note notePlayHandleVector m_subNotes;// used for chords and arpeggios bool m_released; // indicates whether note is released diff --git a/include/oscillator.h b/include/oscillator.h index d7ec209498..f90a4886d2 100644 --- a/include/oscillator.h +++ b/include/oscillator.h @@ -71,7 +71,8 @@ public: oscillator( const modulationAlgos _modulation_algo, const float _freq, const Sint16 _phase_offset, const float _volume_factor, - oscillator * _m_subOsc ) FASTCALL; + const sample_rate_t _sample_rate, + oscillator * _m_subOsc ) FASTCALL; virtual ~oscillator() { delete m_subOsc; @@ -112,6 +113,7 @@ public: const float _freq, const Sint16 _phase_offset, const float _volume_factor, + const sample_rate_t _sample_rate, oscillator * _m_subOsc = NULL ); inline bool syncOk( void ) { @@ -212,6 +214,7 @@ protected: float m_freq; float m_volumeFactor; Sint16 m_phaseOffset; + const sample_rate_t m_sampleRate; oscillator * m_subOsc; f_cnt_t m_sample; float m_oscCoeff; diff --git a/include/pattern.h b/include/pattern.h index a5a88ba013..45361a3cf6 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -78,8 +78,8 @@ public: BEAT_PATTERN, MELODY_PATTERN/*, AUTOMATION_PATTERN*/ } ; - pattern( channelTrack * _channel_track ) FASTCALL; - pattern( const pattern & _pat_to_copy ) FASTCALL; + pattern( channelTrack * _channel_track ); + pattern( const pattern & _pat_to_copy ); virtual ~pattern(); void init( void ); @@ -139,8 +139,9 @@ public: // if channel-track recognizes that this pattern is frozen, it calls // this instead of playing all the notes - void FASTCALL playFrozenData( sampleFrame * _ab, Uint32 _start_frame, - Uint32 _frames ); + void FASTCALL playFrozenData( sampleFrame * _ab, + const f_cnt_t _start_frame, + const fpab_t _frames ); // settings-management virtual void FASTCALL saveSettings( QDomDocument & _doc, @@ -269,7 +270,7 @@ signals: -class patternFreezeThread : public QThread +class patternFreezeThread : public QThread, public engineObject { public: patternFreezeThread( pattern * _pattern ); diff --git a/include/piano_roll.h b/include/piano_roll.h index 94e9b46d0c..139ac2f44d 100644 --- a/include/piano_roll.h +++ b/include/piano_roll.h @@ -45,6 +45,7 @@ #include "types.h" #include "note.h" +#include "engine.h" class QPainter; @@ -52,26 +53,16 @@ class QPixmap; class QScrollBar; class comboBox; -class lmmsMainWin; class notePlayHandle; class pattern; class timeLine; class toolButton; -class pianoRoll : public QWidget +class pianoRoll : public QWidget, public engineObject { Q_OBJECT public: - static inline pianoRoll * inst( void ) - { - if( s_instanceOfMe == NULL ) - { - s_instanceOfMe = new pianoRoll(); - } - return( s_instanceOfMe ); - } - void FASTCALL setCurrentPattern( pattern * _new_pattern ); inline bool isRecording( void ) const @@ -170,14 +161,11 @@ private: } ; - pianoRoll( void ); + pianoRoll( engine * _engine ); pianoRoll( const pianoRoll & ); - ~pianoRoll(); + virtual ~pianoRoll(); - - static pianoRoll * s_instanceOfMe; - static QPixmap * s_whiteKeyBigPm; static QPixmap * s_whiteKeySmallPm; static QPixmap * s_blackKeyPm; @@ -251,7 +239,7 @@ private: - friend class lmmsMainWin; + friend class engine; signals: diff --git a/include/play_handle.h b/include/play_handle.h index 230e40123b..9e3a5ad280 100644 --- a/include/play_handle.h +++ b/include/play_handle.h @@ -44,7 +44,10 @@ #endif -class playHandle +#include "engine.h" + + +class playHandle : public engineObject { public: enum types @@ -53,7 +56,8 @@ public: PRESET_PREVIEW_PLAY_HANDLE } ; - inline playHandle( types _type ) : + inline playHandle( const types _type, engine * _engine ) FASTCALL : + engineObject( _engine ), m_type( _type ) { } diff --git a/include/plugin.h b/include/plugin.h index a547c2a4ee..58fba3aded 100644 --- a/include/plugin.h +++ b/include/plugin.h @@ -49,6 +49,7 @@ #include "types.h" #include "settings.h" #include "embed.h" +#include "engine.h" #define STRINGIFY_PLUGIN_NAME(s) STR(s) @@ -58,7 +59,7 @@ class QPixmap; -class plugin : public settings +class plugin : public settings, public engineObject { public: enum pluginTypes @@ -85,7 +86,7 @@ public: } ; // contructor of a plugin - plugin( const descriptor * _descriptor ); + plugin( const descriptor * _descriptor, engine * _engine ); virtual ~plugin(); // returns public-name out of descriptor diff --git a/include/plugin_browser.h b/include/plugin_browser.h index 48eb17bd86..f09c936316 100644 --- a/include/plugin_browser.h +++ b/include/plugin_browser.h @@ -1,7 +1,7 @@ /* * plugin_browser.h - include file for pluginBrowser * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -53,11 +53,11 @@ class trackContainer; -class pluginBrowser : public sideBarWidget +class pluginBrowser : public sideBarWidget, public engineObject { Q_OBJECT public: - pluginBrowser( QWidget * _parent ); + pluginBrowser( QWidget * _parent, engine * _engine ); virtual ~pluginBrowser(); @@ -71,10 +71,11 @@ private: -class pluginDescWidget : public QWidget +class pluginDescWidget : public QWidget, public engineObject { public: - pluginDescWidget( const plugin::descriptor & _pd, QWidget * _parent ); + pluginDescWidget( const plugin::descriptor & _pd, QWidget * _parent, + engine * _engine ); virtual ~pluginDescWidget(); diff --git a/include/preset_preview_play_handle.h b/include/preset_preview_play_handle.h index cd93d2b838..7dfa8f94f8 100644 --- a/include/preset_preview_play_handle.h +++ b/include/preset_preview_play_handle.h @@ -27,31 +27,49 @@ #ifndef _PRESET_PREVIEW_PLAY_HANDLE_H #define _PRESET_PREVIEW_PLAY_HANDLE_H -#include "note_play_handle.h" +#include "qt3support.h" + +#ifdef QT4 + +#include +#include + +#else #include +#include +#endif + + +#include "note_play_handle.h" + + +class previewTrackContainer; class channelTrack; -class QMutex; class presetPreviewPlayHandle : public playHandle { public: - presetPreviewPlayHandle( const QString & _preset_file ); + presetPreviewPlayHandle( const QString & _preset_file, + engine * _engine ) FASTCALL; virtual ~presetPreviewPlayHandle(); virtual void play( void ); virtual bool done( void ) const; - static void cleanUp( void ); + static void cleanUp( engine * _engine ); static constNotePlayHandleVector nphsOfChannelTrack( const channelTrack * _ct ); private: - static channelTrack * s_globalChannelTrack; - static notePlayHandle * s_globalPreviewNote; - static QMutex s_globalDataMutex; + inline previewTrackContainer * previewTC( void ) + { + return( s_previewTCs[eng()] ); + } + + static QMap s_previewTCs; notePlayHandle * m_previewNote; diff --git a/include/project_notes.h b/include/project_notes.h index 59d9fcc35d..893cfb317d 100644 --- a/include/project_notes.h +++ b/include/project_notes.h @@ -1,7 +1,7 @@ /* * project_notes.h - header for project-notes-editor * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -39,6 +39,7 @@ #endif #include "settings.h" +#include "engine.h" class QAction; @@ -46,11 +47,13 @@ class QComboBox; class QTextEdit; -class projectNotes : public QMainWindow, public settings +class projectNotes : public QMainWindow, public settings, public engineObject { Q_OBJECT public: - projectNotes(); + projectNotes( engine * _engine ); + virtual ~projectNotes(); + void clear( void ); virtual void FASTCALL saveSettings( QDomDocument & _doc, diff --git a/include/sample_buffer.h b/include/sample_buffer.h index 46d0863101..e4e81168cd 100644 --- a/include/sample_buffer.h +++ b/include/sample_buffer.h @@ -57,7 +57,7 @@ class QPainter; -class sampleBuffer : public QObject +class sampleBuffer : public QObject, public engineObject { Q_OBJECT public: @@ -69,16 +69,16 @@ public: // constructor which either loads sample _audio_file or decodes // base64-data out of string - sampleBuffer( const QString & _audio_file = "", + sampleBuffer( engine * _engine, const QString & _audio_file = "", bool _is_base64_data = FALSE ); - sampleBuffer( const sampleFrame * _data, const f_cnt_t _frames ); - sampleBuffer( const f_cnt_t _frames ); + sampleBuffer( const sampleFrame * _data, const f_cnt_t _frames, + engine * _engine ); + sampleBuffer( const f_cnt_t _frames, engine * _engine ); - ~sampleBuffer(); + virtual ~sampleBuffer(); bool FASTCALL play( sampleFrame * _ab, const f_cnt_t _start_frame, - const fpab_t _frames = - mixer::inst()->framesPerAudioBuffer(), + const fpab_t _frames, const float _freq = BASE_FREQ, const bool _looped = FALSE, void * * _resampling_data = NULL ); @@ -131,15 +131,16 @@ public: static sampleBuffer * FASTCALL resample( sampleFrame * _data, const f_cnt_t _frames, const sample_rate_t _src_sr, - const sample_rate_t _dst_sr ); + const sample_rate_t _dst_sr, + engine * _engine ); static inline sampleBuffer * FASTCALL resample( - const sampleBuffer * _buf, + sampleBuffer * _buf, const sample_rate_t _src_sr, const sample_rate_t _dst_sr ) { return( resample( _buf->m_data, _buf->m_frames, _src_sr, - _dst_sr ) ); + _dst_sr, _buf->eng() ) ); } diff --git a/include/sample_play_handle.h b/include/sample_play_handle.h index ef2aa27133..049659f0a5 100644 --- a/include/sample_play_handle.h +++ b/include/sample_play_handle.h @@ -1,7 +1,7 @@ /* * sample_play_handle.h - play-handle for playing a sample * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -37,15 +37,16 @@ class audioPort; class samplePlayHandle : public playHandle { public: - samplePlayHandle( const QString & _sample_file ); - samplePlayHandle( sampleBuffer * _sample_buffer ); + samplePlayHandle( const QString & _sample_file, engine * _engine ) + FASTCALL; + samplePlayHandle( sampleBuffer * _sample_buffer ) FASTCALL; virtual ~samplePlayHandle(); virtual void play( void ); virtual bool done( void ) const; - Uint32 totalFrames( void ) const; - inline Uint32 framesDone( void ) const + f_cnt_t totalFrames( void ) const; + inline f_cnt_t framesDone( void ) const { return( m_frame ); } @@ -60,7 +61,7 @@ private: const bool m_ownSampleBuffer; bool m_doneMayReturnTrue; - Uint32 m_frame; + f_cnt_t m_frame; audioPort * m_audioPort; diff --git a/include/sample_track.h b/include/sample_track.h index 8330240f07..276500fcd5 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 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -58,8 +58,8 @@ public: virtual ~sampleTCO(); virtual void FASTCALL changeLength( const midiTime & _length ); - void FASTCALL play( sampleFrame * _ab, Uint32 _start_frame, - Uint32 _frames ); + void FASTCALL play( sampleFrame * _ab, f_cnt_t _start_frame, + const fpab_t _frames ); const QString & sampleFile( void ) const; virtual void FASTCALL saveSettings( QDomDocument & _doc, @@ -73,7 +73,7 @@ public: public slots: void setSampleFile( const QString & _sf ); - void updateLength( int = 0 ); + void updateLength( bpm_t = 0 ); protected: @@ -127,8 +127,9 @@ public: virtual trackTypes type( void ) const; virtual bool FASTCALL play( const midiTime & _start, - Uint32 _start_frame, Uint32 _frames, - Uint32 _frame_base, + const f_cnt_t _start_frame, + const fpab_t _frames, + const f_cnt_t _frame_base, Sint16 _tco_num = -1 ); virtual trackContentObject * FASTCALL createTCO( const midiTime & _pos ); diff --git a/include/setup_dialog.h b/include/setup_dialog.h index babe5c8d6d..23eefa4d95 100644 --- a/include/setup_dialog.h +++ b/include/setup_dialog.h @@ -53,7 +53,7 @@ class QSlider; class tabBar; -class setupDialog : public QDialog +class setupDialog : public QDialog, public engineObject { Q_OBJECT public: @@ -63,7 +63,8 @@ public: AUDIO_SETTINGS, MIDI_SETTINGS } ; - setupDialog( configTabs _tab_to_open = GENERAL_SETTINGS ); + setupDialog( engine * _engine, + configTabs _tab_to_open = GENERAL_SETTINGS ); virtual ~setupDialog(); diff --git a/include/song_editor.h b/include/song_editor.h index 17b73210bb..f512613ec1 100644 --- a/include/song_editor.h +++ b/include/song_editor.h @@ -38,16 +38,14 @@ class QSlider; class comboBox; class lcdSpinBox; -class lmmsMainWin; class pattern; -class projectNotes; class textFloat; class timeLine; -const int MIN_BPM = 10; -const int DEFAULT_BPM = 140; -const int MAX_BPM = 999; +const bpm_t MIN_BPM = 10; +const bpm_t DEFAULT_BPM = 140; +const bpm_t MAX_BPM = 999; const Uint16 MAX_SONG_LENGTH = 9999; @@ -75,11 +73,11 @@ public: m_currentFrame( 0 ) { } - inline void setCurrentFrame( Uint32 _f ) + inline void setCurrentFrame( const f_cnt_t _f ) { m_currentFrame = _f; } - inline Uint32 currentFrame( void ) const + inline f_cnt_t currentFrame( void ) const { return( m_currentFrame ); } @@ -87,20 +85,11 @@ public: bool m_timeLineUpdate; private: - Uint32 m_currentFrame; + f_cnt_t m_currentFrame; } ; - static inline songEditor * inst( void ) - { - if( s_instanceOfMe == NULL ) - { - s_instanceOfMe = new songEditor(); - } - return( s_instanceOfMe ); - } - void processNextBuffer( void ); @@ -140,7 +129,8 @@ public: tact lengthInTacts( void ) const; - int getBPM( void ); + bpm_t getTempo( void ); + // every function that replaces current file (e.g. creates new file, // opens another file...) has to call this before and may only process @@ -175,11 +165,6 @@ public: int masterPitch( void ) const; - projectNotes * getProjectNotesWindow( void ) - { - return( m_projectNotes ); - } - public slots: void play( void ); @@ -195,8 +180,9 @@ public slots: void startExport( void ); void stopExport( void ); - // set BPM (beats per minute) - void setBPM( int _new_bpm = DEFAULT_BPM ); + + // set tempo in BPM (beats per minute) + void setTempo( int _new_bpm = DEFAULT_BPM ); inline void setModified( void ) { @@ -244,7 +230,7 @@ protected slots: private: - songEditor(); + songEditor( engine * _engine ); songEditor( const songEditor & ); virtual ~songEditor(); @@ -266,8 +252,6 @@ private: - static songEditor * s_instanceOfMe; - QScrollBar * m_leftRightScroll; QWidget * m_toolBar; @@ -310,9 +294,6 @@ private: bool m_scrollBack; - projectNotes * m_projectNotes; - - enum ACTIONS { @@ -322,12 +303,11 @@ private: vvector m_actions; - friend class lmmsMainWin; - + friend class engine; signals: - void bpmChanged( int _new_bpm ); + void tempoChanged( bpm_t _new_bpm ); } ; diff --git a/include/string_pair_drag.h b/include/string_pair_drag.h index 0568946f59..09fd309274 100644 --- a/include/string_pair_drag.h +++ b/include/string_pair_drag.h @@ -2,7 +2,7 @@ * string_pair_drag.h - class stringPairDrag which provides general support * for drag'n'drop of string-pairs * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -39,19 +39,23 @@ #endif +#include "engine.h" + + class QPixmap; class stringPairDrag : public #ifdef QT4 - QDrag + QDrag, #else - QStoredDrag + QStoredDrag, #endif + public engineObject { public: stringPairDrag( const QString & _key, const QString & _value, - const QPixmap & _icon, QWidget * _w ); + const QPixmap & _icon, QWidget * _w, engine * _engine ); ~stringPairDrag(); static bool processDragEnterEvent( QDragEnterEvent * _dee, diff --git a/include/tempo_sync_knob.h b/include/tempo_sync_knob.h index 45c36970ec..b5d736a0a3 100644 --- a/include/tempo_sync_knob.h +++ b/include/tempo_sync_knob.h @@ -37,6 +37,7 @@ #endif #include "knob.h" +#include "types.h" class QAction; @@ -59,8 +60,8 @@ public: } ; - tempoSyncKnob( int _knob_num, QWidget * _parent, const QString & _name, - float _scale = 1.0f ); + tempoSyncKnob( int _knob_num, QWidget * _parent, const QString & _name, + engine * _engine, float _scale = 1.0f ); virtual ~tempoSyncKnob(); tempoSyncMode getSyncMode( void ); @@ -95,7 +96,7 @@ protected: protected slots: - void calculateTempoSyncTime( int _bpm ); + void calculateTempoSyncTime( bpm_t _bpm ); private: diff --git a/include/timeline.h b/include/timeline.h index 1a2c68fc1e..8c42091f25 100644 --- a/include/timeline.h +++ b/include/timeline.h @@ -1,7 +1,7 @@ /* * timeline.h - class timeLine, representing a time-line with position marker * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -47,7 +47,7 @@ class nStateButton; class textFloat; -class timeLine : public QWidget +class timeLine : public QWidget, public engineObject { Q_OBJECT public: @@ -68,7 +68,7 @@ public: timeLine( int _xoff, int _yoff, float _ppt, songEditor::playPos & _pos, - const midiTime & _begin, QWidget * _parent ); + const midiTime & _begin, QWidget * _parent, engine * _engine ); virtual ~timeLine(); inline songEditor::playPos & pos( void ) diff --git a/include/track.h b/include/track.h index 6da5d61fdd..87dd596315 100644 --- a/include/track.h +++ b/include/track.h @@ -2,7 +2,7 @@ * track.h - declaration of classes concerning tracks -> neccessary for all * track-like objects (beat/bassline, sample-track...) * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -56,6 +56,7 @@ #include "midi_time.h" #include "settings.h" #include "rubberband.h" +#include "engine.h" class QMenu; @@ -77,7 +78,8 @@ const Uint16 TRACK_OP_WIDTH = 70; const Uint16 TCO_BORDER_WIDTH = 1; -class trackContentObject : public selectableObject, public settings +class trackContentObject : public selectableObject, public settings, + public engineObject { Q_OBJECT public: @@ -345,7 +347,7 @@ private: // base-class for all tracks -class track : public settings +class track : public settings, public engineObject { public: enum trackTypes @@ -361,6 +363,7 @@ public: track( trackContainer * _tc ); virtual ~track(); + static track * FASTCALL create( trackTypes _tt, trackContainer * _tc ); static track * FASTCALL create( const QDomElement & _this, trackContainer * _tc ); @@ -383,9 +386,9 @@ public: virtual trackTypes type( void ) const = 0; virtual bool FASTCALL play( const midiTime & _start, - Uint32 _start_frame, - Uint32 _frames, - Uint32 _frame_base, + const f_cnt_t _start_frame, + const fpab_t _frames, + const f_cnt_t _frame_base, Sint16 _tco_num = -1 ) = 0; diff --git a/include/track_container.h b/include/track_container.h index c651426553..1e78beb411 100644 --- a/include/track_container.h +++ b/include/track_container.h @@ -47,19 +47,21 @@ #include "track.h" #include "settings.h" #include "rubberband.h" +#include "engine.h" + const Uint16 DEFAULT_PIXELS_PER_TACT = 16; - const Uint16 DEFAULT_SCROLLBAR_SIZE = 16; -class trackContainer : public QMainWindow, public settings + +class trackContainer : public QMainWindow, public settings, public engineObject { Q_OBJECT public: - trackContainer( void ); - ~trackContainer(); + trackContainer( engine * _engine ); + virtual ~trackContainer(); inline QWidget * containerWidget( void ) { @@ -100,7 +102,9 @@ public: void FASTCALL removeTrack( track * _track ); void FASTCALL moveTrackUp( track * _track ); void FASTCALL moveTrackDown( track * _track ); + void FASTCALL realignTracks( bool _complete_update = FALSE ); + void clearAllTracks( void ); const trackWidget * trackWidgetAt( const int _y ) const; diff --git a/include/visualization_widget.h b/include/visualization_widget.h index 0158dd38cf..160b8499ef 100644 --- a/include/visualization_widget.h +++ b/include/visualization_widget.h @@ -1,7 +1,7 @@ /* * visualization_widget.h - widget for visualization of sound-data * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -23,8 +23,8 @@ */ -#ifndef _OUTPUT_GRAPH_H -#define _OUTPUT_GRAPH_H +#ifndef _VISUALIZATION_WIDGET +#define _VISUALIZATION_WIDGET #include "qt3support.h" @@ -43,10 +43,11 @@ #include "mixer.h" + class QTimer; -class visualizationWidget : public QWidget +class visualizationWidget : public QWidget, public engineObject { Q_OBJECT public: @@ -55,6 +56,7 @@ public: SIMPLE // add more here } ; visualizationWidget( const QPixmap & _bg, QWidget * _parent, + engine * _engine, visualizationTypes _vtype = SIMPLE ); virtual ~visualizationWidget(); diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index 57a013b200..6ae7593184 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -1,7 +1,7 @@ /* * audio_file_processor.cpp - instrument for using audio-files * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -41,6 +41,8 @@ #include #include #include +#include +#include #endif @@ -88,7 +90,7 @@ QPixmap * audioFileProcessor::s_artwork = NULL; audioFileProcessor::audioFileProcessor( channelTrack * _channel_track ) : instrument( _channel_track, &audiofileprocessor_plugin_descriptor ), specialBgHandlingWidget( PLUGIN_NAME::getIconPixmap( "artwork" ) ), - m_sampleBuffer( "" ), + m_sampleBuffer( eng(), "" ), m_drawMethod( sampleBuffer::LINE_CONNECT ) { connect( &m_sampleBuffer, SIGNAL( sampleUpdated() ), this, @@ -166,7 +168,7 @@ audioFileProcessor::audioFileProcessor( channelTrack * _channel_track ) : "This is useful for things like string- and choir-" "samples." ) ); - m_ampKnob = new knob( knobDark_28, this, tr( "Amplify" ) ); + m_ampKnob = new knob( knobDark_28, this, tr( "Amplify" ), eng() ); m_ampKnob->setRange( 0, 500, 1.0f ); m_ampKnob->move( 6, 114 ); m_ampKnob->setValue( 100.0f, TRUE ); @@ -184,7 +186,8 @@ audioFileProcessor::audioFileProcessor( channelTrack * _channel_track ) : "Otherwise it will be amplified up or down (your " "actual sample-file isn't touched!)" ) ); - m_startKnob = new knob( knobDark_28, this, tr( "Start of sample" ) ); + m_startKnob = new knob( knobDark_28, this, tr( "Start of sample" ), + eng() ); m_startKnob->setRange( 0.0f, 1.0f, 0.00001f ); m_startKnob->move( 46, 114 ); m_startKnob->setValue( 0.0f, TRUE ); @@ -203,7 +206,7 @@ audioFileProcessor::audioFileProcessor( channelTrack * _channel_track ) : "which AudioFileProcessor returns if a note is longer " "than the sample between start- and end-point." ) ); - m_endKnob = new knob( knobDark_28, this, tr( "End of sample" ) ); + m_endKnob = new knob( knobDark_28, this, tr( "End of sample" ), eng() ); m_endKnob->setRange( 0.0f, 1.0f, 0.00001f ); m_endKnob->move( 84, 114 ); m_endKnob->setValue( 1.0f, TRUE ); @@ -365,7 +368,7 @@ Uint32 audioFileProcessor::getBeatLen( notePlayHandle * _n ) const const float freq_factor = BASE_FREQ / ( getChannelTrack()->frequency( _n ) * DEFAULT_SAMPLE_RATE / - mixer::inst()->sampleRate() ); + eng()->getMixer()->sampleRate() ); return( static_cast( floorf( ( m_sampleBuffer.endFrame() - m_sampleBuffer.startFrame() ) * @@ -398,12 +401,12 @@ void audioFileProcessor::setAudioFile( const QString & _audio_file ) void audioFileProcessor::playNote( notePlayHandle * _n ) { - const Uint32 frames = mixer::inst()->framesPerAudioBuffer(); + const Uint32 frames = eng()->getMixer()->framesPerAudioBuffer(); sampleFrame * buf = bufferAllocator::alloc( frames ); // calculate frequency of note const float note_freq = getChannelTrack()->frequency( _n ) / - ( mixer::inst()->sampleRate() / + ( eng()->getMixer()->sampleRate() / DEFAULT_SAMPLE_RATE ); if( m_sampleBuffer.play( buf, _n->totalFramesPlayed(), frames, note_freq, @@ -560,7 +563,7 @@ void audioFileProcessor::sampleUpdated( void ) void audioFileProcessor::reverseBtnToggled( bool _on ) { m_sampleBuffer.setReversed( _on ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -568,7 +571,7 @@ void audioFileProcessor::reverseBtnToggled( bool _on ) void audioFileProcessor::lineDrawBtnToggled( bool _on ) { - if( _on ) + if( _on == TRUE ) { m_drawMethod = sampleBuffer::LINE_CONNECT; sampleUpdated(); @@ -580,7 +583,7 @@ void audioFileProcessor::lineDrawBtnToggled( bool _on ) void audioFileProcessor::dotDrawBtnToggled( bool _on ) { - if( _on ) + if( _on == TRUE ) { m_drawMethod = sampleBuffer::DOTS; sampleUpdated(); @@ -592,7 +595,7 @@ void audioFileProcessor::dotDrawBtnToggled( bool _on ) void audioFileProcessor::ampKnobChanged( float _val ) { - m_sampleBuffer.setAmplification( _val/100.0f ); + m_sampleBuffer.setAmplification( _val / 100.0f ); } @@ -628,7 +631,7 @@ void audioFileProcessor::startKnobChanged( float _new_value ) } else { - m_startKnob->setValue( m_endKnob->value() - 0.01 ); + m_startKnob->setValue( m_endKnob->value() - 0.01f ); } update(); } @@ -653,7 +656,7 @@ void audioFileProcessor::endKnobChanged( float _new_value ) } else { - m_endKnob->setValue( m_startKnob->value() + 0.01 ); + m_endKnob->setValue( m_startKnob->value() + 0.01f ); } update(); } @@ -667,7 +670,7 @@ void audioFileProcessor::openAudioFile( void ) if( af != "" ) { setAudioFile( af ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } } diff --git a/plugins/bit_invader/bit_invader.cpp b/plugins/bit_invader/bit_invader.cpp index d9b3c0646f..0576a4657f 100644 --- a/plugins/bit_invader/bit_invader.cpp +++ b/plugins/bit_invader/bit_invader.cpp @@ -91,7 +91,7 @@ plugin::descriptor bitinvader_plugin_descriptor = QPixmap * bitInvader::s_artwork = NULL; -bSynth::bSynth(float* shape, int length, float _pitch, bool _interpolation, float factor) +bSynth::bSynth(float* shape, int length, float _pitch, bool _interpolation, float factor, const sample_rate_t _sample_rate ) { interpolation = _interpolation; @@ -110,8 +110,8 @@ bSynth::bSynth(float* shape, int length, float _pitch, bool _interpolation, floa sample_realindex = 0; - sample_step = static_cast( sample_length / - ((float)mixer::inst()->sampleRate() / _pitch) ); + sample_step = static_cast( sample_length / ( _sample_rate / + _pitch ) ); } @@ -190,7 +190,8 @@ bitInvader::bitInvader( channelTrack * _channel_track ) : } - m_sampleLengthKnob = new knob( knobDark_28, this, tr( "Samplelength" ) ); + m_sampleLengthKnob = new knob( knobDark_28, this, tr( "Samplelength" ), + eng() ); m_sampleLengthKnob->setRange( 8, 128, 1 ); m_sampleLengthKnob->setValue( 128, TRUE ); m_sampleLengthKnob->move( 10, 120 ); @@ -213,7 +214,7 @@ bitInvader::bitInvader( channelTrack * _channel_track ) : this, SLOT ( normalizeToggle( bool ) ) ); - m_graph = new graph( "", this ); + m_graph = new graph( this, eng() ); m_graph->move(53,118); // 55,120 - 2px border m_graph->setCursor( QCursor( Qt::CrossCursor ) ); @@ -436,7 +437,7 @@ void bitInvader::usrWaveClicked( void ) } // load user shape - sampleBuffer buffer; + sampleBuffer buffer( eng() ); QString af = buffer.openAudioFile(); if ( af != "" ) { @@ -634,15 +635,14 @@ void bitInvader::interpolationToggle( bool value ) { interpolation = value; - songEditor::inst()->setModified(); - + eng()->getSongEditor()->setModified(); } void bitInvader::normalizeToggle( bool value ) { normalize = value; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -674,8 +674,7 @@ void bitInvader::smoothClicked( void ) update(); m_graph->update(); - songEditor::inst()->setModified(); - + eng()->getSongEditor()->setModified(); } @@ -697,14 +696,15 @@ void bitInvader::playNote( notePlayHandle * _n ) } _n->m_pluginData = new bSynth( sample_shape, sample_length,freq - , interpolation, factor ); + , interpolation, factor, + eng()->getMixer()->sampleRate() ); } - const Uint32 frames = mixer::inst()->framesPerAudioBuffer(); + const fpab_t frames = eng()->getMixer()->framesPerAudioBuffer(); sampleFrame * buf = bufferAllocator::alloc( frames ); bSynth * ps = static_cast( _n->m_pluginData ); - for( Uint32 frame = 0; frame < frames; ++frame ) + for( fpab_t frame = 0; frame < frames; ++frame ) { const sample_t cur = ps->nextStringSample(); for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) @@ -772,7 +772,7 @@ void bitInvader::sampleSizeChanged( float _new_sample_length ) m_graph->setSamplePointer( sample_shape, sample_length ); // set Song modified - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -793,7 +793,7 @@ void bitInvader::sampleChanged() m_graph->update(); } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } diff --git a/plugins/bit_invader/bit_invader.h b/plugins/bit_invader/bit_invader.h index a79d8ee803..4d6b4658f6 100644 --- a/plugins/bit_invader/bit_invader.h +++ b/plugins/bit_invader/bit_invader.h @@ -53,7 +53,7 @@ class pixmapButton; class bSynth { public: - bSynth(float* sample, int length, float _pitch, bool _interpolation, float factor); + bSynth(float* sample, int length, float _pitch, bool _interpolation, float factor, const sample_rate_t _sample_rate); virtual ~bSynth(); sample_t nextStringSample(); diff --git a/plugins/bit_invader/graph.cpp b/plugins/bit_invader/graph.cpp index 4d195a35f5..3038b5e75a 100644 --- a/plugins/bit_invader/graph.cpp +++ b/plugins/bit_invader/graph.cpp @@ -50,8 +50,9 @@ using namespace std; -graph::graph( const QString & _text, QWidget * _parent) : - QWidget( _parent ) +graph::graph( QWidget * _parent, engine * _engine ) : + QWidget( _parent ), + engineObject( _engine ) { // m_background = 0; TODO @@ -86,7 +87,7 @@ void graph::setSamplePointer( float * _pointer, int _length ) update(); } -void graph::loadSampleFromFile( const QString filename ) +void graph::loadSampleFromFile( const QString & _filename ) { // zero sample_shape for (int i = 0; i < sampleLength; i++) @@ -95,9 +96,8 @@ void graph::loadSampleFromFile( const QString filename ) } // load user shape - sampleBuffer buffer; - buffer.setAudioFile( filename ); - + sampleBuffer buffer( eng(), _filename ); + // copy buffer data sampleLength = min( sampleLength, static_cast(buffer.frames()) ); for ( int i = 0; i < sampleLength; i++ ) diff --git a/plugins/bit_invader/graph.h b/plugins/bit_invader/graph.h index 02b6dcfc40..c71e2f4de6 100644 --- a/plugins/bit_invader/graph.h +++ b/plugins/bit_invader/graph.h @@ -39,22 +39,23 @@ #include #include #include + #endif -//class QPixmap; +#include "engine.h" -class graph : public QWidget +class graph : public QWidget, public engineObject { Q_OBJECT public: - graph( const QString & _txt, QWidget * _parent ); + graph( QWidget * _parent, engine * _engine ); virtual ~graph(); void setSamplePointer( float * pointer, int length ); void setBackground ( const QPixmap & _pixmap ); - void graph::loadSampleFromFile( QString filename ); + void loadSampleFromFile( const QString & _filename ); signals: void sampleSizeChanged( float f ); diff --git a/plugins/plucked_string_synth/plucked_string_synth.cpp b/plugins/plucked_string_synth/plucked_string_synth.cpp index 8579945ad0..80a7d7358a 100644 --- a/plugins/plucked_string_synth/plucked_string_synth.cpp +++ b/plugins/plucked_string_synth/plucked_string_synth.cpp @@ -72,13 +72,15 @@ plugin::descriptor pluckedstringsynth_plugin_descriptor = pluckedStringSynth::pluckedStringSynth( channelTrack * _channel_track ) : instrument( _channel_track, &pluckedstringsynth_plugin_descriptor ) { - m_pickKnob = new knob( knobDark_28, this, tr( "Pick position" ) ); + m_pickKnob = new knob( knobDark_28, this, tr( "Pick position" ), + eng() ); m_pickKnob->setRange( 0.0f, 0.5f, 0.005f ); m_pickKnob->setValue( 0.0f, TRUE ); m_pickKnob->move( 86, 134 ); m_pickKnob->setHintText( tr( "Pick position:" ) + " ", "" ); - m_pickupKnob = new knob( knobDark_28, this, tr( "Pickup position" ) ); + m_pickupKnob = new knob( knobDark_28, this, tr( "Pickup position" ), + eng() ); m_pickupKnob->setRange( 0.0f, 0.5f, 0.005f ); m_pickupKnob->setValue( 0.05f, TRUE ); m_pickupKnob->move( 138, 134 ); @@ -139,10 +141,11 @@ void pluckedStringSynth::playNote( notePlayHandle * _n ) { float freq = getChannelTrack()->frequency( _n ); _n->m_pluginData = new pluckSynth( freq, m_pickKnob->value(), - m_pickupKnob->value() ); + m_pickupKnob->value(), + eng()->getMixer()->sampleRate() ); } - const Uint32 frames = mixer::inst()->framesPerAudioBuffer(); + const Uint32 frames = eng()->getMixer()->framesPerAudioBuffer(); sampleFrame * buf = bufferAllocator::alloc( frames ); pluckSynth * ps = static_cast( _n->m_pluginData ); @@ -208,11 +211,11 @@ void FASTCALL pluckSynth::freeDelayLine( delayLine * _dl ) -pluckSynth::pluckSynth( float _pitch, float _pick, float _pickup ) +pluckSynth::pluckSynth( const float _pitch, const float _pick, + const float _pickup, const sample_rate_t _sample_rate ) { const float AMP = 1.5f; - int rail_length = static_cast( mixer::inst()->sampleRate() / 2 / - _pitch ) + 1; + int rail_length = static_cast( _sample_rate / 2 / _pitch ) + 1; // Round pick position to nearest spatial sample. // A pick position at x = 0 is not allowed. int pick_sample = static_cast( tMax( rail_length * _pick, diff --git a/plugins/plucked_string_synth/plucked_string_synth.h b/plugins/plucked_string_synth/plucked_string_synth.h index 13ef759f69..b544356846 100644 --- a/plugins/plucked_string_synth/plucked_string_synth.h +++ b/plugins/plucked_string_synth/plucked_string_synth.h @@ -38,7 +38,8 @@ class notePlayHandle; class pluckSynth { public: - pluckSynth( float _pitch, float _pick, float _pickup ); + pluckSynth( const float _pitch, const float _pick, const float _pickup, + const sample_rate_t _sample_rate ); inline ~pluckSynth( void ) { diff --git a/plugins/triple_oscillator/triple_oscillator.cpp b/plugins/triple_oscillator/triple_oscillator.cpp index e944ee0871..3c8ea9cf11 100644 --- a/plugins/triple_oscillator/triple_oscillator.cpp +++ b/plugins/triple_oscillator/triple_oscillator.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #define setChecked setOn @@ -53,6 +54,7 @@ #include "buffer_allocator.h" #include "debug.h" #include "tooltip.h" +#include "sample_buffer.h" #include "embed.cpp" @@ -81,6 +83,11 @@ tripleOscillator::tripleOscillator( channelTrack * _channel_track ) : m_modulationAlgo1( oscillator::MIX ), m_modulationAlgo2( oscillator::MIX ) { + for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) + { + m_osc[i].m_sampleBuffer = new sampleBuffer( eng() ); + } + #ifdef QT4 QPalette pal; pal.setBrush( backgroundRole(), @@ -258,10 +265,10 @@ tripleOscillator::tripleOscillator( channelTrack * _channel_track ) : // setup volume-knob m_osc[i].volKnob = new knob( knobSmall_17, this, tr( - "Osc %1 volume" ).arg( i+1 ) ); + "Osc %1 volume" ).arg( i+1 ), eng() ); m_osc[i].volKnob->move( 6, 104+i*50 ); m_osc[i].volKnob->setRange( MIN_VOLUME, MAX_VOLUME, 1.0f ); - m_osc[i].volKnob->setValue( DEFAULT_VOLUME, TRUE ); + m_osc[i].volKnob->setValue( DEFAULT_VOLUME / 3, TRUE ); m_osc[i].volKnob->setHintText( tr( "Osc %1 volume:" ).arg( i+1 ) + " ", "%" ); #ifdef QT4 @@ -277,7 +284,7 @@ tripleOscillator::tripleOscillator( channelTrack * _channel_track ) : // setup panning-knob m_osc[i].panKnob = new knob( knobSmall_17, this, - tr( "Osc %1 panning" ).arg( i + 1 ) ); + tr( "Osc %1 panning" ).arg( i + 1 ), eng() ); m_osc[i].panKnob->move( 33, 104+i*50 ); m_osc[i].panKnob->setRange( PANNING_LEFT, PANNING_RIGHT, 1.0f ); m_osc[i].panKnob->setValue( DEFAULT_PANNING, TRUE ); @@ -295,7 +302,8 @@ tripleOscillator::tripleOscillator( channelTrack * _channel_track ) : // setup coarse-knob m_osc[i].coarseKnob = new knob( knobSmall_17, this, - tr("Osc %1 coarse detuning").arg( i + 1 ) ); + tr("Osc %1 coarse detuning").arg( i + 1 ), + eng() ); m_osc[i].coarseKnob->move( 66, 104 + i * 50 ); m_osc[i].coarseKnob->setRange( -2 * NOTES_PER_OCTAVE, 2 * NOTES_PER_OCTAVE, 1.0f ); @@ -316,7 +324,8 @@ tripleOscillator::tripleOscillator( channelTrack * _channel_track ) : // setup knob for left fine-detuning m_osc[i].fineLKnob = new knob( knobSmall_17, this, - tr( "Osc %1 fine detuning left" ).arg( i+1 ) ); + tr( "Osc %1 fine detuning left" ).arg( i+1 ), + eng() ); m_osc[i].fineLKnob->move( 90, 104 + i * 50 ); m_osc[i].fineLKnob->setRange( -100.0f, 100.0f, 1.0f ); m_osc[i].fineLKnob->setValue( 0.0f, TRUE ); @@ -338,7 +347,7 @@ tripleOscillator::tripleOscillator( channelTrack * _channel_track ) : // setup knob for right fine-detuning m_osc[i].fineRKnob = new knob( knobSmall_17, this, tr( "Osc %1 fine detuning right" - ).arg( i + 1 ) ); + ).arg( i + 1 ), eng() ); m_osc[i].fineRKnob->move( 110, 104 + i * 50 ); m_osc[i].fineRKnob->setRange( -100.0f, 100.0f, 1.0f ); m_osc[i].fineRKnob->setValue( 0.0f, TRUE ); @@ -359,7 +368,8 @@ tripleOscillator::tripleOscillator( channelTrack * _channel_track ) : // setup phase-offset-knob m_osc[i].phaseOffsetKnob = new knob( knobSmall_17, this, tr( "Osc %1 phase-" - "offset" ).arg( i+1 ) ); + "offset" ).arg( i+1 ), + eng() ); m_osc[i].phaseOffsetKnob->move( 142, 104 + i * 50 ); m_osc[i].phaseOffsetKnob->setRange( 0.0f, 360.0f, 1.0f ); m_osc[i].phaseOffsetKnob->setValue( 0.0f, TRUE ); @@ -384,8 +394,8 @@ tripleOscillator::tripleOscillator( channelTrack * _channel_track ) : // setup stereo-phase-detuning-knob m_osc[i].stereoPhaseDetuningKnob = new knob( knobSmall_17, this, tr( "Osc %1 stereo phase-" - "detuning" ).arg( i+1 ) - ); + "detuning" ).arg( i+1 ), + eng() ); m_osc[i].stereoPhaseDetuningKnob->move( 166, 104 + i * 50 ); m_osc[i].stereoPhaseDetuningKnob->setRange( 0.0f, 360.0f, 1.0f ); @@ -601,6 +611,10 @@ tripleOscillator::tripleOscillator( channelTrack * _channel_track ) : tripleOscillator::~tripleOscillator() { + for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) + { + delete m_osc[i].m_sampleBuffer; + } } @@ -633,7 +647,7 @@ void tripleOscillator::saveSettings( QDomDocument & _doc, to_de.setAttribute( "wavetype" + is, QString::number( m_osc[i].waveShape ) ); to_de.setAttribute( "userwavefile" + is, - m_osc[i].m_sampleBuffer.audioFile() ); + m_osc[i].m_sampleBuffer->audioFile() ); } _parent.appendChild( to_de ); @@ -669,7 +683,7 @@ void tripleOscillator::loadSettings( const QDomElement & _this ) "phoffset" + is ).toFloat() ); m_osc[i].stereoPhaseDetuningKnob->setValue( _this.attribute( "stphdetun" + is ).toFloat() ); - m_osc[i].m_sampleBuffer.setAudioFile( _this.attribute( + m_osc[i].m_sampleBuffer->setAudioFile( _this.attribute( "userwavefile" + is ) ); switch( _this.attribute( "wavetype" + is ).toInt() ) { @@ -693,7 +707,7 @@ void tripleOscillator::loadSettings( const QDomElement & _this ) break; case oscillator::USER_DEF_WAVE: toolTip::add( m_osc[i].usrWaveBtn, - m_osc[i].m_sampleBuffer.audioFile() ); + m_osc[i].m_sampleBuffer->audioFile() ); m_osc[i].usrWaveBtn->setChecked( TRUE ); break; case oscillator::SIN_WAVE: @@ -762,14 +776,16 @@ void tripleOscillator::playNote( notePlayHandle * _n ) static_cast( m_osc[i].phaseOffsetKnob->value() + m_osc[i].stereoPhaseDetuningKnob->value() ), - vol_fac_l ); + vol_fac_l, + eng()->getMixer()->sampleRate() ); oscs_r[i] = oscillator::createOsc( m_osc[i].waveShape, oscillator::MIX, freq*osc_detuning_r, static_cast( m_osc[i].phaseOffsetKnob->value() ), - vol_fac_r ); + vol_fac_r, + eng()->getMixer()->sampleRate() ); } else { @@ -780,7 +796,9 @@ void tripleOscillator::playNote( notePlayHandle * _n ) static_cast( m_osc[i].phaseOffsetKnob->value() + m_osc[i].stereoPhaseDetuningKnob->value() ), - vol_fac_l, oscs_l[i + 1] ); + vol_fac_l, + eng()->getMixer()->sampleRate(), + oscs_l[i + 1] ); oscs_r[i] = oscillator::createOsc( m_osc[i].waveShape, getModulationAlgo( i + 1 ), @@ -788,17 +806,18 @@ void tripleOscillator::playNote( notePlayHandle * _n ) static_cast( m_osc[i].phaseOffsetKnob->value() ), vol_fac_r, + eng()->getMixer()->sampleRate(), oscs_r[i + 1] ); } if( m_osc[i].waveShape == oscillator::USER_DEF_WAVE ) { oscs_l[i]->setUserWave( - m_osc[i].m_sampleBuffer.data(), - m_osc[i].m_sampleBuffer.frames() ); + m_osc[i].m_sampleBuffer->data(), + m_osc[i].m_sampleBuffer->frames() ); oscs_r[i]->setUserWave( - m_osc[i].m_sampleBuffer.data(), - m_osc[i].m_sampleBuffer.frames() ); + m_osc[i].m_sampleBuffer->data(), + m_osc[i].m_sampleBuffer->frames() ); } } @@ -813,7 +832,7 @@ void tripleOscillator::playNote( notePlayHandle * _n ) oscillator * osc_r = static_cast( _n->m_pluginData )->oscRight; - const Uint32 frames = mixer::inst()->framesPerAudioBuffer(); + const fpab_t frames = eng()->getMixer()->framesPerAudioBuffer(); sampleFrame * buf = bufferAllocator::alloc( frames ); osc_l->update( buf, frames, 0 ); @@ -857,7 +876,7 @@ void tripleOscillator::setModulationAlgo( m_modulationAlgo2 = _new_modulation_algo; } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -881,7 +900,7 @@ oscillator::modulationAlgos tripleOscillator::getModulationAlgo( int _n ) void tripleOscillator::doSinWaveBtn( oscillatorData * _osc ) { _osc->waveShape = oscillator::SIN_WAVE; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -890,7 +909,7 @@ void tripleOscillator::doSinWaveBtn( oscillatorData * _osc ) void tripleOscillator::doTriangleWaveBtn( oscillatorData * _osc ) { _osc->waveShape = oscillator::TRIANGLE_WAVE; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -899,7 +918,7 @@ void tripleOscillator::doTriangleWaveBtn( oscillatorData * _osc ) void tripleOscillator::doSawWaveBtn( oscillatorData * _osc ) { _osc->waveShape = oscillator::SAW_WAVE; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -908,7 +927,7 @@ void tripleOscillator::doSawWaveBtn( oscillatorData * _osc ) void tripleOscillator::doSqrWaveBtn( oscillatorData * _osc ) { _osc->waveShape = oscillator::SQUARE_WAVE; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -917,7 +936,7 @@ void tripleOscillator::doSqrWaveBtn( oscillatorData * _osc ) void tripleOscillator::doMoogSawWaveBtn( oscillatorData * _osc ) { _osc->waveShape = oscillator::MOOG_SAW_WAVE; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -926,7 +945,7 @@ void tripleOscillator::doMoogSawWaveBtn( oscillatorData * _osc ) void tripleOscillator::doExpWaveBtn( oscillatorData * _osc ) { _osc->waveShape = oscillator::EXP_WAVE; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -935,7 +954,7 @@ void tripleOscillator::doExpWaveBtn( oscillatorData * _osc ) void tripleOscillator::doWhiteNoiseWaveBtn( oscillatorData * _osc ) { _osc->waveShape = oscillator::WHITE_NOISE_WAVE; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -944,7 +963,7 @@ void tripleOscillator::doWhiteNoiseWaveBtn( oscillatorData * _osc ) void tripleOscillator::doUsrWaveBtn( oscillatorData * _osc ) { _osc->waveShape = oscillator::USER_DEF_WAVE; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -992,15 +1011,15 @@ void tripleOscillator::osc01UserDefWaveCh( bool _on ) void tripleOscillator::osc01UserDefWaveDblClick( void ) { - QString af = m_osc[0].m_sampleBuffer.openAudioFile(); + QString af = m_osc[0].m_sampleBuffer->openAudioFile(); if( af != "" ) { - m_osc[0].m_sampleBuffer.setAudioFile( af ); + m_osc[0].m_sampleBuffer->setAudioFile( af ); /*#ifndef QT4 toolTip::remove( m_osc[0].usrWaveBtn ); #endif*/ toolTip::add( m_osc[0].usrWaveBtn, - m_osc[0].m_sampleBuffer.audioFile() ); + m_osc[0].m_sampleBuffer->audioFile() ); } } @@ -1049,15 +1068,15 @@ void tripleOscillator::osc02UserDefWaveCh( bool _on ) void tripleOscillator::osc02UserDefWaveDblClick( void ) { - QString af = m_osc[1].m_sampleBuffer.openAudioFile(); + QString af = m_osc[1].m_sampleBuffer->openAudioFile(); if( af != "" ) { - m_osc[1].m_sampleBuffer.setAudioFile( af ); + m_osc[1].m_sampleBuffer->setAudioFile( af ); /*#ifndef QT4 toolTip::remove( m_osc[1].usrWaveBtn ); #endif*/ toolTip::add( m_osc[1].usrWaveBtn, - m_osc[1].m_sampleBuffer.audioFile() ); + m_osc[1].m_sampleBuffer->audioFile() ); } } @@ -1105,15 +1124,15 @@ void tripleOscillator::osc03UserDefWaveCh( bool _on ) void tripleOscillator::osc03UserDefWaveDblClick( void ) { - QString af = m_osc[2].m_sampleBuffer.openAudioFile(); + QString af = m_osc[2].m_sampleBuffer->openAudioFile(); if( af != "" ) { - m_osc[2].m_sampleBuffer.setAudioFile( af ); + m_osc[2].m_sampleBuffer->setAudioFile( af ); /*#ifndef QT4 toolTip::remove( m_osc[2].usrWaveBtn ); #endif*/ toolTip::add( m_osc[2].usrWaveBtn, - m_osc[2].m_sampleBuffer.audioFile() ); + m_osc[2].m_sampleBuffer->audioFile() ); } } diff --git a/plugins/triple_oscillator/triple_oscillator.h b/plugins/triple_oscillator/triple_oscillator.h index 6010dcbb55..7218c9bc7a 100644 --- a/plugins/triple_oscillator/triple_oscillator.h +++ b/plugins/triple_oscillator/triple_oscillator.h @@ -29,12 +29,12 @@ #include "instrument.h" #include "oscillator.h" -#include "sample_buffer.h" class knob; class pixmapButton; class notePlayHandle; +class sampleBuffer; const int NUM_OF_OSCILLATORS = 3; @@ -125,7 +125,7 @@ private: pixmapButton * expWaveBtn; pixmapButton * whiteNoiseWaveBtn; pixmapButton * usrWaveBtn; - sampleBuffer m_sampleBuffer; + sampleBuffer * m_sampleBuffer; } m_osc[NUM_OF_OSCILLATORS]; struct oscPtr diff --git a/plugins/vestige/lvsl_client.cpp b/plugins/vestige/lvsl_client.cpp index 1c03b5263a..c1fcbe6bf9 100644 --- a/plugins/vestige/lvsl_client.cpp +++ b/plugins/vestige/lvsl_client.cpp @@ -77,13 +77,14 @@ #include "templates.h" #include "config_mgr.h" -#include "lmms_main_win.h" +#include "main_window.h" #include "lvsl_client.h" -remoteVSTPlugin::remoteVSTPlugin( const QString & _plugin ) : +remoteVSTPlugin::remoteVSTPlugin( const QString & _plugin, engine * _engine ) : + engineObject( _engine ), m_failed( TRUE ), m_plugin( _plugin ), m_pluginWidget( NULL ), @@ -241,7 +242,7 @@ void remoteVSTPlugin::showEditor( void ) return; } - m_pluginWidget = new QWidget( lmmsMainWin::inst()->workspace() ); + m_pluginWidget = new QWidget( eng()->getMainWindow()->workspace() ); m_pluginWidget->setFixedSize( m_pluginGeometry ); m_pluginWidget->setWindowTitle( name() ); m_pluginWidget->show(); @@ -274,7 +275,7 @@ void remoteVSTPlugin::hideEditor( void ) void remoteVSTPlugin::process( const sampleFrame * _in_buf, sampleFrame * _out_buf ) { - const fpab_t frames = mixer::inst()->framesPerAudioBuffer(); + const fpab_t frames = eng()->getMixer()->framesPerAudioBuffer(); if( m_shm == NULL ) { @@ -286,7 +287,7 @@ void remoteVSTPlugin::process( const sampleFrame * _in_buf, { (void) processNextMessage(); } - mixer::inst()->clearAudioBuffer( _out_buf, frames ); + eng()->getMixer()->clearAudioBuffer( _out_buf, frames ); return; } @@ -323,7 +324,7 @@ void remoteVSTPlugin::process( const sampleFrame * _in_buf, if( outputs != DEFAULT_CHANNELS ) { // clear buffer, if plugin didn't fill up both channels - mixer::inst()->clearAudioBuffer( _out_buf, frames ); + eng()->getMixer()->clearAudioBuffer( _out_buf, frames ); } for( ch_cnt_t ch = 0; ch < outputs; ++ch ) @@ -341,23 +342,23 @@ void remoteVSTPlugin::process( const sampleFrame * _in_buf, void remoteVSTPlugin::enqueueMidiEvent( const midiEvent & _event, - const Uint32 _frames_ahead ) + const f_cnt_t _frames_ahead ) { lock(); writeValueS( VST_ENQUEUE_MIDI_EVENT ); writeValueS( _event ); - writeValueS( _frames_ahead ); + writeValueS( _frames_ahead ); unlock(); } -void remoteVSTPlugin::setBPM( Uint16 _bpm ) +void remoteVSTPlugin::setTempo( const bpm_t _bpm ) { lock(); writeValueS( VST_BPM ); - writeValueS( _bpm ); + writeValueS( _bpm ); unlock(); } @@ -465,14 +466,14 @@ Sint16 remoteVSTPlugin::processNextMessage( void ) writeValueS( VST_SAMPLE_RATE ); // handle is the same writeValueS( - mixer::inst()->sampleRate() ); + eng()->getMixer()->sampleRate() ); break; case VST_GET_BUFFER_SIZE: writeValueS( VST_BUFFER_SIZE ); // handle is the same writeValueS( - mixer::inst()->framesPerAudioBuffer() ); + eng()->getMixer()->framesPerAudioBuffer() ); break; case VST_SHM_KEY_AND_SIZE: diff --git a/plugins/vestige/lvsl_client.h b/plugins/vestige/lvsl_client.h index 3e9fcda698..215389c6e0 100644 --- a/plugins/vestige/lvsl_client.h +++ b/plugins/vestige/lvsl_client.h @@ -44,13 +44,14 @@ #include "mixer.h" #include "communication.h" #include "midi.h" +#include "engine.h" -class remoteVSTPlugin +class remoteVSTPlugin : public engineObject { public: - remoteVSTPlugin( const QString & _plugin ); + remoteVSTPlugin( const QString & _plugin, engine * _engine ); ~remoteVSTPlugin(); void showEditor( void ); @@ -80,7 +81,7 @@ public: sampleFrame * _out_buf ); void FASTCALL enqueueMidiEvent( const midiEvent & _event, const Uint32 _frames_ahead ); - void FASTCALL setBPM( const Uint16 _bpm ); + void FASTCALL setTempo( const bpm_t _bpm ); const QMap & parameterDump( void ); void setParameterDump( const QMap & _pdump ); diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 46e4b81a4d..775b3907bd 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #endif @@ -52,13 +53,13 @@ #include "note_play_handle.h" #include "buffer_allocator.h" #include "mixer.h" -#include "song_editor.h" #include "instrument_play_handle.h" #include "pixmap_button.h" #include "tooltip.h" #include "spc_bg_hndl_widget.h" #include "vestige.h" #include "text_float.h" +#include "song_editor.h" #include "lvsl_client.h" #include "embed.cpp" @@ -105,8 +106,8 @@ vestigeInstrument::vestigeInstrument( channelTrack * _channel_track ) : setErasePixmap( *s_artwork ); #endif - connect( songEditor::inst(), SIGNAL( bpmChanged( int ) ), - this, SLOT( changeBPM( int ) ) ); + connect( eng()->getSongEditor(), SIGNAL( tempoChanged( bpm_t ) ), + this, SLOT( changeTempo( bpm_t ) ) ); m_openPluginButton = new pixmapButton( this ); m_openPluginButton->setCheckable( FALSE ); @@ -155,7 +156,7 @@ vestigeInstrument::vestigeInstrument( channelTrack * _channel_track ) : // now we need a play-handle which cares for calling play() instrumentPlayHandle * iph = new instrumentPlayHandle( this ); - mixer::inst()->addPlayHandle( iph ); + eng()->getMixer()->addPlayHandle( iph ); } @@ -270,7 +271,7 @@ void vestigeInstrument::setParameter( const QString & _param, PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ), 0 ); m_pluginMutex.lock(); - m_plugin = new remoteVSTPlugin( m_pluginDLL ); + m_plugin = new remoteVSTPlugin( m_pluginDLL, eng() ); if( m_plugin->failed() ) { m_pluginMutex.unlock(); @@ -300,7 +301,7 @@ void vestigeInstrument::setParameter( const QString & _param, return; }*/ m_plugin->showEditor(); - m_plugin->setBPM( songEditor::inst()->getBPM() ); + m_plugin->setTempo( eng()->getSongEditor()->getTempo() ); if( set_ch_name == TRUE ) { getChannelTrack()->setName( m_plugin->name() ); @@ -332,7 +333,7 @@ void vestigeInstrument::play( void ) return; } - const Uint32 frames = mixer::inst()->framesPerAudioBuffer(); + const fpab_t frames = eng()->getMixer()->framesPerAudioBuffer(); sampleFrame * buf = bufferAllocator::alloc( frames ); m_plugin->process( NULL, buf ); @@ -476,12 +477,12 @@ void vestigeInstrument::noteOffAll( void ) -void vestigeInstrument::changeBPM( int _new_val ) +void vestigeInstrument::changeTempo( bpm_t _new_tempo ) { m_pluginMutex.lock(); if( m_plugin != NULL ) { - m_plugin->setBPM( _new_val ); + m_plugin->setTempo( _new_tempo ); } m_pluginMutex.unlock(); } diff --git a/plugins/vestige/vestige.h b/plugins/vestige/vestige.h index 1f358600c7..9dadb73c18 100644 --- a/plugins/vestige/vestige.h +++ b/plugins/vestige/vestige.h @@ -76,7 +76,7 @@ protected slots: void openPlugin( void ); void toggleGUI( void ); void noteOffAll( void ); - void changeBPM( int _new_val ); + void changeTempo( bpm_t _new_tempo ); protected: diff --git a/src/audio/audio_alsa.cpp b/src/audio/audio_alsa.cpp index c83e45cb75..a8d3c32b11 100644 --- a/src/audio/audio_alsa.cpp +++ b/src/audio/audio_alsa.cpp @@ -54,10 +54,12 @@ -audioALSA::audioALSA( const sample_rate_t _sample_rate, bool & _success_ful ) : +audioALSA::audioALSA( const sample_rate_t _sample_rate, bool & _success_ful, + mixer * _mixer ) : audioDevice( _sample_rate, tLimit( configManager::inst()->value( "audioalsa", "channels" ).toInt(), - DEFAULT_CHANNELS, SURROUND_CHANNELS ) ), + DEFAULT_CHANNELS, SURROUND_CHANNELS ), + _mixer ), m_handle( NULL ), m_hwParams( NULL ), m_swParams( NULL ), @@ -213,9 +215,9 @@ void audioALSA::run( void ) { surroundSampleFrame * temp = bufferAllocator::alloc( - mixer::inst()->framesPerAudioBuffer() ); + getMixer()->framesPerAudioBuffer() ); int_sample_t * outbuf = bufferAllocator::alloc( - mixer::inst()->framesPerAudioBuffer() * + getMixer()->framesPerAudioBuffer() * channels() ); m_quit = FALSE; @@ -223,7 +225,7 @@ void audioALSA::run( void ) { const f_cnt_t frames = getNextBuffer( temp ); - convertToS16( temp, frames, mixer::inst()->masterGain(), outbuf, + convertToS16( temp, frames, getMixer()->masterGain(), outbuf, m_littleEndian != isLittleEndian() ); f_cnt_t frame = 0; @@ -336,7 +338,7 @@ int audioALSA::setHWParams( const sample_rate_t _sample_rate, } } - m_periodSize = mixer::inst()->framesPerAudioBuffer(); + m_periodSize = getMixer()->framesPerAudioBuffer(); m_bufferSize = m_periodSize * 8; dir = 0; err = snd_pcm_hw_params_set_period_size_near( m_handle, m_hwParams, diff --git a/src/audio/audio_device.cpp b/src/audio/audio_device.cpp index 46ed5beff9..5b3bd4dd40 100644 --- a/src/audio/audio_device.cpp +++ b/src/audio/audio_device.cpp @@ -37,11 +37,12 @@ audioDevice::audioDevice( const sample_rate_t _sample_rate, - const ch_cnt_t _channels ) : + const ch_cnt_t _channels, mixer * _mixer ) : m_sampleRate( _sample_rate ), m_channels( _channels ), + m_mixer( _mixer ), m_buffer( bufferAllocator::alloc( - mixer::inst()->framesPerAudioBuffer() ) ) + getMixer()->framesPerAudioBuffer() ) ) { #ifdef HAVE_SAMPLERATE_H int error; @@ -77,7 +78,7 @@ audioDevice::~audioDevice() void audioDevice::processNextBuffer( void ) { const fpab_t frames = getNextBuffer( m_buffer ); - writeBuffer( m_buffer, frames, mixer::inst()->masterGain() ); + writeBuffer( m_buffer, frames, getMixer()->masterGain() ); } @@ -85,18 +86,18 @@ void audioDevice::processNextBuffer( void ) fpab_t audioDevice::getNextBuffer( surroundSampleFrame * _ab ) { - fpab_t frames = mixer::inst()->framesPerAudioBuffer(); - const surroundSampleFrame * b = mixer::inst()->renderNextBuffer(); + fpab_t frames = getMixer()->framesPerAudioBuffer(); + const surroundSampleFrame * b = getMixer()->renderNextBuffer(); // make sure, no other thread is accessing device lock(); // now were safe to access the device - if( mixer::inst()->sampleRate() != m_sampleRate ) + if( getMixer()->sampleRate() != m_sampleRate ) { - resample( b, frames, _ab, mixer::inst()->sampleRate(), + resample( b, frames, _ab, getMixer()->sampleRate(), m_sampleRate ); - frames = frames * m_sampleRate / mixer::inst()->sampleRate(); + frames = frames * m_sampleRate / getMixer()->sampleRate(); } else { diff --git a/src/audio/audio_file_device.cpp b/src/audio/audio_file_device.cpp index 766df9208e..371b50ea2b 100644 --- a/src/audio/audio_file_device.cpp +++ b/src/audio/audio_file_device.cpp @@ -48,8 +48,9 @@ audioFileDevice::audioFileDevice( const sample_rate_t _sample_rate, const bool _use_vbr, const bitrate_t _nom_bitrate, const bitrate_t _min_bitrate, - const bitrate_t _max_bitrate ) : - audioDevice( _sample_rate, _channels), + const bitrate_t _max_bitrate, + mixer * _mixer ) : + audioDevice( _sample_rate, _channels, _mixer ), m_outputFile( _file ), m_useVbr( _use_vbr ), m_nomBitrate( _nom_bitrate ), diff --git a/src/audio/audio_file_ogg.cpp b/src/audio/audio_file_ogg.cpp index 6347c4fa1b..ad9d920131 100644 --- a/src/audio/audio_file_ogg.cpp +++ b/src/audio/audio_file_ogg.cpp @@ -46,9 +46,10 @@ audioFileOgg::audioFileOgg( const sample_rate_t _sample_rate, const bool _use_vbr, const bitrate_t _nom_bitrate, const bitrate_t _min_bitrate, - const bitrate_t _max_bitrate ) : + const bitrate_t _max_bitrate, + mixer * _mixer ) : audioFileDevice( _sample_rate, _channels, _file, _use_vbr, - _nom_bitrate, _min_bitrate, _max_bitrate ) + _nom_bitrate, _min_bitrate, _max_bitrate, _mixer ) { _success_ful = startEncoding(); } diff --git a/src/audio/audio_file_wave.cpp b/src/audio/audio_file_wave.cpp index 1f70ff8e9e..b3aa08f035 100644 --- a/src/audio/audio_file_wave.cpp +++ b/src/audio/audio_file_wave.cpp @@ -38,9 +38,10 @@ audioFileWave::audioFileWave( const sample_rate_t _sample_rate, const bool _use_vbr, const bitrate_t _nom_bitrate, const bitrate_t _min_bitrate, - const bitrate_t _max_bitrate ) : + const bitrate_t _max_bitrate, + mixer * _mixer ) : audioFileDevice( _sample_rate, _channels, _file, _use_vbr, - _nom_bitrate, _min_bitrate, _max_bitrate ) + _nom_bitrate, _min_bitrate, _max_bitrate, _mixer ) { _success_ful = startEncoding(); } diff --git a/src/audio/audio_jack.cpp b/src/audio/audio_jack.cpp index 6be4d3c094..190a18953e 100644 --- a/src/audio/audio_jack.cpp +++ b/src/audio/audio_jack.cpp @@ -56,15 +56,17 @@ -audioJACK::audioJACK( Uint32 _sample_rate, bool & _success_ful ) : +audioJACK::audioJACK( const sample_rate_t _sample_rate, bool & _success_ful, + mixer * _mixer ) : audioDevice( _sample_rate, tLimit( configManager::inst()->value( "audiojack", "channels" ).toInt(), - DEFAULT_CHANNELS, SURROUND_CHANNELS ) ), + DEFAULT_CHANNELS, SURROUND_CHANNELS ), + _mixer ), m_client( NULL ), m_stopped( FALSE ), m_processCallbackMutex(), m_outBuf( bufferAllocator::alloc( - mixer::inst()->framesPerAudioBuffer() ) ), + getMixer()->framesPerAudioBuffer() ) ), m_framesDoneInCurBuf( 0 ), m_framesToDoInCurBuf( 0 ) { @@ -177,7 +179,7 @@ audioJACK::audioJACK( Uint32 _sample_rate, bool & _success_ful ) : // try to sync JACK's and LMMS's buffer-size - jack_set_buffer_size( m_client, mixer::inst()->framesPerAudioBuffer() ); + jack_set_buffer_size( m_client, getMixer()->framesPerAudioBuffer() ); @@ -346,7 +348,7 @@ int audioJACK::processCallback( jack_nframes_t _nframes, void * _udata ) } /* const Uint32 frames = tMin( _nframes, - mixer::inst()->framesPerAudioBuffer() ); + getMixer()->framesPerAudioBuffer() ); for( jackPortMap::iterator it = _this->m_portMap.begin(); it != _this->m_portMap.end(); ++it ) { @@ -382,7 +384,7 @@ int audioJACK::processCallback( jack_nframes_t _nframes, void * _udata ) { outbufs[chnl][done+frame] = _this->m_outBuf[_this->m_framesDoneInCurBuf+frame][chnl] * - mixer::inst()->masterGain(); + _this->getMixer()->masterGain(); } } } diff --git a/src/audio/audio_oss.cpp b/src/audio/audio_oss.cpp index c5f4fc686d..64a046dbbb 100644 --- a/src/audio/audio_oss.cpp +++ b/src/audio/audio_oss.cpp @@ -91,10 +91,12 @@ -audioOSS::audioOSS( const sample_rate_t _sample_rate, bool & _success_ful ) : +audioOSS::audioOSS( const sample_rate_t _sample_rate, bool & _success_ful, + mixer * _mixer ) : audioDevice( _sample_rate, tLimit( configManager::inst()->value( "audiooss", "channels" ).toInt(), - DEFAULT_CHANNELS, SURROUND_CHANNELS ) ), + DEFAULT_CHANNELS, SURROUND_CHANNELS ), + _mixer ), m_convertEndian( FALSE ), m_quit( FALSE ) { @@ -125,7 +127,7 @@ audioOSS::audioOSS( const sample_rate_t _sample_rate, bool & _success_ful ) : int frag_spec; for( frag_spec = 0; static_cast( 0x01 << frag_spec ) < - mixer::inst()->framesPerAudioBuffer() * channels() * + getMixer()->framesPerAudioBuffer() * channels() * BYTES_PER_INT_SAMPLE; ++frag_spec ) { @@ -316,9 +318,9 @@ void audioOSS::run( void ) { surroundSampleFrame * temp = bufferAllocator::alloc( - mixer::inst()->framesPerAudioBuffer() ); + getMixer()->framesPerAudioBuffer() ); int_sample_t * outbuf = bufferAllocator::alloc( - mixer::inst()->framesPerAudioBuffer() * + getMixer()->framesPerAudioBuffer() * channels() ); m_quit = FALSE; @@ -327,7 +329,7 @@ void audioOSS::run( void ) const Uint32 frames = getNextBuffer( temp ); int bytes = convertToS16( temp, frames, - mixer::inst()->masterGain(), outbuf, + getMixer()->masterGain(), outbuf, m_convertEndian ); write( m_audioFD, outbuf, bytes ); } diff --git a/src/audio/audio_port.cpp b/src/audio/audio_port.cpp index da752ed652..879d60f2d7 100644 --- a/src/audio/audio_port.cpp +++ b/src/audio/audio_port.cpp @@ -1,7 +1,7 @@ /* * audio_port.cpp - base-class for objects providing sound at a port * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -28,21 +28,22 @@ #include "buffer_allocator.h" -audioPort::audioPort( const QString & _name ) : +audioPort::audioPort( const QString & _name, engine * _engine ) : + engineObject( _engine ), m_bufferUsage( NONE ), m_firstBuffer( bufferAllocator::alloc( - mixer::inst()->framesPerAudioBuffer() ) ), + eng()->getMixer()->framesPerAudioBuffer() ) ), m_secondBuffer( bufferAllocator::alloc( - mixer::inst()->framesPerAudioBuffer() ) ), + eng()->getMixer()->framesPerAudioBuffer() ) ), m_extOutputEnabled( FALSE ), m_nextFxChannel( -1 ), m_name( "unnamed port" ) { - mixer::inst()->clearAudioBuffer( m_firstBuffer, - mixer::inst()->framesPerAudioBuffer() ); - mixer::inst()->clearAudioBuffer( m_secondBuffer, - mixer::inst()->framesPerAudioBuffer() ); - mixer::inst()->addAudioPort( this ); + eng()->getMixer()->clearAudioBuffer( m_firstBuffer, + eng()->getMixer()->framesPerAudioBuffer() ); + eng()->getMixer()->clearAudioBuffer( m_secondBuffer, + eng()->getMixer()->framesPerAudioBuffer() ); + eng()->getMixer()->addAudioPort( this ); setExtOutputEnabled( TRUE ); } @@ -51,10 +52,10 @@ audioPort::audioPort( const QString & _name ) : audioPort::~audioPort() { - mixer::inst()->removeAudioPort( this ); + eng()->getMixer()->removeAudioPort( this ); if( m_extOutputEnabled == TRUE ) { - mixer::inst()->audioDev()->unregisterPort( this ); + eng()->getMixer()->audioDev()->unregisterPort( this ); } bufferAllocator::free( m_firstBuffer ); bufferAllocator::free( m_secondBuffer ); @@ -65,8 +66,8 @@ audioPort::~audioPort() void audioPort::nextPeriod( void ) { - mixer::inst()->clearAudioBuffer( m_firstBuffer, - mixer::inst()->framesPerAudioBuffer() ); + eng()->getMixer()->clearAudioBuffer( m_firstBuffer, + eng()->getMixer()->framesPerAudioBuffer() ); qSwap( m_firstBuffer, m_secondBuffer ); // this is how we decrease state of buffer-usage ;-) m_bufferUsage = ( m_bufferUsage != NONE ) ? @@ -83,11 +84,11 @@ void audioPort::setExtOutputEnabled( bool _enabled ) m_extOutputEnabled = _enabled; if( m_extOutputEnabled ) { - mixer::inst()->audioDev()->registerPort( this ); + eng()->getMixer()->audioDev()->registerPort( this ); } else { - mixer::inst()->audioDev()->unregisterPort( this ); + eng()->getMixer()->audioDev()->unregisterPort( this ); } } } @@ -98,6 +99,6 @@ void audioPort::setExtOutputEnabled( bool _enabled ) void audioPort::setName( const QString & _name ) { m_name = _name; - mixer::inst()->audioDev()->renamePort( this ); + eng()->getMixer()->audioDev()->renamePort( this ); } diff --git a/src/audio/audio_sample_recorder.cpp b/src/audio/audio_sample_recorder.cpp index ba9d6c6361..3111389b1f 100644 --- a/src/audio/audio_sample_recorder.cpp +++ b/src/audio/audio_sample_recorder.cpp @@ -35,8 +35,9 @@ audioSampleRecorder::audioSampleRecorder( const sample_rate_t _sample_rate, const ch_cnt_t _channels, - bool & _success_ful ) : - audioDevice( _sample_rate, _channels ), + bool & _success_ful, + mixer * _mixer ) : + audioDevice( _sample_rate, _channels, _mixer ), m_buffers() { _success_ful = TRUE; @@ -57,9 +58,9 @@ audioSampleRecorder::~audioSampleRecorder() -Uint32 audioSampleRecorder::framesRecorded( void ) const +f_cnt_t audioSampleRecorder::framesRecorded( void ) const { - Uint32 frames = 0; + f_cnt_t frames = 0; for( bufferList::const_iterator it = m_buffers.begin(); it != m_buffers.end(); ++it ) { @@ -72,9 +73,8 @@ Uint32 audioSampleRecorder::framesRecorded( void ) const void audioSampleRecorder::createSampleBuffer( sampleBuffer * * _sample_buf ) - const { - f_cnt_t frames = framesRecorded(); + const f_cnt_t frames = framesRecorded(); // create buffer to store all recorded buffers in sampleFrame * data = bufferAllocator::alloc( frames ); // make sure buffer is cleaned up properly at the end... @@ -92,7 +92,7 @@ void audioSampleRecorder::createSampleBuffer( sampleBuffer * * _sample_buf ) data += ( *it ).second; } // create according sample-buffer out of big buffer - *_sample_buf = new sampleBuffer( ac.ptr(), frames ); + *_sample_buf = new sampleBuffer( ac.ptr(), frames, getMixer()->eng() ); } diff --git a/src/audio/audio_sdl.cpp b/src/audio/audio_sdl.cpp index 7e897631f9..87353799e1 100644 --- a/src/audio/audio_sdl.cpp +++ b/src/audio/audio_sdl.cpp @@ -1,7 +1,7 @@ /* * audio_sdl.cpp - device-class that performs PCM-output via SDL * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -48,10 +48,11 @@ -audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful ) : - audioDevice( _sample_rate, DEFAULT_CHANNELS ), +audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful, + mixer * _mixer ) : + audioDevice( _sample_rate, DEFAULT_CHANNELS, _mixer ), m_outBuf( bufferAllocator::alloc( - mixer::inst()->framesPerAudioBuffer() ) ), + getMixer()->framesPerAudioBuffer() ) ), m_convertEndian( FALSE ) { _success_ful = FALSE; @@ -81,7 +82,7 @@ audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful ) : // of system, so we don't have // to convert the buffers m_audioHandle.channels = channels(); - m_audioHandle.samples = mixer::inst()->framesPerAudioBuffer(); + m_audioHandle.samples = getMixer()->framesPerAudioBuffer(); m_audioHandle.callback = sdlAudioCallback; m_audioHandle.userdata = this; @@ -145,7 +146,7 @@ void audioSDL::sdlAudioCallback( void * _udata, Uint8 * _buf, int _len ) const fpab_t frames = _this->getNextBuffer( _this->m_outBuf ); _this->convertToS16( _this->m_outBuf, frames, - mixer::inst()->masterGain(), + _this->getMixer()->masterGain(), (int_sample_t *)( _buf ), _this->m_convertEndian ); } @@ -171,7 +172,6 @@ audioSDL::setupWidget::setupWidget( QWidget * _parent ) : audioSDL::setupWidget::~setupWidget() { - } diff --git a/src/core/arp_and_chords_tab_widget.cpp b/src/core/arp_and_chords_tab_widget.cpp index 20c5c8e2c8..e8d472c244 100644 --- a/src/core/arp_and_chords_tab_widget.cpp +++ b/src/core/arp_and_chords_tab_widget.cpp @@ -200,6 +200,7 @@ const int ARP_GROUPBOX_HEIGHT = 240 - ARP_GROUPBOX_Y; arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) : QWidget( _channel_track->tabWidgetParent() ), settings(), + engineObject( _channel_track->eng() ), m_arpDirection( UP ) { m_chordsGroupBox = new groupBox( tr( "CHORDS" ), this ); @@ -221,7 +222,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) : } m_chordRangeKnob = new knob( knobBright_26, m_chordsGroupBox, - tr( "Chord range" ) ); + tr( "Chord range" ), eng() ); m_chordRangeKnob->setLabel( tr( "RANGE" ) ); m_chordRangeKnob->setRange( 1.0, 9.0, 1.0 ); m_chordRangeKnob->setValue( 1.0, TRUE ); @@ -273,7 +274,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) : m_arpRangeKnob = new knob( knobBright_26, m_arpGroupBox, - tr( "Arpeggio range" ) ); + tr( "Arpeggio range" ), eng() ); m_arpRangeKnob->setLabel( tr( "RANGE" ) ); m_arpRangeKnob->setRange( 1.0, 9.0, 1.0 ); m_arpRangeKnob->setValue( 1.0, TRUE ); @@ -290,7 +291,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) : "amount of octaves." ) ); m_arpTimeKnob = new tempoSyncKnob( knobBright_26, m_arpGroupBox, - tr( "Arpeggio time" ) ); + tr( "Arpeggio time" ), eng() ); m_arpTimeKnob->setLabel( tr( "TIME" ) ); m_arpTimeKnob->setRange( 10.0, 1000.0, 1.0 ); m_arpTimeKnob->setValue( 100.0, TRUE ); @@ -307,7 +308,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) : "each arpeggio-tone should be played." ) ); m_arpGateKnob = new knob( knobBright_26, m_arpGroupBox, - tr( "Arpeggio gate" ) ); + tr( "Arpeggio gate" ), eng() ); m_arpGateKnob->setLabel( tr( "GATE" ) ); m_arpGateKnob->setRange( 1.0, 200.0, 1.0 ); m_arpGateKnob->setValue( 100.0, TRUE ); @@ -511,9 +512,9 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n ) const int total_range = range * cnphv.size(); // number of frames that every note should be played - const Uint32 arp_frames = (Uint32)( m_arpTimeKnob->value() / 1000.0f * - mixer::inst()->sampleRate() ); - const Uint32 gated_frames = (Uint32)( m_arpGateKnob->value() * + const f_cnt_t arp_frames = (f_cnt_t)( m_arpTimeKnob->value() / 1000.0f * + eng()->getMixer()->sampleRate() ); + const f_cnt_t gated_frames = (f_cnt_t)( m_arpGateKnob->value() * arp_frames / 100.0f ); // used for calculating remaining frames for arp-note, we have to add @@ -524,15 +525,15 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n ) _n->totalFramesPlayed() ) + arp_frames - 1; // used for loop - Uint32 frames_processed = 0; + fpab_t frames_processed = 0; - while( frames_processed < mixer::inst()->framesPerAudioBuffer() ) + while( frames_processed < eng()->getMixer()->framesPerAudioBuffer() ) { - const Uint32 remaining_frames_for_cur_arp = arp_frames - + const f_cnt_t remaining_frames_for_cur_arp = arp_frames - ( cur_frame % arp_frames ); // does current arp-note fill whole audio-buffer? if( remaining_frames_for_cur_arp > - mixer::inst()->framesPerAudioBuffer() ) + eng()->getMixer()->framesPerAudioBuffer() ) { // then we don't have to do something! break; @@ -721,7 +722,7 @@ void arpAndChordsTabWidget::arpUpToggled( bool _on ) { m_arpDirection = UP; } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -733,7 +734,7 @@ void arpAndChordsTabWidget::arpDownToggled( bool _on ) { m_arpDirection = DOWN; } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -745,7 +746,7 @@ void arpAndChordsTabWidget::arpUpAndDownToggled( bool _on ) { m_arpDirection = UP_AND_DOWN; } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -757,7 +758,7 @@ void arpAndChordsTabWidget::arpRandomToggled( bool _on ) { m_arpDirection = RANDOM; } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } diff --git a/src/core/bb_editor.cpp b/src/core/bb_editor.cpp index a2b56ed777..b4d9b1c6b5 100644 --- a/src/core/bb_editor.cpp +++ b/src/core/bb_editor.cpp @@ -36,6 +36,7 @@ #include #include +#include #endif @@ -51,19 +52,16 @@ #include "debug.h" #include "tooltip.h" #include "combobox.h" - +#include "main_window.h" const int BBE_PPT = 192; -bbEditor * bbEditor::s_instanceOfMe = NULL; - - -bbEditor::bbEditor() : - trackContainer() +bbEditor::bbEditor( engine * _engine ) : + trackContainer( _engine ) { // create toolbar m_toolBar = new QWidget( this ); @@ -88,7 +86,7 @@ bbEditor::bbEditor() : setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH + BBE_PPT + 2 * TCO_BORDER_WIDTH + DEFAULT_SCROLLBAR_SIZE ); - if( lmmsMainWin::inst()->workspace() != NULL ) + if( eng()->getMainWindow()->workspace() != NULL ) { setGeometry( 10, 340, minimumWidth(), 300 ); } @@ -178,9 +176,9 @@ void bbEditor::setCurrentBB( int _bb ) // now update all track-labels (the current one has to become white, // the others green) - for( csize i = 0; i < bbEditor::inst()->numOfBBs(); ++i ) + for( csize i = 0; i < numOfBBs(); ++i ) { - bbTrack::findBBTrack( i )->trackLabel()->update(); + bbTrack::findBBTrack( i, eng() )->trackLabel()->update(); } emit positionChanged( m_currentPosition = midiTime( @@ -244,7 +242,7 @@ bool FASTCALL bbEditor::play( midiTime _start, Uint32 _start_frame, csize bbEditor::numOfBBs( void ) const { - return( songEditor::inst()->countTracks( track::BB_TRACK ) ); + return( eng()->getSongEditor()->countTracks( track::BB_TRACK ) ); } @@ -275,7 +273,7 @@ void bbEditor::removeBB( csize _bb ) void bbEditor::updateBBTrack( trackContentObject * _tco ) { - bbTrack * t = bbTrack::findBBTrack( _tco->startPosition() / 64 ); + bbTrack * t = bbTrack::findBBTrack( _tco->startPosition() / 64, eng() ); if( t != NULL ) { t->getTrackContentWidget()->updateTCOs(); @@ -291,7 +289,7 @@ void bbEditor::updateComboBox( void ) for( csize i = 0; i < numOfBBs(); ++i ) { - bbTrack * bbt = bbTrack::findBBTrack( i ); + bbTrack * bbt = bbTrack::findBBTrack( i, eng() ); m_bbComboBox->addItem( bbt->trackLabel()->text(), bbt->trackLabel()->pixmap() ); } @@ -316,7 +314,7 @@ void bbEditor::keyPressEvent( QKeyEvent * _ke ) { if ( _ke->key() == Qt::Key_Space ) { - if( songEditor::inst()->playing() ) + if( eng()->getSongEditor()->playing() ) { stop(); } @@ -374,31 +372,31 @@ QRect bbEditor::scrollAreaRect( void ) const void bbEditor::play( void ) { - if( songEditor::inst()->playing() ) + if( eng()->getSongEditor()->playing() ) { - if( songEditor::inst()->playMode() != songEditor::PLAY_BB ) + if( eng()->getSongEditor()->playMode() != songEditor::PLAY_BB ) { - songEditor::inst()->stop(); - songEditor::inst()->playBB(); + eng()->getSongEditor()->stop(); + eng()->getSongEditor()->playBB(); m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); } else { - songEditor::inst()->pause(); + eng()->getSongEditor()->pause(); m_playButton->setIcon( embed::getIconPixmap( "play" ) ); } } - else if( songEditor::inst()->paused() ) + else if( eng()->getSongEditor()->paused() ) { - songEditor::inst()->resumeFromPause(); + eng()->getSongEditor()->resumeFromPause(); m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); } else { m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); - songEditor::inst()->playBB(); + eng()->getSongEditor()->playBB(); } } @@ -408,7 +406,7 @@ void bbEditor::play( void ) void bbEditor::stop( void ) { - songEditor::inst()->stop(); + eng()->getSongEditor()->stop(); m_playButton->setIcon( embed::getIconPixmap( "play" ) ); m_playButton->update(); } diff --git a/src/core/envelope_and_lfo_widget.cpp b/src/core/envelope_and_lfo_widget.cpp index 33fbc4b93d..4a5cd51065 100644 --- a/src/core/envelope_and_lfo_widget.cpp +++ b/src/core/envelope_and_lfo_widget.cpp @@ -1,8 +1,8 @@ /* - * envelope_widget.cpp - widget which is m_used by envelope/lfo/filter-tab of - * channel-window + * envelope_and_lfo_widget.cpp - widget which is m_used by envelope/lfo/filter- + * tab of channel-window * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -100,12 +100,15 @@ const int LFO_SHAPES_Y = LFO_GRAPH_Y + 50; QPixmap * envelopeAndLFOWidget::s_envGraph = NULL; QPixmap * envelopeAndLFOWidget::s_lfoGraph = NULL; -Uint32 envelopeAndLFOWidget::s_lfoFrame = 0; + +QMap > + envelopeAndLFOWidget::s_EaLWidgets; envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, - QWidget * _parent ) : + QWidget * _parent, + engine * _engine ) : QWidget( _parent ), settings(), #ifdef QT4 @@ -113,12 +116,15 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, #else specialBgHandlingWidget( paletteBackgroundColor() ), #endif + engineObject( _engine ), m_used( FALSE ), m_valueForZeroAmount( _value_for_zero_amount ), m_pahdEnv( NULL ), m_rEnv( NULL ), + m_lfoFrame( 0 ), m_lfoAmountIsZero( FALSE ), m_lfoShapeData( NULL ), + m_userWave( eng() ), m_lfoShape( SIN ), m_busy( FALSE ) { @@ -132,7 +138,11 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, s_lfoGraph = new QPixmap( embed::getIconPixmap( "lfo_graph" ) ); } - m_predelayKnob = new knob( knobBright_26, this, tr( "Predelay-time" ) ); + s_EaLWidgets[eng()].push_back( this ); + + + m_predelayKnob = new knob( knobBright_26, this, tr( "Predelay-time" ), + eng() ); m_predelayKnob->setLabel( tr( "DEL" ) ); m_predelayKnob->setRange( 0.0, 1.0, 0.001 ); m_predelayKnob->setValue( 0.0, TRUE ); @@ -149,7 +159,8 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, connect( m_predelayKnob, SIGNAL( valueChanged( float ) ), this, SLOT( updateAfterKnobChange( float ) ) ); - m_attackKnob = new knob( knobBright_26, this, tr( "Attack-time" ) ); + m_attackKnob = new knob( knobBright_26, this, tr( "Attack-time" ), + eng() ); m_attackKnob->setLabel( tr( "ATT" ) ); m_attackKnob->setRange( 0.0, 1.0, 0.001 ); m_attackKnob->setValue( 0.0, TRUE ); @@ -168,7 +179,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, connect( m_attackKnob, SIGNAL( valueChanged( float ) ), this, SLOT( updateAfterKnobChange( float ) ) ); - m_holdKnob = new knob( knobBright_26, this, tr( "Hold-time" ) ); + m_holdKnob = new knob( knobBright_26, this, tr( "Hold-time" ), eng() ); m_holdKnob->setLabel( tr( "HOLD" ) ); m_holdKnob->setRange( 0.0, 1.0, 0.001 ); m_holdKnob->setValue( 0.5, TRUE ); @@ -186,7 +197,8 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, connect( m_holdKnob, SIGNAL( valueChanged( float ) ), this, SLOT( updateAfterKnobChange( float ) ) ); - m_decayKnob = new knob( knobBright_26, this, tr( "Decay-time" ) ); + m_decayKnob = new knob( knobBright_26, this, tr( "Decay-time" ), + eng() ); m_decayKnob->setLabel( tr( "DEC" ) ); m_decayKnob->setRange( 0.0, 1.0, 0.001 ); m_decayKnob->setValue( 0.5, TRUE ); @@ -205,7 +217,8 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, connect( m_decayKnob, SIGNAL( valueChanged( float ) ), this, SLOT( updateAfterKnobChange( float ) ) ); - m_sustainKnob = new knob( knobBright_26, this, tr( "Sustain-level" ) ); + m_sustainKnob = new knob( knobBright_26, this, tr( "Sustain-level" ), + eng() ); m_sustainKnob->setLabel( tr( "SUST" ) ); m_sustainKnob->setRange( 0.0, 1.0, 0.001 ); m_sustainKnob->setValue( 0.5, TRUE ); @@ -223,7 +236,8 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, connect( m_sustainKnob, SIGNAL( valueChanged( float ) ), this, SLOT( updateAfterKnobChange( float ) ) ); - m_releaseKnob = new knob( knobBright_26, this, tr( "Release-time" ) ); + m_releaseKnob = new knob( knobBright_26, this, tr( "Release-time" ), + eng() ); m_releaseKnob->setLabel( tr( "REL" ) ); m_releaseKnob->setRange( 0.0, 1.0, 0.001 ); m_releaseKnob->setValue( 0.1, TRUE ); @@ -243,7 +257,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, SLOT( updateAfterKnobChange( float ) ) ); m_amountKnob = new knob( knobBright_26, this, - tr( "Modulation amount" ) ); + tr( "Modulation amount" ), eng() ); m_amountKnob->setLabel( tr( "AMT" ) ); m_amountKnob->setRange( -1.0, 1.0, 0.005 ); m_amountKnob->setValue( 0.0, TRUE ); @@ -264,7 +278,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, m_lfoPredelayKnob = new knob( knobBright_26, this, - tr( "LFO-predelay-time" ) ); + tr( "LFO-predelay-time" ), eng() ); m_lfoPredelayKnob->setLabel( tr( "DEL" ) ); m_lfoPredelayKnob->setRange( 0.0, 1.0, 0.001 ); m_lfoPredelayKnob->setValue( 0.0, TRUE ); @@ -282,7 +296,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, SLOT( updateAfterKnobChange( float ) ) ); m_lfoAttackKnob = new knob( knobBright_26, this, - tr( "LFO-attack-time" ) ); + tr( "LFO-attack-time" ), eng() ); m_lfoAttackKnob->setLabel( tr( "ATT" ) ); m_lfoAttackKnob->setRange( 0.0, 1.0, 0.001 ); m_lfoAttackKnob->setValue( 0.0, TRUE ); @@ -300,7 +314,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, SLOT( updateAfterKnobChange( float ) ) ); m_lfoSpeedKnob = new tempoSyncKnob( knobBright_26, this, - tr( "LFO-speed" ), 20000.0 ); + tr( "LFO-speed" ), eng(), 20000.0 ); m_lfoSpeedKnob->setLabel( tr( "SPD" ) ); m_lfoSpeedKnob->setRange( 0.01, 1.0, 0.0001 ); m_lfoSpeedKnob->setValue( 0.1, TRUE ); @@ -318,7 +332,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, SLOT( updateAfterKnobChange( float ) ) ); m_lfoAmountKnob = new knob( knobBright_26, this, - tr( "LFO-modulation-amount" ) ); + tr( "LFO-modulation-amount" ), eng() ); m_lfoAmountKnob->setLabel( tr( "AMT" ) ); m_lfoAmountKnob->setRange( -1.0, 1.0, 0.005 ); m_lfoAmountKnob->setValue( 0.0, TRUE ); @@ -468,7 +482,7 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount, #endif setAcceptDrops( TRUE ); - connect( mixer::inst(), SIGNAL( sampleRateChanged() ), this, + connect( eng()->getMixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleVars() ) ); updateSampleVars(); @@ -482,29 +496,46 @@ envelopeAndLFOWidget::~envelopeAndLFOWidget() delete[] m_pahdEnv; delete[] m_rEnv; delete[] m_lfoShapeData; + + vvector & v = s_EaLWidgets[eng()]; + if( qFind( v.begin(), v.end(), this ) != v.end() ) + { + v.erase( qFind( v.begin(), v.end(), this ) ); + } } -void envelopeAndLFOWidget::triggerLFO( void ) +void envelopeAndLFOWidget::triggerLFO( engine * _engine ) { - s_lfoFrame += mixer::inst()->framesPerAudioBuffer(); + vvector & v = s_EaLWidgets[_engine]; + for( vvector::iterator it = v.begin(); + it != v.end(); ++it ) + { + ( *it )->m_lfoFrame += + _engine->getMixer()->framesPerAudioBuffer(); + } } -void envelopeAndLFOWidget::resetLFO( void ) +void envelopeAndLFOWidget::resetLFO( engine * _engine ) { - s_lfoFrame = 0; + vvector & v = s_EaLWidgets[_engine]; + for( vvector::iterator it = v.begin(); + it != v.end(); ++it ) + { + ( *it )->m_lfoFrame = 0; + } } -inline float FASTCALL envelopeAndLFOWidget::lfoLevel( Uint32 _frame, - Uint32 _frame_offset ) const +inline float FASTCALL envelopeAndLFOWidget::lfoLevel( f_cnt_t _frame, + const f_cnt_t _frame_offset ) const { if( m_lfoAmountIsZero == FALSE && _frame > m_lfoPredelayFrames ) { @@ -514,10 +545,10 @@ inline float FASTCALL envelopeAndLFOWidget::lfoLevel( Uint32 _frame, _frame -= m_lfoPredelayFrames; if( _frame > m_lfoAttackFrames ) { - return( m_lfoShapeData[( s_lfoFrame + _frame_offset ) % + return( m_lfoShapeData[( m_lfoFrame + _frame_offset ) % m_lfoOscillationFrames] ); } - return( m_lfoShapeData[( s_lfoFrame + _frame_offset ) % + return( m_lfoShapeData[( m_lfoFrame + _frame_offset ) % m_lfoOscillationFrames] * _frame / m_lfoAttackFrames ); } @@ -527,9 +558,9 @@ inline float FASTCALL envelopeAndLFOWidget::lfoLevel( Uint32 _frame, -float FASTCALL envelopeAndLFOWidget::level( Uint32 _frame, - Uint32 _release_begin, - Uint32 _frame_offset ) const +float FASTCALL envelopeAndLFOWidget::level( f_cnt_t _frame, + const f_cnt_t _release_begin, + const f_cnt_t _frame_offset ) const { if( m_busy ) { @@ -825,7 +856,7 @@ void envelopeAndLFOWidget::paintEvent( QPaintEvent * ) int graph_y_base = LFO_GRAPH_Y + 3 + LFO_GRAPH_H / 2; const float frames_for_graph = SECS_PER_LFO_OSCILLATION * - mixer::inst()->sampleRate() / 10; + eng()->getMixer()->sampleRate() / 10; const float lfo_gray_amount = 1.0f - fabsf( m_lfoAmountKnob->value() ); p.setPen( QPen( QColor( static_cast( 96 * lfo_gray_amount ), @@ -851,7 +882,7 @@ void envelopeAndLFOWidget::paintEvent( QPaintEvent * ) { float val = 0.0; float cur_sample = x * frames_for_graph / LFO_GRAPH_W; - if( static_cast( cur_sample ) > m_lfoPredelayFrames ) + if( static_cast( cur_sample ) > m_lfoPredelayFrames ) { float phase = ( cur_sample -= m_lfoPredelayFrames ) / osc_frames; @@ -875,7 +906,8 @@ void envelopeAndLFOWidget::paintEvent( QPaintEvent * ) m_userWave.data(), m_userWave.frames() ); } - if( (Uint32) cur_sample <= m_lfoAttackFrames ) + if( static_cast( cur_sample ) <= + m_lfoAttackFrames ) { val *= cur_sample / m_lfoAttackFrames; } @@ -918,18 +950,21 @@ void envelopeAndLFOWidget::updateSampleVars( void ) m_busy = TRUE; const float frames_per_env_seg = SECS_PER_ENV_SEGMENT * - mixer::inst()->sampleRate(); - Uint32 predelay_frames = static_cast( + eng()->getMixer()->sampleRate(); + const f_cnt_t predelay_frames = static_cast( frames_per_env_seg * expKnobVal( m_predelayKnob->value() ) ); - Uint32 attack_frames = static_cast( frames_per_env_seg * + const f_cnt_t attack_frames = static_cast( + frames_per_env_seg * expKnobVal( m_attackKnob->value() ) ); - Uint32 hold_frames = static_cast( frames_per_env_seg * + const f_cnt_t hold_frames = static_cast( + frames_per_env_seg * expKnobVal( m_holdKnob->value() ) ); - Uint32 decay_frames = static_cast( frames_per_env_seg * + const f_cnt_t decay_frames = static_cast( + frames_per_env_seg * expKnobVal( m_decayKnob->value() * m_sustainKnob->value() ) ); @@ -947,7 +982,7 @@ void envelopeAndLFOWidget::updateSampleVars( void ) m_pahdFrames = predelay_frames + attack_frames + hold_frames + decay_frames; - m_rFrames = static_cast( frames_per_env_seg * + m_rFrames = static_cast( frames_per_env_seg * expKnobVal( m_releaseKnob->value() ) ); if( static_cast( floorf( m_amount * 1000.0f ) ) == 0 ) @@ -956,30 +991,30 @@ void envelopeAndLFOWidget::updateSampleVars( void ) m_rFrames = 0; } - float * new_pahd_env = new float[m_pahdFrames]; - float * new_r_env = new float[m_rFrames]; + sample_t * new_pahd_env = new sample_t[m_pahdFrames]; + sample_t * new_r_env = new sample_t[m_rFrames]; - for( Uint32 i = 0; i < predelay_frames; ++i ) + for( f_cnt_t i = 0; i < predelay_frames; ++i ) { new_pahd_env[i] = m_amountAdd; } - Uint32 add = predelay_frames; + f_cnt_t add = predelay_frames; - for( Uint32 i = 0; i < attack_frames; ++i ) + for( f_cnt_t i = 0; i < attack_frames; ++i ) { new_pahd_env[add+i] = ( (float)i / attack_frames ) * m_amount + m_amountAdd; } add += attack_frames; - for( Uint32 i = 0; i < hold_frames; ++i ) + for( f_cnt_t i = 0; i < hold_frames; ++i ) { new_pahd_env[add+i] = m_amount + m_amountAdd; } add += hold_frames; - for( Uint32 i = 0; i < decay_frames; ++i ) + for( f_cnt_t i = 0; i < decay_frames; ++i ) { new_pahd_env[add+i] = ( m_sustainLevel + ( 1.0f - (float)i / decay_frames ) * @@ -993,7 +1028,7 @@ void envelopeAndLFOWidget::updateSampleVars( void ) m_pahdEnv = new_pahd_env; m_rEnv = new_r_env; - for( Uint32 i = 0; i < m_rFrames; ++i ) + for( f_cnt_t i = 0; i < m_rFrames; ++i ) { new_r_env[i] = ( (float)( m_rFrames - i ) / m_rFrames * m_sustainLevel ) * m_amount; @@ -1005,14 +1040,14 @@ void envelopeAndLFOWidget::updateSampleVars( void ) const float frames_per_lfo_oscillation = SECS_PER_LFO_OSCILLATION * - mixer::inst()->sampleRate(); - m_lfoPredelayFrames = static_cast( + eng()->getMixer()->sampleRate(); + m_lfoPredelayFrames = static_cast( frames_per_lfo_oscillation * expKnobVal( m_lfoPredelayKnob->value() ) ); - m_lfoAttackFrames = static_cast( + m_lfoAttackFrames = static_cast( frames_per_lfo_oscillation * expKnobVal( m_lfoAttackKnob->value() ) ); - m_lfoOscillationFrames = static_cast( + m_lfoOscillationFrames = static_cast( frames_per_lfo_oscillation * m_lfoSpeedKnob->value() ); if( m_x100Cb->isChecked() ) @@ -1039,8 +1074,8 @@ void envelopeAndLFOWidget::updateSampleVars( void ) if( m_lfoAmountIsZero == FALSE ) { delete[] m_lfoShapeData; - m_lfoShapeData = new float[m_lfoOscillationFrames]; - for( Uint32 frame = 0; frame < m_lfoOscillationFrames; + m_lfoShapeData = new sample_t[m_lfoOscillationFrames]; + for( f_cnt_t frame = 0; frame < m_lfoOscillationFrames; ++frame ) { const float phase = frame / static_cast( @@ -1088,7 +1123,7 @@ void envelopeAndLFOWidget::updateSampleVars( void ) void envelopeAndLFOWidget::x100Toggled( bool ) { - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); updateSampleVars(); } @@ -1109,7 +1144,7 @@ void envelopeAndLFOWidget::lfoSinWaveCh( bool _on ) { m_lfoShape = SIN; } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); update(); } @@ -1123,7 +1158,7 @@ void envelopeAndLFOWidget::lfoTriangleWaveCh( bool _on ) { m_lfoShape = TRIANGLE; } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); update(); } @@ -1137,7 +1172,7 @@ void envelopeAndLFOWidget::lfoSawWaveCh( bool _on ) { m_lfoShape = SAW; } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); update(); } @@ -1151,7 +1186,7 @@ void envelopeAndLFOWidget::lfoSquareWaveCh( bool _on ) { m_lfoShape = SQUARE; } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); update(); } @@ -1172,7 +1207,7 @@ void envelopeAndLFOWidget::lfoUserWaveCh( bool _on ) } m_lfoShape = USER; } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); update(); } diff --git a/src/core/envelope_tab_widget.cpp b/src/core/envelope_tab_widget.cpp index bac0ffd9b3..0a1f93a9fa 100644 --- a/src/core/envelope_tab_widget.cpp +++ b/src/core/envelope_tab_widget.cpp @@ -83,7 +83,8 @@ static const QString targetNames[envelopeTabWidget::TARGET_COUNT][2] = envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) : QWidget( _channel_track->tabWidgetParent() ), - settings() + settings(), + engineObject( _channel_track->eng() ) { m_targetsTabWidget = new tabWidget( tr( "TARGET" ), this ); @@ -118,7 +119,9 @@ envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) : value_for_zero_amount = 1.0; } m_envLFOWidgets[i] = new envelopeAndLFOWidget( - value_for_zero_amount, m_targetsTabWidget ); + value_for_zero_amount, + m_targetsTabWidget, + eng() ); m_targetsTabWidget->addTab( m_envLFOWidgets[i], tr( targetNames[i][0] #ifdef QT4 @@ -171,7 +174,7 @@ envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) : m_filterCutKnob = new knob( knobBright_26, m_filterGroupBox, tr( - "cutoff-frequency" ) ); + "cutoff-frequency" ), eng() ); m_filterCutKnob->setLabel( tr( "CUTOFF" ) ); m_filterCutKnob->setRange( 0.0, 16000.0, 1.0 ); m_filterCutKnob->move( 140, 18 ); @@ -191,7 +194,7 @@ envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) : "frequencies below cutoff-frequency and so on..." ) ); m_filterResKnob = new knob( knobBright_26, m_filterGroupBox, tr( - "Q/Resonance" ) ); + "Q/Resonance" ), eng() ); m_filterResKnob->setLabel( tr( "Q/RESO" ) ); m_filterResKnob->setRange( 0.01, 10.0, 0.01 ); m_filterResKnob->move( 190, 18 ); @@ -220,14 +223,14 @@ envelopeTabWidget::~envelopeTabWidget() float FASTCALL envelopeTabWidget::volumeLevel( notePlayHandle * _n, - Uint32 _frame ) + const f_cnt_t _frame ) { - Uint32 release_begin = _frame - _n->releaseFramesDone() + + f_cnt_t release_begin = _frame - _n->releaseFramesDone() + _n->framesBeforeRelease(); if( _n->released() == FALSE ) { - release_begin += mixer::inst()->framesPerAudioBuffer(); + release_begin += eng()->getMixer()->framesPerAudioBuffer(); } return( m_envLFOWidgets[VOLUME]->level( _frame, release_begin, 0 ) ); @@ -236,16 +239,17 @@ float FASTCALL envelopeTabWidget::volumeLevel( notePlayHandle * _n, -void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, +void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, + const fpab_t _frames, notePlayHandle * _n ) { - Uint32 total_frames = _n->totalFramesPlayed(); - Uint32 release_begin = total_frames - _n->releaseFramesDone() + + f_cnt_t total_frames = _n->totalFramesPlayed(); + f_cnt_t release_begin = total_frames - _n->releaseFramesDone() + _n->framesBeforeRelease(); if( _n->released() == FALSE ) { - release_begin += mixer::inst()->framesPerAudioBuffer(); + release_begin += eng()->getMixer()->framesPerAudioBuffer(); } // because of optimizations, there's special code for several cases: @@ -265,7 +269,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, if( _n->m_filter == NULL ) { _n->m_filter = new basicFilters<>( - mixer::inst()->sampleRate() ); + eng()->getMixer()->sampleRate() ); } if( m_filterGroupBox->isActive() ) @@ -281,7 +285,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, m_envLFOWidgets[CUT]->used() && m_envLFOWidgets[RES]->used() ) { - for( Uint32 frame = 0; frame < _frames; + for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) { float new_cut_val = m_envLFOWidgets[CUT]->level( total_frames, release_begin, frame ); @@ -302,7 +306,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, float vol_level = m_envLFOWidgets[VOLUME]->level( total_frames, release_begin, frame ); vol_level = vol_level*vol_level; - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { _ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl ); } @@ -310,7 +314,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, } else if( m_envLFOWidgets[VOLUME]->used() && m_envLFOWidgets[CUT]->used() ) { - for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) { float new_cut_val = m_envLFOWidgets[CUT]->level( total_frames, release_begin, frame ); new_cut_val = envelopeAndLFOWidget::expKnobVal( new_cut_val ) * CUT_FREQ_MULTIPLIER + @@ -325,7 +329,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, float vol_level = m_envLFOWidgets[VOLUME]->level( total_frames, release_begin, frame ); vol_level = vol_level*vol_level; - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { _ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl ); } @@ -334,7 +338,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, else if( m_envLFOWidgets[VOLUME]->used() && m_envLFOWidgets[RES]->used() ) { - for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) { float new_res_val = m_filterResKnob->value() + RES_MULTIPLIER * m_envLFOWidgets[RES]->level( total_frames, release_begin, frame ); @@ -348,7 +352,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, float vol_level = m_envLFOWidgets[VOLUME]->level( total_frames, release_begin, frame ); vol_level = vol_level*vol_level; - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { _ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl ); } @@ -357,7 +361,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, } else if( m_envLFOWidgets[CUT]->used() ) { - for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) { float new_cut_val = m_envLFOWidgets[CUT]->level( total_frames, release_begin, frame ); new_cut_val = envelopeAndLFOWidget::expKnobVal( new_cut_val ) * CUT_FREQ_MULTIPLIER + @@ -369,7 +373,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, old_filter_cut = static_cast( new_cut_val ); } - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { _ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl ); } @@ -377,7 +381,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, } else if( m_envLFOWidgets[RES]->used() ) { - for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) { float new_res_val = m_filterResKnob->value() + RES_MULTIPLIER * m_envLFOWidgets[RES]->level( total_frames, release_begin, frame ); @@ -388,7 +392,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, old_filter_res = static_cast( new_res_val*RES_PRECISION ); } - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { _ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl ); } @@ -398,12 +402,12 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, { _n->m_filter->calcFilterCoeffs( filter, m_filterCutKnob->value(), m_filterResKnob->value() ); - for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) { float vol_level = m_envLFOWidgets[VOLUME]->level( total_frames, release_begin, frame ); vol_level = vol_level*vol_level; - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { _ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl ); } @@ -413,9 +417,9 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, { _n->m_filter->calcFilterCoeffs( filter, m_filterCutKnob->value(), m_filterResKnob->value() ); - for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) { - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { _ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl ); } @@ -425,11 +429,11 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, else if( m_envLFOWidgets[VOLUME]->used() /*&& m_envLFOWidgets[PANNING]->used() == FALSE*/ ) { // only use volume-envelope... - for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) { float vol_level = m_envLFOWidgets[VOLUME]->level( total_frames, release_begin, frame ); vol_level = vol_level*vol_level; - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { _ab[frame][chnl] = vol_level * _ab[frame][chnl]; } @@ -438,11 +442,11 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, /* else if( m_envLFOWidgets[VOLUME]->used() == FALSE && m_envLFOWidgets[PANNING]->used() ) { // only use panning-envelope... - for( Uint32 frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) { float vol_level = m_envLFOWidgets[PANNING]->level( total_frames, release_begin, frame ); vol_level = vol_level*vol_level; - for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { _ab[frame][chnl] = vol_level * _ab[frame][chnl]; } @@ -453,9 +457,9 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames, -Uint32 envelopeTabWidget::envFrames( void ) +f_cnt_t envelopeTabWidget::envFrames( void ) { - Uint32 ret_val = m_envLFOWidgets[VOLUME]->m_pahdFrames; + f_cnt_t ret_val = m_envLFOWidgets[VOLUME]->m_pahdFrames; for( int i = VOLUME+1; i < TARGET_COUNT; ++i ) { @@ -471,9 +475,9 @@ Uint32 envelopeTabWidget::envFrames( void ) -Uint32 envelopeTabWidget::releaseFrames( void ) +f_cnt_t envelopeTabWidget::releaseFrames( void ) { - Uint32 ret_val = m_envLFOWidgets[VOLUME]->m_rFrames; + f_cnt_t ret_val = m_envLFOWidgets[VOLUME]->m_rFrames; for( int i = VOLUME+1; i < TARGET_COUNT; ++i ) { if( m_envLFOWidgets[i]->used() && diff --git a/src/core/export_project_dialog.cpp b/src/core/export_project_dialog.cpp index 51a51cdd30..92e98e7bce 100644 --- a/src/core/export_project_dialog.cpp +++ b/src/core/export_project_dialog.cpp @@ -49,7 +49,7 @@ #include "export_project_dialog.h" #include "song_editor.h" -#include "lmms_main_win.h" +#include "main_window.h" #include "combobox.h" #include "led_checkbox.h" #include "embed.h" @@ -127,8 +127,10 @@ Sint16 exportProjectDialog::s_availableBitrates[] = // TODO: rewrite that crap using layouts!! exportProjectDialog::exportProjectDialog( const QString & _file_name, - QWidget * _parent ) : + QWidget * _parent, + engine * _engine ) : QDialog( _parent ), + engineObject( _engine ), m_fileName( _file_name ), m_hourglassLbl( NULL ), m_deleteFile( FALSE ) @@ -156,7 +158,7 @@ exportProjectDialog::exportProjectDialog( const QString & _file_name, connect( m_typeCombo, SIGNAL( activated( const QString & ) ), this, SLOT( changedType( const QString & ) ) ); - int idx = 0; + Uint8 idx = 0; while( fileEncodeDevices[idx].m_fileType != NULL_FILE ) { m_typeCombo->addItem( @@ -253,7 +255,7 @@ void exportProjectDialog::keyPressEvent( QKeyEvent * _ke ) { if( _ke->key() == Qt::Key_Escape ) { - if( songEditor::inst()->exporting() == FALSE ) + if( eng()->getSongEditor()->exporting() == FALSE ) { accept(); } @@ -269,7 +271,7 @@ void exportProjectDialog::keyPressEvent( QKeyEvent * _ke ) void exportProjectDialog::closeEvent( QCloseEvent * _ce ) { - if( songEditor::inst()->exporting() == TRUE ) + if( eng()->getSongEditor()->exporting() == TRUE ) { abortProjectExport(); _ce->ignore(); @@ -326,8 +328,8 @@ void exportProjectDialog::exportBtnClicked( void ) m_vbrCb->isChecked(), m_kbpsCombo->currentText().toInt(), m_kbpsCombo->currentText().toInt() - 64, - m_kbpsCombo->currentText().toInt() + 64 - ); + m_kbpsCombo->currentText().toInt() + 64, + eng()->getMixer() ); if( success_ful == FALSE ) { QMessageBox::information( this, @@ -373,26 +375,26 @@ void exportProjectDialog::exportBtnClicked( void ) - mixer::inst()->setAudioDevice( dev, m_hqmCb->isChecked() ); - songEditor::inst()->startExport(); + eng()->getMixer()->setAudioDevice( dev, m_hqmCb->isChecked() ); + eng()->getSongEditor()->startExport(); - songEditor::playPos & pp = songEditor::inst()->getPlayPos( + songEditor::playPos & pp = eng()->getSongEditor()->getPlayPos( songEditor::PLAY_SONG ); - while( songEditor::inst()->exportDone() == FALSE && - songEditor::inst()->exporting() == TRUE ) + while( eng()->getSongEditor()->exportDone() == FALSE && + eng()->getSongEditor()->exporting() == TRUE ) { dev->processNextBuffer(); int pval = pp * 100 / - ( ( songEditor::inst()->lengthInTacts() + 1 ) * 64 ); + ( ( eng()->getSongEditor()->lengthInTacts() + 1 ) * 64 ); #ifdef QT4 m_exportProgressBar->setValue( pval ); #else m_exportProgressBar->setProgress( pval ); #endif // update lmms-main-win-caption - lmmsMainWin::inst()->setWindowTitle( tr( "Rendering:" ) + " " + + eng()->getMainWindow()->setWindowTitle( tr( "Rendering:" ) + " " + QString::number( pval ) + "%" ); // process paint-events etc. qApp->processEvents(); @@ -413,7 +415,7 @@ void exportProjectDialog::exportBtnClicked( void ) void exportProjectDialog::cancelBtnClicked( void ) { // is song-export-thread active? - if( songEditor::inst()->exporting() == TRUE ) + if( eng()->getSongEditor()->exporting() == TRUE ) { // then dispose abort of export abortProjectExport(); @@ -438,7 +440,7 @@ void exportProjectDialog::abortProjectExport( void ) void exportProjectDialog::finishProjectExport( void ) { - mixer::inst()->restoreAudioDevice(); + eng()->getMixer()->restoreAudioDevice(); // if the user aborted export-process, the file has to be deleted if( m_deleteFile ) @@ -447,9 +449,9 @@ void exportProjectDialog::finishProjectExport( void ) } // restore window-title - lmmsMainWin::inst()->resetWindowTitle(); + eng()->getMainWindow()->resetWindowTitle(); - songEditor::inst()->stopExport(); + eng()->getSongEditor()->stopExport(); // if we rendered file from command line, quit after export if( file_to_render != "" ) diff --git a/src/core/file_browser.cpp b/src/core/file_browser.cpp index 4eb63f5c77..3796e9b867 100644 --- a/src/core/file_browser.cpp +++ b/src/core/file_browser.cpp @@ -2,7 +2,7 @@ * file_browser.cpp - implementation of the project-, preset- and * sample-file-browser * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -32,12 +32,15 @@ #include #include #include +#include #else #include #include #include +#include +#include #endif @@ -55,19 +58,21 @@ #include "instrument.h" #include "text_float.h" #include "string_pair_drag.h" +#include "main_window.h" fileBrowser::fileBrowser( const QString & _path, const QString & _filter, const QString & _title, const QPixmap & _pm, - QWidget * _parent ) : + QWidget * _parent, engine * _engine ) : sideBarWidget( _title, _pm, _parent ), + engineObject( _engine ), m_contextMenuItem( NULL ), m_path( _path ), m_filter( _filter ) { setWindowTitle( tr( "Browser" ) ); - m_l = new listView( contentParent() ); + m_l = new listView( contentParent(), eng() ); addContentWidget( m_l ); #ifdef QT4 @@ -190,10 +195,11 @@ void fileBrowser::contextMenuRequest( QListViewItem * i, const QPoint &, int ) void fileBrowser::sendToActiveChannel( void ) { - if( lmmsMainWin::inst()->workspace() != NULL ) + if( eng()->getMainWindow()->workspace() != NULL ) { // get all windows opened in the workspace - QWidgetList pl = lmmsMainWin::inst()->workspace()->windowList( + QWidgetList pl = + eng()->getMainWindow()->workspace()->windowList( #if QT_VERSION >= 0x030200 QWorkspace::StackingOrder #endif @@ -290,7 +296,7 @@ void fileBrowser::openInNewChannel( trackContainer * _tc ) void fileBrowser::openInNewChannelSE( void ) { - openInNewChannel( songEditor::inst() ); + openInNewChannel( eng()->getSongEditor() ); } @@ -298,7 +304,7 @@ void fileBrowser::openInNewChannelSE( void ) void fileBrowser::openInNewChannelBBE( void ) { - openInNewChannel( bbEditor::inst() ); + openInNewChannel( eng()->getBBEditor() ); } @@ -308,8 +314,9 @@ void fileBrowser::openInNewChannelBBE( void ) -listView::listView( QWidget * _parent ) : +listView::listView( QWidget * _parent, engine * _engine ) : Q3ListView( _parent ), + engineObject( _engine ), m_mousePressed( FALSE ), m_pressPos(), m_previewPlayHandle( NULL ) @@ -344,9 +351,8 @@ void listView::contentsMouseDoubleClickEvent( QMouseEvent * _me ) // samples are per default opened in bb-editor because // they're likely drum-samples etc. channelTrack * ct = dynamic_cast( - track::create( - track::CHANNEL_TRACK, - bbEditor::inst() ) ); + track::create( track::CHANNEL_TRACK, + eng()->getBBEditor() ) ); #ifdef LMMS_DEBUG assert( ct != NULL ); #endif @@ -364,7 +370,7 @@ void listView::contentsMouseDoubleClickEvent( QMouseEvent * _me ) // presets are per default opened in bb-editor multimediaProject mmp( f->fullName() ); track * t = track::create( track::CHANNEL_TRACK, - bbEditor::inst() ); + eng()->getBBEditor() ); channelTrack * ct = dynamic_cast( t ); if( ct != NULL ) { @@ -376,9 +382,9 @@ void listView::contentsMouseDoubleClickEvent( QMouseEvent * _me ) } else if( f->type() == fileItem::PROJECT_FILE ) { - if( songEditor::inst()->mayChangeProject() == TRUE ) + if( eng()->getSongEditor()->mayChangeProject() == TRUE ) { - songEditor::inst()->loadProject( + eng()->getSongEditor()->loadProject( f->fullName() ); } } @@ -414,7 +420,7 @@ void listView::contentsMousePressEvent( QMouseEvent * _me ) { if( m_previewPlayHandle != NULL ) { - mixer::inst()->removePlayHandle( m_previewPlayHandle ); + eng()->getMixer()->removePlayHandle( m_previewPlayHandle ); m_previewPlayHandle = NULL; } if( f->type() == fileItem::SAMPLE_FILE ) @@ -431,7 +437,7 @@ void listView::contentsMousePressEvent( QMouseEvent * _me ) qApp->processEvents(); #endif samplePlayHandle * s = new samplePlayHandle( - f->fullName() ); + f->fullName(), eng() ); s->setDoneMayReturnTrue( FALSE ); m_previewPlayHandle = s; delete tf; @@ -439,11 +445,11 @@ void listView::contentsMousePressEvent( QMouseEvent * _me ) else if( f->type() == fileItem::PRESET_FILE ) { m_previewPlayHandle = new presetPreviewPlayHandle( - f->fullName() ); + f->fullName(), eng() ); } if( m_previewPlayHandle != NULL ) { - mixer::inst()->addPlayHandle( m_previewPlayHandle ); + eng()->getMixer()->addPlayHandle( m_previewPlayHandle ); } } } @@ -469,7 +475,7 @@ void listView::contentsMouseMoveEvent( QMouseEvent * _me ) f->fullName(), embed::getIconPixmap( "preset_file" ), - this ); + this, eng() ); break; case fileItem::SAMPLE_FILE: @@ -477,7 +483,7 @@ void listView::contentsMouseMoveEvent( QMouseEvent * _me ) f->fullName(), embed::getIconPixmap( "sound_file" ), - this ); + this, eng() ); break; case fileItem::MIDI_FILE: @@ -485,7 +491,7 @@ void listView::contentsMouseMoveEvent( QMouseEvent * _me ) f->fullName(), embed::getIconPixmap( "midi_file" ), - this ); + this, eng() ); break; default: @@ -511,14 +517,14 @@ void listView::contentsMouseReleaseEvent( QMouseEvent * _me ) { if( s->totalFrames() - s->framesDone() <= static_cast( - mixer::inst()->sampleRate() * 3 ) ) + eng()->getMixer()->sampleRate() * 3 ) ) { s->setDoneMayReturnTrue( TRUE ); m_previewPlayHandle = NULL; return; } } - mixer::inst()->removePlayHandle( m_previewPlayHandle ); + eng()->getMixer()->removePlayHandle( m_previewPlayHandle ); m_previewPlayHandle = NULL; } } diff --git a/src/core/instrument.cpp b/src/core/instrument.cpp index 07c8887c5a..237c77b3db 100644 --- a/src/core/instrument.cpp +++ b/src/core/instrument.cpp @@ -1,7 +1,7 @@ /* * instrument.cpp - base-class for all instrument-plugins (synths, samplers etc) * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -31,7 +31,7 @@ instrument::instrument( channelTrack * _channel_track, const descriptor * _descriptor ) : QWidget( _channel_track->tabWidgetParent() ), - plugin( _descriptor ), + plugin( _descriptor, _channel_track->eng() ), m_channelTrack( _channel_track ), m_valid( TRUE ) { @@ -73,7 +73,7 @@ void instrument::deleteNotePluginData( notePlayHandle * ) -Uint32 instrument::beatLen( notePlayHandle * ) const +f_cnt_t instrument::beatLen( notePlayHandle * ) const { return( 0 ); } diff --git a/src/core/main.cpp b/src/core/main.cpp index e48862a0d8..9b56285f6a 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -46,7 +46,7 @@ #endif -#include "lmms_main_win.h" +#include "main_window.h" #include "embed.h" #include "config_mgr.h" #include "export_project_dialog.h" @@ -54,19 +54,20 @@ #include "gui_templates.h" +QString file_to_render; + + #if QT_VERSION >= 0x030100 int splash_alignment_flags = Qt::AlignTop | Qt::AlignLeft; #endif -QString file_to_load; -QString file_to_render; - int main( int argc, char * * argv ) { QApplication app( argc, argv ); QString extension = "wav"; + QString file_to_load; for( int i = 1; i < app.argc(); ++i ) { @@ -187,10 +188,10 @@ int main( int argc, char * * argv ) #if QT_VERSION >= 0x030200 // init splash screen QPixmap splash = embed::getIconPixmap( "splash" ); - lmmsMainWin::s_splashScreen = new QSplashScreen( splash ); - lmmsMainWin::s_splashScreen->show(); + mainWindow::s_splashScreen = new QSplashScreen( splash ); + mainWindow::s_splashScreen->show(); - lmmsMainWin::s_splashScreen->showMessage( lmmsMainWin::tr( + mainWindow::s_splashScreen->showMessage( mainWindow::tr( "Setting up main-" "window and " "workspace..." ), @@ -198,33 +199,45 @@ int main( int argc, char * * argv ) Qt::white ); #endif + engine * main_engine = new engine(); + + // we try to load given file + if( file_to_load != "" ) + { + main_engine->getSongEditor()->loadProject( file_to_load ); + } + else + { + main_engine->getSongEditor()->createNewProject(); + } #ifndef QT4 - app.setMainWidget( lmmsMainWin::inst() ); + app.setMainWidget( main_engine->getMainWindow() ); #endif // MDI-mode? - if( lmmsMainWin::inst()->workspace() != NULL ) + if( main_engine->getMainWindow()->workspace() != NULL ) { // then maximize - lmmsMainWin::inst()->showMaximized(); + main_engine->getMainWindow()->showMaximized(); } else { // otherwise arrange at top-left edge of screen - lmmsMainWin::inst()->show(); - lmmsMainWin::inst()->move( 0, 0 ); - lmmsMainWin::inst()->resize( 200, 500 ); + main_engine->getMainWindow()->show(); + main_engine->getMainWindow()->move( 0, 0 ); + main_engine->getMainWindow()->resize( 200, 500 ); } #if QT_VERSION >= 0x030200 - delete lmmsMainWin::s_splashScreen; - lmmsMainWin::s_splashScreen = NULL; + delete mainWindow::s_splashScreen; + mainWindow::s_splashScreen = NULL; #endif if( file_to_render != "" ) { exportProjectDialog * e = new exportProjectDialog( - file_to_render, - lmmsMainWin::inst() ); + file_to_render, + main_engine->getMainWindow(), + main_engine ); e->show(); e->exportBtnClicked(); } diff --git a/src/core/main_window.cpp b/src/core/main_window.cpp new file mode 100644 index 0000000000..e776e4a5aa --- /dev/null +++ b/src/core/main_window.cpp @@ -0,0 +1,864 @@ +/* + * main_window.cpp - implementation of LMMS-main-window + * + * Copyright (c) 2004-2006 Tobias Doerffel + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + + +#include "qt3support.h" + +#ifdef QT4 + +#include +#include +#include +#include +#include +#include +#include + +#else + +#include +#include +#include +#include +#include +#include +#include + +#if QT_VERSION >= 0x030200 +#include +#endif + +#endif + +#ifdef HAVE_CONFIG_H +#include +#endif + + +#include "main_window.h" +#include "bb_editor.h" +#include "song_editor.h" +#include "piano_roll.h" +#include "embed.h" +#include "about_dialog.h" +#include "file_browser.h" +#include "plugin_browser.h" +#include "side_bar.h" +#include "config_mgr.h" +#include "mixer.h" +#include "project_notes.h" +#include "buffer_allocator.h" +#include "setup_dialog.h" +#include "audio_dummy.h" +#include "tool_button.h" + + +#if QT_VERSION >= 0x030100 +QSplashScreen * mainWindow::s_splashScreen = NULL; +extern int splash_alignment_flags; +#endif + + + +mainWindow::mainWindow( engine * _engine ) : + QMainWindow( +#ifndef QT4 + 0 , NULL, WDestructiveClose +#endif + ), + engineObject( _engine ), + m_workspace( NULL ), + m_templatesMenu( NULL ) +{ +#ifdef QT4 + setAttribute( Qt::WA_DeleteOnClose ); +#endif + + bool no_mdi = configManager::inst()->value( "app", "gimplikewindows" + ).toInt(); + + QWidget * main_widget = new QWidget( this ); + QVBoxLayout * vbox = new QVBoxLayout( main_widget ); + vbox->setSpacing( 0 ); + vbox->setMargin( 0 ); + + + QWidget * w = new QWidget( main_widget ); + QHBoxLayout * hbox = new QHBoxLayout( w ); + hbox->setSpacing( 0 ); + hbox->setMargin( 0 ); + + sideBar * side_bar = new sideBar( sideBar::Vertical, w ); + side_bar->setStyle( sideBar::VSNET/*KDEV3ICON*/ ); + side_bar->setPosition( sideBar::Left ); + + QSplitter * splitter = new QSplitter( Qt::Horizontal, w ); +#if QT_VERSION >= 0x030200 + splitter->setChildrenCollapsible( FALSE ); +#endif + + int id = 0; + QString wdir = configManager::inst()->workingDir(); + side_bar->appendTab( new pluginBrowser( splitter, eng() ), ++id ); + side_bar->appendTab( new fileBrowser( wdir+"projects", + "*.mmp *.xml *.mid", + tr( "My projects" ), + embed::getIconPixmap( "project_file" ), + splitter, eng() ), + ++id ); + side_bar->appendTab( new fileBrowser( wdir+"samples", "*.wav *.ogg *.au" + "*.voc *.aif *.aiff *.flac *.raw", + tr( "My samples" ), + embed::getIconPixmap( "sound_file" ), + splitter, eng() ), + ++id ); + side_bar->appendTab( new fileBrowser( wdir+"presets", "*.cs.xml", + tr( "My presets" ), + embed::getIconPixmap( "preset_file" ), + splitter, eng() ), + ++id ); + side_bar->appendTab( new fileBrowser( QDir::homePath(), "*", + tr( "My home" ), + embed::getIconPixmap( "home" ), + splitter, eng() ), + ++id ); + side_bar->appendTab( new fileBrowser( QDir::rootPath(), "*", + tr( "Root directory" ), + embed::getIconPixmap( "root" ), + splitter, eng() ), + ++id ); + + if( no_mdi == FALSE ) + { + m_workspace = new QWorkspace( splitter ); + m_workspace->setScrollBarsEnabled( TRUE ); + +#ifdef QT4 +/* m_workspace->setBackground( embed::getIconPixmap( + "background_artwork" ) );*/ +#else + m_workspace->setPaletteBackgroundPixmap( embed::getIconPixmap( + "background_artwork" ) ); +#endif + } + + hbox->addWidget( side_bar ); + hbox->addWidget( splitter ); + + + // create global-toolbar at the top of our window + m_toolBar = new QWidget( main_widget ); + m_toolBar->setFixedHeight( 64 ); + m_toolBar->move( 0, 0 ); +#ifdef QT4 + QPalette pal; + pal.setBrush( m_toolBar->backgroundRole(), QBrush( + embed::getIconPixmap( "main_toolbar_bg" ) ) ); + m_toolBar->setPalette( pal ); +#else + m_toolBar->setPaletteBackgroundPixmap( + embed::getIconPixmap( "main_toolbar_bg" ) ); +#endif + + // add layout for organizing quite complex toolbar-layouting + m_toolBarLayout = new QGridLayout( m_toolBar/*, 2, 1*/ ); + m_toolBarLayout->setMargin( 0 ); + m_toolBarLayout->setSpacing( 0 ); + + vbox->addWidget( m_toolBar ); + vbox->addWidget( w ); + setCentralWidget( main_widget ); + + + +} + + + + +mainWindow::~mainWindow() +{ +/* // first make sure, there're no mixing/audio-device-threads any more + eng()->getMixer()->stopProcessing(); + + // destroy editors with all their children + delete eng()->getSongEditor(); + delete eng()->getBBEditor(); + + + + // destroy mixer + delete eng()->getMixer(); + + // destroy config-manager (which automatically saves config-file) +*/ + delete eng(); +} + + + +void mainWindow::finalize( void ) +{ +#if QT_VERSION >= 0x030200 + if( qApp->argc() > 1 ) + { + s_splashScreen->showMessage( tr( "Loading song..." ), + splash_alignment_flags, + Qt::white ); + } + else + { + s_splashScreen->showMessage( tr( "Creating new song..." ), + splash_alignment_flags, + Qt::white ); + } +#endif + eng()->getSongEditor(); + + +#if QT_VERSION >= 0x030200 + s_splashScreen->showMessage( tr( "Creating GUI..." ), + splash_alignment_flags, + Qt::white ); +#endif + resetWindowTitle( "" ); + setWindowIcon( embed::getIconPixmap( "icon" ) ); + + + // create tool-buttons + toolButton * project_new = new toolButton( + embed::getIconPixmap( "project_new" ), + tr( "Create new project" ), + this, SLOT( createNewProject() ), + m_toolBar ); + + QDir d( configManager::inst()->projectsDir() + "templates" ); + QStringList templates = d.entryList( +#ifdef QT4 + QStringList( "*.mpt" ), +#else + "*.mpt", +#endif + QDir::Files | QDir::Readable ); + if( !templates.isEmpty() ) + { + m_templatesMenu = new QMenu( project_new ); + for( QStringList::iterator it = templates.begin(); + it != templates.end(); ++it ) + { + m_templatesMenu->addAction( + embed::getIconPixmap( "project_file" ), + ( *it ).left( ( *it ).length() - 4 ) ); + } + connect( m_templatesMenu, SIGNAL( activated( int ) ), + this, SLOT( createNewProjectFromTemplate( int ) ) ); + project_new->setMenu( m_templatesMenu ); +#ifdef QT4 + project_new->setPopupMode( toolButton::MenuButtonPopup ); +#else + project_new->setPopupDelay( 0 ); +#endif + } + + + toolButton * project_open = new toolButton( + embed::getIconPixmap( "project_open" ), + tr( "Open existing project" ), + this, SLOT( openProject() ), + m_toolBar ); + + + toolButton * project_save = new toolButton( + embed::getIconPixmap( "project_save" ), + tr( "Save current project" ), + this, SLOT( saveProject() ), + m_toolBar ); + + + toolButton * project_export = new toolButton( + embed::getIconPixmap( "project_export" ), + tr( "Export current project" ), + eng()->getSongEditor(), + SLOT( exportProject() ), + m_toolBar ); + + + m_toolBarLayout->setColumnMinimumWidth( 0, 5 ); + m_toolBarLayout->addWidget( project_new, 0, 1 ); + m_toolBarLayout->addWidget( project_open, 0, 2 ); + m_toolBarLayout->addWidget( project_save, 0, 3 ); + m_toolBarLayout->addWidget( project_export, 0, 4 ); + + + + // window-toolbar + toolButton * bb_editor_window = new toolButton( + embed::getIconPixmap( "bb_track" ), + tr( "Show/hide Beat+Bassline Editor" ) + + " (F6)", + this, SLOT( toggleBBEditorWin() ), + m_toolBar ); + bb_editor_window->setShortcut( Qt::Key_F6 ); +#ifdef QT4 + bb_editor_window->setWhatsThis( +#else + QWhatsThis::add( bb_editor_window, +#endif + tr( "By pressing this button, you can show or hide the " + "Beat+Bassline Editor. The Beat+Bassline Editor is " + "needed for setting beats, opening, adding and " + "removing channels, cutting, copying and pasting " + "beat- and bassline-patterns and other things like " + "that." ) ); + + + toolButton * piano_roll_window = new toolButton( + embed::getIconPixmap( "piano" ), + tr( "Show/hide Piano-Roll" ) + + " (F7)", + this, SLOT( togglePianoRollWin() ), + m_toolBar ); + piano_roll_window->setShortcut( Qt::Key_F7 ); +#ifdef QT4 + piano_roll_window->setWhatsThis( +#else + QWhatsThis::add( piano_roll_window, +#endif + tr( "By pressing this button, you can show or hide the " + "Piano-Roll. With the help of the Piano-Roll " + "you can edit melody-patterns in an easy way." + ) ); + + toolButton * song_editor_window = new toolButton( + embed::getIconPixmap( "songeditor" ), + tr( "Show/hide Song-Editor" ) + " (F8)", + this, SLOT( toggleSongEditorWin() ), + m_toolBar ); + song_editor_window->setShortcut( Qt::Key_F8 ); +#ifdef QT4 + song_editor_window->setWhatsThis( +#else + QWhatsThis::add( song_editor_window, +#endif + tr( "By pressing this button, you can show or hide the " + "Song-Editor. With the help of the Song-Editor you can " + "edit song-playlist and specify when which track " + "should be played. " + "You can also insert and move samples (e.g. " + "rap-samples) directly into the playlist." ) ); + + +/* toolButton * effect_board_window = new toolButton( + embed::getIconPixmap( "effect_board" ), + tr( "Show/hide EffectBoard" ) + " (F9)", + this, SLOT( emptySlot() ), m_toolBar ); + effect_board_window->setShortcut( Qt::Key_F9 ); +#ifdef QT4 + effect_board_window->setWhatsThis( +#else + QWhatsThis::add( effect_board_window, +#endif + tr( "By pressing this button, you can show or hide the " + "EffectBoard. The EffectBoard is a very powerful tool " + "for managing effects for your song. You can insert " + "effects into different effect-channels." ) );*/ + + toolButton * project_notes_window = new toolButton( + embed::getIconPixmap( "project_notes" ), + tr( "Show/hide project notes" ) + + " (F10)", + this, SLOT( toggleProjectNotesWin() ), + m_toolBar ); + project_notes_window->setShortcut( Qt::Key_F10 ); +#ifdef QT4 + project_notes_window->setWhatsThis( +#else + QWhatsThis::add( project_notes_window, +#endif + tr( "By pressing this button, you can show or hide the " + "project notes window. In this window you can put " + "down your project notes.") ); + + m_toolBarLayout->addWidget( bb_editor_window, 1, 1 ); + m_toolBarLayout->addWidget( piano_roll_window, 1, 2 ); + m_toolBarLayout->addWidget( song_editor_window, 1, 3 ); + //m_toolBarLayout->addWidget( effect_board_window, 1, 4 ); + m_toolBarLayout->addWidget( project_notes_window, 1, 5 ); + + m_toolBarLayout->setColumnStretch( 100, 1 ); + + + + // project-popup-menu + QMenu * project_menu = new QMenu( this ); +#ifdef QT4 + menuBar()->addMenu( project_menu )->setText( tr( "&Project" ) ); +#else + menuBar()->insertItem( tr( "&Project" ), project_menu ); +#endif + project_menu->addAction( embed::getIconPixmap( "project_new" ), + tr( "&New" ), + this, SLOT( createNewProject() ), + Qt::CTRL + Qt::Key_N ); + + project_menu->addAction( embed::getIconPixmap( "project_open" ), + tr( "&Open..." ), + this, SLOT( openProject() ), + Qt::CTRL + Qt::Key_O ); + + project_menu->addAction( embed::getIconPixmap( "project_save" ), + tr( "&Save" ), + this, SLOT( saveProject() ), + Qt::CTRL + Qt::Key_S ); + + project_menu->addAction( embed::getIconPixmap( "project_saveas" ), + tr( "Save &As..." ), + this, SLOT( saveProjectAs() ), + Qt::CTRL + Qt::SHIFT + Qt::Key_S ); +#ifdef QT4 + project_menu->addSeparator(); +#else + project_menu->insertSeparator(); +#endif + project_menu->addAction( /*embed::getIconPixmap( "project_import" ),*/ + tr( "Import file" ), + eng()->getSongEditor(), + SLOT( importProject() ) ); +#ifdef QT4 + project_menu->addSeparator(); +#else + project_menu->insertSeparator(); +#endif + project_menu->addAction( embed::getIconPixmap( "project_export" ), + tr( "E&xport" ), + eng()->getSongEditor(), + SLOT( exportProject() ), + Qt::CTRL + Qt::Key_E ); +#ifdef QT4 + project_menu->addSeparator(); +#else + project_menu->insertSeparator(); +#endif + project_menu->addAction( embed::getIconPixmap( "exit" ), tr( "&Quit" ), + qApp, SLOT( closeAllWindows() ), + Qt::CTRL+Qt::Key_Q ); + + + QMenu * settings_menu = new QMenu( this ); +#ifdef QT4 + menuBar()->addMenu( settings_menu )->setText( tr( "&Settings" ) ); +#else + menuBar()->insertItem( tr( "&Settings" ), settings_menu ); +#endif + settings_menu->addAction( embed::getIconPixmap( "setup_general" ), + tr( "Show settings dialog" ), + this, SLOT( showSettingsDialog() ) ); + settings_menu->addAction( embed::getIconPixmap( "wizard" ), + tr( "Show setup wizard" ), + configManager::inst(), SLOT( exec() ) ); + + + // help-popup-menu + QMenu * help_menu = new QMenu( this ); +#ifdef QT4 + menuBar()->addMenu( help_menu )->setText( tr( "&Help" ) ); +#else + menuBar()->insertItem( tr( "&Help" ), help_menu ); +#endif + help_menu->addAction( embed::getIconPixmap( "help" ), tr( "Help" ), + this, SLOT( help() ) ); + help_menu->addAction( embed::getIconPixmap( "whatsthis" ), + tr( "What's this?" ), + this, SLOT( enterWhatsThisMode() ) ); +#ifdef QT4 + help_menu->addSeparator(); +#else + help_menu->insertSeparator(); +#endif + help_menu->addAction( embed::getIconPixmap( "icon" ), tr( "About" ), + this, SLOT( aboutLMMS() ) ); + + // setup-dialog opened before? + if( !configManager::inst()->value( "app", "configured" ).toInt() ) + { + // no, so show it that user can setup everything + setupDialog( eng() ).exec(); + configManager::inst()->setValue( "app", "configured", "1" ); + } + // look whether mixer could use a audio-interface beside audioDummy + else if( eng()->getMixer()->audioDevName() == audioDummy::name() ) + { + // no, so we offer setup-dialog with audio-settings... + setupDialog sd( eng(), setupDialog::AUDIO_SETTINGS ); + sd.exec(); + } +} + + + + +int mainWindow::addWidgetToToolBar( QWidget * _w, int _row, int _col ) +{ + int col = ( _col == -1 ) ? m_toolBarLayout->columnCount() + 6 : _col; + if( _w->height() > 32 || _row == -1 ) + { +#ifdef QT4 + m_toolBarLayout->addWidget( _w, 0, col, 2, 1 ); +#else + m_toolBarLayout->addMultiCellWidget( _w, 0, 1, col, col ); +#endif + } + else + { + m_toolBarLayout->addWidget( _w, _row, col ); + } + return( col ); +} + + + + +void mainWindow::addSpacingToToolBar( int _size ) +{ + m_toolBarLayout->setColumnMinimumWidth( m_toolBarLayout->columnCount() + + 6, _size ); +} + + + + +void mainWindow::resetWindowTitle( const QString & _add ) +{ + QString title = _add; + if( _add == "" && eng()->getSongEditor()->projectFileName() != "" ) + { + title = QFileInfo( eng()->getSongEditor()->projectFileName() +#ifdef QT4 + ).completeBaseName(); +#else + ).baseName( TRUE ); +#endif + } + if( title != "" ) + { + title += " - "; + } + setWindowTitle( title + tr( "LMMS %1" ).arg( VERSION ) ); +} + + + + +void mainWindow::clearKeyModifiers( void ) +{ + m_keyMods.m_ctrl = FALSE; + m_keyMods.m_shift = FALSE; + m_keyMods.m_alt = FALSE; +} + + + + +void mainWindow::createNewProject( void ) +{ + if( eng()->getSongEditor()->mayChangeProject() == TRUE ) + { + eng()->getSongEditor()->createNewProject(); + } +} + + + + +void mainWindow::createNewProjectFromTemplate( int _idx ) +{ +#ifdef QT4 + // TODO!!! +#else + if( m_templatesMenu != NULL && + eng()->getSongEditor()->mayChangeProject() == TRUE ) + { + eng()->getSongEditor()->createNewProjectFromTemplate( + configManager::inst()->projectsDir() + "templates/" + + m_templatesMenu->text( _idx ) + ".mpt" ); + } +#endif +} + + + + +void mainWindow::openProject( void ) +{ + if( eng()->getSongEditor()->mayChangeProject() == TRUE ) + { +#ifdef QT4 + QFileDialog ofd( this, tr( "Open project" ), "", + tr( "MultiMedia Project (*.mmp *.xml)" ) ); +#else + QFileDialog ofd( QString::null, + tr( "MultiMedia Project (*.mmp *.xml)" ), + this, "", TRUE ); + ofd.setWindowTitle( tr( "Open project" ) ); +#endif + ofd.setDirectory( configManager::inst()->projectsDir() ); + ofd.setFileMode( QFileDialog::ExistingFiles ); + if( ofd.exec () == QDialog::Accepted && + !ofd.selectedFiles().isEmpty() ) + { + eng()->getSongEditor()->loadProject( + ofd.selectedFiles()[0] ); + } + } +} + + + + +bool mainWindow::saveProject( void ) +{ + if( eng()->getSongEditor()->projectFileName() == "" ) + { + return( saveProjectAs() ); + } + else + { + eng()->getSongEditor()->saveProject(); + } + return( TRUE ); +} + + + + +bool mainWindow::saveProjectAs( void ) +{ +#ifdef QT4 + QFileDialog sfd( this, tr( "Save project" ), "", + tr( "MultiMedia Project (*.mmp);;" + "MultiMedia Project Template (*.mpt)" ) ); +#else + QFileDialog sfd( QString::null, + tr( "MultiMedia Project (*.mmp);;" + "MultiMedia Project Template (*.mpt)" ), + this, "", TRUE ); + sfd.setWindowTitle( tr( "Save project" ) ); +#endif + sfd.setFileMode( QFileDialog::AnyFile ); + QString f = eng()->getSongEditor()->projectFileName(); + if( f != "" ) + { + sfd.selectFile( QFileInfo( f ).fileName() ); +#ifdef QT4 + sfd.setDirectory( QFileInfo( f ).absolutePath() ); +#else + sfd.setDirectory( QFileInfo( f ).dirPath( TRUE ) ); +#endif + } + else + { + sfd.setDirectory( configManager::inst()->projectsDir() ); + } + + if( sfd.exec () == QFileDialog::Accepted && +#ifdef QT4 + !sfd.selectedFiles().isEmpty() && sfd.selectedFiles()[0] != "" +#else + sfd.selectedFile() != "" +#endif + ) + { +#ifdef QT4 + eng()->getSongEditor()->saveProjectAs( sfd.selectedFiles()[0] ); +#else + eng()->getSongEditor()->saveProjectAs( sfd.selectedFile() ); +#endif + return( TRUE ); + } + return( FALSE ); +} + + + + +void mainWindow::showSettingsDialog( void ) +{ + setupDialog( eng() ).exec(); +} + + + + +void mainWindow::aboutLMMS( void ) +{ + aboutDialog().exec(); +} + + + + +void mainWindow::help( void ) +{ + QMessageBox::information( this, tr( "Help not available" ), + tr( "Currently there's no help " + "available in LMMS.\n" + "Please visit " + "http://wiki.mindrules.net " + "for documentation on LMMS." ), + QMessageBox::Ok ); +} + + + + +void mainWindow::toggleBBEditorWin( void ) +{ + if( eng()->getBBEditor()->isHidden() == TRUE || + ( m_workspace != NULL && + m_workspace->activeWindow() != eng()->getBBEditor() ) ) + { + eng()->getBBEditor()->show(); + eng()->getBBEditor()->setFocus(); + } + else + { + eng()->getBBEditor()->hide(); + } +} + + + + +void mainWindow::toggleSongEditorWin( void ) +{ + if( eng()->getSongEditor()->isHidden() == TRUE || + ( m_workspace != NULL && + m_workspace->activeWindow() != eng()->getSongEditor() ) ) + { + eng()->getSongEditor()->show(); + eng()->getSongEditor()->setFocus(); + } + else + { + eng()->getSongEditor()->hide(); + } +} + + + + +void mainWindow::toggleProjectNotesWin( void ) +{ + if( eng()->getProjectNotes()->isHidden() == TRUE || + ( m_workspace != NULL && m_workspace->activeWindow() != + eng()->getProjectNotes() ) ) + { + eng()->getProjectNotes()->show(); + eng()->getProjectNotes()->setFocus(); + } + else + { + eng()->getProjectNotes()->hide(); + } +} + + + + +void mainWindow::togglePianoRollWin( void ) +{ + if( eng()->getPianoRoll()->isHidden() == TRUE || + ( m_workspace != NULL && + m_workspace->activeWindow() != eng()->getPianoRoll() ) ) + { + eng()->getPianoRoll()->show(); + eng()->getPianoRoll()->setFocus(); + } + else + { + eng()->getPianoRoll()->hide(); + } +} + + + + +void mainWindow::closeEvent( QCloseEvent * _ce ) +{ + if( eng()->getSongEditor()->mayChangeProject() == TRUE ) + { + _ce->accept(); + } + else + { + _ce->ignore(); + } +} + + + + +void mainWindow::focusOutEvent( QFocusEvent * _fe ) +{ + // when loosing focus we do not receive key-(release!)-events anymore, + // so we might miss release-events of one the modifiers we're watching! + clearKeyModifiers(); + QMainWindow::leaveEvent( _fe ); +} + + + + +void mainWindow::keyPressEvent( QKeyEvent * _ke ) +{ + switch( _ke->key() ) + { + case Qt::Key_Control: m_keyMods.m_ctrl = TRUE; break; + case Qt::Key_Shift: m_keyMods.m_shift = TRUE; break; + case Qt::Key_Alt: m_keyMods.m_alt = TRUE; break; + default: + QMainWindow::keyPressEvent( _ke ); + } +} + + + + +void mainWindow::keyReleaseEvent( QKeyEvent * _ke ) +{ + switch( _ke->key() ) + { + case Qt::Key_Control: m_keyMods.m_ctrl = FALSE; break; + case Qt::Key_Shift: m_keyMods.m_shift = FALSE; break; + case Qt::Key_Alt: m_keyMods.m_alt = FALSE; break; + default: + QMainWindow::keyReleaseEvent( _ke ); + } +} + + + + +#include "main_window.moc" + diff --git a/src/core/midi_tab_widget.cpp b/src/core/midi_tab_widget.cpp index ff2e7aa39e..40af4f3f18 100644 --- a/src/core/midi_tab_widget.cpp +++ b/src/core/midi_tab_widget.cpp @@ -62,6 +62,7 @@ midiTabWidget::midiTabWidget( channelTrack * _channel_track, midiPort * _port ) : QWidget( _channel_track->tabWidgetParent() ), settings(), + engineObject( _channel_track->eng() ), m_channelTrack( _channel_track ), m_midiPort( _port ), m_readablePorts( NULL ), @@ -119,7 +120,7 @@ midiTabWidget::midiTabWidget( channelTrack * _channel_track, // when using with non-raw-clients we can provide buttons showing // our port-menus when being clicked - midiClient * mc = mixer::inst()->getMIDIClient(); + midiClient * mc = eng()->getMixer()->getMIDIClient(); if( mc->isRaw() == FALSE ) { m_readablePorts = new QMenu( m_setupTabWidget ); @@ -345,7 +346,7 @@ void midiTabWidget::loadSettings( const QDomElement & _this ) void midiTabWidget::inputChannelChanged( int _new_chnl ) { m_midiPort->setInputChannel( _new_chnl - 1 ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -354,7 +355,7 @@ void midiTabWidget::inputChannelChanged( int _new_chnl ) void midiTabWidget::outputChannelChanged( int _new_chnl ) { m_midiPort->setOutputChannel( _new_chnl - 1 ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -418,7 +419,7 @@ void midiTabWidget::midiPortModeToggled( bool ) } #endif } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -450,7 +451,7 @@ void midiTabWidget::readablePortsChanged( void ) #endif m_readablePorts->clear(); - const QStringList & rp = mixer::inst()->getMIDIClient()-> + const QStringList & rp = eng()->getMixer()->getMIDIClient()-> readablePorts(); // now insert new ports and restore selections for( QStringList::const_iterator it = rp.begin(); it != rp.end(); ++it ) @@ -501,7 +502,7 @@ void midiTabWidget::writeablePortsChanged( void ) #endif m_writeablePorts->clear(); - const QStringList & wp = mixer::inst()->getMIDIClient()-> + const QStringList & wp = eng()->getMixer()->getMIDIClient()-> writeablePorts(); // now insert new ports and restore selections for( QStringList::const_iterator it = wp.begin(); it != wp.end(); ++it ) @@ -536,7 +537,7 @@ void midiTabWidget::activatedReadablePort( QAction * _item ) m_receiveCheckBox->setChecked( TRUE ); } _item->setChecked( !_item->isChecked() ); - mixer::inst()->getMIDIClient()->subscribeReadablePort( m_midiPort, + eng()->getMixer()->getMIDIClient()->subscribeReadablePort( m_midiPort, _item->text(), !_item->isChecked() ); } @@ -553,7 +554,7 @@ void midiTabWidget::activatedWriteablePort( QAction * _item ) m_sendCheckBox->setChecked( TRUE ); } _item->setChecked( !_item->isChecked() ); - mixer::inst()->getMIDIClient()->subscribeWriteablePort( m_midiPort, + eng()->getMixer()->getMIDIClient()->subscribeWriteablePort( m_midiPort, _item->text(), !_item->isChecked() ); } @@ -575,7 +576,7 @@ void midiTabWidget::activatedReadablePort( int _id ) } m_readablePorts->setItemChecked( _id, !m_readablePorts->isItemChecked( _id ) ); - mixer::inst()->getMIDIClient()->subscribeReadablePort( + eng()->getMixer()->getMIDIClient()->subscribeReadablePort( m_midiPort, m_readablePorts->text( _id ), !m_readablePorts->isItemChecked( _id ) ); } @@ -594,7 +595,7 @@ void midiTabWidget::activatedWriteablePort( int _id ) } m_writeablePorts->setItemChecked( _id, !m_writeablePorts->isItemChecked( _id ) ); - mixer::inst()->getMIDIClient()->subscribeWriteablePort( + eng()->getMixer()->getMIDIClient()->subscribeWriteablePort( m_midiPort, m_writeablePorts->text( _id ), !m_writeablePorts->isItemChecked( _id ) ); } diff --git a/src/core/mixer.cpp b/src/core/mixer.cpp index 27198e60e7..52a3f5113b 100644 --- a/src/core/mixer.cpp +++ b/src/core/mixer.cpp @@ -57,11 +57,9 @@ sample_rate_t SAMPLE_RATES[QUALITY_LEVELS] = { 44100, 88200 } ; -mixer * mixer::s_instanceOfMe = NULL; - - -mixer::mixer() : +mixer::mixer( engine * _engine ) : QObject(), + engineObject( _engine ), m_framesPerAudioBuffer( DEFAULT_BUFFER_SIZE ), m_curBuf( NULL ), m_nextBuf( NULL ), @@ -73,9 +71,6 @@ mixer::mixer() : m_mixMutex(), m_mixMutexLockLevel( 0 ) { - // small hack because code calling mixer::inst() is called out of ctor - s_instanceOfMe = this; - if( configManager::inst()->value( "mixer", "framesperaudiobuffer" ).toInt() >= 32 ) { @@ -94,17 +89,10 @@ mixer::mixer() : m_nextBuf = bufferAllocator::alloc( m_framesPerAudioBuffer ); - - m_audioDev = tryAudioDevices(); - m_midiClient = tryMIDIClients(); - - // now clear our two output-buffers before using them... clearAudioBuffer( m_curBuf, m_framesPerAudioBuffer ); clearAudioBuffer( m_nextBuf, m_framesPerAudioBuffer ); - m_audioDev->startProcessing(); - } @@ -122,6 +110,23 @@ mixer::~mixer() +void mixer::initDevices( void ) +{ + m_audioDev = tryAudioDevices(); + m_midiClient = tryMIDIClients(); +} + + + + +void mixer::startProcessing( void ) +{ + m_audioDev->startProcessing(); +} + + + + void mixer::stopProcessing( void ) { m_audioDev->stopProcessing(); @@ -133,7 +138,7 @@ void mixer::stopProcessing( void ) bool mixer::criticalXRuns( void ) const { return( ( m_cpuLoad >= 98 && - songEditor::inst()->realTimeTask() == TRUE ) ); + eng()->getSongEditor()->realTimeTask() == TRUE ) ); } @@ -145,13 +150,14 @@ const surroundSampleFrame * mixer::renderNextBuffer( void ) static songEditor::playPos last_metro_pos = -1; - songEditor::playPos p = songEditor::inst()->getPlayPos( + songEditor::playPos p = eng()->getSongEditor()->getPlayPos( songEditor::PLAY_PATTERN ); - if( songEditor::inst()->playMode() == songEditor::PLAY_PATTERN && - pianoRoll::inst()->isRecording() == TRUE && + if( eng()->getSongEditor()->playMode() == songEditor::PLAY_PATTERN && + eng()->getPianoRoll()->isRecording() == TRUE && p != last_metro_pos && p.getTact64th() % 16 == 0 ) { - addPlayHandle( new samplePlayHandle( "misc/metronome01.ogg" ) ); + addPlayHandle( new samplePlayHandle( "misc/metronome01.ogg", + eng() ) ); last_metro_pos = p; } @@ -208,7 +214,7 @@ const surroundSampleFrame * mixer::renderNextBuffer( void ) } } - songEditor::inst()->processNextBuffer(); + eng()->getSongEditor()->processNextBuffer(); for( vvector::iterator it = m_audioPorts.begin(); it != m_audioPorts.end(); ++it ) @@ -229,7 +235,7 @@ const surroundSampleFrame * mixer::renderNextBuffer( void ) // and trigger LFOs - envelopeAndLFOWidget::triggerLFO(); + envelopeAndLFOWidget::triggerLFO( eng() ); const float new_cpu_load = timer.elapsed() / 10000.0f * sampleRate() / m_framesPerAudioBuffer; @@ -427,7 +433,7 @@ audioDevice * mixer::tryAudioDevices( void ) if( dev_name == audioALSA::name() || dev_name == "" ) { dev = new audioALSA( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL], - success_ful ); + success_ful, this ); if( success_ful ) { m_audioDevName = audioALSA::name(); @@ -442,7 +448,7 @@ audioDevice * mixer::tryAudioDevices( void ) if( dev_name == audioOSS::name() || dev_name == "" ) { dev = new audioOSS( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL], - success_ful ); + success_ful, this ); if( success_ful ) { m_audioDevName = audioOSS::name(); @@ -457,7 +463,7 @@ audioDevice * mixer::tryAudioDevices( void ) if( dev_name == audioJACK::name() || dev_name == "" ) { dev = new audioJACK( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL], - success_ful ); + success_ful, this ); if( success_ful ) { m_audioDevName = audioJACK::name(); @@ -472,7 +478,7 @@ audioDevice * mixer::tryAudioDevices( void ) if( dev_name == audioSDL::name() || dev_name == "" ) { dev = new audioSDL( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL], - success_ful ); + success_ful, this ); if( success_ful ) { m_audioDevName = audioSDL::name(); @@ -483,7 +489,7 @@ audioDevice * mixer::tryAudioDevices( void ) #endif // add more device-classes here... - //dev = new audioXXXX( SAMPLE_RATES[m_qualityLevel], success_ful ); + //dev = new audioXXXX( SAMPLE_RATES[m_qualityLevel], success_ful, this ); //if( sucess_ful ) //{ // return( dev ); @@ -496,7 +502,8 @@ audioDevice * mixer::tryAudioDevices( void ) m_audioDevName = audioDummy::name(); - return( new audioDummy( SAMPLE_RATES[m_qualityLevel], success_ful ) ); + return( new audioDummy( SAMPLE_RATES[m_qualityLevel], success_ful, + this ) ); } @@ -510,7 +517,7 @@ midiClient * mixer::tryMIDIClients( void ) #ifdef ALSA_SUPPORT if( client_name == midiALSASeq::name() || client_name == "" ) { - midiALSASeq * malsas = new midiALSASeq(); + midiALSASeq * malsas = new midiALSASeq( eng() ); if( malsas->isRunning() ) { m_midiClientName = midiALSASeq::name(); @@ -521,7 +528,7 @@ midiClient * mixer::tryMIDIClients( void ) if( client_name == midiALSARaw::name() || client_name == "" ) { - midiALSARaw * malsar = new midiALSARaw(); + midiALSARaw * malsar = new midiALSARaw( eng() ); if( malsar->isRunning() ) { m_midiClientName = midiALSARaw::name(); @@ -534,7 +541,7 @@ midiClient * mixer::tryMIDIClients( void ) #ifdef OSS_SUPPORT if( client_name == midiOSS::name() || client_name == "" ) { - midiOSS * moss = new midiOSS(); + midiOSS * moss = new midiOSS( eng() ); if( moss->isRunning() ) { m_midiClientName = midiOSS::name(); @@ -549,7 +556,7 @@ midiClient * mixer::tryMIDIClients( void ) m_midiClientName = midiDummy::name(); - return( new midiDummy() ); + return( new midiDummy( eng() ) ); } diff --git a/src/core/name_label.cpp b/src/core/name_label.cpp index 22dbcb9af5..766a01b1eb 100644 --- a/src/core/name_label.cpp +++ b/src/core/name_label.cpp @@ -50,8 +50,10 @@ -nameLabel::nameLabel( const QString & _initial_name, QWidget * _parent ) : +nameLabel::nameLabel( const QString & _initial_name, QWidget * _parent, + engine * _engine ) : QLabel( _initial_name, _parent ), + engineObject( _engine ), m_pixmap(), m_pixmapFile( "" ) { @@ -267,7 +269,8 @@ void nameLabel::paintEvent( QPaintEvent * ) } p.setPen( QColor( 0, 224, 0 ) ); - bbTrack * bbt = bbTrack::findBBTrack( bbEditor::inst()->currentBB() ); + bbTrack * bbt = bbTrack::findBBTrack( + eng()->getBBEditor()->currentBB(), eng() ); if( bbt != NULL && bbt->getTrackSettingsWidget() == dynamic_cast( parentWidget() ) ) { diff --git a/src/core/note.cpp b/src/core/note.cpp index 6abad57140..fdf0d3b975 100644 --- a/src/core/note.cpp +++ b/src/core/note.cpp @@ -1,7 +1,7 @@ /* * note.cpp - implementation of class note * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index 3432657532..c7ce4ff62c 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -24,8 +24,6 @@ */ -#include - #include "note_play_handle.h" #include "channel_track.h" #include "envelope_tab_widget.h" @@ -38,11 +36,11 @@ notePlayHandle::notePlayHandle( channelTrack * _chnl_trk, - const Uint32 _frames_ahead, - const Uint32 _frames, + const f_cnt_t _frames_ahead, + const f_cnt_t _frames, note * _n, const bool _arp_note ) : - playHandle( NOTE_PLAY_HANDLE ), + playHandle( NOTE_PLAY_HANDLE, _chnl_trk->eng() ), note( *_n ), m_pluginData( NULL ), m_filter( NULL ), @@ -72,8 +70,8 @@ notePlayHandle::notePlayHandle( channelTrack * _chnl_trk, (Uint16) ( ( getVolume() / 100.0f ) * ( m_channelTrack->getVolume() / 100.0f ) * 127 ), 0, 127 ) ), - midiTime::fromFrames( m_framesAhead, - songEditor::inst()->framesPerTact() ) ); + midiTime::fromFrames( m_framesAhead, + eng()->getSongEditor()->framesPerTact() ) ); } @@ -112,8 +110,8 @@ void notePlayHandle::play( void ) } if( m_released == FALSE && - m_totalFramesPlayed + mixer::inst()->framesPerAudioBuffer() >= - m_frames ) + m_totalFramesPlayed + + eng()->getMixer()->framesPerAudioBuffer() >= m_frames ) { noteOff( m_frames - m_totalFramesPlayed ); } @@ -123,7 +121,7 @@ void notePlayHandle::play( void ) if( m_released == TRUE ) { - Uint32 todo = mixer::inst()->framesPerAudioBuffer(); + f_cnt_t todo = eng()->getMixer()->framesPerAudioBuffer(); // if this note is base-note for arpeggio, always set // m_releaseFramesToDo to bigger value than m_releaseFramesDone // because we do not allow notePlayHandle::done() to be true @@ -132,7 +130,7 @@ void notePlayHandle::play( void ) if( arpBaseNote() == TRUE ) { m_releaseFramesToDo = m_releaseFramesDone + 2 * - mixer::inst()->framesPerAudioBuffer(); + eng()->getMixer()->framesPerAudioBuffer(); } // look whether we have frames left to be done before release if( m_framesBeforeRelease ) @@ -140,7 +138,7 @@ void notePlayHandle::play( void ) // yes, then look whether these samples can be played // within one audio-buffer if( m_framesBeforeRelease <= - mixer::inst()->framesPerAudioBuffer() ) + eng()->getMixer()->framesPerAudioBuffer() ) { // yes, then we did less releaseFramesDone todo -= m_framesBeforeRelease; @@ -153,7 +151,7 @@ void notePlayHandle::play( void ) // release-phase yet) todo = 0; m_framesBeforeRelease -= - mixer::inst()->framesPerAudioBuffer(); + eng()->getMixer()->framesPerAudioBuffer(); } } // look whether we're in release-phase @@ -201,7 +199,7 @@ void notePlayHandle::play( void ) } // update internal data - m_totalFramesPlayed += mixer::inst()->framesPerAudioBuffer(); + m_totalFramesPlayed += eng()->getMixer()->framesPerAudioBuffer(); } @@ -233,7 +231,7 @@ void notePlayHandle::checkValidity( void ) -void notePlayHandle::noteOff( Uint32 _s ) +void notePlayHandle::noteOff( const f_cnt_t _s ) { // first note-off all sub-notes for( notePlayHandleVector::iterator it = m_subNotes.begin(); @@ -260,7 +258,7 @@ void notePlayHandle::noteOff( Uint32 _s ) key(), 0 ), midiTime::fromFrames( m_framesBeforeRelease, - songEditor::inst()->framesPerTact() ) ); + eng()->getSongEditor()->framesPerTact() ) ); } else { @@ -273,7 +271,7 @@ void notePlayHandle::noteOff( Uint32 _s ) -Uint32 notePlayHandle::actualReleaseFramesToDo( void ) const +f_cnt_t notePlayHandle::actualReleaseFramesToDo( void ) const { return( ( m_channelTrack != NULL ) ? m_channelTrack->m_envWidget->releaseFrames() : 0 ); @@ -282,7 +280,7 @@ Uint32 notePlayHandle::actualReleaseFramesToDo( void ) const -void notePlayHandle::setFrames( Uint32 _frames ) +void notePlayHandle::setFrames( const f_cnt_t _frames ) { m_frames = _frames; if( m_frames == 0 && m_channelTrack != NULL ) @@ -294,7 +292,7 @@ void notePlayHandle::setFrames( Uint32 _frames ) -float notePlayHandle::volumeLevel( Uint32 _frame ) +float notePlayHandle::volumeLevel( const f_cnt_t _frame ) { return( ( m_channelTrack != NULL ) ? m_channelTrack->m_envWidget->volumeLevel( this, _frame ) : 0 ); @@ -319,7 +317,7 @@ void notePlayHandle::mute( void ) int notePlayHandle::index( void ) const { - const playHandleVector & phv = mixer::inst()->playHandles(); + const playHandleVector & phv = eng()->getMixer()->playHandles(); int idx = 0; for( constPlayHandleVector::const_iterator it = phv.begin(); it != phv.end(); ++it ) @@ -346,7 +344,7 @@ int notePlayHandle::index( void ) const constNotePlayHandleVector notePlayHandle::nphsOfChannelTrack( const channelTrack * _ct ) { - const playHandleVector & phv = mixer::inst()->playHandles(); + const playHandleVector & phv = _ct->eng()->getMixer()->playHandles(); constNotePlayHandleVector cnphv; for( constPlayHandleVector::const_iterator it = phv.begin(); diff --git a/src/core/piano_roll.cpp b/src/core/piano_roll.cpp index 4155938e35..22b7331d40 100644 --- a/src/core/piano_roll.cpp +++ b/src/core/piano_roll.cpp @@ -56,7 +56,7 @@ #include "piano_roll.h" #include "song_editor.h" -#include "lmms_main_win.h" +#include "main_window.h" #include "pattern.h" #include "embed.h" #include "pixmap_button.h" @@ -103,9 +103,6 @@ const int NE_LINE_WIDTH = 3; const int INITIAL_START_KEY = C + OCTAVE_3 * NOTES_PER_OCTAVE; -// init static members of pianoRoll -pianoRoll * pianoRoll::s_instanceOfMe = NULL; - QPixmap * pianoRoll::s_whiteKeySmallPm = NULL; QPixmap * pianoRoll::s_whiteKeyBigPm = NULL; QPixmap * pianoRoll::s_blackKeyPm = NULL; @@ -126,8 +123,9 @@ pianoRoll::pianoRollKeyTypes pianoRoll::prKeyOrder[] = const int DEFAULT_PR_PPT = KEY_LINE_HEIGHT * DEFAULT_STEPS_PER_TACT; -pianoRoll::pianoRoll( void ) : - QWidget( lmmsMainWin::inst()->workspace() ), +pianoRoll::pianoRoll( engine * _engine ) : + QWidget( _engine->getMainWindow()->workspace() ), + engineObject( _engine ), m_paintPixmap(), m_cursorInside( FALSE ), m_pattern( NULL ), @@ -185,14 +183,15 @@ pianoRoll::pianoRoll( void ) : #ifdef QT4 // add us to workspace - lmmsMainWin::inst()->workspace()->addWindow( this ); + eng()->getMainWindow()->workspace()->addWindow( this ); #endif // add time-line m_timeLine = new timeLine( WHITE_KEY_WIDTH, 32, m_ppt, - songEditor::inst()->getPlayPos( + eng()->getSongEditor()->getPlayPos( songEditor::PLAY_PATTERN ), - m_currentPosition, this ); + m_currentPosition, this, + eng() ); connect( this, SIGNAL( positionChanged( const midiTime & ) ), m_timeLine, SLOT( updatePosition( const midiTime & ) ) ); connect( m_timeLine, SIGNAL( positionChanged( const midiTime & ) ), @@ -459,12 +458,7 @@ void pianoRoll::setCurrentPattern( pattern * _new_pattern ) if( validPattern() == FALSE ) { - // we must not call resizeEvent with NULL-pointer when - // being called of of ctor - if( s_instanceOfMe == this ) - { - resizeEvent( NULL ); - } + //resizeEvent( NULL ); setWindowTitle( tr( "Piano-Roll - no pattern" ) ); update(); @@ -1050,7 +1044,7 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke ) break; case Qt::Key_Space: - if( songEditor::inst()->playing() ) + if( eng()->getSongEditor()->playing() ) { stop(); } @@ -1236,7 +1230,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) QApplication::setOverrideCursor( c ); } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } else if( ( _me->button() == Qt::RightButton && m_editMode == DRAW ) || @@ -1256,7 +1250,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) ( *it )->setLength( 0 ); m_pattern->update(); } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } } else if( _me->button() == Qt::LeftButton && @@ -1295,7 +1289,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) m_action = MOVE_SELECTION; play_note = FALSE; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } else if( _me->button() == Qt::RightButton && m_editMode == MOVE ) @@ -1311,7 +1305,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me ) // was there an action where should be played the note? if( play_note == TRUE && m_recording == FALSE && - songEditor::inst()->playing() == FALSE ) + eng()->getSongEditor()->playing() == FALSE ) { m_pattern->getChannelTrack()->processInEvent( midiEvent( NOTE_ON, 0, key_num, @@ -1403,7 +1397,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) m_action != SELECT_NOTES && m_action != MOVE_SELECTION && m_recording == FALSE && - songEditor::inst()->playing() == FALSE ) + eng()->getSongEditor()->playing() == FALSE ) { m_pattern->getChannelTrack()->processInEvent( midiEvent( NOTE_ON, 0, key_num, @@ -1483,7 +1477,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me ) m_pattern->update(); } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } else if( @@ -1907,7 +1901,6 @@ void pianoRoll::paintEvent( QPaintEvent * ) // responsible for moving/resizing scrollbars after window-resizing void pianoRoll::resizeEvent( QResizeEvent * ) { - m_leftRightScroll->setGeometry( WHITE_KEY_WIDTH, height() - SCROLLBAR_SIZE, width()-WHITE_KEY_WIDTH, @@ -1936,9 +1929,10 @@ void pianoRoll::resizeEvent( QResizeEvent * ) } m_topBottomScroll->setValue( m_totalKeysToScroll - m_startKey ); - songEditor::inst()->getPlayPos( songEditor::PLAY_PATTERN + eng()->getSongEditor()->getPlayPos( songEditor::PLAY_PATTERN ).m_timeLine->setFixedWidth( width() ); m_toolBar->setFixedWidth( width() ); + update(); } @@ -1947,7 +1941,7 @@ void pianoRoll::resizeEvent( QResizeEvent * ) void pianoRoll::wheelEvent( QWheelEvent * _we ) { _we->accept(); - if( lmmsMainWin::isCtrlPressed() == TRUE ) + if( eng()->getMainWindow()->isCtrlPressed() == TRUE ) { if( _we->delta() > 0 ) { @@ -1967,7 +1961,7 @@ void pianoRoll::wheelEvent( QWheelEvent * _we ) m_timeLine->setPixelsPerTact( m_ppt ); update(); } - else if( lmmsMainWin::isShiftPressed() ) + else if( eng()->getMainWindow()->isShiftPressed() ) { m_leftRightScroll->setValue( m_leftRightScroll->value() - _we->delta() * 2 / 15 ); @@ -2013,30 +2007,31 @@ void pianoRoll::play( void ) return; } - if( songEditor::inst()->playing() ) + if( eng()->getSongEditor()->playing() ) { - if( songEditor::inst()->playMode() != songEditor::PLAY_PATTERN ) + if( eng()->getSongEditor()->playMode() != + songEditor::PLAY_PATTERN ) { - songEditor::inst()->stop(); - songEditor::inst()->playPattern( m_pattern ); + eng()->getSongEditor()->stop(); + eng()->getSongEditor()->playPattern( m_pattern ); m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); } else { - songEditor::inst()->pause(); + eng()->getSongEditor()->pause(); m_playButton->setIcon( embed::getIconPixmap( "play" ) ); } } - else if( songEditor::inst()->paused() ) + else if( eng()->getSongEditor()->paused() ) { - songEditor::inst()->resumeFromPause(); + eng()->getSongEditor()->resumeFromPause(); m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); } else { m_playButton->setIcon( embed::getIconPixmap( "pause" ) ); - songEditor::inst()->playPattern( m_pattern ); + eng()->getSongEditor()->playPattern( m_pattern ); } } @@ -2045,7 +2040,7 @@ void pianoRoll::play( void ) void pianoRoll::record( void ) { - if( songEditor::inst()->playing() ) + if( eng()->getSongEditor()->playing() ) { stop(); } @@ -2055,7 +2050,7 @@ void pianoRoll::record( void ) } m_recording = TRUE; - songEditor::inst()->playPattern( m_pattern, FALSE ); + eng()->getSongEditor()->playPattern( m_pattern, FALSE ); } @@ -2063,7 +2058,7 @@ void pianoRoll::record( void ) void pianoRoll::stop( void ) { - songEditor::inst()->stop(); + eng()->getSongEditor()->stop(); m_playButton->setIcon( embed::getIconPixmap( "play" ) ); m_playButton->update(); m_recording = FALSE; @@ -2078,7 +2073,7 @@ void pianoRoll::recordNote( const note & _n ) if( m_recording == TRUE && validPattern() == TRUE ) { note n( _n ); - n.setPos( songEditor::inst()->getPlayPos( + n.setPos( eng()->getSongEditor()->getPlayPos( songEditor::PLAY_PATTERN ) - n.length() ); #ifndef QT4 qApp->lock(); @@ -2088,7 +2083,7 @@ void pianoRoll::recordNote( const note & _n ) #ifndef QT4 qApp->unlock(); #endif - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } } @@ -2315,7 +2310,7 @@ void pianoRoll::cutSelectedNotes( void ) if( selected_notes.empty() == FALSE ) { - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); midiTime start_pos( selected_notes.front()->pos().getTact(), 0 ); @@ -2334,7 +2329,7 @@ void pianoRoll::cutSelectedNotes( void ) } update(); - songEditor::inst()->update(); + eng()->getSongEditor()->update(); } @@ -2359,9 +2354,9 @@ void pianoRoll::pasteNotes( void ) // we only have to do the following lines if we pasted at // least one note... - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); update(); - songEditor::inst()->update (); + eng()->getSongEditor()->update(); } } @@ -2386,11 +2381,11 @@ void pianoRoll::deleteSelectedNotes( void ) selected_notes.erase( selected_notes.begin() ); } - if( update_after_delete ) + if( update_after_delete == TRUE ) { - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); update(); - songEditor::inst()->update(); + eng()->getSongEditor()->update(); } } @@ -2399,8 +2394,9 @@ void pianoRoll::deleteSelectedNotes( void ) void pianoRoll::updatePosition( const midiTime & _t ) { - if( ( songEditor::inst()->playing() && - songEditor::inst()->playMode() == songEditor::PLAY_PATTERN ) || + if( ( eng()->getSongEditor()->playing() && + eng()->getSongEditor()->playMode() == + songEditor::PLAY_PATTERN ) || m_scrollBack == TRUE ) { const int w = width() - WHITE_KEY_WIDTH; diff --git a/src/core/plugin.cpp b/src/core/plugin.cpp index 21f34390da..12a08c571d 100644 --- a/src/core/plugin.cpp +++ b/src/core/plugin.cpp @@ -61,8 +61,9 @@ static plugin::descriptor dummy_plugin_descriptor = -plugin::plugin( const descriptor * _descriptor ) : +plugin::plugin( const descriptor * _descriptor, engine * _engine ) : settings(), + engineObject( _engine ), m_descriptor( _descriptor ) { if( m_descriptor == NULL ) diff --git a/src/core/plugin_browser.cpp b/src/core/plugin_browser.cpp index dc3e677346..ca8dc2f0ea 100644 --- a/src/core/plugin_browser.cpp +++ b/src/core/plugin_browser.cpp @@ -1,7 +1,7 @@ /* * plugin_browser.cpp - implementation of the plugin-browser * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -49,9 +49,10 @@ -pluginBrowser::pluginBrowser( QWidget * _parent ) : +pluginBrowser::pluginBrowser( QWidget * _parent, engine * _engine ) : sideBarWidget( tr( "Instrument plugins" ), - embed::getIconPixmap( "plugins" ), _parent ) + embed::getIconPixmap( "plugins" ), _parent ), + engineObject( _engine ) { setWindowTitle( tr( "Plugin browser" ) ); m_view = new QWidget( contentParent() ); @@ -84,7 +85,8 @@ pluginBrowser::pluginBrowser( QWidget * _parent ) : m_pluginDescriptors.begin(); it != m_pluginDescriptors.end(); ++it ) { - pluginDescWidget * p = new pluginDescWidget( *it, m_view ); + pluginDescWidget * p = new pluginDescWidget( *it, m_view, + eng() ); p->show(); view_layout->addWidget( p ); } @@ -106,8 +108,9 @@ pluginBrowser::~pluginBrowser() pluginDescWidget::pluginDescWidget( const plugin::descriptor & _pd, - QWidget * _parent ) : + QWidget * _parent, engine * _engine ) : QWidget( _parent ), + engineObject( _engine ), m_pluginDescriptor( _pd ), m_logo(), m_mouseOver( FALSE ) @@ -234,7 +237,7 @@ void pluginDescWidget::mousePressEvent( QMouseEvent * _me ) if( _me->button() == Qt::LeftButton ) { new stringPairDrag( "instrument", m_pluginDescriptor.name, - m_logo, this ); + m_logo, this, eng() ); m_mouseOver = FALSE; update(); } diff --git a/src/core/preset_preview_play_handle.cpp b/src/core/preset_preview_play_handle.cpp index dde5405798..650dfce69f 100644 --- a/src/core/preset_preview_play_handle.cpp +++ b/src/core/preset_preview_play_handle.cpp @@ -48,19 +48,26 @@ -// invisible track-container which is needed as parents for preview-channels -class blindTrackContainer : public trackContainer +// invisible track-container which is needed as parent for preview-channels +class previewTrackContainer : public trackContainer { public: - static inline blindTrackContainer * inst( void ) + previewTrackContainer( engine * _engine ) : + trackContainer( _engine ), + m_previewChannelTrack( dynamic_cast( + track::create( track::CHANNEL_TRACK, + this ) )), + m_previewNote( NULL ), + m_dataMutex() { - if( s_instanceOfMe == NULL ) - { - s_instanceOfMe = new blindTrackContainer(); - } - return( s_instanceOfMe ); + hide(); } + virtual ~previewTrackContainer() + { + } + + // implement pure-virtual functions... virtual inline bool fixedTCOs( void ) const { @@ -69,83 +76,87 @@ public: virtual inline QString nodeName( void ) const { - return( "blindtc" ); + return( "previewtc" ); + } + + channelTrack * previewChannelTrack( void ) + { + return( m_previewChannelTrack ); + } + + notePlayHandle * previewNote( void ) + { + return( m_previewNote ); + } + + void setPreviewNote( notePlayHandle * _note ) + { + m_previewNote = _note; + } + + void lockData( void ) + { + m_dataMutex.lock(); + } + + void unlockData( void ) + { + m_dataMutex.unlock(); } private: - blindTrackContainer( void ) : - trackContainer() - { - hide(); - } - - virtual ~blindTrackContainer() - { - } - - - static blindTrackContainer * s_instanceOfMe; - - friend void presetPreviewPlayHandle::cleanUp( void ); + channelTrack * m_previewChannelTrack; + notePlayHandle * m_previewNote; + QMutex m_dataMutex; } ; +QMap + presetPreviewPlayHandle::s_previewTCs; -blindTrackContainer * blindTrackContainer::s_instanceOfMe = NULL; - -channelTrack * presetPreviewPlayHandle::s_globalChannelTrack = NULL; -notePlayHandle * presetPreviewPlayHandle::s_globalPreviewNote = NULL; -QMutex presetPreviewPlayHandle::s_globalDataMutex; presetPreviewPlayHandle::presetPreviewPlayHandle( - const QString & _preset_file ) : - playHandle( PRESET_PREVIEW_PLAY_HANDLE ), + const QString & _preset_file, + engine * _engine ) : + playHandle( PRESET_PREVIEW_PLAY_HANDLE, _engine ), m_previewNote( NULL ) { -/* if( s_globalDataMutex == NULL ) + if( s_previewTCs.contains( _engine ) == FALSE ) { - s_globalDataMutex = new QMutex; + s_previewTCs[_engine] = new previewTrackContainer( eng() ); } - s_globalDataMutex->lock();*/ - s_globalDataMutex.lock(); + previewTC()->lockData(); - if( s_globalPreviewNote != NULL ) + if( previewTC()->previewNote() != NULL ) { - s_globalPreviewNote->mute(); + previewTC()->previewNote()->mute(); } multimediaProject mmp( _preset_file ); - if( s_globalChannelTrack == NULL ) - { - track * t = track::create( track::CHANNEL_TRACK, - blindTrackContainer::inst() ); - s_globalChannelTrack = dynamic_cast( t ); -#ifdef LMMS_DEBUG - assert( s_globalChannelTrack != NULL ); -#endif - } - s_globalChannelTrack->loadTrackSpecificSettings( mmp.content(). - firstChild(). - toElement() ); + previewTC()->previewChannelTrack()->loadTrackSpecificSettings( + mmp.content().firstChild().toElement() ); + // make sure, our preset-preview-track does not appear in any MIDI- // devices list, so just disable receiving/sending MIDI-events at all - s_globalChannelTrack->m_midiPort->setMode( midiPort::DUMMY ); + previewTC()->previewChannelTrack()->m_midiPort->setMode( + midiPort::DUMMY ); // create temporary note note n( 0, 0, static_cast( A ), static_cast( DEFAULT_OCTAVE-1 ), 100 ); // create note-play-handle for it - m_previewNote = new notePlayHandle( s_globalChannelTrack, 0, ~0, &n ); + m_previewNote = new notePlayHandle( previewTC()->previewChannelTrack(), + 0, ~0, &n ); - s_globalPreviewNote = m_previewNote; + previewTC()->setPreviewNote( m_previewNote ); - s_globalDataMutex.unlock(); + previewTC()->unlockData(); } @@ -153,13 +164,15 @@ presetPreviewPlayHandle::presetPreviewPlayHandle( presetPreviewPlayHandle::~presetPreviewPlayHandle() { - s_globalDataMutex.lock(); + previewTC()->lockData(); + // not muted by other preset-preview-handle? if( m_previewNote->muted() == FALSE ) { - s_globalPreviewNote = NULL; + // then set according state + previewTC()->setPreviewNote( NULL ); } delete m_previewNote; - s_globalDataMutex.unlock(); + previewTC()->unlockData(); } @@ -181,9 +194,13 @@ bool presetPreviewPlayHandle::done( void ) const -void presetPreviewPlayHandle::cleanUp( void ) +void presetPreviewPlayHandle::cleanUp( engine * _engine ) { - delete blindTrackContainer::inst(); + if( s_previewTCs.contains( _engine ) == TRUE ) + { + delete s_previewTCs[_engine]; + s_previewTCs.remove( _engine ); + } } @@ -193,13 +210,17 @@ constNotePlayHandleVector presetPreviewPlayHandle::nphsOfChannelTrack( const channelTrack * _ct ) { constNotePlayHandleVector cnphv; - s_globalDataMutex.lock(); - if( s_globalPreviewNote != NULL && - s_globalPreviewNote->getChannelTrack() == _ct ) + if( s_previewTCs.contains( _ct->eng() ) == TRUE ) { - cnphv.push_back( s_globalPreviewNote ); + previewTrackContainer * tc = s_previewTCs[_ct->eng()]; + tc->lockData(); + if( tc->previewNote() != NULL && + tc->previewNote()->getChannelTrack() == _ct ) + { + cnphv.push_back( tc->previewNote() ); + } + tc->unlockData(); } - s_globalDataMutex.unlock(); return( cnphv ); } diff --git a/src/core/sample_play_handle.cpp b/src/core/sample_play_handle.cpp index 34be21d06e..96f64ec0f0 100644 --- a/src/core/sample_play_handle.cpp +++ b/src/core/sample_play_handle.cpp @@ -1,7 +1,7 @@ /* * sample_play_handle.cpp - implementation of class samplePlayHandle * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -23,11 +23,6 @@ */ -#include "qt3support.h" -#ifndef QT4 -#include -#endif - #include "sample_play_handle.h" #include "sample_buffer.h" #include "buffer_allocator.h" @@ -35,13 +30,14 @@ -samplePlayHandle::samplePlayHandle( const QString & _sample_file ) : - playHandle( SAMPLE_PLAY_HANDLE ), - m_sampleBuffer( new sampleBuffer( _sample_file ) ), +samplePlayHandle::samplePlayHandle( const QString & _sample_file, + engine * _engine ) : + playHandle( SAMPLE_PLAY_HANDLE, _engine ), + m_sampleBuffer( new sampleBuffer( eng(), _sample_file ) ), m_ownSampleBuffer( TRUE ), m_doneMayReturnTrue( TRUE ), m_frame( 0 ), - m_audioPort( new audioPort( "samplePlayHandle" ) ) + m_audioPort( new audioPort( "samplePlayHandle", eng() ) ) { } @@ -49,17 +45,18 @@ samplePlayHandle::samplePlayHandle( const QString & _sample_file ) : samplePlayHandle::samplePlayHandle( sampleBuffer * _sample_buffer ) : - playHandle( SAMPLE_PLAY_HANDLE ), + playHandle( SAMPLE_PLAY_HANDLE, _sample_buffer->eng() ), m_sampleBuffer( _sample_buffer ), m_ownSampleBuffer( FALSE ), m_doneMayReturnTrue( TRUE ), m_frame( 0 ), - m_audioPort( new audioPort( "samplePlayHandle" ) ) + m_audioPort( new audioPort( "samplePlayHandle", eng() ) ) { } + samplePlayHandle::~samplePlayHandle() { if( m_ownSampleBuffer == TRUE ) @@ -79,21 +76,19 @@ void samplePlayHandle::play( void ) return; } - sampleFrame * buf = bufferAllocator::alloc( - mixer::inst()->framesPerAudioBuffer() * - DEFAULT_CHANNELS ); + const fpab_t frames = eng()->getMixer()->framesPerAudioBuffer(); + sampleFrame * buf = bufferAllocator::alloc( frames ); volumeVector v = { 1.0f, 1.0f #ifndef DISABLE_SURROUND , 1.0f, 1.0f #endif } ; - m_sampleBuffer->play( buf, m_frame ); - mixer::inst()->bufferToPort( buf, mixer::inst()->framesPerAudioBuffer(), - 0, v, m_audioPort ); + m_sampleBuffer->play( buf, m_frame, frames ); + eng()->getMixer()->bufferToPort( buf, frames, 0, v, m_audioPort ); bufferAllocator::free( buf ); - m_frame += mixer::inst()->framesPerAudioBuffer(); + m_frame += frames; } @@ -107,7 +102,7 @@ bool samplePlayHandle::done( void ) const -Uint32 samplePlayHandle::totalFrames( void ) const +f_cnt_t samplePlayHandle::totalFrames( void ) const { return( m_sampleBuffer->endFrame() - m_sampleBuffer->startFrame() ); } diff --git a/src/core/setup_dialog.cpp b/src/core/setup_dialog.cpp index 98bc2c6aa3..81d8999554 100644 --- a/src/core/setup_dialog.cpp +++ b/src/core/setup_dialog.cpp @@ -96,9 +96,10 @@ inline void labelWidget( QWidget * _w, const QString & _txt ) -setupDialog::setupDialog( configTabs _tab_to_open ) : +setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) : QDialog(), - m_bufferSize( mixer::inst()->framesPerAudioBuffer() ), + engineObject( _engine ), + m_bufferSize( eng()->getMixer()->framesPerAudioBuffer() ), m_disableToolTips( configManager::inst()->value( "tooltips", "disabled" ).toInt() ), m_classicalKnobUsability( configManager::inst()->value( "knobs", @@ -401,11 +402,11 @@ setupDialog::setupDialog( configTabs _tab_to_open ) : } #ifdef QT4 m_audioInterfaces->setCurrentIndex( m_audioInterfaces->findText( - mixer::inst()->audioDevName() ) ); + eng()->getMixer()->audioDevName() ) ); #else - m_audioInterfaces->setCurrentText( mixer::inst()->audioDevName() ); + m_audioInterfaces->setCurrentText( eng()->getMixer()->audioDevName() ); #endif - m_audioIfaceSetupWidgets[mixer::inst()->audioDevName()]->show(); + m_audioIfaceSetupWidgets[eng()->getMixer()->audioDevName()]->show(); connect( m_audioInterfaces, SIGNAL( activated( const QString & ) ), this, SLOT( audioInterfaceChanged( const QString & ) ) ); @@ -482,11 +483,11 @@ setupDialog::setupDialog( configTabs _tab_to_open ) : #ifdef QT4 m_midiInterfaces->setCurrentIndex( m_midiInterfaces->findText( - mixer::inst()->midiClientName() ) ); + eng()->getMixer()->midiClientName() ) ); #else - m_midiInterfaces->setCurrentText( mixer::inst()->midiClientName() ); + m_midiInterfaces->setCurrentText( eng()->getMixer()->midiClientName() ); #endif - m_midiIfaceSetupWidgets[mixer::inst()->midiClientName()]->show(); + m_midiIfaceSetupWidgets[eng()->getMixer()->midiClientName()]->show(); connect( m_midiInterfaces, SIGNAL( activated( const QString & ) ), this, SLOT( midiInterfaceChanged( const QString & ) ) ); @@ -642,7 +643,7 @@ void setupDialog::setBufferSize( int _value ) m_bufSizeLbl->setText( tr( "Frames: %1\nLatency: %2 ms" ).arg( m_bufferSize ).arg( 1000.0f * m_bufferSize / - mixer::inst()->sampleRate(), + eng()->getMixer()->sampleRate(), 0, 'f', 1 ) ); } diff --git a/src/core/song_editor.cpp b/src/core/song_editor.cpp index 2adf23441f..9acb663341 100644 --- a/src/core/song_editor.cpp +++ b/src/core/song_editor.cpp @@ -89,20 +89,15 @@ #include "cpuload_widget.h" #include "text_float.h" #include "combobox.h" +#include "main_window.h" #include "debug.h" -extern QString file_to_load; - - -songEditor * songEditor::s_instanceOfMe = NULL; - - -songEditor::songEditor() : - trackContainer(), +songEditor::songEditor( engine * _engine ) : + trackContainer( _engine ), m_fileName( "" ), m_oldFileName( "" ), m_exporting( FALSE ), @@ -115,14 +110,9 @@ songEditor::songEditor() : m_loopPattern( FALSE ), m_scrollBack( FALSE ) { - // hack, because code called out of this function uses - // songEditor::inst(), which assigns s_instanceOfMe this function - // returns... - s_instanceOfMe = this; - setWindowTitle( tr( "Song-Editor" ) ); setWindowIcon( embed::getIconPixmap( "songeditor" ) ); - if( lmmsMainWin::inst()->workspace() != NULL ) + if( eng()->getMainWindow()->workspace() != NULL ) { setGeometry( 10, 10, 680, 300 ); } @@ -146,7 +136,7 @@ songEditor::songEditor() : timeLine * tl = new timeLine( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH, 32, pixelsPerTact(), m_playPos[PLAY_SONG], - m_currentPosition, cw ); + m_currentPosition, cw, eng() ); connect( this, SIGNAL( positionChanged( const midiTime & ) ), m_playPos[PLAY_SONG].m_timeLine, SLOT( updatePosition( const midiTime & ) ) ); @@ -155,14 +145,14 @@ songEditor::songEditor() : // add some essential widgets to global tool-bar - QWidget * tb = lmmsMainWin::inst()->toolBar(); + QWidget * tb = eng()->getMainWindow()->toolBar(); - lmmsMainWin::inst()->addSpacingToToolBar( 10 ); + eng()->getMainWindow()->addSpacingToToolBar( 10 ); m_bpmSpinBox = new lcdSpinBox( MIN_BPM, MAX_BPM, 3, tb ); m_bpmSpinBox->setLabel( tr( "TEMPO/BPM" ) ); connect( m_bpmSpinBox, SIGNAL( valueChanged( int ) ), this, - SLOT( setBPM( int ) ) ); + SLOT( setTempo( int ) ) ); toolTip::add( m_bpmSpinBox, tr( "tempo of song" ) ); #ifdef QT4 @@ -177,20 +167,20 @@ songEditor::songEditor() : "should be played within a minute (or how many tacts " "should be played within four minutes)." ) ); - int col = lmmsMainWin::inst()->addWidgetToToolBar( m_bpmSpinBox, 0 ); + int col = eng()->getMainWindow()->addWidgetToToolBar( m_bpmSpinBox, 0 ); toolButton * hq_btn = new toolButton( embed::getIconPixmap( "hq_mode" ), tr( "High quality mode" ), NULL, NULL, tb ); hq_btn->setCheckable( TRUE ); - connect( hq_btn, SIGNAL( toggled( bool ) ), mixer::inst(), + connect( hq_btn, SIGNAL( toggled( bool ) ), eng()->getMixer(), SLOT( setHighQuality( bool ) ) ); hq_btn->setFixedWidth( 42 ); - lmmsMainWin::inst()->addWidgetToToolBar( hq_btn, 1, col ); + eng()->getMainWindow()->addWidgetToToolBar( hq_btn, 1, col ); - lmmsMainWin::inst()->addSpacingToToolBar( 10 ); + eng()->getMainWindow()->addSpacingToToolBar( 10 ); @@ -224,11 +214,11 @@ songEditor::songEditor() : m_mvsStatus->setTitle( tr( "Master volume" ) ); m_mvsStatus->setPixmap( embed::getIconPixmap( "master_volume" ) ); - lmmsMainWin::inst()->addWidgetToToolBar( master_vol_lbl ); - lmmsMainWin::inst()->addWidgetToToolBar( m_masterVolumeSlider ); + eng()->getMainWindow()->addWidgetToToolBar( master_vol_lbl ); + eng()->getMainWindow()->addWidgetToToolBar( m_masterVolumeSlider ); - lmmsMainWin::inst()->addSpacingToToolBar( 10 ); + eng()->getMainWindow()->addSpacingToToolBar( 10 ); QLabel * master_pitch_lbl = new QLabel( tb ); master_pitch_lbl->setPixmap( embed::getIconPixmap( "master_pitch" ) ); @@ -259,10 +249,10 @@ songEditor::songEditor() : m_mpsStatus->setTitle( tr( "Master pitch" ) ); m_mpsStatus->setPixmap( embed::getIconPixmap( "master_pitch" ) ); - lmmsMainWin::inst()->addWidgetToToolBar( master_pitch_lbl ); - lmmsMainWin::inst()->addWidgetToToolBar( m_masterPitchSlider ); + eng()->getMainWindow()->addWidgetToToolBar( master_pitch_lbl ); + eng()->getMainWindow()->addWidgetToToolBar( m_masterPitchSlider ); - lmmsMainWin::inst()->addSpacingToToolBar( 10 ); + eng()->getMainWindow()->addSpacingToToolBar( 10 ); // create widget for visualization- and cpu-load-widget QWidget * vc_w = new QWidget( tb ); @@ -272,12 +262,12 @@ songEditor::songEditor() : vcw_layout->addStretch(); vcw_layout->addWidget( new visualizationWidget( - embed::getIconPixmap( "output_graph" ), vc_w ) ); + embed::getIconPixmap( "output_graph" ), vc_w, eng() ) ); - vcw_layout->addWidget( new cpuloadWidget( vc_w ) ); + vcw_layout->addWidget( new cpuloadWidget( vc_w, eng() ) ); vcw_layout->addStretch(); - lmmsMainWin::inst()->addWidgetToToolBar( vc_w ); + eng()->getMainWindow()->addWidgetToToolBar( vc_w ); // create own toolbar @@ -423,31 +413,8 @@ songEditor::songEditor() : this, SLOT( scrolled( int ) ) ); - show(); - m_projectNotes = new projectNotes(); - m_projectNotes->resize( 300, 200 ); - if( lmmsMainWin::inst()->workspace() != NULL ) - { - m_projectNotes->move( 700, 10 ); - } - else - { - m_projectNotes->move( 800, 10 ); - } - m_projectNotes->show(); - - - // we try to load given file - if( file_to_load != "" ) - { - loadProject( file_to_load ); - } - else - { - createNewProject(); - } } @@ -517,13 +484,13 @@ void songEditor::resizeEvent( QResizeEvent * _re ) void songEditor::keyPressEvent( QKeyEvent * _ke ) { if( /*_ke->modifiers() & Qt::ShiftModifier*/ - lmmsMainWin::isShiftPressed() == TRUE && + eng()->getMainWindow()->isShiftPressed() == TRUE && _ke->key() == Qt::Key_Insert ) { insertBar(); } else if(/* _ke->modifiers() & Qt::ShiftModifier &&*/ - lmmsMainWin::isShiftPressed() == TRUE && + eng()->getMainWindow()->isShiftPressed() == TRUE && _ke->key() == Qt::Key_Delete ) { removeBar(); @@ -584,7 +551,7 @@ void songEditor::scrolled( int _new_pos ) void songEditor::wheelEvent( QWheelEvent * _we ) { - if( lmmsMainWin::isCtrlPressed() == TRUE ) + if( eng()->getMainWindow()->isCtrlPressed() == TRUE ) { if( _we->delta() > 0 ) { @@ -606,7 +573,7 @@ void songEditor::wheelEvent( QWheelEvent * _we ) // and make sure, all TCO's are resized and relocated realignTracks( TRUE ); } - else if( lmmsMainWin::isShiftPressed() == TRUE ) + else if( eng()->getMainWindow()->isShiftPressed() == TRUE ) { m_leftRightScroll->setValue( m_leftRightScroll->value() - _we->delta() / 30 ); @@ -634,7 +601,7 @@ void songEditor::masterVolumeChanged( int _new_val ) QPoint( m_masterVolumeSlider->width() + 2, -2 ) ); m_mvsStatus->setVisibilityTimeOut( 1000 ); } - mixer::inst()->setMasterGain( 2.0f - _new_val / 100.0f ); + eng()->getMixer()->setMasterGain( 2.0f - _new_val / 100.0f ); setModified(); } @@ -755,11 +722,11 @@ void songEditor::zoomingChanged( const QString & _zfac ) -void songEditor::setBPM( int _new_bpm ) +void songEditor::setTempo( int _new_bpm ) { - m_bpmSpinBox->setValue( tLimit( _new_bpm, MIN_BPM, MAX_BPM ) ); + m_bpmSpinBox->setValue( tLimit( _new_bpm, MIN_BPM, MAX_BPM ) ); setModified(); - emit bpmChanged( _new_bpm ); + emit tempoChanged( _new_bpm ); } @@ -821,7 +788,7 @@ void songEditor::doActions( void ) updateTimeLinePosition(); // remove all note-play-handles that are active - mixer::inst()->clear(); + eng()->getMixer()->clear(); break; } @@ -909,7 +876,7 @@ void songEditor::processNextBuffer( void ) // at song-start we have to reset the LFOs if( m_playPos[PLAY_SONG] == 0 ) { - envelopeAndLFOWidget::resetLFO(); + envelopeAndLFOWidget::resetLFO( eng() ); } break; @@ -918,10 +885,11 @@ void songEditor::processNextBuffer( void ) break; case PLAY_BB: - if( bbEditor::inst()->numOfBBs() > 0 ) + if( eng()->getBBEditor()->numOfBBs() > 0 ) { - tco_num = bbEditor::inst()->currentBB(); - tv.push_back( bbTrack::findBBTrack( tco_num ) ); + tco_num = eng()->getBBEditor()->currentBB(); + tv.push_back( bbTrack::findBBTrack( tco_num, + eng() ) ); } break; @@ -969,9 +937,9 @@ void songEditor::processNextBuffer( void ) frames_per_tact / 64 ); } - while( total_frames_played < mixer::inst()->framesPerAudioBuffer() ) + while( total_frames_played < eng()->getMixer()->framesPerAudioBuffer() ) { - Uint32 played_frames = mixer::inst()->framesPerAudioBuffer() - + Uint32 played_frames = eng()->getMixer()->framesPerAudioBuffer() - total_frames_played; // did we play a whole tact? @@ -986,7 +954,7 @@ void songEditor::processNextBuffer( void ) if( m_playMode == PLAY_BB ) { max_tact = - bbEditor::inst()->lengthOfCurrentBB(); + eng()->getBBEditor()->lengthOfCurrentBB(); } else if( m_playMode == PLAY_PATTERN && m_loopPattern == TRUE && @@ -1011,7 +979,7 @@ void songEditor::processNextBuffer( void ) // or do we have some samples left in this tact but this are // less then samples we have to play? else if( frames_per_tact - m_playPos[m_playMode].currentFrame() - < mixer::inst()->framesPerAudioBuffer() ) + < eng()->getMixer()->framesPerAudioBuffer() ) { // then set played_samples to remaining samples, the // rest will be played in next loop @@ -1066,7 +1034,7 @@ void songEditor::play( void ) if( m_playMode != PLAY_SONG ) { // make sure, bb-editor updates/resets it play-button - bbEditor::inst()->stop(); + eng()->getBBEditor()->stop(); //pianoRoll::inst()->stop(); } else @@ -1289,14 +1257,14 @@ float songEditor::framesPerTact( void ) const // when fooling around with tempo while playing, we sometimes get // 0 here which leads to FP-exception, so handle it separately const int bpm = tMax( 1, m_bpmSpinBox->value() ); - return( mixer::inst()->sampleRate() * 60.0f * BEATS_PER_TACT / + return( eng()->getMixer()->sampleRate() * 60.0f * BEATS_PER_TACT / bpm ); } -int songEditor::getBPM( void ) +bpm_t songEditor::getTempo( void ) { return( m_bpmSpinBox->value() ); } @@ -1317,7 +1285,7 @@ bool songEditor::mayChangeProject( void ) #else information #endif - ( lmmsMainWin::inst(), + ( eng()->getMainWindow(), tr( "Project not saved" ), tr( "The current project was " "modified since last " @@ -1338,12 +1306,12 @@ bool songEditor::mayChangeProject( void ) QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel, - lmmsMainWin::inst() ); + eng()->getMainWindow() ); int answer = mb.exec(); if( answer == QMessageBox::Yes ) { - return( lmmsMainWin::inst()->saveProject() ); + return( eng()->getMainWindow()->saveProject() ); } else if( answer == QMessageBox::No ) { @@ -1368,8 +1336,8 @@ void songEditor::clearProject( void ) // make sure all running notes are cleared, otherwise the whole // thing will end up in a SIGSEGV... - mixer::inst()->clear( TRUE ); - while( mixer::inst()->haveNoRunningNotes() == FALSE ) + eng()->getMixer()->clear( TRUE ); + while( eng()->getMixer()->haveNoRunningNotes() == FALSE ) { #ifdef QT4 QApplication::processEvents( QEventLoop::AllEvents ); @@ -1378,17 +1346,10 @@ void songEditor::clearProject( void ) #endif } - trackVector tv = tracks(); - for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it ) - { - removeTrack( *it ); - } - tv = bbEditor::inst()->tracks(); - for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it ) - { - bbEditor::inst()->removeTrack( *it ); - } - m_projectNotes->clear(); + clearAllTracks(); + eng()->getBBEditor()->clearAllTracks(); + + eng()->getProjectNotes()->clear(); } @@ -1405,13 +1366,13 @@ void songEditor::createNewProject( void ) dynamic_cast< channelTrack * >( t )->loadInstrument( "tripleoscillator" ); track::create( track::SAMPLE_TRACK, this ); - t = track::create( track::CHANNEL_TRACK, bbEditor::inst() ); + t = track::create( track::CHANNEL_TRACK, eng()->getBBEditor() ); dynamic_cast< channelTrack * >( t )->loadInstrument( "tripleoscillator" ); track::create( track::BB_TRACK, this ); m_loadingProject = TRUE; - setBPM( DEFAULT_BPM ); + setTempo( DEFAULT_BPM ); m_masterVolumeSlider->setValue( 100 ); m_masterPitchSlider->setValue( 0 ); m_loadingProject = FALSE; @@ -1420,7 +1381,7 @@ void songEditor::createNewProject( void ) m_modified = FALSE; - lmmsMainWin::inst()->resetWindowTitle( "" ); + eng()->getMainWindow()->resetWindowTitle( "" ); } @@ -1441,8 +1402,8 @@ void FASTCALL songEditor::createNewProjectFromTemplate( const QString & // load given song void FASTCALL songEditor::loadProject( const QString & _file_name ) { - clearProject(); + m_fileName = _file_name; m_oldFileName = _file_name; @@ -1466,7 +1427,7 @@ void FASTCALL songEditor::loadProject( const QString & _file_name ) if( node.nodeName() == "bpm" && node.toElement().attribute( "value" ).toInt() > 0 ) { - setBPM( node.toElement().attribute( "value" + setTempo( node.toElement().attribute( "value" ).toInt() ); } else if( node.nodeName() == "mastervol" ) @@ -1502,9 +1463,10 @@ void FASTCALL songEditor::loadProject( const QString & _file_name ) { loadSettings( node.toElement() ); } - else if( node.nodeName() == m_projectNotes->nodeName() ) + else if( node.nodeName() == + eng()->getProjectNotes()->nodeName() ) { - m_projectNotes->loadSettings( + eng()->getProjectNotes()->loadSettings( node.toElement() ); } } @@ -1516,7 +1478,7 @@ void FASTCALL songEditor::loadProject( const QString & _file_name ) m_loadingProject = FALSE; - lmmsMainWin::inst()->resetWindowTitle( "" ); + eng()->getMainWindow()->resetWindowTitle( "" ); } @@ -1541,7 +1503,7 @@ bool songEditor::saveProject( void ) saveSettings( mmp, mmp.content() ); - m_projectNotes->saveSettings( mmp, mmp.content() ); + eng()->getProjectNotes()->saveSettings( mmp, mmp.content() ); if( mmp.writeFile( m_fileName, m_oldFileName == "" || m_fileName != m_oldFileName ) == TRUE ) @@ -1553,7 +1515,7 @@ bool songEditor::saveProject( void ) ).arg( m_fileName ), embed::getIconPixmap( "project_save", 24, 24 ), 2000 ); - lmmsMainWin::inst()->resetWindowTitle( "" ); + eng()->getMainWindow()->resetWindowTitle( "" ); } else { @@ -1624,7 +1586,7 @@ void songEditor::exportProject( void ) } base_filename += fileEncodeDevices[0].m_extension; - QFileDialog efd( lmmsMainWin::inst() ); + QFileDialog efd( eng()->getMainWindow() ); efd.setFileMode( QFileDialog::AnyFile ); int idx = 0; @@ -1662,7 +1624,7 @@ void songEditor::exportProject( void ) const QString export_file_name = efd.selectedFile(); #endif if( QFileInfo( export_file_name ).exists() == TRUE && - QMessageBox::warning( lmmsMainWin::inst(), + QMessageBox::warning( eng()->getMainWindow(), tr( "File already exists" ), tr( "The file \"%1\" already " "exists. Do you want " @@ -1678,7 +1640,7 @@ void songEditor::exportProject( void ) return; } exportProjectDialog epd( export_file_name, - lmmsMainWin::inst() ); + eng()->getMainWindow(), eng() ); epd.exec(); } } diff --git a/src/core/timeline.cpp b/src/core/timeline.cpp index 07cd7b8023..3df38bbd93 100644 --- a/src/core/timeline.cpp +++ b/src/core/timeline.cpp @@ -1,7 +1,7 @@ /* * timeline.cpp - class timeLine, representing a time-line with position marker * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -47,7 +47,7 @@ #include "embed.h" #include "templates.h" #include "nstate_button.h" -#include "lmms_main_win.h" +#include "main_window.h" #include "text_float.h" @@ -60,8 +60,9 @@ QPixmap * timeLine::s_loopPointDisabledPixmap = NULL; timeLine::timeLine( const int _xoff, const int _yoff, const float _ppt, songEditor::playPos & _pos, const midiTime & _begin, - QWidget * _parent ) : + QWidget * _parent, engine * _engine ) : QWidget( _parent ), + engineObject( _engine ), m_autoScroll( AUTOSCROLL_ENABLED ), m_loopPoints( LOOP_POINTS_DISABLED ), m_behaviourAtStop( BACK_TO_ZERO ), @@ -79,23 +80,23 @@ timeLine::timeLine( const int _xoff, const int _yoff, const float _ppt, m_loopPos[0] = 0; m_loopPos[1] = 64; - if( s_timeLinePixmap == NULL) + if( s_timeLinePixmap == NULL ) { s_timeLinePixmap = new QPixmap( embed::getIconPixmap( "timeline" ) ); } - if( s_posMarkerPixmap == NULL) + if( s_posMarkerPixmap == NULL ) { s_posMarkerPixmap = new QPixmap( embed::getIconPixmap( "playpos_marker" ) ); } - if( s_loopPointPixmap == NULL) + if( s_loopPointPixmap == NULL ) { s_loopPointPixmap = new QPixmap( embed::getIconPixmap( "loop_point" ) ); } - if( s_loopPointDisabledPixmap == NULL) + if( s_loopPointDisabledPixmap == NULL ) { s_loopPointDisabledPixmap = new QPixmap( embed::getIconPixmap( "loop_point_disabled" ) ); @@ -307,7 +308,7 @@ void timeLine::mousePressEvent( QMouseEvent * _me ) qSwap( pmin, pmax ); m_action = MOVE_LOOP_END; } - if( lmmsMainWin::isShiftPressed() == TRUE ) + if( eng()->getMainWindow()->isShiftPressed() == TRUE ) { m_loopPos[pmax] = t; m_action = ( m_action == MOVE_LOOP_BEGIN ) ? @@ -360,8 +361,8 @@ void timeLine::mouseMoveEvent( QMouseEvent * _me ) case MOVE_LOOP_BEGIN: case MOVE_LOOP_END: { - Uint8 i = m_action - MOVE_LOOP_BEGIN; - if( lmmsMainWin::isCtrlPressed() == TRUE ) + const Uint8 i = m_action - MOVE_LOOP_BEGIN; + if( eng()->getMainWindow()->isCtrlPressed() == TRUE ) { // no ctrl-press-hint when having ctrl pressed delete m_hint; diff --git a/src/core/track.cpp b/src/core/track.cpp index b441f042b5..e58a21e782 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -60,7 +60,7 @@ #include "tooltip.h" #include "string_pair_drag.h" #include "mmp.h" -#include "lmms_main_win.h" +#include "main_window.h" #include "text_float.h" @@ -85,6 +85,7 @@ trackContentObject::trackContentObject( track * _track ) : , Qt::WDestructiveClose #endif ), + engineObject( _track->eng() ), m_track( _track ), m_startPosition(), m_length(), @@ -136,7 +137,7 @@ void trackContentObject::movePosition( const midiTime & _pos ) { if( m_startPosition != _pos ) { - songEditor::inst()->setModified(); + getTrack()->eng()->getSongEditor()->setModified(); } m_startPosition = _pos; m_track->getTrackWidget()->changePosition(); @@ -152,7 +153,7 @@ void trackContentObject::changeLength( const midiTime & _length ) { if( m_length != _length ) { - songEditor::inst()->setModified(); + getTrack()->eng()->getSongEditor()->setModified(); } m_length = _length; setFixedWidth( static_cast( m_length * pixelsPerTact() / 64 ) + @@ -232,7 +233,8 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me ) { if( m_track->getTrackContainer()->rubberBandActive() == FALSE ) { - if( lmmsMainWin::isCtrlPressed() == TRUE ) + if( + getTrack()->eng()->getMainWindow()->isCtrlPressed() == TRUE ) { setSelected( !isSelected() ); } @@ -248,12 +250,12 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me ) } return; } - else if( lmmsMainWin::isShiftPressed() == TRUE ) + else if( getTrack()->eng()->getMainWindow()->isShiftPressed() == TRUE ) { selectableObject::mousePressEvent( _me ); } else if( _me->button() == Qt::LeftButton && - lmmsMainWin::isCtrlPressed() == TRUE ) + getTrack()->eng()->getMainWindow()->isCtrlPressed() == TRUE ) { multimediaProject mmp( multimediaProject::DRAG_N_DROP_DATA ); saveSettings( mmp, mmp.content() ); @@ -270,10 +272,11 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me ) #endif new stringPairDrag( "tco_" + QString::number( m_track->type() ), - mmp.toString(), thumbnail, this ); + mmp.toString(), thumbnail, this, + m_track->eng() ); } else if( _me->button() == Qt::LeftButton && - /* lmmsMainWin::isShiftPressed() == FALSE &&*/ + /* eng()->getMainWindow()->isShiftPressed() == FALSE &&*/ fixedTCOs() == FALSE ) { m_initialMouseX = _me->x(); @@ -299,7 +302,7 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me ) } else if( ( _me->button() == Qt::MidButton/* || ( _me->button() == Qt::LeftButton && - lmmsMainWin::isShiftPressed() == TRUE )*/ ) && + eng()->getMainWindow()->isShiftPressed() == TRUE )*/ ) && fixedTCOs() == FALSE ) { close(); @@ -544,7 +547,7 @@ trackContentObject * FASTCALL trackContentWidget::addTCO( m_trackContentObjects.push_back( _tco ); _tco->move( 0, 1 ); m_trackWidget->changePosition(); - songEditor::inst()->setModified(); + getTrack()->eng()->getSongEditor()->setModified(); return( _tco ); // just for convenience } @@ -572,7 +575,7 @@ void trackContentWidget::removeTCO( trackContentObject * _tco, delete _tco; } m_trackContentObjects.erase( it ); - songEditor::inst()->setModified(); + getTrack()->eng()->getSongEditor()->setModified(); } } @@ -711,7 +714,7 @@ void trackContentWidget::mousePressEvent( QMouseEvent * _me ) { QWidget::mousePressEvent( _me ); } - else if( lmmsMainWin::isShiftPressed() == TRUE ) + else if( getTrack()->eng()->getMainWindow()->isShiftPressed() == TRUE ) { QWidget::mousePressEvent( _me ); } @@ -871,7 +874,7 @@ bool trackOperationsWidget::muted( void ) const void trackOperationsWidget::mousePressEvent( QMouseEvent * _me ) { if( _me->button() == Qt::LeftButton && - lmmsMainWin::isCtrlPressed() == TRUE && +m_trackWidget->getTrack()->eng()->getMainWindow()->isCtrlPressed() == TRUE && m_trackWidget->getTrack()->type() != track::BB_TRACK ) { multimediaProject mmp( multimediaProject::DRAG_N_DROP_DATA ); @@ -880,7 +883,7 @@ void trackOperationsWidget::mousePressEvent( QMouseEvent * _me ) QString::number( m_trackWidget->getTrack()->type() ), mmp.toString(), QPixmap::grabWidget( &m_trackWidget->getTrackSettingsWidget() ), - this ); + this, m_trackWidget->getTrack()->eng() ); } else if( _me->button() == Qt::LeftButton ) { @@ -1099,7 +1102,7 @@ void trackWidget::mousePressEvent( QMouseEvent * _me ) } else if( _me->button() == Qt::LeftButton ) { - if( lmmsMainWin::isShiftPressed() == TRUE ) + if( m_track->eng()->getMainWindow()->isShiftPressed() == TRUE ) { m_action = RESIZE_TRACK; QCursor::setPos( mapToGlobal( QPoint( _me->x(), @@ -1240,6 +1243,7 @@ midiTime trackWidget::endPosition( const midiTime & _pos_start ) track::track( trackContainer * _tc ) : settings(), + engineObject( _tc->eng() ), m_trackContainer( _tc ) { m_trackWidget = new trackWidget( this, @@ -1266,7 +1270,7 @@ track * FASTCALL track::create( trackTypes _tt, trackContainer * _tc ) { // while adding track, pause mixer for not getting into any trouble // because of track being not created completely so far - mixer::inst()->pause(); + _tc->eng()->getMixer()->pause(); track * t = NULL; @@ -1283,7 +1287,7 @@ track * FASTCALL track::create( trackTypes _tt, trackContainer * _tc ) assert( t != NULL ); // allow mixer to continue - mixer::inst()->play(); + _tc->eng()->getMixer()->play(); return( t ); } diff --git a/src/core/track_container.cpp b/src/core/track_container.cpp index db5106e432..4358cdcf84 100644 --- a/src/core/track_container.cpp +++ b/src/core/track_container.cpp @@ -2,7 +2,7 @@ * track_container.cpp - implementation of base-class for all track-containers * like Song-Editor, BB-Editor... * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -49,7 +49,7 @@ #include "track.h" #include "templates.h" #include "bb_track.h" -#include "lmms_main_win.h" +#include "main_window.h" #include "mixer.h" #include "song_editor.h" #include "string_pair_drag.h" @@ -62,13 +62,14 @@ -trackContainer::trackContainer() : - QMainWindow( lmmsMainWin::inst()->workspace() +trackContainer::trackContainer( engine * _engine ) : + QMainWindow( _engine->getMainWindow()->workspace() #ifdef QT3 , 0, Qt::WStyle_Title #endif ), settings(), + engineObject( _engine ), m_currentPosition( 0, 0 ), m_scrollArea( new scrollArea( this ) ), m_ppt( DEFAULT_PIXELS_PER_TACT ), @@ -76,9 +77,9 @@ trackContainer::trackContainer() : m_origin() { #ifdef QT4 - if( lmmsMainWin::inst()->workspace() != NULL ) + if( eng()->getMainWindow()->workspace() != NULL ) { - lmmsMainWin::inst()->workspace()->addWindow( this ); + eng()->getMainWindow()->workspace()->addWindow( this ); } #endif @@ -214,7 +215,7 @@ void trackContainer::removeTrack( track * _track ) m_trackWidgets.end(), _track->getTrackWidget() ); if( it != m_trackWidgets.end() ) { - mixer::inst()->pause(); + eng()->getMixer()->pause(); #ifndef QT4 m_scrollArea->removeChild( _track->getTrackWidget() ); #endif @@ -222,10 +223,10 @@ void trackContainer::removeTrack( track * _track ) delete _track; - mixer::inst()->play(); + eng()->getMixer()->play(); realignTracks(); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } } @@ -306,6 +307,17 @@ void trackContainer::realignTracks( bool _complete_update ) +void trackContainer::clearAllTracks( void ) +{ + while( m_trackWidgets.size() ) + { + removeTrack( m_trackWidgets.front()->getTrack() ); + } +} + + + + const trackWidget * trackContainer::trackWidgetAt( const int _y ) const { int y_cnt = 0; diff --git a/src/lib/buffer_allocator.cpp b/src/lib/buffer_allocator.cpp index 30fb3ef730..7639a7f836 100644 --- a/src/lib/buffer_allocator.cpp +++ b/src/lib/buffer_allocator.cpp @@ -150,7 +150,8 @@ void bufferAllocator::free( void * _buf ) // do clean-up if neccessary static const Uint32 CLEANUP_LEVEL = static_cast( 768 / ( logf( - mixer::inst()->framesPerAudioBuffer() ) / + /*mixer::inst()->framesPerAudioBuffer()*/ + 128 ) / logf( 2 ) ) ); static int count = 0; // only cleanup every 10th time, because otherwise there's a lot of diff --git a/src/lib/oscillator.cpp b/src/lib/oscillator.cpp index 11bc82457e..3886ac5cd3 100644 --- a/src/lib/oscillator.cpp +++ b/src/lib/oscillator.cpp @@ -29,10 +29,13 @@ oscillator::oscillator( const modulationAlgos _modulation_algo, const float _freq, const Sint16 _phase_offset, - const float _volume_factor, oscillator * _sub_osc ) : + const float _volume_factor, + const sample_rate_t _sample_rate, + oscillator * _sub_osc ) : m_freq( _freq ), m_volumeFactor( _volume_factor ), m_phaseOffset( _phase_offset ), + m_sampleRate( _sample_rate ), m_subOsc( _sub_osc ), m_userWaveData( &ZERO_FRAME ), m_userWaveFrames( 1 ) @@ -155,9 +158,10 @@ class x : public oscillator \ public: \ x( const modulationAlgos modulation_algo, const float _freq, \ const Sint16 _phase_offset, const float _volume_factor, \ + const sample_rate_t _sample_rate, \ oscillator * _sub_osc ) FASTCALL : \ oscillator( modulation_algo, _freq, _phase_offset, \ - _volume_factor, _sub_osc ) \ + _volume_factor, _sample_rate, _sub_osc ) \ { \ } \ virtual ~x() \ @@ -201,6 +205,7 @@ oscillator * oscillator::createOsc( const waveShapes _wave_shape, const float _freq, const Sint16 _phase_offset, const float _volume_factor, + const sample_rate_t _sample_rate, oscillator * _sub_osc ) { switch( _wave_shape ) @@ -208,39 +213,39 @@ oscillator * oscillator::createOsc( const waveShapes _wave_shape, case SIN_WAVE: return( new sinWaveOsc( _modulation_algo, _freq, _phase_offset, _volume_factor, - _sub_osc ) ); + _sample_rate, _sub_osc ) ); case TRIANGLE_WAVE: return( new triangleWaveOsc( _modulation_algo, _freq, _phase_offset, _volume_factor, - _sub_osc ) ); + _sample_rate, _sub_osc ) ); case SAW_WAVE: return( new sawWaveOsc( _modulation_algo, _freq, _phase_offset, _volume_factor, - _sub_osc ) ); + _sample_rate, _sub_osc ) ); case SQUARE_WAVE: return( new squareWaveOsc( _modulation_algo, _freq, _phase_offset, _volume_factor, - _sub_osc ) ); + _sample_rate, _sub_osc ) ); case MOOG_SAW_WAVE: return( new moogSawWaveOsc( _modulation_algo, _freq, _phase_offset, _volume_factor, - _sub_osc ) ); + _sample_rate, _sub_osc ) ); case EXP_WAVE: return( new expWaveOsc( _modulation_algo, _freq, _phase_offset, _volume_factor, - _sub_osc ) ); + _sample_rate, _sub_osc ) ); case WHITE_NOISE_WAVE: return( new noiseWaveOsc( _modulation_algo, _freq, _phase_offset, _volume_factor, - _sub_osc ) ); + _sample_rate, _sub_osc ) ); case USER_DEF_WAVE: return( new userWaveOsc( _modulation_algo, _freq, _phase_offset, _volume_factor, - _sub_osc ) ); + _sample_rate, _sub_osc ) ); default: return( new sinWaveOsc( _modulation_algo, _freq, _phase_offset, _volume_factor, - _sub_osc ) ); + _sample_rate, _sub_osc ) ); } } @@ -251,12 +256,11 @@ oscillator * oscillator::createOsc( const waveShapes _wave_shape, // should be called every time phase-offset or frequency is changed... void oscillator::recalcOscCoeff( const float additional_phase_offset ) { - m_oscCoeff = m_freq / static_cast( mixer::inst()->sampleRate() ); + m_oscCoeff = m_freq / static_cast( m_sampleRate ); m_sample = static_cast( ( m_phaseOffset * ( 1.0f / 360.0f ) + additional_phase_offset ) * - ( mixer::inst()->sampleRate() / - m_freq ) ); + ( m_sampleRate / m_freq ) ); // because we pre-increment m_sample in update-function, we should // decrement it here... (not possible when 0 because it is // unsigned - overflow!!!) diff --git a/src/lib/sample_buffer.cpp b/src/lib/sample_buffer.cpp index 3a64f397c5..22379802c7 100644 --- a/src/lib/sample_buffer.cpp +++ b/src/lib/sample_buffer.cpp @@ -100,9 +100,10 @@ -sampleBuffer::sampleBuffer( const QString & _audio_file, +sampleBuffer::sampleBuffer( engine * _engine, const QString & _audio_file, bool _is_base64_data ) : QObject(), + engineObject( _engine ), m_audioFile( ( _is_base64_data == TRUE ) ? "" : _audio_file ), m_origData( NULL ), m_origFrames( 0 ), @@ -131,8 +132,10 @@ sampleBuffer::sampleBuffer( const QString & _audio_file, -sampleBuffer::sampleBuffer( const sampleFrame * _data, const f_cnt_t _frames ) : +sampleBuffer::sampleBuffer( const sampleFrame * _data, const f_cnt_t _frames, + engine * _engine ) : QObject(), + engineObject( _engine ), m_audioFile( "" ), m_origData( NULL ), m_origFrames( 0 ), @@ -160,8 +163,9 @@ sampleBuffer::sampleBuffer( const sampleFrame * _data, const f_cnt_t _frames ) : -sampleBuffer::sampleBuffer( const f_cnt_t _frames ) : +sampleBuffer::sampleBuffer( const f_cnt_t _frames, engine * _engine ) : QObject(), + engineObject( _engine ), m_audioFile( "" ), m_origData( NULL ), m_origFrames( 0 ), @@ -623,7 +627,7 @@ SRC_STATE * sampleBuffer::createResamplingContext( void ) int error; SRC_STATE * state; if( ( state = src_new(/* - ( mixer::inst()->highQuality() == TRUE ) ? + ( eng()->getMixer()->highQuality() == TRUE ) ? SRC_SINC_FASTEST :*/ SRC_LINEAR, DEFAULT_CHANNELS, &error ) ) == NULL ) @@ -652,7 +656,7 @@ bool FASTCALL sampleBuffer::play( sampleFrame * _ab, const bool _looped, void * * _resampling_data ) { - mixer::inst()->clearAudioBuffer( _ab, _frames ); + eng()->getMixer()->clearAudioBuffer( _ab, _frames ); if( m_data == NULL || m_frames == 0 || m_endFrame == 0 || _frames == 0 ) { @@ -741,7 +745,7 @@ bool FASTCALL sampleBuffer::play( sampleFrame * _ab, #else f_cnt_t src_frame_base = 0; // check whether we're in high-quality-mode - if( mixer::inst()->highQuality() == TRUE ) + if( eng()->getMixer()->highQuality() == TRUE ) { // we are, so let's use cubic interpolation... for( f_cnt_t frame = 0; frame < frames_to_process; @@ -1091,7 +1095,7 @@ QString & sampleBuffer::toBase64( QString & _dst ) const /* FLAC__stream_encoder_set_do_exhaustive_model_search( flac_enc, TRUE ); FLAC__stream_encoder_set_do_mid_side_stereo( flac_enc, TRUE );*/ FLAC__stream_encoder_set_sample_rate( flac_enc, - mixer::inst()->sampleRate() ); + eng()->getMixer()->sampleRate() ); QBuffer ba_writer; #ifdef QT4 ba_writer.open( QBuffer::WriteOnly ); @@ -1152,11 +1156,12 @@ QString & sampleBuffer::toBase64( QString & _dst ) const sampleBuffer * sampleBuffer::resample( sampleFrame * _data, const f_cnt_t _frames, const sample_rate_t _src_sr, - const sample_rate_t _dst_sr ) + const sample_rate_t _dst_sr, + engine * _engine ) { const f_cnt_t dst_frames = static_cast( _frames / (float) _src_sr * (float) _dst_sr ); - sampleBuffer * dst_sb = new sampleBuffer( dst_frames ); + sampleBuffer * dst_sb = new sampleBuffer( dst_frames, _engine ); sampleFrame * dst_buf = dst_sb->m_origData; #ifdef HAVE_SAMPLERATE_H // yeah, libsamplerate, let's rock with sinc-interpolation! diff --git a/src/lib/string_pair_drag.cpp b/src/lib/string_pair_drag.cpp index 4346d7c649..7aeb17c147 100644 --- a/src/lib/string_pair_drag.cpp +++ b/src/lib/string_pair_drag.cpp @@ -26,7 +26,7 @@ #include "string_pair_drag.h" -#include "lmms_main_win.h" +#include "main_window.h" #ifdef QT4 @@ -38,12 +38,14 @@ stringPairDrag::stringPairDrag( const QString & _key, const QString & _value, - const QPixmap & _icon, QWidget * _w ) : + const QPixmap & _icon, QWidget * _w, + engine * _engine ) : #ifdef QT4 - QDrag( _w ) + QDrag( _w ), #else - QStoredDrag( "lmms/stringpair", _w ) + QStoredDrag( "lmms/stringpair", _w ), #endif + engineObject( _engine ) { setPixmap( _icon ); QString txt = _key + ":" + _value; @@ -65,7 +67,7 @@ stringPairDrag::~stringPairDrag() { // during a drag, we might have lost key-press-events, so reset // modifiers of main-win - lmmsMainWin::inst()->clearKeyModifiers(); + eng()->getMainWindow()->clearKeyModifiers(); // TODO: do we have to delete anything??? } diff --git a/src/midi/midi_alsa_raw.cpp b/src/midi/midi_alsa_raw.cpp index b29691b1ce..98647f1150 100644 --- a/src/midi/midi_alsa_raw.cpp +++ b/src/midi/midi_alsa_raw.cpp @@ -1,7 +1,7 @@ /* * midi_alsa_raw.cpp - midi-client for RawMIDI via ALSA * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -47,8 +47,8 @@ #ifdef ALSA_SUPPORT -midiALSARaw::midiALSARaw( void ) : - midiClientRaw(), +midiALSARaw::midiALSARaw( engine * _engine ) : + midiClientRaw( _engine ), QThread(), m_inputp( &m_input ), m_outputp( &m_output ), diff --git a/src/midi/midi_alsa_seq.cpp b/src/midi/midi_alsa_seq.cpp index e01cf5bfbf..8a30e2c0d5 100644 --- a/src/midi/midi_alsa_seq.cpp +++ b/src/midi/midi_alsa_seq.cpp @@ -50,11 +50,11 @@ #ifdef ALSA_SUPPORT -midiALSASeq::midiALSASeq( void ) : +midiALSASeq::midiALSASeq( engine * _engine ) : #ifndef QT4 QObject(), #endif - midiClient(), + midiClient( _engine ), QThread(), m_seqHandle( NULL ), m_queueID( -1 ), @@ -82,14 +82,14 @@ midiALSASeq::midiALSASeq( void ) : snd_seq_queue_tempo_t * tempo; snd_seq_queue_tempo_alloca( &tempo ); snd_seq_queue_tempo_set_tempo( tempo, 6000000 / - songEditor::inst()->getBPM() ); + eng()->getSongEditor()->getTempo() ); snd_seq_queue_tempo_set_ppq( tempo, 16 ); snd_seq_set_queue_tempo( m_seqHandle, m_queueID, tempo ); snd_seq_start_queue( m_seqHandle, m_queueID, NULL ); - changeQueueTempo( songEditor::inst()->getBPM() ); - connect( songEditor::inst(), SIGNAL( bpmChanged( int ) ), - this, SLOT( changeQueueTempo( int ) ) ); + changeQueueTempo( eng()->getSongEditor()->getTempo() ); + connect( eng()->getSongEditor(), SIGNAL( tempoChanged( bpm_t ) ), + this, SLOT( changeQueueTempo( bpm_t ) ) ); // initial list-update updatePortList(); @@ -503,10 +503,10 @@ void midiALSASeq::run( void ) -void midiALSASeq::changeQueueTempo( int _bpm ) +void midiALSASeq::changeQueueTempo( bpm_t _bpm ) { - snd_seq_change_queue_tempo( m_seqHandle, m_queueID, 60000000 / _bpm, - NULL ); + snd_seq_change_queue_tempo( m_seqHandle, m_queueID, + 60000000 / (int) _bpm, NULL ); snd_seq_drain_output( m_seqHandle ); } diff --git a/src/midi/midi_client.cpp b/src/midi/midi_client.cpp index c4bfdcac11..ebcf1f894b 100644 --- a/src/midi/midi_client.cpp +++ b/src/midi/midi_client.cpp @@ -1,7 +1,7 @@ /* * midi_client.cpp - base-class for MIDI-clients like ALSA-sequencer-client * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * This file partly contains code from Fluidsynth, Peter Hanappe * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net @@ -38,7 +38,8 @@ -midiClient::midiClient( void ) +midiClient::midiClient( engine * _engine ) : + engineObject( _engine ) { } @@ -66,6 +67,7 @@ void midiClient::applyPortName( midiPort * ) + midiPort * midiClient::addPort( midiEventProcessor * _mep, const QString & _name ) { @@ -126,8 +128,8 @@ void midiClient::subscribeWriteablePort( midiPort * , const QString & , bool) -midiClientRaw::midiClientRaw() : - midiClient() +midiClientRaw::midiClientRaw( engine * _engine ) : + midiClient( _engine ) { } diff --git a/src/midi/midi_oss.cpp b/src/midi/midi_oss.cpp index 5dffeba0f4..1dcea6ab0e 100644 --- a/src/midi/midi_oss.cpp +++ b/src/midi/midi_oss.cpp @@ -1,7 +1,7 @@ /* * midi_oss.cpp - OSS-raw-midi-client * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -53,8 +53,8 @@ -midiOSS::midiOSS( void ) : - midiClientRaw(), +midiOSS::midiOSS( engine * _engine ) : + midiClientRaw( _engine ), QThread(), m_midiDev( probeDevice() ), m_quit( FALSE ) diff --git a/src/tracks/bb_track.cpp b/src/tracks/bb_track.cpp index fe1a3057fd..1f265d38ec 100644 --- a/src/tracks/bb_track.cpp +++ b/src/tracks/bb_track.cpp @@ -66,7 +66,7 @@ bbTCO::bbTCO( track * _track, const QColor & _c ) : #ifndef QT4 setBackgroundMode( Qt::NoBackground ); #endif - tact t = bbEditor::inst()->lengthOfBB( + tact t = eng()->getBBEditor()->lengthOfBB( bbTrack::numOfBBTrack( getTrack() ) ); if( t > 0 ) { @@ -158,7 +158,7 @@ void bbTCO::paintEvent( QPaintEvent * ) } #endif - tact t = bbEditor::inst()->lengthOfBB( bbTrack::numOfBBTrack( + tact t = eng()->getBBEditor()->lengthOfBB( bbTrack::numOfBBTrack( getTrack() ) ); if( length() > 64 && t > 0 ) { @@ -227,9 +227,10 @@ void bbTCO::loadSettings( const QDomElement & _this ) void bbTCO::openInBBEditor( bool ) { - bbEditor::inst()->setCurrentBB( bbTrack::numOfBBTrack( getTrack() ) ); - bbEditor::inst()->show(); - bbEditor::inst()->setFocus(); + eng()->getBBEditor()->setCurrentBB( bbTrack::numOfBBTrack( + getTrack() ) ); + eng()->getBBEditor()->show(); + eng()->getBBEditor()->setFocus(); } @@ -270,7 +271,7 @@ void bbTCO::changeColor( void ) if( _new_color.isValid() && _new_color != m_color ) { m_color = _new_color; - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); update(); } } @@ -291,7 +292,7 @@ bbTrack::bbTrack( trackContainer * _tc ) : s_infoMap[this] = bbNum; m_trackLabel = new nameLabel( tr( "Beat/Bassline %1" ).arg( bbNum ), - getTrackSettingsWidget() ); + getTrackSettingsWidget(), eng() ); m_trackLabel->setPixmap( embed::getIconPixmap( "bb_track" ) ); m_trackLabel->setGeometry( 1, 1, DEFAULT_SETTINGS_WIDGET_WIDTH - 2, 29 ); @@ -299,13 +300,13 @@ bbTrack::bbTrack( trackContainer * _tc ) : connect( m_trackLabel, SIGNAL( clicked() ), this, SLOT( clickedTrackLabel() ) ); connect( m_trackLabel, SIGNAL( nameChanged() ), - bbEditor::inst(), SLOT( updateComboBox() ) ); + eng()->getBBEditor(), SLOT( updateComboBox() ) ); connect( m_trackLabel, SIGNAL( pixmapChanged() ), - bbEditor::inst(), SLOT( updateComboBox() ) ); + eng()->getBBEditor(), SLOT( updateComboBox() ) ); - bbEditor::inst()->setCurrentBB( bbNum ); - bbEditor::inst()->updateComboBox(); + eng()->getBBEditor()->setCurrentBB( bbNum ); + eng()->getBBEditor()->updateComboBox(); _tc->updateAfterTrackAdd(); } @@ -316,7 +317,7 @@ bbTrack::bbTrack( trackContainer * _tc ) : bbTrack::~bbTrack() { csize bb = s_infoMap[this]; - bbEditor::inst()->removeBB( bb ); + eng()->getBBEditor()->removeBB( bb ); for( infoMap::iterator it = s_infoMap.begin(); it != s_infoMap.end(); ++it ) { @@ -346,20 +347,22 @@ track::trackTypes bbTrack::type( void ) const // play _frames frames of given TCO within starting with _start/_start_frame -bool FASTCALL bbTrack::play( const midiTime & _start, Uint32 _start_frame, - Uint32 _frames, Uint32 _frame_base, +bool FASTCALL bbTrack::play( const midiTime & _start, + const f_cnt_t _start_frame, + const fpab_t _frames, + const f_cnt_t _frame_base, Sint16 _tco_num ) { if( _tco_num >= 0 ) { - return( bbEditor::inst()->play( _start, _start_frame, _frames, + return( eng()->getBBEditor()->play( _start, _start_frame, _frames, _frame_base, s_infoMap[this] ) ); } vlist tcos; getTCOsInRange( tcos, _start, _start +static_cast( _frames * - 64 / songEditor::inst()->framesPerTact() ) ); + 64 / eng()->getSongEditor()->framesPerTact() ) ); if ( tcos.size() == 0 ) { @@ -379,7 +382,7 @@ bool FASTCALL bbTrack::play( const midiTime & _start, Uint32 _start_frame, } if( _start - lastPosition < lastLen ) { - return( bbEditor::inst()->play( _start - lastPosition, + return( eng()->getBBEditor()->play( _start - lastPosition, _start_frame, _frames, _frame_base, s_infoMap[this] ) ); @@ -418,12 +421,12 @@ void bbTrack::saveTrackSpecificSettings( QDomDocument & _doc, bbt_de.setAttribute( "name", m_trackLabel->text() ); bbt_de.setAttribute( "icon", m_trackLabel->pixmapFile() ); /* bbt_de.setAttribute( "current", s_infoMap[this] == - bbEditor::inst()->currentBB() );*/ + eng()->getBBEditor()->currentBB() );*/ _parent.appendChild( bbt_de ); if( s_infoMap[this] == 0 && _parent.parentNode().nodeName() != "clone" ) { - bbEditor::inst()->saveSettings( _doc, bbt_de ); + eng()->getBBEditor()->saveSettings( _doc, bbt_de ); } } @@ -439,7 +442,7 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this ) } if( _this.firstChild().isElement() ) { - bbEditor::inst()->loadSettings( + eng()->getBBEditor()->loadSettings( _this.firstChild().toElement() ); } /* doesn't work yet because bbTrack-ctor also sets current bb so if @@ -447,7 +450,7 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this ) help at all.... if( _this.attribute( "current" ).toInt() ) { - bbEditor::inst()->setCurrentBB( s_infoMap[this] ); + eng()->getBBEditor()->setCurrentBB( s_infoMap[this] ); }*/ } @@ -455,15 +458,15 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this ) // return pointer to bbTrack specified by _bb_num -bbTrack * bbTrack::findBBTrack( csize _bb_num ) +bbTrack * bbTrack::findBBTrack( csize _bb_num, engine * _engine ) { for( infoMap::iterator it = s_infoMap.begin(); it != s_infoMap.end(); ++it ) { #ifdef QT4 - if( it.value() == _bb_num ) + if( it.value() == _bb_num && it.key()->eng() == _engine ) #else - if( it.data() == _bb_num ) + if( it.data() == _bb_num && it.key()->eng() == _engine ) #endif { return( it.key() ); @@ -494,8 +497,9 @@ void bbTrack::swapBBTracks( track * _track1, track * _track2 ) if( t1 != NULL && t2 != NULL ) { qSwap( s_infoMap[t1], s_infoMap[t2] ); - bbEditor::inst()->swapBB( s_infoMap[t1], s_infoMap[t2] ); - bbEditor::inst()->setCurrentBB( s_infoMap[t2] ); + _track1->eng()->getBBEditor()->swapBB( s_infoMap[t1], + s_infoMap[t2] ); + _track1->eng()->getBBEditor()->setCurrentBB( s_infoMap[t2] ); } } @@ -504,8 +508,8 @@ void bbTrack::swapBBTracks( track * _track1, track * _track2 ) void bbTrack::clickedTrackLabel( void ) { - bbEditor::inst()->setCurrentBB( s_infoMap[this] ); - bbEditor::inst()->show(); + eng()->getBBEditor()->setCurrentBB( s_infoMap[this] ); + eng()->getBBEditor()->show(); } diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 1356e1efa0..4b130a7039 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -68,6 +68,7 @@ #include "bb_editor.h" #include "string_pair_drag.h" #include "buffer_allocator.h" +#include "main_window.h" QPixmap * pattern::s_stepBtnOn = NULL; @@ -123,9 +124,9 @@ pattern::pattern( const pattern & _pat_to_copy ) : pattern::~pattern() { - if( pianoRoll::inst()->currentPattern() == this ) + if( eng()->getPianoRoll()->currentPattern() == this ) { - pianoRoll::inst()->setCurrentPattern( NULL ); + eng()->getPianoRoll()->setCurrentPattern( NULL ); } for( noteVector::iterator it = m_notes.begin(); it != m_notes.end(); ++it ) @@ -312,9 +313,9 @@ void pattern::clearNotes( void ) m_notes.clear(); checkType(); update(); - if( pianoRoll::inst()->currentPattern() == this ) + if( eng()->getPianoRoll()->currentPattern() == this ) { - pianoRoll::inst()->update(); + eng()->getPianoRoll()->update(); } } @@ -377,8 +378,8 @@ void pattern::checkType( void ) -void pattern::playFrozenData( sampleFrame * _ab, Uint32 _start_frame, - Uint32 _frames ) +void pattern::playFrozenData( sampleFrame * _ab, const f_cnt_t _start_frame, + const fpab_t _frames ) { m_frozenPatternMutex.lock(); if( m_frozenPattern != NULL ) @@ -491,9 +492,9 @@ void pattern::openInPianoRoll( void ) void pattern::openInPianoRoll( bool ) { - pianoRoll::inst()->setCurrentPattern( this ); - pianoRoll::inst()->show(); - pianoRoll::inst()->setFocus(); + eng()->getPianoRoll()->setCurrentPattern( this ); + eng()->getPianoRoll()->show(); + eng()->getPianoRoll()->setFocus(); } @@ -527,7 +528,7 @@ void pattern::changeName( void ) void pattern::freeze( void ) { - if( songEditor::inst()->playing() ) + if( eng()->getSongEditor()->playing() ) { QMessageBox::information( 0, tr( "Cannot freeze pattern" ), tr( "The pattern currently " @@ -794,19 +795,21 @@ void pattern::mousePressEvent( QMouseEvent * _me ) { n->setLength( -64 ); } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); update(); - if( pianoRoll::inst()->currentPattern() == this ) + if( eng()->getPianoRoll()->currentPattern() == this ) { - pianoRoll::inst()->update(); + eng()->getPianoRoll()->update(); } } else if( m_frozenPattern != NULL && _me->button() == Qt::LeftButton && - lmmsMainWin::isShiftPressed() == TRUE ) + eng()->getMainWindow()->isShiftPressed() == TRUE ) { QString s; - new stringPairDrag( "sampledata", m_frozenPattern->toBase64( s ), - embed::getIconPixmap( "freeze" ), this ); + new stringPairDrag( "sampledata", + m_frozenPattern->toBase64( s ), + embed::getIconPixmap( "freeze" ), + this, eng() ); } else { @@ -856,11 +859,11 @@ void pattern::wheelEvent( QWheelEvent * _we ) n->setLength( 0 ); } } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); update(); - if( pianoRoll::inst()->currentPattern() == this ) + if( eng()->getPianoRoll()->currentPattern() == this ) { - pianoRoll::inst()->update(); + eng()->getPianoRoll()->update(); } _we->accept(); } @@ -1132,9 +1135,9 @@ void pattern::ensureBeatNotes( void ) void pattern::updateBBTrack( void ) { - if( getTrack()->getTrackContainer() == bbEditor::inst() ) + if( getTrack()->getTrackContainer() == eng()->getBBEditor() ) { - bbEditor::inst()->updateBBTrack( this ); + eng()->getBBEditor()->updateBBTrack( this ); } } @@ -1249,6 +1252,7 @@ void patternFreezeStatusDialog::updateProgress( void ) patternFreezeThread::patternFreezeThread( pattern * _pattern ) : QThread(), + engineObject( _pattern->eng() ), m_pattern( _pattern ) { // create status-dialog @@ -1280,13 +1284,15 @@ void patternFreezeThread::run( void ) // mixer::restoreAudioDevice(...) deletes old audio-dev and thus // audioSampleRecorder would be destroyed two times... audioSampleRecorder * freeze_recorder = new audioSampleRecorder( - mixer::inst()->sampleRate(), DEFAULT_CHANNELS, b ); - mixer::inst()->setAudioDevice( freeze_recorder, - mixer::inst()->highQuality() ); + eng()->getMixer()->sampleRate(), + DEFAULT_CHANNELS, b, + eng()->getMixer() ); + eng()->getMixer()->setAudioDevice( freeze_recorder, + eng()->getMixer()->highQuality() ); // prepare stuff for playing correct things later - songEditor::inst()->playPattern( m_pattern, FALSE ); - songEditor::playPos & ppp = songEditor::inst()->getPlayPos( + eng()->getSongEditor()->playPattern( m_pattern, FALSE ); + songEditor::playPos & ppp = eng()->getSongEditor()->getPlayPos( songEditor::PLAY_PATTERN ); ppp.setTact( 0 ); ppp.setTact64th( 0 ); @@ -1309,7 +1315,7 @@ void patternFreezeThread::run( void ) m_pattern->m_freezing = FALSE; // reset song-editor settings - songEditor::inst()->stop(); + eng()->getSongEditor()->stop(); ppp.m_timeLineUpdate = TRUE; // create final sample-buffer if freezing was successful @@ -1324,7 +1330,7 @@ void patternFreezeThread::run( void ) bufferAllocator::disableAutoCleanup( FALSE ); // restore original audio-device - mixer::inst()->restoreAudioDevice(); + eng()->getMixer()->restoreAudioDevice(); m_statusDlg->setProgress( -1 ); // we're finished diff --git a/src/tracks/sample_track.cpp b/src/tracks/sample_track.cpp index ca57c9b28c..761166d21c 100644 --- a/src/tracks/sample_track.cpp +++ b/src/tracks/sample_track.cpp @@ -56,7 +56,7 @@ sampleTCO::sampleTCO( track * _track ) : trackContentObject( _track ), - m_sampleBuffer() + m_sampleBuffer( eng() ) { #ifndef QT4 setBackgroundMode( Qt::NoBackground ); @@ -66,8 +66,8 @@ sampleTCO::sampleTCO( track * _track ) : // we need to receive bpm-change-events, because then we have to // change length of this TCO - connect( songEditor::inst(), SIGNAL( bpmChanged( int ) ), this, - SLOT( updateLength( int ) ) ); + connect( eng()->getSongEditor(), SIGNAL( tempoChanged( bpm_t ) ), this, + SLOT( updateLength( bpm_t ) ) ); } @@ -89,12 +89,12 @@ void sampleTCO::changeLength( const midiTime & _length ) -void FASTCALL sampleTCO::play( sampleFrame * _ab, Uint32 _start_frame, - Uint32 _frames ) +void FASTCALL sampleTCO::play( sampleFrame * _ab, f_cnt_t _start_frame, + const fpab_t _frames ) { _start_frame = static_cast( tMax( 0.0f, _start_frame - startPosition() * - songEditor::inst()->framesPerTact() / 64 ) ); + eng()->getSongEditor()->framesPerTact() / 64 ) ); m_sampleBuffer.play( _ab, _start_frame, _frames ); } @@ -124,7 +124,7 @@ void sampleTCO::setSampleFile( const QString & _sf ) -void sampleTCO::updateLength( int ) +void sampleTCO::updateLength( bpm_t ) { changeLength( getSampleLength() ); } @@ -155,7 +155,7 @@ void sampleTCO::dropEvent( QDropEvent * _de ) { m_sampleBuffer.loadFromBase64( stringPairDrag::decodeValue( _de ) ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); updateLength(); update(); _de->accept(); @@ -175,7 +175,7 @@ void sampleTCO::mouseDoubleClickEvent( QMouseEvent * ) if( af != "" && af != m_sampleBuffer.audioFile() ) { setSampleFile( af ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } } @@ -240,7 +240,7 @@ void sampleTCO::paintEvent( QPaintEvent * ) midiTime sampleTCO::getSampleLength( void ) const { return( static_cast( m_sampleBuffer.frames() / - songEditor::inst()->framesPerTact() * + eng()->getSongEditor()->framesPerTact() * 64 ) ); } @@ -346,7 +346,7 @@ void sampleTCOSettingsDialog::setSampleFile( const QString & _f ) { m_fileLbl->setText( _f ); m_sampleTCO->setSampleFile( _f ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } */ @@ -356,12 +356,12 @@ void sampleTCOSettingsDialog::setSampleFile( const QString & _f ) sampleTrack::sampleTrack( trackContainer * _tc ) : track( _tc ), - m_audioPort( new audioPort( tr( "Sample track" ) ) ) + m_audioPort( new audioPort( tr( "Sample track" ), eng() ) ) { getTrackWidget()->setFixedHeight( 32 ); m_trackLabel = new nameLabel( tr( "Sample track" ), - getTrackSettingsWidget() ); + getTrackSettingsWidget(), eng() ); m_trackLabel->setPixmap( embed::getIconPixmap( "sample_track" ) ); m_trackLabel->setGeometry( 1, 1, DEFAULT_SETTINGS_WIDGET_WIDTH-2, 29 ); m_trackLabel->show(); @@ -388,13 +388,15 @@ track::trackTypes sampleTrack::type( void ) const -bool FASTCALL sampleTrack::play( const midiTime & _start, Uint32 _start_frame, - Uint32 _frames, Uint32 _frame_base, +bool FASTCALL sampleTrack::play( const midiTime & _start, + const f_cnt_t _start_frame, + const fpab_t _frames, + const f_cnt_t _frame_base, Sint16 /*_tco_num*/ ) { vlist tcos; getTCOsInRange( tcos, _start, _start+static_cast( _frames * 64 / - songEditor::inst()->framesPerTact() ) ); + eng()->getSongEditor()->framesPerTact() ) ); if ( tcos.size() == 0 ) { @@ -408,7 +410,7 @@ bool FASTCALL sampleTrack::play( const midiTime & _start, Uint32 _start_frame, , 1.0f, 1.0f #endif } ; - float fpt = songEditor::inst()->framesPerTact(); + float fpt = eng()->getSongEditor()->framesPerTact(); for( vlist::iterator it = tcos.begin(); it != tcos.end(); ++it ) @@ -420,7 +422,8 @@ bool FASTCALL sampleTrack::play( const midiTime & _start, Uint32 _start_frame, static_cast( _start.getTact() * fpt ), _frames ); - mixer::inst()->bufferToPort( buf, _frames, _frame_base + + eng()->getMixer()->bufferToPort( buf, _frames, + _frame_base + static_cast( st->startPosition().getTact64th() * fpt / 64.0f ), v, diff --git a/src/widgets/cpuload_widget.cpp b/src/widgets/cpuload_widget.cpp index d1df6989fc..e4660f917a 100644 --- a/src/widgets/cpuload_widget.cpp +++ b/src/widgets/cpuload_widget.cpp @@ -2,7 +2,7 @@ * cpuload_widget.cpp - widget for displaying CPU-load (partly based on * Hydrogen's CPU-load-widget) * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -42,8 +42,9 @@ #include "mixer.h" -cpuloadWidget::cpuloadWidget( QWidget * _parent ) : +cpuloadWidget::cpuloadWidget( QWidget * _parent, engine * _engine ) : QWidget( _parent ), + engineObject( _engine ), m_currentLoad( 0 ), m_temp(), m_background( embed::getIconPixmap( "cpuload_bg" ) ), @@ -103,7 +104,7 @@ void cpuloadWidget::paintEvent( QPaintEvent * ) void cpuloadWidget::updateCpuLoad() { // smooth load-values a bit - Uint8 new_load = ( m_currentLoad + mixer::inst()->cpuLoad() ) / 2; + Uint8 new_load = ( m_currentLoad + eng()->getMixer()->cpuLoad() ) / 2; if( new_load != m_currentLoad ) { m_currentLoad = new_load; diff --git a/src/widgets/group_box.cpp b/src/widgets/group_box.cpp index e1e62cd8c7..4f2b146e92 100644 --- a/src/widgets/group_box.cpp +++ b/src/widgets/group_box.cpp @@ -1,7 +1,7 @@ /* * group_box.cpp - groupbox for LMMS * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * diff --git a/src/widgets/knob.cpp b/src/widgets/knob.cpp index 044a8d60c6..47062ac32c 100644 --- a/src/widgets/knob.cpp +++ b/src/widgets/knob.cpp @@ -4,7 +4,7 @@ * This file is based on the knob-widget of the Qwt Widget Library from * Josef Wilgen * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -53,6 +53,8 @@ #include #include #include +#include +#include #define addSeparator insertSeparator @@ -74,6 +76,7 @@ #include "gui_templates.h" #include "templates.h" #include "string_pair_drag.h" +#include "main_window.h" @@ -87,12 +90,14 @@ textFloat * knob::s_textFloat = NULL; -knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) : +knob::knob( int _knob_num, QWidget * _parent, const QString & _name, + engine * _engine ) : QWidget( _parent #ifndef QT4 , _name.ascii() #endif ), + engineObject( _engine ), m_mouseOffset( 0.0f ), m_buttonPressed( FALSE ), m_angle( 0.0f ), @@ -140,9 +145,9 @@ knob::~knob() { /* // make sure pointer to this knob isn't used anymore in active // midi-device-class - if( mixer::inst()->getMIDIClient()->pitchBendKnob() == this ) + if( eng()->getMixer()->getMIDIClient()->pitchBendKnob() == this ) { - mixer::inst()->getMIDIClient()->setPitchBendKnob( NULL ); + eng()->getMixer()->getMIDIClient()->setPitchBendKnob( NULL ); }*/ } @@ -401,7 +406,7 @@ void knob::dropEvent( QDropEvent * _de ) void knob::mousePressEvent( QMouseEvent * _me ) { if( _me->button() == Qt::LeftButton && - lmmsMainWin::inst()->isCtrlPressed() == FALSE ) + eng()->getMainWindow()->isCtrlPressed() == FALSE ) { const QPoint & p = _me->pos(); m_origMousePos = p; @@ -428,10 +433,10 @@ void knob::mousePressEvent( QMouseEvent * _me ) m_buttonPressed = TRUE; } else if( _me->button() == Qt::LeftButton && - lmmsMainWin::isCtrlPressed() == TRUE ) + eng()->getMainWindow()->isCtrlPressed() == TRUE ) { new stringPairDrag( "float_value", QString::number( value() ), - QPixmap(), this ); + QPixmap(), this, eng() ); } else if( _me->button() == Qt::MidButton ) { @@ -454,7 +459,7 @@ void knob::mouseMoveEvent( QMouseEvent * _me ) { QCursor::setPos( mapToGlobal( m_origMousePos ) ); } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } s_textFloat->setText( m_hintTextBeforeValue + @@ -546,7 +551,7 @@ void knob::wheelEvent( QWheelEvent * _we ) _we->accept(); const int inc = ( _we->delta() > 0 ) ? 1 : -1; incValue( inc ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); s_textFloat->reparent( this ); @@ -747,7 +752,7 @@ void knob::setStep( float _vstep ) void knob::reset( void ) { setValue( m_initValue ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); s_textFloat->reparent( this ); s_textFloat->setText( m_hintTextBeforeValue + QString::number( value() ) + @@ -771,7 +776,7 @@ void knob::copyValue( void ) void knob::pasteValue( void ) { setValue( s_copiedValue ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); s_textFloat->reparent( this ); s_textFloat->setText( m_hintTextBeforeValue + QString::number( value() ) + @@ -812,7 +817,7 @@ void knob::enterValue( void ) void knob::connectToMidiDevice( void ) { - //mixer::inst()->getMIDIDevice()->setPitchBendKnob( this ); + //eng()->getMixer()->getMIDIDevice()->setPitchBendKnob( this ); } diff --git a/src/widgets/pixmap_button.cpp b/src/widgets/pixmap_button.cpp index f6401c2be9..36d3ca06ec 100644 --- a/src/widgets/pixmap_button.cpp +++ b/src/widgets/pixmap_button.cpp @@ -2,7 +2,7 @@ * pixmap_button.cpp - implementation of pixmap-button (often used as "themed" * checkboxes/radiobuttons etc) * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * diff --git a/src/widgets/project_notes.cpp b/src/widgets/project_notes.cpp index e3e69aac26..6de8105fc8 100644 --- a/src/widgets/project_notes.cpp +++ b/src/widgets/project_notes.cpp @@ -1,7 +1,7 @@ /* * project_notes.cpp - implementation of project-notes-editor * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -67,20 +67,21 @@ #include "project_notes.h" #include "embed.h" -#include "lmms_main_win.h" +#include "main_window.h" #include "song_editor.h" -projectNotes::projectNotes() : - QMainWindow( lmmsMainWin::inst()->workspace() +projectNotes::projectNotes( engine * _engine) : + QMainWindow( _engine->getMainWindow()->workspace() #ifndef QT4 , 0, Qt::WStyle_Title #endif - ) + ), + engineObject( _engine ) { #ifdef QT4 - lmmsMainWin::inst()->workspace()->addWindow( this ); + eng()->getMainWindow()->workspace()->addWindow( this ); #endif m_edit = new QTextEdit( this ); @@ -101,13 +102,33 @@ projectNotes::projectNotes() : connect( m_edit, SIGNAL( currentAlignmentChanged( int ) ), this, SLOT( alignmentChanged( int ) ) ); connect( m_edit, SIGNAL( textChanged() ), - songEditor::inst(), SLOT( setModified() ) ); + eng()->getSongEditor(), SLOT( setModified() ) ); setupActions(); setCentralWidget( m_edit ); setWindowTitle( tr( "Project notes" ) ); setWindowIcon( embed::getIconPixmap( "project_notes" ) ); + + resize( 300, 200 ); + if( eng()->getMainWindow()->workspace() != NULL ) + { + move( 700, 10 ); + } + else + { + move( 800, 10 ); + } + + show(); + +} + + + + +projectNotes::~projectNotes() +{ } @@ -405,7 +426,7 @@ void projectNotes::setupActions() void projectNotes::textBold() { m_edit->setFontWeight( m_actionTextBold->isChecked() ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -414,7 +435,7 @@ void projectNotes::textBold() void projectNotes::textUnderline() { m_edit->setFontUnderline( m_actionTextUnderline->isChecked() ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -423,7 +444,7 @@ void projectNotes::textUnderline() void projectNotes::textItalic() { m_edit->setFontItalic( m_actionTextItalic->isChecked() ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -433,7 +454,7 @@ void projectNotes::textFamily( const QString & _f ) { m_edit->setFontFamily( _f ); m_edit->viewport()->setFocus(); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -443,7 +464,7 @@ void projectNotes::textSize( const QString & _p ) { m_edit->setFontPointSize( _p.toInt() ); m_edit->viewport()->setFocus(); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -499,7 +520,7 @@ void projectNotes::fontChanged( const QFont & _f ) m_actionTextBold->setChecked( _f.bold() ); m_actionTextItalic->setChecked( _f.italic() ); m_actionTextUnderline->setChecked( _f.underline() ); - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -514,7 +535,7 @@ void projectNotes::colorChanged( const QColor & _c ) #else m_actionTextColor->setIconSet( pix ); #endif - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } @@ -542,7 +563,7 @@ void projectNotes::alignmentChanged( int _a ) { m_actionAlignJustify->setChecked( TRUE ); } - songEditor::inst()->setModified(); + eng()->getSongEditor()->setModified(); } diff --git a/src/widgets/tempo_sync_knob.cpp b/src/widgets/tempo_sync_knob.cpp index a4e7ced9f0..68fa72eb2a 100644 --- a/src/widgets/tempo_sync_knob.cpp +++ b/src/widgets/tempo_sync_knob.cpp @@ -52,16 +52,18 @@ tempoSyncKnob::tempoSyncKnob( int _knob_num, QWidget * _parent, - const QString & _name, float _scale ) : - knob( _knob_num, _parent, _name ), + const QString & _name, + engine * _engine, + float _scale ) : + knob( _knob_num, _parent, _name, _engine ), m_tempoSyncMode( NO_SYNC ), m_scale( _scale ), m_tempoSyncIcon( embed::getIconPixmap( "xclock" ) ), m_tempoSyncDescription( tr( "Tempo Sync" ) ), m_tempoLastSyncMode( NO_SYNC ) { - connect( songEditor::inst(), SIGNAL( bpmChanged( int ) ), - this, SLOT( calculateTempoSyncTime( int ) ) ); + connect( eng()->getSongEditor(), SIGNAL( tempoChanged( bpm_t ) ), + this, SLOT( calculateTempoSyncTime( bpm_t ) ) ); } @@ -189,7 +191,7 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) void tempoSyncKnob::mouseMoveEvent( QMouseEvent * _me ) { m_tempoSyncMode = NO_SYNC; - calculateTempoSyncTime( songEditor::inst()->getBPM() ); + calculateTempoSyncTime( eng()->getSongEditor()->getTempo() ); knob::mouseMoveEvent( _me ); } @@ -200,7 +202,7 @@ void tempoSyncKnob::wheelEvent( QWheelEvent * _we ) { knob::wheelEvent( _we ); m_tempoSyncMode = NO_SYNC; - calculateTempoSyncTime( songEditor::inst()->getBPM() ); + calculateTempoSyncTime( eng()->getSongEditor()->getTempo() ); } @@ -219,17 +221,18 @@ void tempoSyncKnob::setTempoSync( QAction * ) { } #endif + void tempoSyncKnob::setTempoSync( int _note_type ) { m_tempoSyncMode = ( tempoSyncMode ) _note_type; - calculateTempoSyncTime( songEditor::inst()->getBPM() ); - songEditor::inst()->setModified(); + calculateTempoSyncTime( eng()->getSongEditor()->getTempo() ); + eng()->getSongEditor()->setModified(); } -void tempoSyncKnob::calculateTempoSyncTime( int _bpm ) +void tempoSyncKnob::calculateTempoSyncTime( bpm_t _bpm ) { float conversionFactor = 1.0; @@ -324,7 +327,7 @@ tempoSyncKnob::tempoSyncMode tempoSyncKnob::getSyncMode( void ) void tempoSyncKnob::setSyncMode( tempoSyncMode _new_mode ) { m_tempoSyncMode = _new_mode; - calculateTempoSyncTime( songEditor::inst()->getBPM() ); + calculateTempoSyncTime( eng()->getSongEditor()->getTempo() ); } @@ -341,7 +344,7 @@ float tempoSyncKnob::getScale( void ) void tempoSyncKnob::setScale( float _new_scale ) { m_scale = _new_scale; - calculateTempoSyncTime( songEditor::inst()->getBPM() ); + calculateTempoSyncTime( eng()->getSongEditor()->getTempo() ); emit scaleChanged( _new_scale ); } diff --git a/src/widgets/text_float.cpp b/src/widgets/text_float.cpp index 711ea0e188..77849797c8 100644 --- a/src/widgets/text_float.cpp +++ b/src/widgets/text_float.cpp @@ -1,7 +1,7 @@ /* * text_float.cpp - class textFloat, a floating text-label * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -43,7 +43,6 @@ #include "text_float.h" #include "gui_templates.h" -#include "lmms_main_win.h" @@ -152,10 +151,6 @@ textFloat * textFloat::displayMessage( const QString & _msg, int _timeout, { #ifdef QT4 QWidget * mw = QApplication::activeWindow(); - if( mw == NULL ) - { - mw = lmmsMainWin::inst(); - } #else QWidget * mw = qApp->mainWidget(); if( mw == NULL ) diff --git a/src/widgets/tool_button.cpp b/src/widgets/tool_button.cpp index b78fb7db54..7313ff639d 100644 --- a/src/widgets/tool_button.cpp +++ b/src/widgets/tool_button.cpp @@ -1,7 +1,7 @@ /* * tool_button.cpp - implementation of LMMS-tool-button for common (cool) look * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * diff --git a/src/widgets/visualization_widget.cpp b/src/widgets/visualization_widget.cpp index 74dadf864e..7109c0e661 100644 --- a/src/widgets/visualization_widget.cpp +++ b/src/widgets/visualization_widget.cpp @@ -1,7 +1,7 @@ /* * visualization_widget.cpp - widget for visualization of sound-data * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -53,8 +53,10 @@ const int UPDATE_TIME = 1000 / 20; // 20 fps visualizationWidget::visualizationWidget( const QPixmap & _bg, QWidget * _p, + engine * _engine, visualizationTypes _vtype ) : QWidget( _p ), + engineObject( _engine ), s_background( _bg ), m_enabled( TRUE ) { @@ -64,10 +66,10 @@ visualizationWidget::visualizationWidget( const QPixmap & _bg, QWidget * _p, setFixedSize( s_background.width(), s_background.height() ); - const fpab_t frames = mixer::inst()->framesPerAudioBuffer(); + const fpab_t frames = eng()->getMixer()->framesPerAudioBuffer(); m_buffer = bufferAllocator::alloc( frames ); - mixer::inst()->clearAudioBuffer( m_buffer, frames ); + eng()->getMixer()->clearAudioBuffer( m_buffer, frames ); m_updateTimer = new QTimer( this ); @@ -77,7 +79,7 @@ visualizationWidget::visualizationWidget( const QPixmap & _bg, QWidget * _p, m_updateTimer->start( UPDATE_TIME ); } - connect( mixer::inst(), SIGNAL( nextAudioBuffer( + connect( eng()->getMixer(), SIGNAL( nextAudioBuffer( const surroundSampleFrame *, const fpab_t ) ), this, SLOT( setAudioBuffer( const surroundSampleFrame *, const fpab_t ) ) ); @@ -121,7 +123,7 @@ void visualizationWidget::paintEvent( QPaintEvent * ) if( m_enabled == TRUE ) { - float master_output = mixer::inst()->masterGain(); + float master_output = eng()->getMixer()->masterGain(); Uint16 w = width()-4; float half_h = -( height() - 6 ) / 3.0 * master_output - 1; Uint16 x_base = 2; @@ -136,12 +138,13 @@ void visualizationWidget::paintEvent( QPaintEvent * ) float max_level = 0.0; - const fpab_t frames = mixer::inst()->framesPerAudioBuffer(); + const fpab_t frames = eng()->getMixer()->framesPerAudioBuffer(); // analyse wave-stream for max-level for( fpab_t frame = 0; frame < frames; ++frame ) { - for( ch_cnt_t chnl = 0; chnl < SURROUND_CHANNELS; ++chnl ) + for( ch_cnt_t chnl = 0; chnl < SURROUND_CHANNELS; + ++chnl ) { if( tAbs( m_buffer[frame][chnl] ) > max_level ) @@ -211,5 +214,5 @@ void visualizationWidget::mousePressEvent( QMouseEvent * _me ) -#include +#include "visualization_widget.moc"