More fixes

This commit is contained in:
Vesa
2014-08-23 16:04:50 +03:00
parent 9972cb3d4d
commit 5e4308507b
10 changed files with 71 additions and 27 deletions

View File

@@ -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 );

View File

@@ -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

View File

@@ -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

View File

@@ -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
{

View File

@@ -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:

View File

@@ -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,

View File

@@ -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,

View File

@@ -26,6 +26,7 @@
#include "MemoryManager.h"
#include <QtGlobal>
#include <stdint.h>
MemoryPoolVector MemoryManager::s_memoryPools;

View File

@@ -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

View File

@@ -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();
}
}