diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index e648a00e3..eba606f00 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -60,6 +60,7 @@ class trackLabelButton; class EXPORT InstrumentTrack : public track, public MidiEventProcessor { Q_OBJECT + MM_OPERATORS mapPropertyFromModel(int,getVolume,setVolume,m_volumeModel); public: InstrumentTrack( TrackContainer* tc ); diff --git a/include/MemoryManager.h b/include/MemoryManager.h index ddc5596e7..e1df35e20 100644 --- a/include/MemoryManager.h +++ b/include/MemoryManager.h @@ -127,4 +127,32 @@ static void operator delete[] ( void * ptr ) \ // and just for symmetry... #define MM_FREE( ptr ) MemoryManager::free( ptr ) + + +// for debugging purposes + +#define MM_OPERATORS_DEBUG \ +public: \ +static void * operator new ( size_t size ) \ +{ \ + qDebug( "MM_OPERATORS_DEBUG: new called for %d bytes", size ); \ + return MemoryManager::alloc( size ); \ +} \ +static void * operator new[] ( size_t size ) \ +{ \ + qDebug( "MM_OPERATORS_DEBUG: new[] called for %d bytes", size ); \ + return MemoryManager::alloc( size ); \ +} \ +static void operator delete ( void * ptr ) \ +{ \ + qDebug( "MM_OPERATORS_DEBUG: delete called for %p", ptr ); \ + MemoryManager::free( ptr ); \ +} \ +static void operator delete[] ( void * ptr ) \ +{ \ + qDebug( "MM_OPERATORS_DEBUG: delete[] called for %p", ptr ); \ + MemoryManager::free( ptr ); \ +} + + #endif diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index b1cee4190..11479f368 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -91,8 +91,6 @@ public: return m_frequency; } - void updateFrequency(); - /*! Returns frequency without pitch wheel influence */ float unpitchedFrequency() const { @@ -240,10 +238,15 @@ public: return m_songGlobalParentOffset; } + void setFrequencyUpdate() + { + m_frequencyNeedsUpdate = true; + } private: class BaseDetuning { + MM_OPERATORS public: BaseDetuning( DetuningHelper* detuning ); @@ -263,6 +266,8 @@ private: } ; + void updateFrequency(); + InstrumentTrack* m_instrumentTrack; // needed for calling // InstrumentTrack::playNote f_cnt_t m_frames; // total frames to play @@ -298,6 +303,7 @@ private: const int m_midiChannel; const Origin m_origin; + bool m_frequencyNeedsUpdate; // used to update pitch } ; #endif diff --git a/include/Oscillator.h b/include/Oscillator.h index da3e8ceae..de7aee66b 100644 --- a/include/Oscillator.h +++ b/include/Oscillator.h @@ -22,8 +22,8 @@ * */ -#ifndef _OSCILLATOR_H -#define _OSCILLATOR_H +#ifndef OSCILLATOR_H +#define OSCILLATOR_H #include "lmmsconfig.h" @@ -43,6 +43,7 @@ class IntModel; class EXPORT Oscillator { + MM_OPERATORS public: enum WaveShapes { diff --git a/include/track.h b/include/track.h index d57f01110..3c9812f62 100644 --- a/include/track.h +++ b/include/track.h @@ -76,6 +76,7 @@ const int TCO_BORDER_WIDTH = 2; class trackContentObject : public Model, public JournallingObject { Q_OBJECT + MM_OPERATORS mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel); mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel); public: @@ -406,6 +407,7 @@ signals: class EXPORT track : public Model, public JournallingObject { Q_OBJECT + MM_OPERATORS mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel); mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel); public: diff --git a/plugins/organic/organic.h b/plugins/organic/organic.h index 14418d283..e41349763 100644 --- a/plugins/organic/organic.h +++ b/plugins/organic/organic.h @@ -150,6 +150,7 @@ private: struct oscPtr { + MM_OPERATORS Oscillator * oscLeft; Oscillator * oscRight; } ; @@ -181,6 +182,7 @@ private: struct OscillatorKnobs { + MM_OPERATORS OscillatorKnobs( knob * h, knob * v, diff --git a/plugins/triple_oscillator/TripleOscillator.h b/plugins/triple_oscillator/TripleOscillator.h index c10b733bb..622472080 100644 --- a/plugins/triple_oscillator/TripleOscillator.h +++ b/plugins/triple_oscillator/TripleOscillator.h @@ -124,6 +124,7 @@ private: struct oscPtr { + MM_OPERATORS Oscillator * oscLeft; Oscillator * oscRight; } ; @@ -151,6 +152,7 @@ private: struct OscillatorKnobs { + MM_OPERATORS OscillatorKnobs( knob * v, knob * p, knob * c, diff --git a/src/core/MemoryManager.cpp b/src/core/MemoryManager.cpp index 34de7de59..c901d9bf2 100644 --- a/src/core/MemoryManager.cpp +++ b/src/core/MemoryManager.cpp @@ -26,6 +26,7 @@ #include "MemoryManager.h" #include +#include MemoryPoolVector MemoryManager::s_memoryPools; diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 5b428d26a..89e472a26 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -76,7 +76,8 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, m_baseDetuning( NULL ), m_songGlobalParentOffset( 0 ), m_midiChannel( midiEventChannel >= 0 ? midiEventChannel : instrumentTrack->midiPort()->realOutputChannel() ), - m_origin( origin ) + m_origin( origin ), + m_frequencyNeedsUpdate( false ) { lock(); if( hasParent() == false ) @@ -97,6 +98,24 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, updateFrequency(); setFrames( _frames ); + + // inform attached components about new MIDI note (used for recording in Piano Roll) + if( m_origin == OriginMidiInput ) + { + m_instrumentTrack->midiNoteOn( *this ); + } + + if( hasParent() || ! m_instrumentTrack->isArpeggioEnabled() ) + { + const int baseVelocity = m_instrumentTrack->midiPort()->baseVelocity(); + + // send MidiNoteOn event + m_instrumentTrack->processOutEvent( + MidiEvent( MidiNoteOn, midiChannel(), midiKey(), midiVelocity( baseVelocity ) ), + MidiTime::fromFrames( offset(), engine::framesPerTick() ), + offset() ); + } + unlock(); } @@ -189,25 +208,9 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) } lock(); - - if( m_totalFramesPlayed == 0 ) + if( m_frequencyNeedsUpdate ) { - // inform attached components about new MIDI note (used for recording in Piano Roll) - if( m_origin == OriginMidiInput ) - { - m_instrumentTrack->midiNoteOn( *this ); - } - - if( hasParent() || ! m_instrumentTrack->isArpeggioEnabled() ) - { - const int baseVelocity = m_instrumentTrack->midiPort()->baseVelocity(); - - // send MidiNoteOn event - m_instrumentTrack->processOutEvent( - MidiEvent( MidiNoteOn, midiChannel(), midiKey(), midiVelocity( baseVelocity ) ), - MidiTime::fromFrames( offset(), engine::framesPerTick() ), - offset() ); - } + updateFrequency(); } // number of frames that can be played this period diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index dfc4e9278..c57603d28 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -148,7 +148,7 @@ InstrumentTrack::~InstrumentTrack() silenceAllNotes( true ); // now we're save deleting the instrument - delete m_instrument; + if( m_instrument ) delete m_instrument; } @@ -538,9 +538,7 @@ void InstrumentTrack::updateBaseNote() for( NotePlayHandleList::Iterator it = m_processHandles.begin(); it != m_processHandles.end(); ++it ) { - ( *it )->lock(); - ( *it )->updateFrequency(); - ( *it )->unlock(); + ( *it )->setFrequencyUpdate(); } }