From b91c6076511d1a4783cb1896df9e2adaa7e748f0 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 9 Dec 2006 23:34:57 +0000 Subject: [PATCH] support for more special instrument-properties (monophonic, own number of release-frames) git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@436 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 21 +++++++++++++++++++++ configure.in | 12 +++++++----- include/envelope_tab_widget.h | 1 + include/instrument.h | 16 ++++++++++++++++ include/instrument_track.h | 5 +++++ include/mixer.h | 7 ++++--- src/core/envelope_tab_widget.cpp | 10 +++++++++- src/core/mixer.cpp | 3 ++- src/core/note_play_handle.cpp | 19 ++++++++++++++++++- 9 files changed, 83 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a82f29fb..c88a75afb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2006-12-09 Tobias Doerffel + + * configure.in: + check for ${prefix} before extending CFLAGS etc. - should fix issue + with make-problems when using older automake-versions + + * include/instrument.h: + * include/envelope_tab_widget.h: + * src/core/envelope_tab_widget.cpp: + support for instruments which want to define their own number of + release-frames + + * include/instrument_track.h: + * include/instrument.h: + * src/core/note_play_handle.cpp: + support for monophonic instruments + + * include/mixer.h: + * src/core/mixer.cpp: + made mixer::removePlayHandle() to accept const-pointers + 2006-12-06 Javier Serrano Polo * include/note.h: diff --git a/configure.in b/configure.in index 4d50bbbdb..3de93b9f4 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-svn20061206, lmms-devel/at/lists/dot/sf/dot/net) -AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20061206) +AC_INIT(lmms, 0.2.1-svn20061209, lmms-devel/at/lists/dot/sf/dot/net) +AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20061209) AM_CONFIG_HEADER(config.h) @@ -15,9 +15,11 @@ AC_PROG_LN_S AC_PROG_GCC_TRADITIONAL AM_PROG_LIBTOOL -CFLAGS="$CFLAGS -I${prefix}/include" -CPPFLAGS="$CPPFLAGS -I${prefix}/include" -LDFLAGS="$LDFLAGS -L${prefix}/bin" +if ! test -z "${prefix}" -o "${prefix}" = "NONE" ; then + CFLAGS="$CFLAGS -I${prefix}/include" + CPPFLAGS="$CPPFLAGS -I${prefix}/include" + LDFLAGS="$LDFLAGS -L${prefix}/bin" +fi AH_TEMPLATE(BUILD_LINUX, [Build LMMS for Linux]) AH_TEMPLATE(BUILD_WIN32, [Build LMMS for Win32]) diff --git a/include/envelope_tab_widget.h b/include/envelope_tab_widget.h index 75885b979..6817efaf2 100644 --- a/include/envelope_tab_widget.h +++ b/include/envelope_tab_widget.h @@ -97,6 +97,7 @@ public: private: tabWidget * m_targetsTabWidget; envelopeAndLFOWidget * m_envLFOWidgets[TARGET_COUNT]; + instrumentTrack * m_instrumentTrack; // filter-stuff groupBox * m_filterGroupBox; diff --git a/include/instrument.h b/include/instrument.h index 42e45409c..bfde4b533 100644 --- a/include/instrument.h +++ b/include/instrument.h @@ -87,6 +87,22 @@ public: virtual f_cnt_t FASTCALL beatLen( notePlayHandle * _n ) const; + // some instruments need a certain number of release-frames even + // if no envelope is active - such instruments can re-implement this + // method for returning how many frames they at least like to have for + // release + virtual f_cnt_t desiredReleaseFrames( void ) const + { + return( 0 ); + } + + // monophonic instruments can re-implement this indicate that they do + // not allow more then one note being played at the same time + virtual bool isMonophonic( void ) const + { + return( FALSE ); + } + // instrument-play-handles use this for checking whether they can mark // themselves as done, so that mixer trashes them inline virtual bool valid( void ) const diff --git a/include/instrument_track.h b/include/instrument_track.h index 24dd42b02..714a6c24a 100755 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -107,6 +107,11 @@ public: void FASTCALL playNote( notePlayHandle * _n, bool _try_parallelizing ); QString instrumentName( void ) const; + inline const instrument * getInstrument( void ) const + { + return( m_instrument ); + } + void FASTCALL deleteNotePluginData( notePlayHandle * _n ); // name-stuff diff --git a/include/mixer.h b/include/mixer.h index eba5e8d52..4e1a4b17d 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -172,7 +172,7 @@ public: return( FALSE ); } - inline void removePlayHandle( playHandle * _ph ) + inline void removePlayHandle( const playHandle * _ph ) { m_playHandlesToRemove.push_back( _ph ); } @@ -287,6 +287,7 @@ public slots: void setHighQuality( bool _hq_on = FALSE ); void setClipScaling( bool _state ); + signals: void sampleRateChanged( void ); void nextAudioBuffer( const surroundSampleFrame *, int _frames ); @@ -294,7 +295,7 @@ signals: private: mixer( engine * _engine ); - ~mixer(); + virtual ~mixer(); void startProcessing( void ); void stopProcessing( void ); @@ -341,7 +342,7 @@ private: int m_parallelizingLevel; playHandleVector m_playHandles; - playHandleVector m_playHandlesToRemove; + constPlayHandleVector m_playHandlesToRemove; qualityLevels m_qualityLevel; float m_masterGain; diff --git a/src/core/envelope_tab_widget.cpp b/src/core/envelope_tab_widget.cpp index af85c1285..8ea5181ce 100644 --- a/src/core/envelope_tab_widget.cpp +++ b/src/core/envelope_tab_widget.cpp @@ -84,7 +84,8 @@ static const QString targetNames[envelopeTabWidget::TARGET_COUNT][2] = envelopeTabWidget::envelopeTabWidget( instrumentTrack * _instrument_track ) : QWidget( _instrument_track->tabWidgetParent() ), - journallingObject( _instrument_track->eng() ) + journallingObject( _instrument_track->eng() ), + m_instrumentTrack( _instrument_track ) { m_targetsTabWidget = new tabWidget( tr( "TARGET" ), this ); @@ -525,6 +526,13 @@ f_cnt_t envelopeTabWidget::releaseFrames( const bool _only_vol ) { f_cnt_t ret_val = m_envLFOWidgets[VOLUME]->used() ? m_envLFOWidgets[VOLUME]->m_rFrames : 0; + if( m_instrumentTrack->getInstrument()->desiredReleaseFrames() > + ret_val ) + { + ret_val = m_instrumentTrack->getInstrument()-> + desiredReleaseFrames(); + } + if( m_envLFOWidgets[VOLUME]->used() == FALSE ) { for( int i = VOLUME+1; i < TARGET_COUNT; ++i ) diff --git a/src/core/mixer.cpp b/src/core/mixer.cpp index ab13838d9..4fe40f421 100644 --- a/src/core/mixer.cpp +++ b/src/core/mixer.cpp @@ -235,8 +235,9 @@ const surroundSampleFrame * mixer::renderNextBuffer( void ) { if( *it == m_playHandlesToRemove.front() ) { + delete *it; m_playHandles.erase( it ); - delete m_playHandlesToRemove.front(); + //delete m_playHandlesToRemove.front(); break; } ++it; diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index c67377853..5c55293b2 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -60,6 +60,20 @@ notePlayHandle::notePlayHandle( instrumentTrack * _it, m_muted( FALSE ), m_bbTrack( NULL ) { + // if the instrument is monophonic we do not allow other note-play- + // handles to exist for this track and therefore remove them + if( m_instrumentTrack->getInstrument()->isMonophonic() ) + { + constNotePlayHandleVector cphv = nphsOfInstrumentTrack( + m_instrumentTrack ); + for( constNotePlayHandleVector::iterator it = cphv.begin(); + it != cphv.end(); ++it ) + { + m_instrumentTrack->eng()->getMixer()-> + removePlayHandle( *it ); + } + } + setDetuning( _n.detuning() ); if( detuning() ) { @@ -318,7 +332,9 @@ void notePlayHandle::setFrames( const f_cnt_t _frames ) float notePlayHandle::volumeLevel( const f_cnt_t _frame ) { return( ( m_instrumentTrack != NULL ) ? - m_instrumentTrack->m_envWidget->volumeLevel( this, _frame ) : 0 ); + m_instrumentTrack->m_envWidget->volumeLevel( this, _frame ) + : + 0 ); } @@ -388,6 +404,7 @@ constNotePlayHandleVector notePlayHandle::nphsOfInstrumentTrack( + bool notePlayHandle::operator==( const notePlayHandle & _nph ) const { return( length() == _nph.length() &&