diff --git a/ChangeLog b/ChangeLog index 7c011f3dc..bb19360fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,120 @@ +2007-04-24 Javier Serrano Polo + + * include/buffer_allocator.h: + * src/lib/buffer_allocator.cpp: + removed, obsoleted by small audio buffers + + * Makefile.am: + * include/audio_device.h: + * plugins/audio_file_processor/audio_file_processor.cpp: + * plugins/bit_invader/bit_invader.cpp: + * plugins/kicker/kicker.cpp: + * plugins/ladspa_effect/ladspa_effect.cpp: + * plugins/lb302/lb302.cpp: + * plugins/organic/organic.cpp: + * plugins/patman/patman.cpp: + * plugins/plucked_string_synth/plucked_string_synth.cpp: + * plugins/polyb302/polyb302.cpp: + * plugins/singerbot/singerbot.cpp: + * plugins/stk/mallets/mallets.cpp: + * plugins/stk/mallets/mallets.h: + * plugins/triple_oscillator/triple_oscillator.cpp: + * plugins/vestige/vestige.cpp: + * plugins/vibed/vibed.cpp: + * plugins/vibed/vibed.h: + * plugins/vibed/vibrating_string.cpp: + * plugins/vibed/vibrating_string.h: + * plugins/vst_effect/vst_effect.cpp: + * src/lmms_single_source.cpp: + * src/audio/audio_alsa.cpp: + * src/audio/audio_device.cpp: + * src/audio/audio_file_device.cpp: + * src/audio/audio_file_wave.cpp: + * src/audio/audio_jack.cpp: + * src/audio/audio_oss.cpp: + * src/audio/audio_port.cpp: + * src/audio/audio_sample_recorder.cpp: + * src/audio/audio_sdl.cpp: + * src/core/main_window.cpp: + * src/core/mixer.cpp: + * src/core/sample_play_handle.cpp: + * src/tracks/pattern.cpp: + * src/widgets/visualization_widget.cpp: + removed buffer allocator + + * include/automatable_object_templates.h: + initial release, templates extracted from automatable_object.h + + * Makefile.am: + * include/automatable_object.h: + * plugins/ladspa_base/ladspa_control.cpp: + * plugins/ladspa_effect/ladspa_effect.h: + * plugins/patman/patman.cpp: + * plugins/singerbot/singerbot.cpp: + * src/core/automation_editor.cpp: + * src/core/bb_editor.cpp: + * src/core/envelope_and_lfo_widget.cpp: + * src/core/export_project_dialog.cpp: + * src/core/note.cpp: + * src/core/note_play_handle.cpp: + * src/core/piano_roll.cpp: + * src/core/piano_widget.cpp: + * src/core/setup_dialog.cpp: + * src/core/song_editor.cpp: + * src/core/surround_area.cpp: + * src/core/track.cpp: + * src/tracks/instrument_track.cpp: + * src/tracks/sample_track.cpp: + * src/widgets/automatable_button.cpp: + * src/widgets/automatable_slider.cpp: + * src/widgets/combobox.cpp: + * src/widgets/effect_label.cpp: + * src/widgets/knob.cpp: + * src/widgets/lcd_spinbox.cpp: + * src/widgets/led_checkbox.cpp: + * src/widgets/pixmap_button.cpp: + * src/widgets/rack_plugin.cpp: + * src/widgets/tempo_sync_knob.cpp: + * src/widgets/volume_knob.cpp: + reduced dependencies on automatable object + + * src/audio/audio_device.cpp: + * src/core/export_project_dialog.cpp: + * src/core/mixer.cpp: + fixed deadlocks + + * include/audio_dummy.h: + don't process buffers + + * src/audio/audio_sample_recorder.cpp: + fixed high quality + + * include/basic_filters.h: + * include/envelope_and_lfo_widget.h: + * src/core/envelope_tab_widget.cpp: + simplified envelope processing + + * include/basic_filters.h: + - use samplerate member as sample rate + - reformatted + + * plugins/ladspa_effect/ladspa_subplugin_features.cpp: + reverted layout changes in QT3, fixes descriptions + + * plugins/triple_oscillator/artwork.png: + * plugins/triple_oscillator/triple_oscillator.cpp: + updated GUI + + * include/tempo_sync_knob.h: + * src/widgets/tempo_sync_knob.cpp: + graceful shutdown + + * src/widgets/automatable_button.cpp: + fixed undef + + * plugins/ladspa_effect/caps/Makefile.am: + use DESTDIR + 2007-04-21 Javier Serrano Polo * plugins/singerbot/singerbot.cpp: diff --git a/Makefile.am b/Makefile.am index a1972e31a..80244b5ce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -172,7 +172,6 @@ lmms_SOURCES = \ $(srcdir)/src/core/surround_area.cpp \ $(srcdir)/src/core/timeline.cpp \ $(srcdir)/src/lib/base64.cpp \ - $(srcdir)/src/lib/buffer_allocator.cpp \ $(srcdir)/src/lib/clipboard.cpp \ $(srcdir)/src/lib/journalling_object.cpp \ $(srcdir)/src/lib/project_journal.cpp \ @@ -309,7 +308,6 @@ lmms_SOURCES = \ $(srcdir)/include/nstate_button.h \ $(srcdir)/include/midi_dummy.h \ $(srcdir)/include/midi_mapper.h \ - $(srcdir)/include/buffer_allocator.h \ $(srcdir)/include/lcd_spinbox.h \ $(srcdir)/include/tooltip.h \ $(srcdir)/include/automatable_button.h \ @@ -336,6 +334,7 @@ lmms_SOURCES = \ $(srcdir)/include/rubberband.h \ $(srcdir)/include/base64.h \ $(srcdir)/include/automatable_object.h \ + $(srcdir)/include/automatable_object_templates.h \ $(srcdir)/include/journalling_object.h \ $(srcdir)/include/level_object.h \ $(srcdir)/include/project_journal.h \ diff --git a/configure.in b/configure.in index 24eec65fd..967515220 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.2.1-svn20070421, lmms-devel/at/lists/dot/sf/dot/net) -AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20070421) +AC_INIT(lmms, 0.2.1-svn20070424, lmms-devel/at/lists/dot/sf/dot/net) +AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20070424) AM_CONFIG_HEADER(config.h) diff --git a/include/audio_device.h b/include/audio_device.h index c5e5f9187..1977c754e 100644 --- a/include/audio_device.h +++ b/include/audio_device.h @@ -97,10 +97,11 @@ public: return( m_channels ); } - bool processNextBuffer( void ); + void processNextBuffer( void ); virtual void startProcessing( void ) { + m_in_process = TRUE; } virtual void stopProcessing( void ); @@ -175,6 +176,7 @@ private: sample_rate_t m_sampleRate; ch_cnt_t m_channels; mixer * m_mixer; + bool m_in_process; QMutex m_devMutex; diff --git a/include/audio_dummy.h b/include/audio_dummy.h index d909ef5f0..9e1ca5edc 100644 --- a/include/audio_dummy.h +++ b/include/audio_dummy.h @@ -92,10 +92,14 @@ private: while( TRUE ) { timer.reset(); - if ( !processNextBuffer() ) + const surroundSampleFrame * b = + getMixer()->nextBuffer(); + if( !b ) { break; } + delete[] b; + const Sint32 microseconds = static_cast( getMixer()->framesPerAudioBuffer() * 1000000.0f / getMixer()->sampleRate() - diff --git a/include/automatable_object.h b/include/automatable_object.h index 88e5f809d..c69d126ae 100644 --- a/include/automatable_object.h +++ b/include/automatable_object.h @@ -29,29 +29,24 @@ #include #include "qt3support.h" -#include "automation_editor.h" -#include "automation_pattern.h" -#include "engine.h" #include "journalling_object.h" -#include "templates.h" -#include "midi_time.h" #include "level_object.h" #ifndef QT3 -#include -#include #include #else -#include -#include #include #endif +class automationPattern; +class track; + + template class automatableObject : public journallingObject, public levelObject { @@ -60,32 +55,9 @@ public: automatableObject( track * _track = NULL, const T _val = 0, const T _min = 0, const T _max = 0, - const T _step = defaultRelStep() ) : - m_value( _val ), - m_minValue( _min ), - m_maxValue( _max ), - m_step( _step ), - m_automation_pattern( NULL ), - m_track( _track ), - m_journalEntryReady( FALSE ) - { - m_curLevel = level( _val ); - m_minLevel = level( _min ); - m_maxLevel = level( _max ); - } + const T _step = defaultRelStep() ); - virtual ~automatableObject() - { - if( m_automation_pattern ) - { - delete m_automation_pattern; - } - while( m_linkedObjects.empty() == FALSE ) - { - m_linkedObjects.last()->unlinkObject( this ); - m_linkedObjects.erase( m_linkedObjects.end() - 1 ); - } - } + virtual ~automatableObject(); static inline T minRelStep( void ) { @@ -128,217 +100,32 @@ public: return( m_curLevel ); } - inline T fittedValue( T _value ) - { - _value = tLimit( _value, minValue(), maxValue() ); + inline T fittedValue( T _value ); - if( m_step != 0 ) - { - _value = static_cast( roundf( _value - / (float)step() ) * step() ); - } - else - { - _value = minValue(); - } + virtual void setInitValue( const T _value ); - // correct rounding error at the border - if( tAbs( _value - maxValue() ) < minEps() * - tAbs( step() ) ) - { - _value = maxValue(); - } - - // correct rounding error if value = 0 - if( tAbs( _value ) < minEps() * tAbs( step() ) ) - { - _value = 0; - } - - return( _value ); - } - - inline virtual void setInitValue( const T _value ) - { - bool journalling = testAndSetJournalling( FALSE ); - setValue( _value ); - if( m_automation_pattern ) - { - setFirstValue(); - } - setJournalling( journalling ); - } - - inline virtual void setValue( const T _value ) - { - const T old_val = m_value; - - m_value = fittedValue( _value ); - if( old_val != m_value ) - { - m_curLevel = level( m_value ); - - // add changes to history so user can undo it - addJournalEntry( journalEntry( 0, - static_cast( m_value ) - - static_cast( old_val ) ) ); - - // notify linked objects - - // doesn't work because of implicit typename T - // for( autoObjVector::iterator it = - // m_linkedObjects.begin(); - // it != m_linkedObjects.end(); ++it ) - for( csize i = 0; i < m_linkedObjects.size(); ++i ) - { - autoObj * it = m_linkedObjects[i]; - if( value() != it->value() && - it->fittedValue( value() ) != - it->value() ) - { - bool journalling = - it->testAndSetJournalling( - isJournalling() ); - it->setValue( value() ); - it->setJournalling( journalling ); - } - } - } - } + inline virtual void setValue( const T _value ); inline virtual void incValue( int _steps ) { setValue( m_value + _steps * m_step ); } - inline virtual void setRange( const T _min, const T _max, - const T _step = defaultRelStep() ) - { - m_minValue = _min; - m_maxValue = _max; - if( m_minValue > m_maxValue ) - { - qSwap( m_minValue, m_maxValue ); - } - setStep( _step ); - // re-adjust value - autoObj::setInitValue( value() ); - } + virtual void setRange( const T _min, const T _max, + const T _step = defaultRelStep() ); - inline virtual void setStep( const T _step ) - { - /* - const T intv = maxValue() - minValue(); + inline virtual void setStep( const T _step ); - if( _step == 0 ) - { - m_step = intv * defaultRelStep(); - } - else - { - if( ( intv > 0 ) && ( _step < 0 ) || ( intv < 0 ) && - ( _step > 0 ) ) - { - m_step = -_step; - } - else - { - m_step = _step; - } - if( tAbs( m_step ) < - tAbs( minRelStep() * intv ) ) - { - m_step = minRelStep() * intv; - } - }*/ - m_step = _step; - m_curLevel = level( m_value ); - m_minLevel = level( m_minValue ); - m_maxLevel = level( m_maxValue ); - } + static void linkObjects( autoObj * _object1, autoObj * _object2 ); - static inline void linkObjects( autoObj * _object1, - autoObj * _object2 ) - { - _object1->linkObject( _object2 ); - _object2->linkObject( _object1 ); - - if( _object1->m_automation_pattern - != _object2->m_automation_pattern ) - { - if( _object2->m_automation_pattern ) - { - delete _object2->m_automation_pattern; - } - _object2->m_automation_pattern - = _object1->m_automation_pattern; - } - } - - static void unlinkObjects( autoObj * _object1, - autoObj * _object2 ) - { - _object1->unlinkObject( _object2 ); - _object2->unlinkObject( _object1 ); - - if( _object1->m_automation_pattern - && _object1->m_automation_pattern - == _object2->m_automation_pattern ) - { - _object2->m_automation_pattern = new automationPattern( - *_object1->m_automation_pattern, _object2 ); - } - } + static void unlinkObjects( autoObj * _object1, autoObj * _object2 ); virtual void FASTCALL saveSettings( QDomDocument & _doc, QDomElement & _this, - const QString & _name = "value" ) - { - if( m_automation_pattern ) - { - QDomElement pattern_element; - QDomNode node = _this.namedItem( - automationPattern::classNodeName() ); - if( node.isElement() ) - { - pattern_element = node.toElement(); - } - else - { - pattern_element = _doc.createElement( - automationPattern::classNodeName() ); - _this.appendChild( pattern_element ); - } - QDomElement element = _doc.createElement( _name ); - m_automation_pattern->saveSettings( _doc, element ); - pattern_element.appendChild( element ); - } - else - { - _this.setAttribute( _name, value() ); - } - } + const QString & _name = "value" ); virtual void FASTCALL loadSettings( const QDomElement & _this, - const QString & _name = "value" ) - { - QDomNode node = _this.namedItem( - automationPattern::classNodeName() ); - if( node.isElement() ) - { - node = node.namedItem( _name ); - if( node.isElement() ) - { - m_automation_pattern->loadSettings( - node.toElement() ); - setLevel( m_automation_pattern->valueAt( - midiTime( 0 ) ) ); - return; - } - } - - setInitValue( attributeValue( _this.attribute( _name ) ) ); - } + const QString & _name = "value" ); virtual QString nodeName( void ) const { @@ -355,16 +142,7 @@ public: m_data = _data; } - inline automationPattern * getAutomationPattern( void ) - { - if( !m_automation_pattern ) - { - m_automation_pattern = new automationPattern( m_track, - this ); - syncAutomationPattern(); - } - return( m_automation_pattern ); - } + inline automationPattern * getAutomationPattern( void ); inline bool nullTrack( void ) { @@ -378,67 +156,15 @@ public: protected: - virtual void redoStep( journalEntry & _je ) - { - bool journalling = testAndSetJournalling( FALSE ); -/*#ifndef QT3 - setValue( static_cast( value() + - _je.data().value() ) ); -#else*/ - setValue( static_cast( value() + static_cast( - _je.data().toDouble() ) ) ); -//#endif - setJournalling( journalling ); - } + virtual void redoStep( journalEntry & _je ); - virtual void undoStep( journalEntry & _je ) - { - journalEntry je( _je.actionID(), -/*#ifndef QT3 - -_je.data().value() -#else*/ - static_cast( -_je.data().toDouble() ) -//#endif - ); - redoStep( je ); - } + virtual void undoStep( journalEntry & _je ); - inline void prepareJournalEntryFromOldVal( void ) - { - m_oldValue = value(); - saveJournallingState( FALSE ); - m_journalEntryReady = TRUE; - } + void prepareJournalEntryFromOldVal( void ); - inline void addJournalEntryFromOldToCurVal( void ) - { - if( m_journalEntryReady ) - { - restoreJournallingState(); - if( value() != m_oldValue ) - { - addJournalEntry( journalEntry( 0, value() - - m_oldValue ) ); - } - m_journalEntryReady = FALSE; - } - } + void addJournalEntryFromOldToCurVal( void ); - inline void setFirstValue( void ) - { - if( m_automation_pattern - && m_automation_pattern->updateFirst() ) - { - m_automation_pattern->putValue( midiTime( 0 ), - m_curLevel, FALSE ); - if( engine::getAutomationEditor() && - engine::getAutomationEditor()->currentPattern() - == m_automation_pattern ) - { - engine::getAutomationEditor()->update(); - } - } - } + inline void setFirstValue( void ); private: @@ -459,52 +185,15 @@ private: typedef vvector autoObjVector; autoObjVector m_linkedObjects; - inline void linkObject( autoObj * _object ) - { - if( qFind( m_linkedObjects.begin(), m_linkedObjects.end(), - _object ) == m_linkedObjects.end() ) - { - m_linkedObjects.push_back( _object ); - } - } + inline void linkObject( autoObj * _object ); - inline void unlinkObject( autoObj * _object ) - { - if( qFind( m_linkedObjects.begin(), m_linkedObjects.end(), - _object ) != m_linkedObjects.end() ) - { - m_linkedObjects.erase( qFind( m_linkedObjects.begin(), - m_linkedObjects.end(), - _object ) ); - } - } + inline void unlinkObject( autoObj * _object ); - static T attributeValue( QString _value ); + static inline T attributeValue( QString _value ); - inline void syncAutomationPattern( void ) - { - for( csize i = 0; i < m_linkedObjects.size(); ++i ) - { - autoObj * it = m_linkedObjects[i]; - if( m_automation_pattern != it->m_automation_pattern ) - { - it->m_automation_pattern = m_automation_pattern; - } - } - } + inline void syncAutomationPattern( void ); - void setLevel( int _level ) - { - if( m_curLevel == _level ) - { - return; - } - bool journalling = testAndSetJournalling( FALSE ); - m_automation_pattern->setUpdateFirst( FALSE ); - setValue( _level * m_step ); - m_automation_pattern->setUpdateFirst( TRUE ); - setJournalling( journalling ); - } + inline void setLevel( int _level ); inline int level( T _value ) const { @@ -525,54 +214,6 @@ private: -template<> -inline float automatableObject::minRelStep( void ) -{ - return( 1.0e-10 ); -} - - - -template<> -inline float automatableObject::defaultRelStep( void ) -{ - return( 1.0e-2 ); -} - - -template<> -inline float automatableObject::minEps( void ) -{ - return( 1.0e-10 ); -} - - - -template<> -inline float automatableObject::attributeValue( QString _value ) -{ - return( _value.toFloat() ); -} - - - -template<> -inline int automatableObject::attributeValue( QString _value ) -{ - return( _value.toInt() ); -} - - - -template<> -inline bool automatableObject::attributeValue( - QString _value ) -{ - return( static_cast( _value.toInt() ) ); -} - - - #endif diff --git a/include/automatable_object_templates.h b/include/automatable_object_templates.h new file mode 100644 index 000000000..7853ac26e --- /dev/null +++ b/include/automatable_object_templates.h @@ -0,0 +1,533 @@ +/* + * automatable_object_templates.h - definition of automatableObject templates + * + * Copyright (c) 2006-2007 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + + +#ifndef _AUTOMATABLE_OBJECT_TEMPLATES_H +#define _AUTOMATABLE_OBJECT_TEMPLATES_H + + +#include "automatable_object.h" +#include "automation_editor.h" +#include "automation_pattern.h" +#include "engine.h" +#include "templates.h" + +#ifndef QT3 + +#include + +#else + +#include + +#endif + + +template +automatableObject::automatableObject( track * _track, + const T _val, const T _min, + const T _max, const T _step ) : + m_value( _val ), + m_minValue( _min ), + m_maxValue( _max ), + m_step( _step ), + m_automation_pattern( NULL ), + m_track( _track ), + m_journalEntryReady( FALSE ) +{ + m_curLevel = level( _val ); + m_minLevel = level( _min ); + m_maxLevel = level( _max ); +} + + + + +template +automatableObject::~automatableObject() +{ + if( m_automation_pattern ) + { + delete m_automation_pattern; + } + while( m_linkedObjects.empty() == FALSE ) + { + m_linkedObjects.last()->unlinkObject( this ); + m_linkedObjects.erase( m_linkedObjects.end() - 1 ); + } +} + + + + +template +T automatableObject::fittedValue( T _value ) +{ + _value = tLimit( _value, minValue(), maxValue() ); + + if( m_step != 0 ) + { + _value = static_cast( roundf( _value / (float)step() ) + * step() ); + } + else + { + _value = minValue(); + } + + // correct rounding error at the border + if( tAbs( _value - maxValue() ) < minEps() * tAbs( step() ) ) + { + _value = maxValue(); + } + + // correct rounding error if value = 0 + if( tAbs( _value ) < minEps() * tAbs( step() ) ) + { + _value = 0; + } + + return( _value ); +} + + + + +template +void automatableObject::setInitValue( const T _value ) +{ + bool journalling = testAndSetJournalling( FALSE ); + setValue( _value ); + if( m_automation_pattern ) + { + setFirstValue(); + } + setJournalling( journalling ); +} + + + + +template +void automatableObject::setValue( const T _value ) +{ + const T old_val = m_value; + + m_value = fittedValue( _value ); + if( old_val != m_value ) + { + m_curLevel = level( m_value ); + + // add changes to history so user can undo it + addJournalEntry( journalEntry( 0, + static_cast( m_value ) - + static_cast( old_val ) ) ); + + // notify linked objects + + // doesn't work because of implicit typename T + // for( autoObjVector::iterator it = + // m_linkedObjects.begin(); + // it != m_linkedObjects.end(); ++it ) + for( csize i = 0; i < m_linkedObjects.size(); ++i ) + { + autoObj * it = m_linkedObjects[i]; + if( value() != it->value() && it->fittedValue( value() ) + != it->value() ) + { + bool journalling = it->testAndSetJournalling( + isJournalling() ); + it->setValue( value() ); + it->setJournalling( journalling ); + } + } + } +} + + + + +template +void automatableObject::setRange( const T _min, const T _max, + const T _step ) +{ + m_minValue = _min; + m_maxValue = _max; + if( m_minValue > m_maxValue ) + { + qSwap( m_minValue, m_maxValue ); + } + setStep( _step ); + // re-adjust value + autoObj::setInitValue( value() ); +} + + + + +template +void automatableObject::setStep( const T _step ) +{ + /* + const T intv = maxValue() - minValue(); + + if( _step == 0 ) + { + m_step = intv * defaultRelStep(); + } + else + { + if( ( intv > 0 ) && ( _step < 0 ) || ( intv < 0 ) && + ( _step > 0 ) ) + { + m_step = -_step; + } + else + { + m_step = _step; + } + if( tAbs( m_step ) < tAbs( minRelStep() * intv ) ) + { + m_step = minRelStep() * intv; + } + }*/ + m_step = _step; + m_curLevel = level( m_value ); + m_minLevel = level( m_minValue ); + m_maxLevel = level( m_maxValue ); +} + + + + +template +void automatableObject::linkObjects( autoObj * _object1, + autoObj * _object2 ) +{ + _object1->linkObject( _object2 ); + _object2->linkObject( _object1 ); + + if( _object1->m_automation_pattern != _object2->m_automation_pattern ) + { + if( _object2->m_automation_pattern ) + { + delete _object2->m_automation_pattern; + } + _object2->m_automation_pattern = _object1->m_automation_pattern; + } +} + + + + +template +void automatableObject::unlinkObjects( autoObj * _object1, + autoObj * _object2 ) +{ + _object1->unlinkObject( _object2 ); + _object2->unlinkObject( _object1 ); + + if( _object1->m_automation_pattern && _object1->m_automation_pattern + == _object2->m_automation_pattern ) + { + _object2->m_automation_pattern = new automationPattern( + *_object1->m_automation_pattern, _object2 ); + } +} + + + + +template +void automatableObject::saveSettings( QDomDocument & _doc, + QDomElement & _this, + const QString & _name ) +{ + if( m_automation_pattern ) + { + QDomElement pattern_element; + QDomNode node = _this.namedItem( + automationPattern::classNodeName() ); + if( node.isElement() ) + { + pattern_element = node.toElement(); + } + else + { + pattern_element = _doc.createElement( + automationPattern::classNodeName() ); + _this.appendChild( pattern_element ); + } + QDomElement element = _doc.createElement( _name ); + m_automation_pattern->saveSettings( _doc, element ); + pattern_element.appendChild( element ); + } + else + { + _this.setAttribute( _name, value() ); + } +} + + + + +template +void automatableObject::loadSettings( + const QDomElement & _this, + const QString & _name ) +{ + QDomNode node = _this.namedItem( automationPattern::classNodeName() ); + if( node.isElement() ) + { + node = node.namedItem( _name ); + if( node.isElement() ) + { + m_automation_pattern->loadSettings( node.toElement() ); + setLevel( m_automation_pattern->valueAt( + midiTime( 0 ) ) ); + return; + } + } + + setInitValue( attributeValue( _this.attribute( _name ) ) ); +} + + + + +template +automationPattern * automatableObject::getAutomationPattern( + void ) +{ + if( !m_automation_pattern ) + { + m_automation_pattern = new automationPattern( m_track, this ); + syncAutomationPattern(); + } + return( m_automation_pattern ); +} + + + + +template +void automatableObject::redoStep( journalEntry & _je ) +{ + bool journalling = testAndSetJournalling( FALSE ); +/*#ifndef QT3 + setValue( static_cast( value() + + _je.data().value() ) ); +#else*/ + setValue( static_cast( value() + static_cast( + _je.data().toDouble() ) ) ); +//#endif + setJournalling( journalling ); +} + + + + +template +void automatableObject::undoStep( journalEntry & _je ) +{ + journalEntry je( _je.actionID(), +/*#ifndef QT3 + -_je.data().value() +#else*/ + static_cast( -_je.data().toDouble() ) +//#endif + ); + redoStep( je ); +} + + + + +template +void automatableObject::prepareJournalEntryFromOldVal( void ) +{ + m_oldValue = value(); + saveJournallingState( FALSE ); + m_journalEntryReady = TRUE; +} + + + + +template +void automatableObject::addJournalEntryFromOldToCurVal( + void ) +{ + if( m_journalEntryReady ) + { + restoreJournallingState(); + if( value() != m_oldValue ) + { + addJournalEntry( journalEntry( 0, value() - + m_oldValue ) ); + } + m_journalEntryReady = FALSE; + } +} + + + + +template +void automatableObject::setFirstValue( void ) +{ + if( m_automation_pattern && m_automation_pattern->updateFirst() ) + { + m_automation_pattern->putValue( midiTime( 0 ), m_curLevel, + FALSE ); + if( engine::getAutomationEditor() && + engine::getAutomationEditor()->currentPattern() + == m_automation_pattern ) + { + engine::getAutomationEditor()->update(); + } + } +} + + + + +template +void automatableObject::linkObject( autoObj * _object ) +{ + if( qFind( m_linkedObjects.begin(), m_linkedObjects.end(), _object ) + == m_linkedObjects.end() ) + { + m_linkedObjects.push_back( _object ); + } +} + + + + +template +void automatableObject::unlinkObject( autoObj * _object ) +{ + if( qFind( m_linkedObjects.begin(), m_linkedObjects.end(), _object ) + != m_linkedObjects.end() ) + { + m_linkedObjects.erase( qFind( m_linkedObjects.begin(), + m_linkedObjects.end(), + _object ) ); + } +} + + + + +template +void automatableObject::syncAutomationPattern( void ) +{ + for( csize i = 0; i < m_linkedObjects.size(); ++i ) + { + autoObj * it = m_linkedObjects[i]; + if( m_automation_pattern != it->m_automation_pattern ) + { + it->m_automation_pattern = m_automation_pattern; + } + } +} + + + + +template +void automatableObject::setLevel( int _level ) +{ + if( m_curLevel == _level ) + { + return; + } + bool journalling = testAndSetJournalling( FALSE ); + m_automation_pattern->setUpdateFirst( FALSE ); + setValue( _level * m_step ); + m_automation_pattern->setUpdateFirst( TRUE ); + setJournalling( journalling ); +} + + + + +template<> +inline float automatableObject::minRelStep( void ) +{ + return( 1.0e-10 ); +} + + + + +template<> +inline float automatableObject::defaultRelStep( void ) +{ + return( 1.0e-2 ); +} + + + + +template<> +inline float automatableObject::minEps( void ) +{ + return( 1.0e-10 ); +} + + + + +template<> +inline float automatableObject::attributeValue( QString _value ) +{ + return( _value.toFloat() ); +} + + + + +template<> +inline int automatableObject::attributeValue( QString _value ) +{ + return( _value.toInt() ); +} + + + + +template<> +inline bool automatableObject::attributeValue( + QString _value ) +{ + return( static_cast( _value.toInt() ) ); +} + + + + +#endif + diff --git a/include/basic_filters.h b/include/basic_filters.h index a581a70ab..53bca10b9 100644 --- a/include/basic_filters.h +++ b/include/basic_filters.h @@ -82,7 +82,7 @@ public: m_b2a0( 0.0f ), m_a1a0( 0.0f ), m_a2a0( 0.0f ), - m_sampleRate( 1.0f / _sample_rate ), + m_sampleRate( _sample_rate ), m_subFilter( NULL ) { // reset in/out history @@ -231,13 +231,17 @@ public: return( out ); } - - inline void calcFilterCoeffs( const filterTypes _type, float _freq, - float _q + + void setType( const filterTypes _type ) + { + m_type = _type; + } + + + inline void calcFilterCoeffs( float _freq, float _q /*, const bool _q_is_bandwidth = FALSE*/ ) { // temp coef vars - m_type = _type; _freq = tMax( _freq, 0.01f );// limit freq and q for not getting // bad noise out of the filter... _q = tMax( _q, minQ() ); @@ -250,21 +254,21 @@ public: { m_subFilter = new basicFilters( - static_cast( 1.0f / m_sampleRate ) ); + static_cast( m_sampleRate ) ); + m_subFilter->setType( MOOG ); } - m_subFilter->calcFilterCoeffs( MOOG, _freq, - _q ); + m_subFilter->calcFilterCoeffs( _freq, _q ); } case MOOG: { // [ 0 - 1 ] - const float f = 2 * _freq * m_sampleRate; + const float f = 2 * _freq / m_sampleRate; // (Empirical tunning) - m_k = 3.6f*f - 1.6f*f*f - 1; - m_p = (m_k+1)*0.5f; - m_r = _q*powf( M_E, ( ( 1-m_p ) * 1.386249f ) ); - break; + m_k = 3.6f * f - 1.6f * f * f - 1; + m_p = ( m_k + 1 ) * 0.5f; + m_r = _q * powf( M_E, ( 1 - m_p ) * 1.386249f ); + return; } /* case DOUBLE_MOOG2: @@ -273,7 +277,7 @@ public: { m_subFilter = new basicFilters( - 1.0f / m_sampleRate ); + m_sampleRate ); } m_subFilter->calcFilterCoeffs( MOOG2, _freq, _q ); @@ -281,8 +285,8 @@ public: case MOOG2: { - const float kfc = 2 * _freq * m_sampleRate; - const float kf = _freq * m_sampleRate; + const float kfc = 2 * _freq / m_sampleRate; + const float kf = _freq / m_sampleRate; const float kfcr = 1.8730 * ( kfc*kfc*kfc ) + 0.4955 * ( kfc*kfc ) + 0.6490 * kfc + 0.9988; @@ -295,81 +299,79 @@ public: }*/ default: - { - // other filters - const float omega = F_2PI * _freq * - m_sampleRate; - const float tsin = sinf( omega ); - const float tcos = cosf( omega ); - //float alpha; - - //if (q_is_bandwidth) - //alpha = tsin*sinhf(logf(2.0f)/2.0f*q*omega/ - // tsin); - //else - const float alpha = 0.5f * tsin / _q; - - const float a0 = 1.0f / ( 1.0f + alpha ); - - if( m_type == LOWPASS || - m_type == DOUBLE_LOWPASS ) - { - m_b0a0 = ((1.0f-tcos)*0.5f)*a0; - m_b1a0 = (1.0f-tcos)*a0; - m_b2a0 = m_b0a0;//((1.0f-tcos)/2.0f)*a0; - m_a1a0 = (-2.0f*tcos)*a0; - if( m_type == DOUBLE_LOWPASS ) - { - if( m_subFilter == NULL ) - { - m_subFilter = - new basicFilters( static_cast( - 1.0f / m_sampleRate ) ); - } - m_subFilter->calcFilterCoeffs( - LOWPASS, _freq, _q ); - } - } - else if( m_type == HIPASS ) - { - m_b0a0 = ((1.0f+tcos)*0.5f)*a0; - m_b1a0 = (-1.0f-tcos)*a0; - m_b2a0 = m_b0a0;//((1.0f+tcos)/2.0f)*a0; - m_a1a0 = (-2.0f*tcos)*a0; - } - else if( m_type == BANDPASS_CSG ) - { - m_b0a0 = tsin*0.5f*a0; - m_b1a0 = 0.0f; - m_b2a0 = -tsin*0.5f*a0; - m_a1a0 = (-2.0f*tcos)*a0; - } - else if( m_type == BANDPASS_CZPG ) - { - m_b0a0 = alpha*a0; - m_b1a0 = 0.0f; - m_b2a0 = (-alpha)*a0; - m_a1a0 = (-2.0f*tcos)*a0; - } - else if( m_type == NOTCH ) - { - m_b0a0 = a0; - m_b1a0 = (-2.0f*tcos)*a0; - m_b2a0 = a0; - m_a1a0 = m_b1a0;//(-2.0f*tcos)*a0; - } - else if( m_type == ALLPASS ) - { - m_b0a0 = (1.0f-alpha)*a0; - m_b1a0 = (-2.0f*tcos)*a0; - m_b2a0 = 1.0;//(1.0f+alpha)*a0; - m_a1a0 = m_b1a0;//(-2.0f*tcos)*a0; - //m_a2a0 = m_b0a0;//(1.0f-alpha)*a0; - } - m_a2a0 = (1.0f-alpha)*a0; break; - } } + + // other filters + const float omega = F_2PI * _freq / m_sampleRate; + const float tsin = sinf( omega ); + const float tcos = cosf( omega ); + //float alpha; + + //if (q_is_bandwidth) + //alpha = tsin*sinhf(logf(2.0f)/2.0f*q*omega/ + // tsin); + //else + const float alpha = 0.5f * tsin / _q; + + const float a0 = 1.0f / ( 1.0f + alpha ); + + switch( m_type ) + { + case LOWPASS: + case DOUBLE_LOWPASS: + m_b0a0 = ( 1.0f - tcos ) * 0.5f * a0; + m_b1a0 = ( 1.0f - tcos ) * a0; + m_b2a0 = m_b0a0;//((1.0f-tcos)/2.0f)*a0; + m_a1a0 = -2.0f * tcos * a0; + if( m_type == DOUBLE_LOWPASS ) + { + if( m_subFilter == NULL ) + { + m_subFilter = + new basicFilters( static_cast( + m_sampleRate ) ); + m_subFilter->setType( LOWPASS ); + } + m_subFilter->calcFilterCoeffs( _freq, + _q ); + } + break; + case HIPASS: + m_b0a0 = ( 1.0f + tcos ) * 0.5f * a0; + m_b1a0 = ( -1.0f - tcos ) * a0; + m_b2a0 = m_b0a0;//((1.0f+tcos)/2.0f)*a0; + m_a1a0 = -2.0f * tcos * a0; + break; + case BANDPASS_CSG: + m_b0a0 = tsin * 0.5f * a0; + m_b1a0 = 0.0f; + m_b2a0 = -tsin * 0.5f * a0; + m_a1a0 = -2.0f * tcos * a0; + break; + case BANDPASS_CZPG: + m_b0a0 = alpha * a0; + m_b1a0 = 0.0f; + m_b2a0 = -alpha * a0; + m_a1a0 = -2.0f * tcos * a0; + break; + case NOTCH: + m_b0a0 = a0; + m_b1a0 = -2.0f * tcos * a0; + m_b2a0 = a0; + m_a1a0 = m_b1a0;//(-2.0f*tcos)*a0; + break; + case ALLPASS: + m_b0a0 = ( 1.0f - alpha ) * a0; + m_b1a0 = -2.0f * tcos * a0; + m_b2a0 = 1.0f;//(1.0f+alpha)*a0; + m_a1a0 = m_b1a0;//(-2.0f*tcos)*a0; + //m_a2a0 = m_b0a0;//(1.0f-alpha)*a0; + break; + default: + break; + } + m_a2a0 = ( 1.0f - alpha ) * a0; } diff --git a/include/buffer_allocator.h b/include/buffer_allocator.h deleted file mode 100644 index 51b68218f..000000000 --- a/include/buffer_allocator.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * buffer_allocator.h - namespace bufferAllocator providing routines for own - * optimized memory-management for audio-buffers - * - * Copyright (c) 2005-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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - */ - - -#ifndef _BUFFER_ALLOCATOR_H -#define _BUFFER_ALLOCATOR_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "types.h" - - - - -namespace bufferAllocator -{ - void * FASTCALL allocBytes( const Uint32 _bytes ); - - template - inline T * FASTCALL alloc( const Uint32 _n ) - { - return( (T *) allocBytes( sizeof( T ) * _n ) ); - } - - // free given buffer - void FASTCALL free( void * _buf ); - - // try to cleanup _level unused buffers - void FASTCALL cleanUp( const Uint16 _level ); - - // disable autocleanup-mechanisms - void FASTCALL disableAutoCleanup( const bool _disabled ); - - - // simple class for automatically freeing buffer in complex functions - template - class autoCleaner - { - public: - autoCleaner( T * _ptr ) : - m_ptr( _ptr ) - { - } - ~autoCleaner() - { - bufferAllocator::free( m_ptr ); - } - inline const T * ptr( void ) const - { - return( m_ptr ); - } - - private: - T * m_ptr; - } ; - -} ; - - -#endif diff --git a/include/envelope_and_lfo_widget.h b/include/envelope_and_lfo_widget.h index 2ff7b889f..c10a974cd 100644 --- a/include/envelope_and_lfo_widget.h +++ b/include/envelope_and_lfo_widget.h @@ -77,9 +77,9 @@ public: track * _track ); virtual ~envelopeAndLFOWidget(); - static inline float expKnobVal( float val ) + static inline float expKnobVal( float _val ) { - return( ( ( val < 0 ) ? -1 : 1 ) * val*val ); + return( ( ( _val < 0 ) ? -_val : _val ) * _val ); } static void triggerLFO( void ); diff --git a/include/tempo_sync_knob.h b/include/tempo_sync_knob.h index 96ee52f73..bb01a7b1c 100644 --- a/include/tempo_sync_knob.h +++ b/include/tempo_sync_knob.h @@ -114,7 +114,8 @@ private: QString m_tempoSyncDescription; tempoSyncMode m_tempoLastSyncMode; - meterDialog * m_custom; + QPointer m_custom; + } ; diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index e003f695a..f3581ab32 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -50,7 +50,6 @@ #include "instrument_track.h" #include "note_play_handle.h" #include "interpolation.h" -#include "buffer_allocator.h" #include "file_browser.h" #include "pixmap_button.h" #include "knob.h" @@ -393,7 +392,7 @@ void audioFileProcessor::setAudioFile( const QString & _audio_file, bool _rename void audioFileProcessor::playNote( notePlayHandle * _n, bool ) { const Uint32 frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; // calculate frequency of note const float note_freq = getInstrumentTrack()->frequency( _n ); @@ -409,7 +408,7 @@ void audioFileProcessor::playNote( notePlayHandle * _n, bool ) { getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); } - bufferAllocator::free( buf ); + delete[] buf; } diff --git a/plugins/bit_invader/bit_invader.cpp b/plugins/bit_invader/bit_invader.cpp index 544a0bfcd..d24d15815 100644 --- a/plugins/bit_invader/bit_invader.cpp +++ b/plugins/bit_invader/bit_invader.cpp @@ -56,7 +56,6 @@ using namespace std; #include "instrument_track.h" #include "note_play_handle.h" #include "templates.h" -#include "buffer_allocator.h" #include "knob.h" #include "pixmap_button.h" #include "tooltip.h" @@ -701,7 +700,7 @@ void bitInvader::playNote( notePlayHandle * _n, bool ) } const fpab_t frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; bSynth * ps = static_cast( _n->m_pluginData ); for( fpab_t frame = 0; frame < frames; ++frame ) @@ -715,7 +714,7 @@ void bitInvader::playNote( notePlayHandle * _n, bool ) getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); - bufferAllocator::free( buf ); + delete[] buf; } diff --git a/plugins/kicker/kicker.cpp b/plugins/kicker/kicker.cpp index 5cb055dcf..7c90b4e8d 100644 --- a/plugins/kicker/kicker.cpp +++ b/plugins/kicker/kicker.cpp @@ -42,7 +42,6 @@ #include "instrument_track.h" #include "note_play_handle.h" #include "sweep_oscillator.h" -#include "buffer_allocator.h" #include "knob.h" #undef SINGLE_SOURCE_COMPILE @@ -201,7 +200,7 @@ void kickerInstrument::playNote( notePlayHandle * _n, bool ) const float f1 = m_startFreqKnob->value() + tfp * fdiff / decfr; const float f2 = m_startFreqKnob->value() + (frames+tfp-1)*fdiff/decfr; - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; sweepOsc * so = static_cast( _n->m_pluginData ); @@ -223,7 +222,7 @@ void kickerInstrument::playNote( notePlayHandle * _n, bool ) getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); - bufferAllocator::free( buf ); + delete[] buf; } diff --git a/plugins/ladspa_base/ladspa_control.cpp b/plugins/ladspa_base/ladspa_control.cpp index ae9a47f3c..cc2c9af7f 100644 --- a/plugins/ladspa_base/ladspa_control.cpp +++ b/plugins/ladspa_base/ladspa_control.cpp @@ -37,6 +37,7 @@ #include "ladspa_control.h" +#include "automatable_object_templates.h" #include "ladspa_base.h" #include "tooltip.h" #include "tempo_sync_knob.h" diff --git a/plugins/ladspa_effect/caps/Makefile.am b/plugins/ladspa_effect/caps/Makefile.am index 35b2473fa..1a11b1e11 100644 --- a/plugins/ladspa_effect/caps/Makefile.am +++ b/plugins/ladspa_effect/caps/Makefile.am @@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = foreign 1.4 AM_CXXFLAGS := $(AM_CXXFLAGS) -O6 -ffast-math -funroll-loops -ftracer -I../../../include -DEST = $(libdir)/$(PACKAGE)/ladspa +DEST = $(DESTDIR)$(libdir)/$(PACKAGE)/ladspa SOURCES = $(wildcard *.cc) HDRS = $(wildcard *.h) $(wildcard dsp/*.h) OBJECTS = $(SOURCES:.cc=.o) diff --git a/plugins/ladspa_effect/ladspa_effect.cpp b/plugins/ladspa_effect/ladspa_effect.cpp index 45f8d9163..1fc191d22 100644 --- a/plugins/ladspa_effect/ladspa_effect.cpp +++ b/plugins/ladspa_effect/ladspa_effect.cpp @@ -40,7 +40,6 @@ #include "ladspa_effect.h" #include "mixer.h" #include "config_mgr.h" -#include "buffer_allocator.h" #include "audio_device.h" #include "ladspa_control.h" #include "ladspa_subplugin_features.h" diff --git a/plugins/ladspa_effect/ladspa_effect.h b/plugins/ladspa_effect/ladspa_effect.h index db57904fa..18641e082 100644 --- a/plugins/ladspa_effect/ladspa_effect.h +++ b/plugins/ladspa_effect/ladspa_effect.h @@ -32,6 +32,7 @@ #include "qt3support.h" #include "effect.h" +#include "engine.h" #include "ladspa_2_lmms.h" #include "mixer.h" #include "ladspa_control.h" diff --git a/plugins/ladspa_effect/ladspa_subplugin_features.cpp b/plugins/ladspa_effect/ladspa_subplugin_features.cpp index 45d670b90..6c5017d70 100644 --- a/plugins/ladspa_effect/ladspa_subplugin_features.cpp +++ b/plugins/ladspa_effect/ladspa_subplugin_features.cpp @@ -36,7 +36,8 @@ #else -#include +#include +//#include #include #include @@ -67,10 +68,14 @@ void ladspaSubPluginFeatures::fillDescriptionWidget( QWidget * _parent, QLabel * label = new QLabel( _parent ); label->setText( QWidget::tr( "Name: " ) + lm->getName( lkey ) ); +#ifndef QT3 QWidget * maker = new QWidget( _parent ); QHBoxLayout * l = new QHBoxLayout( maker ); l->setMargin( 0 ); l->setSpacing( 0 ); +#else + QHBox * maker = new QHBox( _parent ); +#endif QLabel * maker_label = new QLabel( maker ); maker_label->setText( QWidget::tr( "Maker: " ) ); @@ -79,16 +84,21 @@ void ladspaSubPluginFeatures::fillDescriptionWidget( QWidget * _parent, maker_content->setText( lm->getMaker( lkey ) ); #ifndef QT3 maker_content->setWordWrap( TRUE ); + l->setStretchFactor( maker_content, 100 ); #else maker_content->setAlignment( Qt::WordBreak ); + maker->setStretchFactor( maker_content, 100 ); #endif - l->setStretchFactor( maker_content, 100 ); +#ifndef QT3 QWidget * copyright = new QWidget( _parent ); l = new QHBoxLayout( copyright ); l->setMargin( 0 ); l->setSpacing( 0 ); +#else + QHBox * copyright = new QHBox( _parent ); +#endif copyright->setMinimumWidth( _parent->minimumWidth() ); QLabel * copyright_label = new QLabel( copyright ); @@ -98,10 +108,11 @@ void ladspaSubPluginFeatures::fillDescriptionWidget( QWidget * _parent, copyright_content->setText( lm->getCopyright( lkey ) ); #ifndef QT3 copyright_content->setWordWrap( TRUE ); + l->setStretchFactor( copyright_content, 100 ); #else copyright_content->setAlignment( Qt::WordBreak ); + copyright->setStretchFactor( copyright_content, 100 ); #endif - l->setStretchFactor( copyright_content, 100 ); QLabel * requiresRealTime = new QLabel( _parent ); requiresRealTime->setText( QWidget::tr( "Requires Real Time: " ) + diff --git a/plugins/lb302/lb302.cpp b/plugins/lb302/lb302.cpp index 918ea8be4..61ef37cc8 100644 --- a/plugins/lb302/lb302.cpp +++ b/plugins/lb302/lb302.cpp @@ -46,7 +46,6 @@ #include "instrument_play_handle.h" #include "note_play_handle.h" #include "templates.h" -#include "buffer_allocator.h" #include "knob.h" #undef SINGLE_SOURCE_COMPILE @@ -731,14 +730,12 @@ void lb302Synth::playNote( notePlayHandle * _n, bool ) } const Uint32 frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame *buf = bufferAllocator::alloc( frames ); + sampleFrame *buf = new sampleFrame[frames]; - if (buf) { process(buf, frames); getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); - bufferAllocator::free( buf ); - } + delete[] buf; lastFramesPlayed = _n->totalFramesPlayed(); } diff --git a/plugins/organic/organic.cpp b/plugins/organic/organic.cpp index d2623d58b..270783241 100644 --- a/plugins/organic/organic.cpp +++ b/plugins/organic/organic.cpp @@ -54,7 +54,6 @@ using namespace std; #include "instrument_track.h" #include "note_play_handle.h" #include "templates.h" -#include "buffer_allocator.h" #include "knob.h" #include "pixmap_button.h" #include "tooltip.h" @@ -371,7 +370,7 @@ void organicInstrument::playNote( notePlayHandle * _n, bool ) )->oscRight; const fpab_t frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; osc_l->update( buf, frames, 0 ); osc_r->update( buf, frames, 1 ); @@ -394,7 +393,7 @@ void organicInstrument::playNote( notePlayHandle * _n, bool ) getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); - bufferAllocator::free( buf ); + delete[] buf; } diff --git a/plugins/patman/patman.cpp b/plugins/patman/patman.cpp index 218be652f..fd1da1413 100644 --- a/plugins/patman/patman.cpp +++ b/plugins/patman/patman.cpp @@ -29,17 +29,18 @@ #include #include +#include #else #include +#include #include #include #endif #include "patman.h" -#include "buffer_allocator.h" #include "endian_handling.h" #include "file_browser.h" #include "note_play_handle.h" @@ -211,7 +212,7 @@ QString patmanSynth::nodeName( void ) const void patmanSynth::playNote( notePlayHandle * _n, bool ) { const Uint32 frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; float freq = getInstrumentTrack()->frequency( _n ); @@ -228,7 +229,7 @@ void patmanSynth::playNote( notePlayHandle * _n, bool ) { getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); } - bufferAllocator::free( buf ); + delete[] buf; } diff --git a/plugins/plucked_string_synth/plucked_string_synth.cpp b/plugins/plucked_string_synth/plucked_string_synth.cpp index 1f8ff7e42..04d88e57b 100644 --- a/plugins/plucked_string_synth/plucked_string_synth.cpp +++ b/plugins/plucked_string_synth/plucked_string_synth.cpp @@ -40,7 +40,6 @@ #include "instrument_track.h" #include "note_play_handle.h" #include "templates.h" -#include "buffer_allocator.h" #include "knob.h" #undef SINGLE_SOURCE_COMPILE @@ -144,7 +143,7 @@ void pluckedStringSynth::playNote( notePlayHandle * _n, bool ) } const Uint32 frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; pluckSynth * ps = static_cast( _n->m_pluginData ); for( Uint32 frame = 0; frame < frames; ++frame ) @@ -158,7 +157,7 @@ void pluckedStringSynth::playNote( notePlayHandle * _n, bool ) getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); - bufferAllocator::free( buf ); + delete[] buf; } diff --git a/plugins/polyb302/polyb302.cpp b/plugins/polyb302/polyb302.cpp index 5174f943d..48ab195f7 100644 --- a/plugins/polyb302/polyb302.cpp +++ b/plugins/polyb302/polyb302.cpp @@ -30,7 +30,6 @@ #include "polyb302.h" -#include "buffer_allocator.h" #include "knob.h" #include "led_checkbox.h" #include "note_play_handle.h" @@ -558,15 +557,12 @@ void polyb302Synth::playNote( notePlayHandle * _n, bool ) } const Uint32 frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; - if( buf ) - { - hstate->process( buf, frames, freq ); - getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); + hstate->process( buf, frames, freq ); + getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); - bufferAllocator::free( buf ); - } + delete[] buf; hstate->m_lastFramesPlayed = _n->totalFramesPlayed(); } diff --git a/plugins/singerbot/singerbot.cpp b/plugins/singerbot/singerbot.cpp index 1c98f16ae..161684368 100644 --- a/plugins/singerbot/singerbot.cpp +++ b/plugins/singerbot/singerbot.cpp @@ -30,17 +30,18 @@ #include #include #include +#include #else #include +#include #include #include #endif #include "singerbot.h" -#include "buffer_allocator.h" #include "instrument_track.h" #include "note_play_handle.h" #include "pattern.h" @@ -145,7 +146,7 @@ singerBot::~singerBot() void singerBot::playNote( notePlayHandle * _n, bool ) { const Uint32 frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; if( !_n->m_pluginData ) { @@ -163,7 +164,7 @@ void singerBot::playNote( notePlayHandle * _n, bool ) getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); } sharedObject::unref( sample_buffer ); - bufferAllocator::free( buf ); + delete[] buf; } diff --git a/plugins/stk/mallets/mallets.cpp b/plugins/stk/mallets/mallets.cpp index 07f614058..5938d127b 100644 --- a/plugins/stk/mallets/mallets.cpp +++ b/plugins/stk/mallets/mallets.cpp @@ -92,8 +92,7 @@ mallets::mallets( instrumentTrack * _channel_track ) : m_spread->move( 178, 173 ); m_spread->setHintText( tr( "Spread:" ) + " ", "" ); - m_buffer = bufferAllocator::alloc( - engine::getMixer()->framesPerAudioBuffer() ); + m_buffer = new sampleFrame[engine::getMixer()->framesPerAudioBuffer()]; } @@ -101,7 +100,7 @@ mallets::mallets( instrumentTrack * _channel_track ) : mallets::~mallets() { - bufferAllocator::free( m_buffer ); + delete[] m_buffer; } @@ -539,7 +538,7 @@ malletsSynth::malletsSynth( const StkFloat _pitch, m_voice = NULL; } - m_delay = bufferAllocator::alloc( 256 ); + m_delay = new StkFloat[256]; m_delayRead = 0; m_delayWrite = _delay; for( Uint16 i = 0; i < 256; i++ ) @@ -587,7 +586,7 @@ malletsSynth::malletsSynth( const StkFloat _pitch, m_voice = NULL; } - m_delay = bufferAllocator::alloc( 256 ); + m_delay = new StkFloat[256]; m_delayRead = 0; m_delayWrite = _delay; for( Uint16 i = 0; i < 256; i++ ) @@ -637,7 +636,7 @@ malletsSynth::malletsSynth( const StkFloat _pitch, m_voice = NULL; } - m_delay = bufferAllocator::alloc( 256 ); + m_delay = new StkFloat[256]; m_delayRead = 0; m_delayWrite = _delay; for( Uint16 i = 0; i < 256; i++ ) diff --git a/plugins/stk/mallets/mallets.h b/plugins/stk/mallets/mallets.h index 380f077d3..a862fa0a8 100644 --- a/plugins/stk/mallets/mallets.h +++ b/plugins/stk/mallets/mallets.h @@ -1,7 +1,7 @@ /* * mallets.h - tuned instruments that one would bang upon * - * Copyright (c) 2006 Danny McRae + * Copyright (c) 2006-2007 Danny McRae * * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net @@ -33,7 +33,6 @@ #include "combobox.h" #include "led_checkbox.h" #include "track.h" -#include "buffer_allocator.h" class knob; class notePlayHandle; @@ -81,7 +80,7 @@ public: inline ~malletsSynth( void ) { m_voice->noteOff( 0.0 ); - bufferAllocator::free( m_delay ); + delete[] m_delay; delete m_voice; } diff --git a/plugins/triple_oscillator/artwork.png b/plugins/triple_oscillator/artwork.png index dcb172f19..3842120b1 100644 Binary files a/plugins/triple_oscillator/artwork.png and b/plugins/triple_oscillator/artwork.png differ diff --git a/plugins/triple_oscillator/triple_oscillator.cpp b/plugins/triple_oscillator/triple_oscillator.cpp index f9e27c6e0..6da5522bc 100644 --- a/plugins/triple_oscillator/triple_oscillator.cpp +++ b/plugins/triple_oscillator/triple_oscillator.cpp @@ -48,7 +48,6 @@ #include "instrument_track.h" #include "note_play_handle.h" #include "knob.h" -#include "buffer_allocator.h" #include "debug.h" #include "tooltip.h" #include "sample_buffer.h" @@ -103,7 +102,7 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : #endif pixmapButton * pm_osc1_btn = new pixmapButton( this, NULL, NULL ); - pm_osc1_btn->move( 80, 50 ); + pm_osc1_btn->move( 46, 50 ); pm_osc1_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "pm_active" ) ); pm_osc1_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -115,7 +114,7 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "oscillator 1" ) ); pixmapButton * am_osc1_btn = new pixmapButton( this, NULL, NULL ); - am_osc1_btn->move( 120, 50 ); + am_osc1_btn->move( 86, 50 ); am_osc1_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "am_active" ) ); am_osc1_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -127,7 +126,7 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "oscillator 1" ) ); pixmapButton * mix_osc1_btn = new pixmapButton( this, NULL, NULL ); - mix_osc1_btn->move( 160, 50 ); + mix_osc1_btn->move( 126, 50 ); mix_osc1_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "mix_active" ) ); mix_osc1_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -137,7 +136,7 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : toolTip::add( mix_osc1_btn, tr( "mix output of oscillator 1 & 2" ) ); pixmapButton * sync_osc1_btn = new pixmapButton( this, NULL, NULL ); - sync_osc1_btn->move( 200, 50 ); + sync_osc1_btn->move( 166, 50 ); sync_osc1_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "sync_active" ) ); sync_osc1_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -148,7 +147,7 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "oscillator 2" ) ); pixmapButton * fm_osc1_btn = new pixmapButton( this, NULL, NULL ); - fm_osc1_btn->move( 330, 50 ); + fm_osc1_btn->move( 206, 50 ); fm_osc1_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "fm_active" ) ); fm_osc1_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -174,7 +173,7 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : pixmapButton * pm_osc2_btn = new pixmapButton( this, NULL, NULL ); - pm_osc2_btn->move( 80, 70 ); + pm_osc2_btn->move( 46, 68 ); pm_osc2_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "pm_active" ) ); pm_osc2_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -186,7 +185,7 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "oscillator 2" ) ); pixmapButton * am_osc2_btn = new pixmapButton( this, NULL, NULL ); - am_osc2_btn->move( 120, 70 ); + am_osc2_btn->move( 86, 68 ); am_osc2_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "am_active" ) ); am_osc2_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -198,7 +197,7 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "oscillator 2" ) ); pixmapButton * mix_osc2_btn = new pixmapButton( this, NULL, NULL ); - mix_osc2_btn->move( 160, 70 ); + mix_osc2_btn->move( 126, 68 ); mix_osc2_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "mix_active" ) ); mix_osc2_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -208,7 +207,7 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : toolTip::add( mix_osc2_btn, tr("mix output of oscillator 2 & 3" ) ); pixmapButton * sync_osc2_btn = new pixmapButton( this, NULL, NULL ); - sync_osc2_btn->move( 200, 70 ); + sync_osc2_btn->move( 166, 68 ); sync_osc2_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "sync_active" ) ); sync_osc2_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -219,7 +218,7 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "oscillator 3" ) ); pixmapButton * fm_osc2_btn = new pixmapButton( this, NULL, NULL ); - fm_osc2_btn->move( 330, 70 ); + fm_osc2_btn->move( 206, 68 ); fm_osc2_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "fm_active" ) ); fm_osc2_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -740,14 +739,14 @@ void tripleOscillator::playNote( notePlayHandle * _n, bool ) )->oscRight; const fpab_t frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; osc_l->update( buf, frames, 0 ); osc_r->update( buf, frames, 1 ); getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); - bufferAllocator::free( buf ); + delete[] buf; } diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index c16d79c89..7c107807d 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -51,7 +51,6 @@ #include "instrument_track.h" #include "note_play_handle.h" -#include "buffer_allocator.h" #include "mixer.h" #include "instrument_play_handle.h" #include "pixmap_button.h" @@ -298,7 +297,7 @@ void vestigeInstrument::waitForWorkerThread( void ) } const fpab_t frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; if( m_plugin->waitForProcessingFinished( buf ) ) { @@ -307,7 +306,7 @@ void vestigeInstrument::waitForWorkerThread( void ) m_pluginMutex.unlock(); - bufferAllocator::free( buf ); + delete[] buf; } diff --git a/plugins/vibed/vibed.cpp b/plugins/vibed/vibed.cpp index a7b95179e..aff5978dd 100644 --- a/plugins/vibed/vibed.cpp +++ b/plugins/vibed/vibed.cpp @@ -48,7 +48,6 @@ #include "note_play_handle.h" #include "instrument_track.h" #include "templates.h" -#include "buffer_allocator.h" #include "knob.h" #include "tooltip.h" #include "oscillator.h" @@ -582,7 +581,7 @@ void vibed::playNote( notePlayHandle * _n, bool ) stringContainer * ps = static_cast( _n->m_pluginData ); - sampleFrame * buf = bufferAllocator::alloc( frames ); + sampleFrame * buf = new sampleFrame[frames]; for( fpab_t i = 0; i < frames; ++i ) { @@ -609,7 +608,7 @@ void vibed::playNote( notePlayHandle * _n, bool ) getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); - bufferAllocator::free( buf ); + delete[] buf; } diff --git a/plugins/vibed/vibed.h b/plugins/vibed/vibed.h index 37238dc7b..690eb7698 100644 --- a/plugins/vibed/vibed.h +++ b/plugins/vibed/vibed.h @@ -1,6 +1,6 @@ /* vibed_strings.h - * - * Copyright (c) 2006 Danny McRae + * Copyright (c) 2006-2007 Danny McRae * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -29,7 +29,6 @@ #include "sample_buffer.h" #include "graph.h" #include "pixmap_button.h" -#include "buffer_allocator.h" #include "led_checkbox.h" #include "impulse_editor.h" #include "lcd_spinbox.h" diff --git a/plugins/vibed/vibrating_string.cpp b/plugins/vibed/vibrating_string.cpp index c3e89ef6e..995d7f7ca 100644 --- a/plugins/vibed/vibrating_string.cpp +++ b/plugins/vibed/vibrating_string.cpp @@ -1,7 +1,7 @@ /* * vibrating_sring.h - model of a vibrating string lifted from pluckedSynth * - * Copyright (c) 2006 Danny McRae + * Copyright (c) 2006-2007 Danny McRae * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -44,7 +44,7 @@ vibratingString::vibratingString( float _pitch, m_stringLoss( 1.0f - _string_loss ), m_state( 0.1f ) { - m_outsamp = bufferAllocator::alloc( m_oversample ); + m_outsamp = new sample_t[m_oversample]; int string_length; string_length = static_cast( m_oversample * _sample_rate / @@ -55,12 +55,12 @@ vibratingString::vibratingString( float _pitch, if( not _state ) { - m_impulse = bufferAllocator::alloc( string_length ); + m_impulse = new float[string_length]; resample( _impulse, _len, string_length ); } else { - m_impulse = bufferAllocator::alloc( _len ); + m_impulse = new float[_len]; for( Uint32 i = 0; i < _len; i++ ) { m_impulse[i] = _impulse[i]; diff --git a/plugins/vibed/vibrating_string.h b/plugins/vibed/vibrating_string.h index 372f5cd45..4f7c36a48 100644 --- a/plugins/vibed/vibrating_string.h +++ b/plugins/vibed/vibrating_string.h @@ -1,7 +1,7 @@ /* * vibrating_string.h - model of a vibrating string lifted from pluckedSynth * - * Copyright (c) 2006 Danny McRae + * Copyright (c) 2006-2007 Danny McRae * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -29,7 +29,6 @@ #include "config.h" #include "types.h" -#include "buffer_allocator.h" class vibratingString { @@ -49,8 +48,8 @@ public: inline ~vibratingString( void ) { - bufferAllocator::free( m_outsamp ); - bufferAllocator::free( m_impulse ); + delete[] m_outsamp; + delete[] m_impulse; vibratingString::freeDelayLine( m_fromBridge ); vibratingString::freeDelayLine( m_toBridge ); } diff --git a/plugins/vst_effect/vst_effect.cpp b/plugins/vst_effect/vst_effect.cpp index c279eafd1..4d62367ff 100644 --- a/plugins/vst_effect/vst_effect.cpp +++ b/plugins/vst_effect/vst_effect.cpp @@ -38,7 +38,6 @@ #include "vst_subplugin_features.h" #include "song_editor.h" #include "text_float.h" -#include "buffer_allocator.h" #undef SINGLE_SOURCE_COMPILE @@ -98,8 +97,7 @@ bool FASTCALL vstEffect::processAudioBuffer( surroundSampleFrame * _buf, if( m_plugin ) { - sampleFrame * buf = bufferAllocator::alloc( - _frames ); + sampleFrame * buf = new sampleFrame[_frames]; for( fpab_t f = 0; f < _frames; ++f ) { for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) @@ -121,7 +119,7 @@ bool FASTCALL vstEffect::processAudioBuffer( surroundSampleFrame * _buf, out_sum += _buf[f][ch]*_buf[f][ch]; } } - bufferAllocator::free( buf ); + delete[] buf; if( out_sum <= getGate() ) { incrementBufferCount(); diff --git a/src/audio/audio_alsa.cpp b/src/audio/audio_alsa.cpp index 3952b8d59..052c65877 100644 --- a/src/audio/audio_alsa.cpp +++ b/src/audio/audio_alsa.cpp @@ -48,7 +48,6 @@ #ifdef ALSA_SUPPORT #include "endian_handling.h" -#include "buffer_allocator.h" #include "config_mgr.h" #include "lcd_spinbox.h" #include "gui_templates.h" @@ -214,13 +213,11 @@ void audioALSA::stopProcessing( void ) void audioALSA::run( void ) { surroundSampleFrame * temp = - bufferAllocator::alloc( - getMixer()->framesPerAudioBuffer() ); - int_sample_t * outbuf = bufferAllocator::alloc( - getMixer()->framesPerAudioBuffer() * - channels() ); - int_sample_t * pcmbuf = bufferAllocator::alloc( - m_periodSize * channels() ); + new surroundSampleFrame[getMixer()->framesPerAudioBuffer()]; + int_sample_t * outbuf = + new int_sample_t[getMixer()->framesPerAudioBuffer() * + channels()]; + int_sample_t * pcmbuf = new int_sample_t[m_periodSize * channels()]; int outbuf_size = getMixer()->framesPerAudioBuffer() * channels(); int outbuf_pos = 0; @@ -286,9 +283,9 @@ void audioALSA::run( void ) } } - bufferAllocator::free( temp ); - bufferAllocator::free( outbuf ); - bufferAllocator::free( pcmbuf ); + delete[] temp; + delete[] outbuf; + delete[] pcmbuf; } diff --git a/src/audio/audio_device.cpp b/src/audio/audio_device.cpp index 9f88bb2c2..5b1383895 100644 --- a/src/audio/audio_device.cpp +++ b/src/audio/audio_device.cpp @@ -33,7 +33,6 @@ #include "audio_device.h" -#include "buffer_allocator.h" #include "debug.h" @@ -43,8 +42,7 @@ audioDevice::audioDevice( const sample_rate_t _sample_rate, m_sampleRate( _sample_rate ), m_channels( _channels ), m_mixer( _mixer ), - m_buffer( bufferAllocator::alloc( - getMixer()->framesPerAudioBuffer() ) ) + m_buffer( new surroundSampleFrame[getMixer()->framesPerAudioBuffer()] ) { #ifdef HAVE_SAMPLERATE_H int error; @@ -70,7 +68,7 @@ audioDevice::~audioDevice() #ifdef HAVE_SAMPLERATE_H src_delete( m_srcState ); #endif - bufferAllocator::free( m_buffer ); + delete[] m_buffer; #ifdef QT3 if( m_devMutex.locked() ) { @@ -85,15 +83,17 @@ audioDevice::~audioDevice() -bool audioDevice::processNextBuffer( void ) +void audioDevice::processNextBuffer( void ) { const fpab_t frames = getNextBuffer( m_buffer ); - if( !frames ) + if( frames ) { - return( FALSE ); + writeBuffer( m_buffer, frames, getMixer()->masterGain() ); + } + else + { + m_in_process = FALSE; } - writeBuffer( m_buffer, frames, getMixer()->masterGain() ); - return( TRUE ); } @@ -136,7 +136,10 @@ fpab_t audioDevice::getNextBuffer( surroundSampleFrame * _ab ) void audioDevice::stopProcessing( void ) { - while( processNextBuffer() ); + while( m_in_process ) + { + processNextBuffer(); + } } diff --git a/src/audio/audio_file_device.cpp b/src/audio/audio_file_device.cpp index 4cc181a3c..f32258e18 100644 --- a/src/audio/audio_file_device.cpp +++ b/src/audio/audio_file_device.cpp @@ -41,7 +41,6 @@ #include "audio_file_device.h" #include "export_project_dialog.h" -#include "buffer_allocator.h" audioFileDevice::audioFileDevice( const sample_rate_t _sample_rate, diff --git a/src/audio/audio_file_wave.cpp b/src/audio/audio_file_wave.cpp index 6abf746d9..cf324cb96 100644 --- a/src/audio/audio_file_wave.cpp +++ b/src/audio/audio_file_wave.cpp @@ -29,7 +29,6 @@ #include "audio_file_wave.h" #include "endian_handling.h" -#include "buffer_allocator.h" #include @@ -96,13 +95,12 @@ void FASTCALL audioFileWave::writeBuffer( const surroundSampleFrame * _ab, const fpab_t _frames, const float _master_gain ) { - int_sample_t * outbuf = bufferAllocator::alloc( - _frames * channels() ); + int_sample_t * outbuf = new int_sample_t[_frames * channels()]; Uint32 bytes = convertToS16( _ab, _frames, _master_gain, outbuf, !isLittleEndian() ); writeData( outbuf, bytes ); - bufferAllocator::free( outbuf ); + delete[] outbuf; m_bytesWritten += bytes; } diff --git a/src/audio/audio_jack.cpp b/src/audio/audio_jack.cpp index 384e6bf6a..325e24093 100644 --- a/src/audio/audio_jack.cpp +++ b/src/audio/audio_jack.cpp @@ -51,7 +51,6 @@ #include "debug.h" #include "templates.h" #include "gui_templates.h" -#include "buffer_allocator.h" #include "config_mgr.h" #include "lcd_spinbox.h" #include "audio_port.h" @@ -69,8 +68,7 @@ audioJACK::audioJACK( const sample_rate_t _sample_rate, bool & _success_ful, m_active( FALSE ), // m_processCallbackMutex(), m_stop_semaphore( 1 ), - m_outBuf( bufferAllocator::alloc( - getMixer()->framesPerAudioBuffer() ) ), + m_outBuf( new surroundSampleFrame[getMixer()->framesPerAudioBuffer()] ), m_framesDoneInCurBuf( 0 ), m_framesToDoInCurBuf( 0 ) { @@ -202,7 +200,7 @@ audioJACK::~audioJACK() jack_client_close( m_client ); } - bufferAllocator::free( m_outBuf ); + delete[] m_outBuf; } diff --git a/src/audio/audio_oss.cpp b/src/audio/audio_oss.cpp index 3cc94b42a..2da17b9a0 100644 --- a/src/audio/audio_oss.cpp +++ b/src/audio/audio_oss.cpp @@ -47,7 +47,6 @@ #endif -#include "buffer_allocator.h" #include "endian_handling.h" #include "lcd_spinbox.h" #include "gui_templates.h" @@ -317,11 +316,10 @@ void audioOSS::stopProcessing( void ) void audioOSS::run( void ) { surroundSampleFrame * temp = - bufferAllocator::alloc( - getMixer()->framesPerAudioBuffer() ); - int_sample_t * outbuf = bufferAllocator::alloc( - getMixer()->framesPerAudioBuffer() * - channels() ); + new surroundSampleFrame[getMixer()->framesPerAudioBuffer()]; + int_sample_t * outbuf = + new int_sample_t[getMixer()->framesPerAudioBuffer() * + channels()]; while( TRUE ) { @@ -337,8 +335,8 @@ void audioOSS::run( void ) write( m_audioFD, outbuf, bytes ); } - bufferAllocator::free( temp ); - bufferAllocator::free( outbuf ); + delete[] temp; + delete[] outbuf; } diff --git a/src/audio/audio_port.cpp b/src/audio/audio_port.cpp index 02dab03d5..fe9b484df 100644 --- a/src/audio/audio_port.cpp +++ b/src/audio/audio_port.cpp @@ -30,15 +30,14 @@ #include "audio_port.h" #include "audio_device.h" -#include "buffer_allocator.h" #include "engine.h" audioPort::audioPort( const QString & _name ) : m_bufferUsage( NONE ), - m_firstBuffer( bufferAllocator::alloc( - engine::getMixer()->framesPerAudioBuffer() ) ), - m_secondBuffer( bufferAllocator::alloc( - engine::getMixer()->framesPerAudioBuffer() ) ), + m_firstBuffer( new surroundSampleFrame[ + engine::getMixer()->framesPerAudioBuffer()] ), + m_secondBuffer( new surroundSampleFrame[ + engine::getMixer()->framesPerAudioBuffer()] ), m_extOutputEnabled( FALSE ), m_nextFxChannel( -1 ), m_name( "unnamed port" ) @@ -63,8 +62,8 @@ audioPort::~audioPort() { engine::getMixer()->audioDev()->unregisterPort( this ); } - bufferAllocator::free( m_firstBuffer ); - bufferAllocator::free( m_secondBuffer ); + delete[] m_firstBuffer; + delete[] m_secondBuffer; } diff --git a/src/audio/audio_sample_recorder.cpp b/src/audio/audio_sample_recorder.cpp index c74cec3ae..9d7d6f951 100644 --- a/src/audio/audio_sample_recorder.cpp +++ b/src/audio/audio_sample_recorder.cpp @@ -30,7 +30,6 @@ #include "audio_sample_recorder.h" #include "sample_buffer.h" -#include "buffer_allocator.h" #include "debug.h" @@ -52,7 +51,7 @@ audioSampleRecorder::~audioSampleRecorder() { while( !m_buffers.empty() ) { - bufferAllocator::free( m_buffers.front().first ); + delete[] m_buffers.front().first; m_buffers.erase( m_buffers.begin() ); } } @@ -78,9 +77,9 @@ void audioSampleRecorder::createSampleBuffer( sampleBuffer * * _sample_buf ) { const f_cnt_t frames = framesRecorded(); // create buffer to store all recorded buffers in - sampleFrame * data = bufferAllocator::alloc( frames ); + sampleFrame * data = new sampleFrame[frames]; // make sure buffer is cleaned up properly at the end... - bufferAllocator::autoCleaner ac( data ); + sampleFrame * data_ptr = data; #ifdef LMMS_DEBUG assert( data != NULL ); @@ -89,12 +88,14 @@ void audioSampleRecorder::createSampleBuffer( sampleBuffer * * _sample_buf ) for( bufferList::const_iterator it = m_buffers.begin(); it != m_buffers.end(); ++it ) { - memcpy( data, ( *it ).first, ( *it ).second * + memcpy( data_ptr, ( *it ).first, ( *it ).second * sizeof( sampleFrame ) ); - data += ( *it ).second; + data_ptr += ( *it ).second; } // create according sample-buffer out of big buffer - *_sample_buf = new sampleBuffer( ac.ptr(), frames ); + *_sample_buf = new sampleBuffer( data, frames ); + ( *_sample_buf )->setSampleRate( sampleRate() ); + delete[] data; } @@ -103,7 +104,7 @@ void audioSampleRecorder::createSampleBuffer( sampleBuffer * * _sample_buf ) void audioSampleRecorder::writeBuffer( const surroundSampleFrame * _ab, const fpab_t _frames, const float ) { - sampleFrame * buf = bufferAllocator::alloc( _frames ); + sampleFrame * buf = new sampleFrame[_frames]; for( fpab_t frame = 0; frame < _frames; ++frame ) { for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) diff --git a/src/audio/audio_sdl.cpp b/src/audio/audio_sdl.cpp index f78c1a133..209481fa3 100644 --- a/src/audio/audio_sdl.cpp +++ b/src/audio/audio_sdl.cpp @@ -43,7 +43,6 @@ #endif -#include "buffer_allocator.h" #include "debug.h" #include "config_mgr.h" #include "gui_templates.h" @@ -55,8 +54,7 @@ audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful, mixer * _mixer ) : audioDevice( _sample_rate, DEFAULT_CHANNELS, _mixer ), - m_outBuf( bufferAllocator::alloc( - getMixer()->framesPerAudioBuffer() ) ), + m_outBuf( new surroundSampleFrame[getMixer()->framesPerAudioBuffer()] ), m_convertedBuf_pos( 0 ), m_convertEndian( FALSE ), m_stop_semaphore( 1 ) @@ -65,8 +63,7 @@ audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful, m_convertedBuf_size = getMixer()->framesPerAudioBuffer() * channels() * sizeof( int_sample_t ); - m_convertedBuf = (Uint8 *)bufferAllocator::allocBytes( - m_convertedBuf_size ); + m_convertedBuf = new Uint8[m_convertedBuf_size]; /* // if device is set, we set AUDIODEV-environment-variable, so that // SDL can evaluate and use it @@ -130,8 +127,8 @@ audioSDL::~audioSDL() #endif SDL_CloseAudio(); SDL_Quit(); - bufferAllocator::free( m_convertedBuf ); - bufferAllocator::free( m_outBuf ); + delete[] m_convertedBuf; + delete[] m_outBuf; } diff --git a/src/core/automation_editor.cpp b/src/core/automation_editor.cpp index 7c8384005..35ecd3e8b 100644 --- a/src/core/automation_editor.cpp +++ b/src/core/automation_editor.cpp @@ -65,6 +65,7 @@ #include "song_editor.h" #include "main_window.h" #include "embed.h" +#include "engine.h" #include "pixmap_button.h" #include "templates.h" #include "gui_templates.h" diff --git a/src/core/bb_editor.cpp b/src/core/bb_editor.cpp index 8ac9fbdea..ce4d01cb4 100644 --- a/src/core/bb_editor.cpp +++ b/src/core/bb_editor.cpp @@ -46,6 +46,7 @@ #include "bb_editor.h" #include "song_editor.h" #include "embed.h" +#include "engine.h" #include "tool_button.h" #include "track_container.h" #include "bb_track.h" diff --git a/src/core/envelope_and_lfo_widget.cpp b/src/core/envelope_and_lfo_widget.cpp index d621ff1f4..ecb14a41f 100644 --- a/src/core/envelope_and_lfo_widget.cpp +++ b/src/core/envelope_and_lfo_widget.cpp @@ -49,6 +49,7 @@ #include "envelope_and_lfo_widget.h" #include "song_editor.h" #include "embed.h" +#include "engine.h" #include "knob.h" #include "pixmap_button.h" #include "oscillator.h" diff --git a/src/core/envelope_tab_widget.cpp b/src/core/envelope_tab_widget.cpp index 7dbadea9e..63afa3e1e 100644 --- a/src/core/envelope_tab_widget.cpp +++ b/src/core/envelope_tab_widget.cpp @@ -253,7 +253,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, const fpab_t _frames, notePlayHandle * _n ) { - f_cnt_t total_frames = _n->totalFramesPlayed(); + const f_cnt_t total_frames = _n->totalFramesPlayed(); f_cnt_t release_begin = total_frames - _n->releaseFramesDone() + _n->framesBeforeRelease(); @@ -263,67 +263,49 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, } // because of optimizations, there's special code for several cases: - // - volume-, cut- and res-lfo/envelope active - // - volume- and cut-lfo/envelope active - // - volume- and res-lfo/envelope active + // - cut- and res-lfo/envelope active // - cut-lfo/envelope active // - res-lfo/envelope active - // - volume-lfo/envelope active // - no lfo/envelope active but filter is used - // now there's a lot of similar code but I didn't found a way to - // generalize it yet... may be later we could do that - // by using preprocessor and macro-expansion... (like in oscillator.cpp) // only use filter, if it is really needed - if( _n->m_filter == NULL ) - { - _n->m_filter = new basicFilters<>( - engine::getMixer()->sampleRate() ); - } - - m_envLFOWidgets[VOLUME]->lock(); - m_envLFOWidgets[CUT]->lock(); - m_envLFOWidgets[RES]->lock(); - - float * vol_buf = NULL; - float * cut_buf = NULL; - float * res_buf = NULL; - - if( m_envLFOWidgets[VOLUME]->used() ) - { - vol_buf = new float[_frames]; - m_envLFOWidgets[VOLUME]->fillLevel( vol_buf, total_frames, - release_begin, _frames ); - } - if( m_envLFOWidgets[CUT]->used() ) - { - cut_buf = new float[_frames]; - m_envLFOWidgets[CUT]->fillLevel( cut_buf, total_frames, - release_begin, _frames ); - } - if( m_envLFOWidgets[RES]->used() ) - { - res_buf = new float[_frames]; - m_envLFOWidgets[RES]->fillLevel( res_buf, total_frames, - release_begin, _frames ); - } - if( m_filterGroupBox->isActive() ) { int old_filter_cut = 0; int old_filter_res = 0; - basicFilters<>::filterTypes filter = - basicFilters<>::getFilterType( - m_filterComboBox->value() ); + if( _n->m_filter == NULL ) + { + _n->m_filter = new basicFilters<>( + engine::getMixer()->sampleRate() ); + } + _n->m_filter->setType( basicFilters<>::getFilterType( + m_filterComboBox->value() ) ); - if( m_envLFOWidgets[VOLUME]->used() && - m_envLFOWidgets[CUT]->used() && + float * cut_buf = NULL; + float * res_buf = NULL; + + m_envLFOWidgets[CUT]->lock(); + m_envLFOWidgets[RES]->lock(); + + if( m_envLFOWidgets[CUT]->used() ) + { + cut_buf = new float[_frames]; + m_envLFOWidgets[CUT]->fillLevel( cut_buf, total_frames, + release_begin, _frames ); + } + if( m_envLFOWidgets[RES]->used() ) + { + res_buf = new float[_frames]; + m_envLFOWidgets[RES]->fillLevel( res_buf, total_frames, + release_begin, _frames ); + } + + if( m_envLFOWidgets[CUT]->used() && m_envLFOWidgets[RES]->used() ) { - for( fpab_t frame = 0; frame < _frames; - ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame ) { float new_cut_val = envelopeAndLFOWidget::expKnobVal( cut_buf[frame] ) * CUT_FREQ_MULTIPLIER + m_filterCutKnob->value(); @@ -334,76 +316,27 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, if( static_cast( new_cut_val ) != old_filter_cut || static_cast( new_res_val*RES_PRECISION ) != old_filter_res ) { - _n->m_filter->calcFilterCoeffs( filter, new_cut_val, new_res_val ); + _n->m_filter->calcFilterCoeffs( new_cut_val, new_res_val ); old_filter_cut = static_cast( new_cut_val ); old_filter_res = static_cast( new_res_val*RES_PRECISION ); } - float vol_level = vol_buf[frame]; - vol_level = vol_level*vol_level; - for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { - _ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl ); + _ab[frame][chnl] = _n->m_filter->update( _ab[frame][chnl], chnl ); } } } - else if( m_envLFOWidgets[VOLUME]->used() && m_envLFOWidgets[CUT]->used() ) - { - for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) - { - float new_cut_val = envelopeAndLFOWidget::expKnobVal( cut_buf[frame] ) * CUT_FREQ_MULTIPLIER + - m_filterCutKnob->value(); - - if( static_cast( new_cut_val ) != old_filter_cut ) - { - _n->m_filter->calcFilterCoeffs( filter, new_cut_val, m_filterResKnob->value() ); - old_filter_cut = static_cast( new_cut_val ); - } - - float vol_level = vol_buf[frame]; - vol_level = vol_level*vol_level; - - for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) - { - _ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl ); - } - } - } - else if( m_envLFOWidgets[VOLUME]->used() && m_envLFOWidgets[RES]->used() ) - { - - for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) - { - float new_res_val = m_filterResKnob->value() + RES_MULTIPLIER * - res_buf[frame]; - - if( static_cast( new_res_val*RES_PRECISION ) != old_filter_res ) - { - _n->m_filter->calcFilterCoeffs( filter, m_filterCutKnob->value(), new_res_val ); - old_filter_res = static_cast( new_res_val*RES_PRECISION ); - } - - float vol_level = vol_buf[frame]; - vol_level = vol_level*vol_level; - - for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) - { - _ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl ); - } - } - - } else if( m_envLFOWidgets[CUT]->used() ) { - for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame ) { float new_cut_val = envelopeAndLFOWidget::expKnobVal( cut_buf[frame] ) * CUT_FREQ_MULTIPLIER + m_filterCutKnob->value(); if( static_cast( new_cut_val ) != old_filter_cut ) { - _n->m_filter->calcFilterCoeffs( filter, new_cut_val, m_filterResKnob->value() ); + _n->m_filter->calcFilterCoeffs( new_cut_val, m_filterResKnob->value() ); old_filter_cut = static_cast( new_cut_val ); } @@ -415,14 +348,14 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, } else if( m_envLFOWidgets[RES]->used() ) { - for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame ) { float new_res_val = m_filterResKnob->value() + RES_MULTIPLIER * res_buf[frame]; if( static_cast( new_res_val*RES_PRECISION ) != old_filter_res ) { - _n->m_filter->calcFilterCoeffs( filter, m_filterCutKnob->value(), new_res_val ); + _n->m_filter->calcFilterCoeffs( m_filterCutKnob->value(), new_res_val ); old_filter_res = static_cast( new_res_val*RES_PRECISION ); } @@ -432,26 +365,11 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, } } } - else if( m_envLFOWidgets[VOLUME]->used() ) - { - _n->m_filter->calcFilterCoeffs( filter, m_filterCutKnob->value(), m_filterResKnob->value() ); - - for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) - { - float vol_level = vol_buf[frame]; - vol_level = vol_level*vol_level; - - for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) - { - _ab[frame][chnl] = vol_level * _n->m_filter->update( _ab[frame][chnl], chnl ); - } - } - } else { - _n->m_filter->calcFilterCoeffs( filter, m_filterCutKnob->value(), m_filterResKnob->value() ); + _n->m_filter->calcFilterCoeffs( m_filterCutKnob->value(), m_filterResKnob->value() ); - for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame ) { for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { @@ -459,24 +377,39 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, } } } + + m_envLFOWidgets[RES]->unlock(); + m_envLFOWidgets[CUT]->unlock(); + + delete[] cut_buf; + delete[] res_buf; } - else if( m_envLFOWidgets[VOLUME]->used() /*&& m_envLFOWidgets[PANNING]->used() == FALSE*/ ) + + m_envLFOWidgets[VOLUME]->lock(); + if( m_envLFOWidgets[VOLUME]->used() ) { - // only use volume-envelope... - for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) + float * vol_buf = new float[_frames]; + m_envLFOWidgets[VOLUME]->fillLevel( vol_buf, total_frames, + release_begin, _frames ); + + for( fpab_t frame = 0; frame < _frames; ++frame ) { float vol_level = vol_buf[frame]; - vol_level = vol_level*vol_level; - for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) + vol_level = vol_level * vol_level; + for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; + ++chnl ) { _ab[frame][chnl] = vol_level * _ab[frame][chnl]; } } + delete[] vol_buf; } + m_envLFOWidgets[VOLUME]->unlock(); + /* else if( m_envLFOWidgets[VOLUME]->used() == FALSE && m_envLFOWidgets[PANNING]->used() ) { // only use panning-envelope... - for( fpab_t frame = 0; frame < _frames; ++frame, ++total_frames ) + for( fpab_t frame = 0; frame < _frames; ++frame ) { float vol_level = pan_buf[frame]; vol_level = vol_level*vol_level; @@ -486,14 +419,6 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, } } }*/ - - delete[] vol_buf; - delete[] cut_buf; - delete[] res_buf; - - m_envLFOWidgets[RES]->unlock(); - m_envLFOWidgets[CUT]->unlock(); - m_envLFOWidgets[VOLUME]->unlock(); } diff --git a/src/core/export_project_dialog.cpp b/src/core/export_project_dialog.cpp index 0fbfbd9f2..cf3dae63a 100644 --- a/src/core/export_project_dialog.cpp +++ b/src/core/export_project_dialog.cpp @@ -55,6 +55,7 @@ #include "combobox.h" #include "led_checkbox.h" #include "embed.h" +#include "engine.h" #include "audio_file_wave.h" #include "audio_file_ogg.h" @@ -383,7 +384,8 @@ void exportProjectDialog::exportBtnClicked( void ) songEditor::PLAY_SONG ); while( engine::getSongEditor()->exportDone() == FALSE && - engine::getSongEditor()->exporting() == TRUE ) + engine::getSongEditor()->exporting() == TRUE + && !m_deleteFile ) { dev->processNextBuffer(); int pval = pp * 100 / @@ -401,13 +403,7 @@ void exportProjectDialog::exportBtnClicked( void ) qApp->processEvents(); } - // if m_deleteFile == TRUE, user aborted export and finalization- - // routines were already called, so we only need to call them if - // export went through without any problems - if( m_deleteFile == FALSE ) - { - finishProjectExport(); - } + finishProjectExport(); } @@ -432,8 +428,6 @@ void exportProjectDialog::cancelBtnClicked( void ) void exportProjectDialog::abortProjectExport( void ) { m_deleteFile = TRUE; - - finishProjectExport(); } diff --git a/src/core/main_window.cpp b/src/core/main_window.cpp index a26a1807c..29f4e725e 100644 --- a/src/core/main_window.cpp +++ b/src/core/main_window.cpp @@ -75,7 +75,6 @@ #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.h" diff --git a/src/core/mixer.cpp b/src/core/mixer.cpp index d258151fa..8fe921353 100644 --- a/src/core/mixer.cpp +++ b/src/core/mixer.cpp @@ -32,7 +32,6 @@ #include "song_editor.h" #include "templates.h" #include "envelope_and_lfo_widget.h" -#include "buffer_allocator.h" #include "debug.h" #include "engine.h" #include "config_mgr.h" @@ -109,8 +108,7 @@ mixer::mixer( void ) : for( Uint8 i = 0; i < 3; i++ ) { - m_readBuf = bufferAllocator::alloc( - m_framesPerAudioBuffer ); + m_readBuf = new surroundSampleFrame[m_framesPerAudioBuffer]; clearAudioBuffer( m_readBuf, m_framesPerAudioBuffer ); m_bufferPool.push_back( m_readBuf ); @@ -135,7 +133,7 @@ mixer::~mixer() for( Uint8 i = 0; i < 3; i++ ) { - bufferAllocator::free( m_bufferPool[i] ); + delete[] m_bufferPool[i]; } } @@ -165,11 +163,12 @@ void mixer::startProcessing( void ) void mixer::stopProcessing( void ) { m_fifo_writer->finish(); + + m_audioDev->stopProcessing(); + m_fifo_writer->wait( 1000 ); m_fifo_writer->terminate(); delete m_fifo_writer; - - m_audioDev->stopProcessing(); } diff --git a/src/core/note.cpp b/src/core/note.cpp index 2e721e794..4b749cc6c 100644 --- a/src/core/note.cpp +++ b/src/core/note.cpp @@ -39,8 +39,8 @@ #include -#include "debug.h" #include "note.h" +#include "automatable_object_templates.h" #include "knob.h" #include "templates.h" diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index 5b6008c97..563d6cdb4 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -27,6 +27,7 @@ #include "note_play_handle.h" +#include "automatable_object_templates.h" #include "instrument_track.h" #include "envelope_tab_widget.h" #include "midi.h" diff --git a/src/core/piano_roll.cpp b/src/core/piano_roll.cpp index 3fcfe09f2..48f435cf0 100644 --- a/src/core/piano_roll.cpp +++ b/src/core/piano_roll.cpp @@ -62,6 +62,7 @@ #include "piano_roll.h" +#include "automatable_object_templates.h" #include "song_editor.h" #include "main_window.h" #include "pattern.h" diff --git a/src/core/piano_widget.cpp b/src/core/piano_widget.cpp index 150a52b30..afe66b31a 100644 --- a/src/core/piano_widget.cpp +++ b/src/core/piano_widget.cpp @@ -48,6 +48,7 @@ #include "piano_widget.h" +#include "automatable_object_templates.h" #include "instrument_track.h" #include "midi.h" #include "templates.h" diff --git a/src/core/sample_play_handle.cpp b/src/core/sample_play_handle.cpp index 9bac56cc6..3dbb18eb4 100644 --- a/src/core/sample_play_handle.cpp +++ b/src/core/sample_play_handle.cpp @@ -31,7 +31,6 @@ #include "pattern.h" #include "sample_buffer.h" #include "sample_track.h" -#include "buffer_allocator.h" #include "audio_port.h" @@ -132,8 +131,7 @@ void samplePlayHandle::play( const fpab_t _frame_base, bool ) if( !( m_track && m_track->muted() ) && !( m_bbTrack && m_bbTrack->muted() ) ) { - sampleFrame * buf = bufferAllocator::alloc( - frames ); + sampleFrame * buf = new sampleFrame[frames]; volumeVector v = { { m_volume, m_volume #ifndef DISABLE_SURROUND , m_volume, m_volume @@ -143,7 +141,7 @@ void samplePlayHandle::play( const fpab_t _frame_base, bool ) engine::getMixer()->bufferToPort( buf, frames, _frame_base, v, m_audioPort ); - bufferAllocator::free( buf ); + delete[] buf; } m_frame += frames; diff --git a/src/core/setup_dialog.cpp b/src/core/setup_dialog.cpp index 92c81ad38..2382b95ec 100644 --- a/src/core/setup_dialog.cpp +++ b/src/core/setup_dialog.cpp @@ -61,6 +61,7 @@ #include "project_journal.h" #include "config_mgr.h" #include "embed.h" +#include "engine.h" #include "debug.h" #include "tooltip.h" #include "led_checkbox.h" diff --git a/src/core/song_editor.cpp b/src/core/song_editor.cpp index 8cc6e2d9d..df6bf77cd 100644 --- a/src/core/song_editor.cpp +++ b/src/core/song_editor.cpp @@ -69,6 +69,7 @@ #include "song_editor.h" +#include "automatable_object_templates.h" #include "automatable_slider.h" #include "bb_editor.h" #include "rename_dialog.h" diff --git a/src/core/surround_area.cpp b/src/core/surround_area.cpp index 57fa42668..f90d87c05 100644 --- a/src/core/surround_area.cpp +++ b/src/core/surround_area.cpp @@ -52,6 +52,7 @@ #include #include "surround_area.h" +#include "automatable_object_templates.h" #include "embed.h" #include "templates.h" #include "tooltip.h" diff --git a/src/core/track.cpp b/src/core/track.cpp index 74c31cb1e..cb698c99d 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -50,6 +50,7 @@ #include "track.h" +#include "automation_pattern.h" #include "track_container.h" #include "automation_track.h" #include "instrument_track.h" diff --git a/src/lib/buffer_allocator.cpp b/src/lib/buffer_allocator.cpp deleted file mode 100644 index 4efd7bf21..000000000 --- a/src/lib/buffer_allocator.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#ifndef SINGLE_SOURCE_COMPILE - -/* - * buffer_allocator.cpp - namespace bufferAllocator providing routines for own - * optimized memory-management for audio-buffers - * - * Copyright (c) 2005-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., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - */ - - -#include "qt3support.h" - -#ifdef QT4 - -#include -#include - -#else - -#include -#include -#include - -#define qSort qHeapSort - -#endif - -#include -#include - -#include "buffer_allocator.h" -#include "templates.h" -#include "mixer.h" -#include "debug.h" - - -struct bufDesc -{ - bool free; - char * origPtr; - void * buf; - Uint32 bytes; - Uint32 timesUsed; - -} ; - - -inline bool operator<( const bufDesc & _bd1, const bufDesc & _bd2 ) -{ - return( _bd1.timesUsed < _bd2.timesUsed ); -} - -#ifndef QT3 - -inline bool operator==( const bufDesc & _bd1, const bufDesc & _bd2 ) -{ - return( memcmp( &_bd1, &_bd2, sizeof( bufDesc ) ) == 0 ); -} - -#else - -inline bool operator!=( const bufDesc & _bd1, const bufDesc & _bd2 ) -{ - return( memcmp( &_bd1, &_bd2, sizeof( bufDesc ) ) != 0 ); -} - -#endif - - -static vlist s_buffers; -typedef vlist::iterator bufIt; - -static int s_freeBufs = 0; -static bool s_autoCleanupDisabled = FALSE; -static QMutex s_buffersMutex; - - -const int BUFFER_ALIGN = 16; -const int BUFFER_ALIGN_MASK = BUFFER_ALIGN - 1; - - - -void bufferAllocator::cleanUp( Uint16 _level ) -{ - // first insert all unused bufs into an array - vlist bufsToRemove; - for( bufIt it = s_buffers.begin(); it != s_buffers.end(); ++it ) - { - if( ( *it ).free ) - { - bufsToRemove.push_back( *it ); - } - } - - // sort array by usage of each buffer - // ( operator<(...) compares bufDesc::timesUsed ) - qSort( bufsToRemove ); - - const Sint16 todo = tMin( s_buffers.size() - _level, - bufsToRemove.size() ); - - // now cleanup the first n elements of sorted array - for( Sint16 i = 0; i < todo; ++i ) - { - delete[] bufsToRemove[i].origPtr; - s_buffers.erase( qFind( s_buffers.begin(), s_buffers.end(), - bufsToRemove[i] ) ); - --s_freeBufs; - } - -#ifdef LMMS_DEBUG - //printf( "cleaned up %d buffers\n", todo ); -#endif -} - - - - -void bufferAllocator::free( void * _buf ) -{ - s_buffersMutex.lock(); - - // look for buffer - for( bufIt it = s_buffers.begin(); it != s_buffers.end(); ++it ) - { - if( !( *it ).free && ( *it ).buf == _buf ) - { - ++( *it ).timesUsed; - ( *it ).free = TRUE; - ++s_freeBufs; - break; - } - } - - // do clean-up if neccessary - static const csize CLEANUP_LEVEL = static_cast( 768 / ( logf( - /*mixer::inst()->framesPerAudioBuffer()*/ - 128 ) / - logf( 2 ) ) ); - static int count = 0; - // only cleanup every 10th time, because otherwise there's a lot of - // overhead e.g. when freeing a lot of single buffers - if( s_autoCleanupDisabled == FALSE && - s_buffers.size() > CLEANUP_LEVEL && ++count > 10 ) - { - cleanUp( CLEANUP_LEVEL ); - count = 0; - } - - s_buffersMutex.unlock(); -} - - - - -void * bufferAllocator::allocBytes( Uint32 _bytes ) -{ - QMutexLocker ml( &s_buffersMutex ); - - // there's a low probability that we find a matching buffer, if there're - // less than 2 bufs available, so do not search - this speeds up - // processes like pattern-freezing because this way we do not have to - // search for a free buffer in an array, containing several - // 10.000 buffers - if( (csize) s_freeBufs > s_buffers.size() / 10 ) - { - bufIt free_buf = s_buffers.end(); - - // look whether there's a buffer matching to the one wanted and - // find out the most used one (higher chances for being in CPU- - // cache) - for( bufIt it = s_buffers.begin(); it != s_buffers.end(); ++it ) - { - if( ( *it ).free && ( *it ).bytes == _bytes ) - { - if( free_buf == s_buffers.end() || - ( *it ).timesUsed > - ( *free_buf ).timesUsed ) - { - free_buf = it; - } - } - } - - if( free_buf != s_buffers.end() ) - { - --s_freeBufs; - ( *free_buf ).free = FALSE; - return( ( *free_buf ).buf ); - } - } - - - // got nothing so far, so we'll alloc a new (aligned) buf - bufDesc d = { FALSE, new char[_bytes + BUFFER_ALIGN], NULL, _bytes, 0 }; - d.buf = (void *)( (size_t) d.origPtr + ( BUFFER_ALIGN - - ( (size_t) d.origPtr & - BUFFER_ALIGN_MASK ) ) ); - s_buffers.push_back( d ); - return( d.buf ); -} - - - - -void bufferAllocator::disableAutoCleanup( bool _disabled ) -{ - s_autoCleanupDisabled = _disabled; -} - - -#endif diff --git a/src/lmms_single_source.cpp b/src/lmms_single_source.cpp index eff314158..9cbcef877 100644 --- a/src/lmms_single_source.cpp +++ b/src/lmms_single_source.cpp @@ -4,7 +4,6 @@ #include "src/core/effect_tab_widget.cpp" #include "src/core/midi_tab_widget.cpp" #include "src/lib/string_pair_drag.cpp" -#include "src/lib/buffer_allocator.cpp" #include "src/lib/journalling_object.cpp" #include "src/lib/project_journal.cpp" #include "src/lib/embed.cpp" diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index f241720d8..f9c64d3d9 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -69,6 +69,7 @@ #include "arp_and_chords_tab_widget.h" #include "instrument.h" #include "audio_port.h" +#include "automation_pattern.h" #include "midi_client.h" #include "midi_port.h" #include "midi_tab_widget.h" diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 434901cc7..c6462f0b6 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -68,7 +68,6 @@ #include "tooltip.h" #include "bb_editor.h" #include "string_pair_drag.h" -#include "buffer_allocator.h" #include "main_window.h" @@ -1317,8 +1316,6 @@ patternFreezeThread::~patternFreezeThread() void patternFreezeThread::run( void ) { - bufferAllocator::disableAutoCleanup( TRUE ); - // create and install audio-sample-recorder bool b; // we cannot create local copy, because at a later stage @@ -1368,8 +1365,6 @@ void patternFreezeThread::run( void ) m_pattern->m_frozenPatternMutex.unlock(); } - bufferAllocator::disableAutoCleanup( FALSE ); - // restore original audio-device engine::getMixer()->restoreAudioDevice(); diff --git a/src/tracks/sample_track.cpp b/src/tracks/sample_track.cpp index c58c22301..cef54f25a 100644 --- a/src/tracks/sample_track.cpp +++ b/src/tracks/sample_track.cpp @@ -49,9 +49,11 @@ #include "sample_track.h" #include "song_editor.h" #include "embed.h" +#include "engine.h" #include "templates.h" #include "tooltip.h" #include "audio_port.h" +#include "automation_pattern.h" #include "sample_play_handle.h" #include "string_pair_drag.h" #include "knob.h" diff --git a/src/widgets/automatable_button.cpp b/src/widgets/automatable_button.cpp index 9f6dcfac9..99b7750ff 100644 --- a/src/widgets/automatable_button.cpp +++ b/src/widgets/automatable_button.cpp @@ -45,6 +45,7 @@ #endif +#include "automatable_object_templates.h" #include "embed.h" @@ -296,7 +297,7 @@ void automatableButtonGroup::setValue( const int _value ) #ifdef QT3 -#undef findIndex +#undef indexOf #endif diff --git a/src/widgets/automatable_slider.cpp b/src/widgets/automatable_slider.cpp index 9be9b5b7e..7c6e0cdc0 100644 --- a/src/widgets/automatable_slider.cpp +++ b/src/widgets/automatable_slider.cpp @@ -42,6 +42,7 @@ #endif +#include "automatable_object_templates.h" #include "embed.h" diff --git a/src/widgets/combobox.cpp b/src/widgets/combobox.cpp index 6b602567d..b83e544b7 100644 --- a/src/widgets/combobox.cpp +++ b/src/widgets/combobox.cpp @@ -26,6 +26,7 @@ #include "combobox.h" +#include "automatable_object_templates.h" #include "templates.h" #include "embed.h" #include "gui_templates.h" diff --git a/src/widgets/effect_label.cpp b/src/widgets/effect_label.cpp index bf7a3b06d..8918faece 100644 --- a/src/widgets/effect_label.cpp +++ b/src/widgets/effect_label.cpp @@ -29,6 +29,7 @@ #include "effect_label.h" #include "sample_track.h" #include "embed.h" +#include "engine.h" #include "gui_templates.h" #include "rename_dialog.h" #include "main_window.h" diff --git a/src/widgets/knob.cpp b/src/widgets/knob.cpp index 75b5a94e9..947a4432e 100644 --- a/src/widgets/knob.cpp +++ b/src/widgets/knob.cpp @@ -66,6 +66,7 @@ #include #include "knob.h" +#include "automatable_object_templates.h" /*#include "midi_client.h"*/ #include "embed.h" #include "spc_bg_hndl_widget.h" diff --git a/src/widgets/lcd_spinbox.cpp b/src/widgets/lcd_spinbox.cpp index 85ddcafd8..e4c4f6a04 100644 --- a/src/widgets/lcd_spinbox.cpp +++ b/src/widgets/lcd_spinbox.cpp @@ -46,6 +46,7 @@ #include "lcd_spinbox.h" +#include "automatable_object_templates.h" #include "embed.h" #include "gui_templates.h" #include "templates.h" diff --git a/src/widgets/led_checkbox.cpp b/src/widgets/led_checkbox.cpp index 8fb2a9565..584f14c49 100644 --- a/src/widgets/led_checkbox.cpp +++ b/src/widgets/led_checkbox.cpp @@ -42,6 +42,7 @@ #include "led_checkbox.h" +#include "automatable_object_templates.h" #include "embed.h" #include "gui_templates.h" #include "spc_bg_hndl_widget.h" diff --git a/src/widgets/pixmap_button.cpp b/src/widgets/pixmap_button.cpp index 0979e8b39..c792aab69 100644 --- a/src/widgets/pixmap_button.cpp +++ b/src/widgets/pixmap_button.cpp @@ -41,6 +41,7 @@ #include "pixmap_button.h" +#include "automatable_object_templates.h" #include "embed.h" diff --git a/src/widgets/rack_plugin.cpp b/src/widgets/rack_plugin.cpp index d2856aa99..ed7fe9a2a 100644 --- a/src/widgets/rack_plugin.cpp +++ b/src/widgets/rack_plugin.cpp @@ -59,6 +59,7 @@ #include "tooltip.h" #include "effect_control_dialog.h" #include "embed.h" +#include "engine.h" #include "gui_templates.h" #include "main_window.h" diff --git a/src/widgets/tempo_sync_knob.cpp b/src/widgets/tempo_sync_knob.cpp index c6ccd1041..46a907836 100644 --- a/src/widgets/tempo_sync_knob.cpp +++ b/src/widgets/tempo_sync_knob.cpp @@ -47,6 +47,7 @@ #include "tempo_sync_knob.h" +#include "automatable_object_templates.h" #include "song_editor.h" #include "embed.h" #include "main_window.h" @@ -76,7 +77,10 @@ tempoSyncKnob::tempoSyncKnob( int _knob_num, QWidget * _parent, tempoSyncKnob::~tempoSyncKnob() { - m_custom->deleteLater(); + if( m_custom ) + { + m_custom->deleteLater(); + } } diff --git a/src/widgets/visualization_widget.cpp b/src/widgets/visualization_widget.cpp index d5fb9f8f8..dc4d806e1 100644 --- a/src/widgets/visualization_widget.cpp +++ b/src/widgets/visualization_widget.cpp @@ -46,7 +46,6 @@ #include "visualization_widget.h" #include "embed.h" #include "engine.h" -#include "buffer_allocator.h" #include "templates.h" #include "tooltip.h" @@ -68,7 +67,7 @@ visualizationWidget::visualizationWidget( const QPixmap & _bg, QWidget * _p, const fpab_t frames = engine::getMixer()->framesPerAudioBuffer(); - m_buffer = bufferAllocator::alloc( frames ); + m_buffer = new surroundSampleFrame[frames]; engine::getMixer()->clearAudioBuffer( m_buffer, frames ); @@ -94,6 +93,7 @@ visualizationWidget::visualizationWidget( const QPixmap & _bg, QWidget * _p, visualizationWidget::~visualizationWidget() { + delete[] m_buffer; } diff --git a/src/widgets/volume_knob.cpp b/src/widgets/volume_knob.cpp index f49dc2f02..b866a8da6 100644 --- a/src/widgets/volume_knob.cpp +++ b/src/widgets/volume_knob.cpp @@ -28,8 +28,10 @@ #include #include "volume_knob.h" +#include "automatable_object_templates.h" #include "main_window.h" #include "config_mgr.h" +#include "engine.h" #include "text_float.h" #include "string_pair_drag.h"