Renamed PlayHandle classes and some functions with bool return values

Next big coding style update - this time all PlayHandle classes are
affected. Functions like done() and released() were renamed to
isFinished() and isReleased().
This commit is contained in:
Tobias Doerffel
2014-01-29 23:52:57 +01:00
parent b4c4b293a0
commit ca0e413fd3
59 changed files with 413 additions and 419 deletions

View File

@@ -25,8 +25,9 @@
#include "Instrument.h"
#include "InstrumentTrack.h"
#include "DummyInstrument.h"
#include "note_play_handle.h"
#include "NotePlayHandle.h"
#include "embed.h"
#include "engine.h"
Instrument::Instrument( InstrumentTrack * _instrument_track,
@@ -53,14 +54,14 @@ void Instrument::play( sampleFrame * )
void Instrument::deleteNotePluginData( notePlayHandle * )
void Instrument::deleteNotePluginData( NotePlayHandle * )
{
}
f_cnt_t Instrument::beatLen( notePlayHandle * ) const
f_cnt_t Instrument::beatLen( NotePlayHandle * ) const
{
return( 0 );
}
@@ -96,7 +97,7 @@ bool Instrument::isFromTrack( const track * _track ) const
void Instrument::applyRelease( sampleFrame * buf, const notePlayHandle * _n )
void Instrument::applyRelease( sampleFrame * buf, const NotePlayHandle * _n )
{
const fpp_t frames = _n->framesLeftForCurrentPeriod();
const fpp_t fpp = engine::mixer()->framesPerPeriod();

View File

@@ -28,8 +28,8 @@
#include "embed.h"
#include "engine.h"
#include "InstrumentTrack.h"
#include "note_play_handle.h"
#include "preset_preview_play_handle.h"
#include "NotePlayHandle.h"
#include "PresetPreviewPlayHandle.h"
@@ -220,7 +220,7 @@ InstrumentFunctionNoteStacking::~InstrumentFunctionNoteStacking()
void InstrumentFunctionNoteStacking::processNote( notePlayHandle * _n )
void InstrumentFunctionNoteStacking::processNote( NotePlayHandle * _n )
{
const int base_note_key = _n->key();
const ChordTable & chord_table = ChordTable::getInstance();
@@ -266,7 +266,7 @@ void InstrumentFunctionNoteStacking::processNote( notePlayHandle * _n )
_n->detuning() );
// create sub-note-play-handle, only note is
// different
new notePlayHandle( _n->instrumentTrack(),
new NotePlayHandle( _n->instrumentTrack(),
_n->offset(),
_n->frames(), note_copy,
_n );
@@ -344,13 +344,12 @@ InstrumentFunctionArpeggio::~InstrumentFunctionArpeggio()
void InstrumentFunctionArpeggio::processNote( notePlayHandle * _n )
void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n )
{
const int base_note_key = _n->key();
if( _n->isTopNote() == false ||
!m_arpEnabledModel.value() ||
( _n->released() && _n->releaseFramesDone() >=
_n->actualReleaseFramesToDo() ) )
( _n->isReleased() && _n->releaseFramesDone() >= _n->actualReleaseFramesToDo() ) )
{
return;
}
@@ -358,13 +357,12 @@ void InstrumentFunctionArpeggio::processNote( notePlayHandle * _n )
const int selected_arp = m_arpModel.value();
ConstNotePlayHandleList cnphv = notePlayHandle::nphsOfInstrumentTrack(
ConstNotePlayHandleList cnphv = NotePlayHandle::nphsOfInstrumentTrack(
_n->instrumentTrack() );
if( m_arpModeModel.value() != FreeMode && cnphv.size() == 0 )
{
// maybe we're playing only a preset-preview-note?
cnphv = presetPreviewPlayHandle::nphsOfInstrumentTrack(
_n->instrumentTrack() );
cnphv = PresetPreviewPlayHandle::nphsOfInstrumentTrack( _n->instrumentTrack() );
if( cnphv.size() == 0 )
{
// still nothing found here, so lets return
@@ -471,7 +469,7 @@ void InstrumentFunctionArpeggio::processNote( notePlayHandle * _n )
}
float vol_level = 1.0f;
if( _n->released() )
if( _n->isReleased() )
{
vol_level = _n->volumeLevel( cur_frame + gated_frames );
}
@@ -485,7 +483,7 @@ void InstrumentFunctionArpeggio::processNote( notePlayHandle * _n )
// create sub-note-play-handle, only ptr to note is different
// and is_arp_note=true
new notePlayHandle( _n->instrumentTrack(),
new NotePlayHandle( _n->instrumentTrack(),
( ( m_arpModeModel.value() != FreeMode ) ?
cnphv.first()->offset() :
_n->offset() ) +

View File

@@ -31,7 +31,7 @@
#include "EnvelopeAndLfoParameters.h"
#include "Instrument.h"
#include "InstrumentTrack.h"
#include "note_play_handle.h"
#include "NotePlayHandle.h"
@@ -106,13 +106,13 @@ InstrumentSoundShaping::~InstrumentSoundShaping()
float InstrumentSoundShaping::volumeLevel( notePlayHandle * _n,
float InstrumentSoundShaping::volumeLevel( NotePlayHandle * _n,
const f_cnt_t _frame )
{
f_cnt_t release_begin = _frame - _n->releaseFramesDone() +
_n->framesBeforeRelease();
if( _n->released() == false )
if( _n->isReleased() == false )
{
release_begin += engine::mixer()->framesPerPeriod();
}
@@ -129,13 +129,13 @@ float InstrumentSoundShaping::volumeLevel( notePlayHandle * _n,
void InstrumentSoundShaping::processAudioBuffer( sampleFrame * _ab,
const fpp_t _frames,
notePlayHandle * _n )
NotePlayHandle * _n )
{
const f_cnt_t total_frames = _n->totalFramesPlayed();
f_cnt_t release_begin = total_frames - _n->releaseFramesDone() +
_n->framesBeforeRelease();
if( _n->released() == false )
if( _n->isReleased() == false )
{
release_begin += engine::mixer()->framesPerPeriod();
}

View File

@@ -27,11 +27,10 @@
#include "Mixer.h"
#include "FxMixer.h"
#include "MixHelpers.h"
#include "play_handle.h"
#include "song.h"
#include "templates.h"
#include "EnvelopeAndLfoParameters.h"
#include "note_play_handle.h"
#include "NotePlayHandle.h"
#include "InstrumentTrack.h"
#include "debug.h"
#include "engine.h"
@@ -214,8 +213,7 @@ void MixerWorkerThread::processJobQueue()
switch( it->type )
{
case PlayHandle:
( (playHandle *) it->job )->
play( m_workingBuf );
( (::PlayHandle *) it->job )->play( m_workingBuf );
break;
case AudioPortEffects:
{
@@ -588,8 +586,7 @@ const surroundSampleFrame * Mixer::renderNextBuffer()
ConstPlayHandleList::Iterator it_rem = m_playHandlesToRemove.begin();
while( it_rem != m_playHandlesToRemove.end() )
{
PlayHandleList::Iterator it = qFind( m_playHandles.begin(),
m_playHandles.end(), *it_rem );
PlayHandleList::Iterator it = qFind( m_playHandles.begin(), m_playHandles.end(), *it_rem );
if( it != m_playHandles.end() )
{
@@ -618,9 +615,7 @@ const surroundSampleFrame * Mixer::renderNextBuffer()
// STAGE 1: run and render all play handles
FILL_JOB_QUEUE(PlayHandleList,m_playHandles,
MixerWorkerThread::PlayHandle,
!( *it )->done());
FILL_JOB_QUEUE(PlayHandleList,m_playHandles,MixerWorkerThread::PlayHandle, !( *it )->isFinished());
START_JOBS();
WAIT_FOR_JOBS();
@@ -634,7 +629,7 @@ const surroundSampleFrame * Mixer::renderNextBuffer()
++it;
continue;
}
if( ( *it )->done() )
if( ( *it )->isFinished() )
{
delete *it;
it = m_playHandles.erase( it );
@@ -689,12 +684,11 @@ void Mixer::clear()
{
// TODO: m_midiClient->noteOffAll();
lock();
for( PlayHandleList::Iterator it = m_playHandles.begin();
it != m_playHandles.end(); ++it )
for( PlayHandleList::Iterator it = m_playHandles.begin(); it != m_playHandles.end(); ++it )
{
// we must not delete instrument-play-handles as they exist
// during the whole lifetime of an instrument
if( ( *it )->type() != playHandle::InstrumentPlayHandle )
if( ( *it )->type() != PlayHandle::TypeInstrumentPlayHandle )
{
m_playHandlesToRemove.push_back( *it );
}
@@ -913,7 +907,7 @@ void Mixer::removeAudioPort( AudioPort * _port )
void Mixer::removePlayHandle( playHandle * _ph )
void Mixer::removePlayHandle( PlayHandle * _ph )
{
lock();
// check thread affinity as we must not delete play-handles
@@ -966,10 +960,9 @@ bool Mixer::hasNotePlayHandles()
{
lock();
for( PlayHandleList::Iterator it = m_playHandles.begin();
it != m_playHandles.end(); ++it )
for( PlayHandleList::Iterator it = m_playHandles.begin(); it != m_playHandles.end(); ++it )
{
if( (*it)->type() == playHandle::NotePlayHandle )
if( (*it)->type() == PlayHandle::TypeNotePlayHandle )
{
unlock();
return true;

View File

@@ -1,6 +1,6 @@
/*
* note_play_handle.cpp - implementation of class notePlayHandle, part of
* rendering engine
* NotePlayHandle.cpp - implementation of class NotePlayHandle which manages
* playback of a single note by an instrument
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
@@ -23,7 +23,7 @@
*
*/
#include "note_play_handle.h"
#include "NotePlayHandle.h"
#include "basic_filters.h"
#include "config_mgr.h"
#include "DetuningHelper.h"
@@ -34,7 +34,7 @@
#include "song.h"
notePlayHandle::BaseDetuning::BaseDetuning( DetuningHelper *detuning ) :
NotePlayHandle::BaseDetuning::BaseDetuning( DetuningHelper *detuning ) :
m_value( detuning ? detuning->automationPattern()->valueAt( 0 ) : 0 )
{
}
@@ -44,20 +44,19 @@ notePlayHandle::BaseDetuning::BaseDetuning( DetuningHelper *detuning ) :
notePlayHandle::notePlayHandle( InstrumentTrack * _it,
const f_cnt_t _offset,
const f_cnt_t _frames,
const note & _n,
notePlayHandle *parent,
const bool _part_of_arp,
int midiEventChannel,
Origin origin ) :
playHandle( NotePlayHandle, _offset ),
note( _n.length(), _n.pos(), _n.key(),
_n.getVolume(), _n.getPanning(), _n.detuning() ),
NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack,
const f_cnt_t _offset,
const f_cnt_t _frames,
const note& n,
NotePlayHandle *parent,
const bool _part_of_arp,
int midiEventChannel,
Origin origin ) :
PlayHandle( TypeNotePlayHandle, _offset ),
note( n.length(), n.pos(), n.key(), n.getVolume(), n.getPanning(), n.detuning() ),
m_pluginData( NULL ),
m_filter( NULL ),
m_instrumentTrack( _it ),
m_instrumentTrack( instrumentTrack ),
m_frames( 0 ),
m_totalFramesPlayed( 0 ),
m_framesBeforeRelease( 0 ),
@@ -72,12 +71,12 @@ notePlayHandle::notePlayHandle( InstrumentTrack * _it,
m_patternIndex( 0 ),
#endif
m_origTempo( engine::getSong()->getTempo() ),
m_origBaseNote( instrumentTrack()->baseNoteModel()->value() ),
m_origBaseNote( instrumentTrack->baseNoteModel()->value() ),
m_frequency( 0 ),
m_unpitchedFrequency( 0 ),
m_baseDetuning( NULL ),
m_songGlobalParentOffset( 0 ),
m_midiChannel( midiEventChannel >= 0 ? midiEventChannel : instrumentTrack()->midiPort()->realOutputChannel() ),
m_midiChannel( midiEventChannel >= 0 ? midiEventChannel : instrumentTrack->midiPort()->realOutputChannel() ),
m_origin( origin )
{
if( isTopNote() )
@@ -111,7 +110,7 @@ notePlayHandle::notePlayHandle( InstrumentTrack * _it,
m_instrumentTrack->midiNoteOn( *this );
}
if( !isTopNote() || !instrumentTrack()->isArpeggioEnabled() )
if( !isTopNote() || !instrumentTrack->isArpeggioEnabled() )
{
// send MidiNoteOn event
m_instrumentTrack->processOutEvent(
@@ -123,7 +122,7 @@ notePlayHandle::notePlayHandle( InstrumentTrack * _it,
notePlayHandle::~notePlayHandle()
NotePlayHandle::~NotePlayHandle()
{
noteOff( 0 );
@@ -163,7 +162,7 @@ notePlayHandle::~notePlayHandle()
void notePlayHandle::setVolume( const volume_t _volume )
void NotePlayHandle::setVolume( const volume_t _volume )
{
note::setVolume( _volume );
@@ -173,7 +172,7 @@ void notePlayHandle::setVolume( const volume_t _volume )
void notePlayHandle::setPanning( const panning_t panning )
void NotePlayHandle::setPanning( const panning_t panning )
{
note::setPanning( panning );
@@ -186,7 +185,7 @@ void notePlayHandle::setPanning( const panning_t panning )
int notePlayHandle::midiVelocity() const
int NotePlayHandle::midiVelocity() const
{
int vel = getVolume();
if( m_instrumentTrack->getVolume() < DefaultVolume )
@@ -199,7 +198,7 @@ int notePlayHandle::midiVelocity() const
int notePlayHandle::midiKey() const
int NotePlayHandle::midiKey() const
{
return key() - m_origBaseNote + instrumentTrack()->baseNoteModel()->value();
}
@@ -207,7 +206,7 @@ int notePlayHandle::midiKey() const
void notePlayHandle::play( sampleFrame * _working_buffer )
void NotePlayHandle::play( sampleFrame * _working_buffer )
{
if( m_muted )
{
@@ -236,7 +235,7 @@ void notePlayHandle::play( sampleFrame * _working_buffer )
f_cnt_t todo = engine::mixer()->framesPerPeriod();
// if this note is base-note for arpeggio, always set
// m_releaseFramesToDo to bigger value than m_releaseFramesDone
// because we do not allow notePlayHandle::done() to be true
// because we do not allow NotePlayHandle::isFinished() to be true
// until all sub-notes are completely played and no new ones
// are inserted by arpAndChordsTabWidget::processNote()
if( isArpeggioBaseNote() )
@@ -290,7 +289,7 @@ void notePlayHandle::play( sampleFrame * _working_buffer )
it != m_subNotes.end(); )
{
( *it )->play( _working_buffer );
if( ( *it )->done() )
if( ( *it )->isFinished() )
{
delete *it;
it = m_subNotes.erase( it );
@@ -303,7 +302,7 @@ void notePlayHandle::play( sampleFrame * _working_buffer )
// if this note is a base-note and there're no more sub-notes left we
// can set m_releaseFramesDone to m_releaseFramesToDo so that
// notePlayHandle::done() returns true and also this base-note is
// NotePlayHandle::isFinished() returns true and also this base-note is
// removed from mixer's active note vector
if( m_released && isArpeggioBaseNote() && m_subNotes.size() == 0 )
{
@@ -318,7 +317,7 @@ void notePlayHandle::play( sampleFrame * _working_buffer )
f_cnt_t notePlayHandle::framesLeft() const
f_cnt_t NotePlayHandle::framesLeft() const
{
if( instrumentTrack()->isSustainPedalPressed() )
{
@@ -339,7 +338,15 @@ f_cnt_t notePlayHandle::framesLeft() const
bool notePlayHandle::isFromTrack( const track * _track ) const
fpp_t NotePlayHandle::framesLeftForCurrentPeriod() const
{
return (fpp_t) qMin<f_cnt_t>( framesLeft(), engine::mixer()->framesPerPeriod() );
}
bool NotePlayHandle::isFromTrack( const track * _track ) const
{
return m_instrumentTrack == _track || m_bbTrack == _track;
}
@@ -347,7 +354,7 @@ bool notePlayHandle::isFromTrack( const track * _track ) const
void notePlayHandle::noteOff( const f_cnt_t _s )
void NotePlayHandle::noteOff( const f_cnt_t _s )
{
if( m_released )
{
@@ -380,7 +387,7 @@ void notePlayHandle::noteOff( const f_cnt_t _s )
f_cnt_t notePlayHandle::actualReleaseFramesToDo() const
f_cnt_t NotePlayHandle::actualReleaseFramesToDo() const
{
return m_instrumentTrack->m_soundShaping.releaseFrames(/*
isArpeggioBaseNote()*/ );
@@ -389,7 +396,7 @@ f_cnt_t notePlayHandle::actualReleaseFramesToDo() const
void notePlayHandle::setFrames( const f_cnt_t _frames )
void NotePlayHandle::setFrames( const f_cnt_t _frames )
{
m_frames = _frames;
if( m_frames == 0 )
@@ -402,7 +409,7 @@ void notePlayHandle::setFrames( const f_cnt_t _frames )
float notePlayHandle::volumeLevel( const f_cnt_t _frame )
float NotePlayHandle::volumeLevel( const f_cnt_t _frame )
{
return m_instrumentTrack->m_soundShaping.volumeLevel( this, _frame );
}
@@ -410,7 +417,7 @@ float notePlayHandle::volumeLevel( const f_cnt_t _frame )
bool notePlayHandle::isArpeggioBaseNote() const
bool NotePlayHandle::isArpeggioBaseNote() const
{
return isTopNote() && ( m_partOfArpeggio || m_instrumentTrack->isArpeggioEnabled() );
}
@@ -418,7 +425,7 @@ bool notePlayHandle::isArpeggioBaseNote() const
void notePlayHandle::mute()
void NotePlayHandle::mute()
{
// mute all sub-notes
for( NotePlayHandleList::Iterator it = m_subNotes.begin();
@@ -432,7 +439,7 @@ void notePlayHandle::mute()
int notePlayHandle::index() const
int NotePlayHandle::index() const
{
const PlayHandleList & playHandles =
engine::mixer()->playHandles();
@@ -440,11 +447,9 @@ int notePlayHandle::index() const
for( PlayHandleList::ConstIterator it = playHandles.begin();
it != playHandles.end(); ++it )
{
const notePlayHandle * nph =
dynamic_cast<const notePlayHandle *>( *it );
if( nph == NULL ||
nph->m_instrumentTrack != m_instrumentTrack ||
nph->released() == true )
const NotePlayHandle * nph =
dynamic_cast<const NotePlayHandle *>( *it );
if( nph == NULL || nph->m_instrumentTrack != m_instrumentTrack || nph->isReleased() )
{
continue;
}
@@ -460,7 +465,7 @@ int notePlayHandle::index() const
ConstNotePlayHandleList notePlayHandle::nphsOfInstrumentTrack(
ConstNotePlayHandleList NotePlayHandle::nphsOfInstrumentTrack(
const InstrumentTrack * _it, bool _all_ph )
{
const PlayHandleList & playHandles = engine::mixer()->playHandles();
@@ -469,10 +474,9 @@ ConstNotePlayHandleList notePlayHandle::nphsOfInstrumentTrack(
for( PlayHandleList::ConstIterator it = playHandles.begin();
it != playHandles.end(); ++it )
{
const notePlayHandle * nph =
dynamic_cast<const notePlayHandle *>( *it );
if( nph != NULL && nph->m_instrumentTrack == _it &&
( nph->released() == false || _all_ph == true ) )
const NotePlayHandle * nph =
dynamic_cast<const NotePlayHandle *>( *it );
if( nph != NULL && nph->m_instrumentTrack == _it && ( nph->isReleased() == false || _all_ph == true ) )
{
cnphv.push_back( nph );
}
@@ -483,7 +487,7 @@ ConstNotePlayHandleList notePlayHandle::nphsOfInstrumentTrack(
bool notePlayHandle::operator==( const notePlayHandle & _nph ) const
bool NotePlayHandle::operator==( const NotePlayHandle & _nph ) const
{
return length() == _nph.length() &&
pos() == _nph.pos() &&
@@ -504,7 +508,7 @@ bool notePlayHandle::operator==( const notePlayHandle & _nph ) const
void notePlayHandle::updateFrequency()
void NotePlayHandle::updateFrequency()
{
const float pitch =
( key() -
@@ -526,7 +530,7 @@ void notePlayHandle::updateFrequency()
void notePlayHandle::processMidiTime( const MidiTime& time )
void NotePlayHandle::processMidiTime( const MidiTime& time )
{
if( detuning() && time >= songGlobalParentOffset()+pos() )
{
@@ -542,7 +546,7 @@ void notePlayHandle::processMidiTime( const MidiTime& time )
void notePlayHandle::resize( const bpm_t _new_tempo )
void NotePlayHandle::resize( const bpm_t _new_tempo )
{
double completed = m_totalFramesPlayed / (double) m_frames;
double new_frames = m_origFrames * m_origTempo / (double) _new_tempo;

View File

@@ -1,8 +1,7 @@
/*
* preset_preview_play_handle.cpp - implementation of class
* presetPreviewPlayHandle
* PresetPreviewPlayHandle.cpp - implementation of class PresetPreviewPlayHandle
*
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -26,55 +25,53 @@
#include <QtCore/QFileInfo>
#include <QtCore/QMutexLocker>
#include "preset_preview_play_handle.h"
#include "PresetPreviewPlayHandle.h"
#include "debug.h"
#include "engine.h"
#include "Instrument.h"
#include "InstrumentTrack.h"
#include "MidiPort.h"
#include "mmp.h"
#include "note_play_handle.h"
#include "NotePlayHandle.h"
#include "ProjectJournal.h"
#include "TrackContainer.h"
// invisible track-container which is needed as parent for preview-channels
class previewTrackContainer : public TrackContainer
class PreviewTrackContainer : public TrackContainer
{
public:
previewTrackContainer() :
PreviewTrackContainer() :
m_previewInstrumentTrack( NULL ),
m_previewNote( NULL ),
m_dataMutex()
{
setJournalling( FALSE );
m_previewInstrumentTrack = dynamic_cast<InstrumentTrack *>(
track::create( track::InstrumentTrack,
this ) );
m_previewInstrumentTrack = dynamic_cast<InstrumentTrack *>( track::create( track::InstrumentTrack, this ) );
m_previewInstrumentTrack->setJournalling( FALSE );
}
virtual ~previewTrackContainer()
virtual ~PreviewTrackContainer()
{
}
virtual QString nodeName() const
{
return "bbtrackcontainer";
return "previewtrackcontainer";
}
InstrumentTrack * previewInstrumentTrack()
InstrumentTrack* previewInstrumentTrack()
{
return m_previewInstrumentTrack;
}
notePlayHandle * previewNote()
NotePlayHandle* previewNote()
{
return m_previewNote;
}
void setPreviewNote( notePlayHandle * _note )
void setPreviewNote( NotePlayHandle * _note )
{
m_previewNote = _note;
}
@@ -101,22 +98,21 @@ public:
private:
InstrumentTrack * m_previewInstrumentTrack;
notePlayHandle * m_previewNote;
InstrumentTrack* m_previewInstrumentTrack;
NotePlayHandle* m_previewNote;
QMutex m_dataMutex;
friend class presetPreviewPlayHandle;
friend class PresetPreviewPlayHandle;
} ;
previewTrackContainer * presetPreviewPlayHandle::s_previewTC;
PreviewTrackContainer * PresetPreviewPlayHandle::s_previewTC;
presetPreviewPlayHandle::presetPreviewPlayHandle( const QString & _preset_file,
bool _load_by_plugin ) :
playHandle( PresetPreviewHandle ),
PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, bool _load_by_plugin ) :
PlayHandle( TypePresetPreviewHandle ),
m_previewNote( NULL )
{
s_previewTC->lockData();
@@ -164,7 +160,7 @@ presetPreviewPlayHandle::presetPreviewPlayHandle( const QString & _preset_file,
midiPort()->setMode( MidiPort::Disabled );
// create note-play-handle for it
m_previewNote = new notePlayHandle(
m_previewNote = new NotePlayHandle(
s_previewTC->previewInstrumentTrack(), 0,
typeInfo<f_cnt_t>::max() / 2,
note( 0, 0, DefaultKey, 100 ) );
@@ -179,7 +175,7 @@ presetPreviewPlayHandle::presetPreviewPlayHandle( const QString & _preset_file,
presetPreviewPlayHandle::~presetPreviewPlayHandle()
PresetPreviewPlayHandle::~PresetPreviewPlayHandle()
{
s_previewTC->lockData();
// not muted by other preset-preview-handle?
@@ -195,7 +191,7 @@ presetPreviewPlayHandle::~presetPreviewPlayHandle()
void presetPreviewPlayHandle::play( sampleFrame * _working_buffer )
void PresetPreviewPlayHandle::play( sampleFrame * _working_buffer )
{
m_previewNote->play( _working_buffer );
}
@@ -203,7 +199,7 @@ void presetPreviewPlayHandle::play( sampleFrame * _working_buffer )
bool presetPreviewPlayHandle::done() const
bool PresetPreviewPlayHandle::isFinished() const
{
return m_previewNote->isMuted();
}
@@ -211,7 +207,7 @@ bool presetPreviewPlayHandle::done() const
bool presetPreviewPlayHandle::isFromTrack( const track * _track ) const
bool PresetPreviewPlayHandle::isFromTrack( const track * _track ) const
{
return s_previewTC->previewInstrumentTrack() == _track;
}
@@ -219,18 +215,18 @@ bool presetPreviewPlayHandle::isFromTrack( const track * _track ) const
void presetPreviewPlayHandle::init()
void PresetPreviewPlayHandle::init()
{
if( !s_previewTC )
{
s_previewTC = new previewTrackContainer;
s_previewTC = new PreviewTrackContainer;
}
}
void presetPreviewPlayHandle::cleanup()
void PresetPreviewPlayHandle::cleanup()
{
delete s_previewTC;
s_previewTC = NULL;
@@ -239,7 +235,7 @@ void presetPreviewPlayHandle::cleanup()
ConstNotePlayHandleList presetPreviewPlayHandle::nphsOfInstrumentTrack(
ConstNotePlayHandleList PresetPreviewPlayHandle::nphsOfInstrumentTrack(
const InstrumentTrack * _it )
{
ConstNotePlayHandleList cnphv;
@@ -256,7 +252,7 @@ ConstNotePlayHandleList presetPreviewPlayHandle::nphsOfInstrumentTrack(
bool presetPreviewPlayHandle::isPreviewing()
bool PresetPreviewPlayHandle::isPreviewing()
{
return s_previewTC->isPreviewing();
}

View File

@@ -34,7 +34,7 @@
SamplePlayHandle::SamplePlayHandle( const QString& sampleFile ) :
playHandle( playHandle::SamplePlayHandle ),
PlayHandle( TypeSamplePlayHandle ),
m_sampleBuffer( new SampleBuffer( sampleFile ) ),
m_doneMayReturnTrue( true ),
m_frame( 0 ),
@@ -51,7 +51,7 @@ SamplePlayHandle::SamplePlayHandle( const QString& sampleFile ) :
SamplePlayHandle::SamplePlayHandle( SampleBuffer* sampleBuffer ) :
playHandle( playHandle::SamplePlayHandle ),
PlayHandle( TypeSamplePlayHandle ),
m_sampleBuffer( sharedObject::ref( sampleBuffer ) ),
m_doneMayReturnTrue( true ),
m_frame( 0 ),
@@ -68,7 +68,7 @@ SamplePlayHandle::SamplePlayHandle( SampleBuffer* sampleBuffer ) :
SamplePlayHandle::SamplePlayHandle( SampleTCO* tco ) :
playHandle( playHandle::SamplePlayHandle ),
PlayHandle( TypeSamplePlayHandle ),
m_sampleBuffer( sharedObject::ref( tco->sampleBuffer() ) ),
m_doneMayReturnTrue( true ),
m_frame( 0 ),
@@ -85,7 +85,7 @@ SamplePlayHandle::SamplePlayHandle( SampleTCO* tco ) :
SamplePlayHandle::SamplePlayHandle( pattern * _pattern ) :
playHandle( playHandle::SamplePlayHandle ),
PlayHandle( TypeSamplePlayHandle ),
m_sampleBuffer( sharedObject::ref( _pattern->frozenPattern() ) ),
m_doneMayReturnTrue( true ),
m_frame( 0 ),
@@ -140,9 +140,9 @@ void SamplePlayHandle::play( sampleFrame * _working_buffer )
bool SamplePlayHandle::done() const
bool SamplePlayHandle::isFinished() const
{
return( framesDone() >= totalFrames() && m_doneMayReturnTrue == true );
return framesDone() >= totalFrames() && m_doneMayReturnTrue == true;
}
@@ -150,7 +150,7 @@ bool SamplePlayHandle::done() const
bool SamplePlayHandle::isFromTrack( const track * _track ) const
{
return( m_track == _track || m_bbTrack == _track );
return m_track == _track || m_bbTrack == _track;
}
@@ -158,9 +158,7 @@ bool SamplePlayHandle::isFromTrack( const track * _track ) const
f_cnt_t SamplePlayHandle::totalFrames() const
{
return( ( m_sampleBuffer->endFrame() - m_sampleBuffer->startFrame() ) *
( engine::mixer()->processingSampleRate() /
engine::mixer()->baseSampleRate() ) );
return ( m_sampleBuffer->endFrame() - m_sampleBuffer->startFrame() ) * ( engine::mixer()->processingSampleRate() / engine::mixer()->baseSampleRate() );
}

View File

@@ -34,7 +34,7 @@
SampleRecordHandle::SampleRecordHandle( SampleTCO* tco ) :
playHandle( SamplePlayHandle ),
PlayHandle( TypeSamplePlayHandle ),
m_framesRecorded( 0 ),
m_minLength( tco->length() ),
m_track( tco->getTrack() ),
@@ -84,7 +84,7 @@ void SampleRecordHandle::play( sampleFrame * /*_working_buffer*/ )
bool SampleRecordHandle::done() const
bool SampleRecordHandle::isFinished() const
{
return false;
}

View File

@@ -3,7 +3,7 @@
/*
* engine.cpp - implementation of LMMS' engine-system
*
* Copyright (c) 2006-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -39,7 +39,7 @@
#include "Mixer.h"
#include "pattern.h"
#include "piano_roll.h"
#include "preset_preview_play_handle.h"
#include "PresetPreviewPlayHandle.h"
#include "ProjectJournal.h"
#include "project_notes.h"
#include "Plugin.h"
@@ -102,7 +102,7 @@ void engine::init( const bool _has_gui )
s_mainWindow->finalize();
}
presetPreviewPlayHandle::init();
PresetPreviewPlayHandle::init();
s_dummyTC = new DummyTrackContainer;
s_mixer->startProcessing();
@@ -122,7 +122,7 @@ void engine::destroy()
deleteHelper( &s_automationEditor );
deleteHelper( &s_fxMixerView );
presetPreviewPlayHandle::cleanup();
PresetPreviewPlayHandle::cleanup();
InstrumentTrackView::cleanupWindowCache();
s_song->clearProject();

View File

@@ -50,7 +50,7 @@
#include "FileDialog.h"
#include "MidiClient.h"
#include "mmp.h"
#include "note_play_handle.h"
#include "NotePlayHandle.h"
#include "pattern.h"
#include "piano_roll.h"
#include "ProjectJournal.h"
@@ -232,8 +232,8 @@ void song::setTempo()
for( PlayHandleList::Iterator it = playHandles.begin();
it != playHandles.end(); ++it )
{
notePlayHandle * nph = dynamic_cast<notePlayHandle *>( *it );
if( nph && !nph->released() )
NotePlayHandle * nph = dynamic_cast<NotePlayHandle *>( *it );
if( nph && !nph->isReleased() )
{
nph->resize( tempo );
}

View File

@@ -44,7 +44,7 @@
#include "InstrumentTrack.h"
#include "MainWindow.h"
#include "mmp.h"
#include "preset_preview_play_handle.h"
#include "PresetPreviewPlayHandle.h"
#include "SamplePlayHandle.h"
#include "song.h"
#include "string_pair_drag.h"
@@ -439,10 +439,7 @@ void fileBrowserTreeWidget::mousePressEvent( QMouseEvent * _me )
( f->handling() == fileItem::LoadAsPreset ||
f->handling() == fileItem::LoadByPlugin ) )
{
m_previewPlayHandle =
new presetPreviewPlayHandle( f->fullName(),
f->handling() ==
fileItem::LoadByPlugin );
m_previewPlayHandle = new PresetPreviewPlayHandle( f->fullName(), f->handling() == fileItem::LoadByPlugin );
}
if( m_previewPlayHandle != NULL )
{
@@ -517,8 +514,7 @@ void fileBrowserTreeWidget::mouseReleaseEvent( QMouseEvent * _me )
{
// if there're samples shorter than 3 seconds, we don't
// stop them if the user releases mouse-button...
if( m_previewPlayHandle->type() ==
playHandle::SamplePlayHandle )
if( m_previewPlayHandle->type() == PlayHandle::TypeSamplePlayHandle )
{
SamplePlayHandle * s = dynamic_cast<SamplePlayHandle *>(
m_previewPlayHandle );

View File

@@ -66,7 +66,7 @@
#include "MidiClient.h"
#include "MidiPortMenu.h"
#include "mmp.h"
#include "note_play_handle.h"
#include "NotePlayHandle.h"
#include "pattern.h"
#include "PluginView.h"
#include "SamplePlayHandle.h"
@@ -152,10 +152,10 @@ InstrumentTrack::~InstrumentTrack()
void InstrumentTrack::processAudioBuffer( sampleFrame * _buf,
const fpp_t _frames,
notePlayHandle * _n )
NotePlayHandle * _n )
{
// we must not play the sound if this InstrumentTrack is muted...
if( isMuted() || ( _n && _n->bbTrackMuted() ) )
if( isMuted() || ( _n && _n->isBbTrackMuted() ) )
{
return;
}
@@ -230,7 +230,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti
switch( event.type() )
{
// we don't send MidiNoteOn, MidiNoteOff and MidiKeyPressure
// events to instrument as notePlayHandle will send them on its
// events to instrument as NotePlayHandle will send them on its
// own
case MidiNoteOn:
if( event.velocity() > 0 )
@@ -238,11 +238,11 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti
if( m_notes[event.key()] == NULL )
{
// create (timed) note-play-handle
notePlayHandle* nph = new notePlayHandle( this, time.frames( engine::framesPerTick() ),
NotePlayHandle* nph = new NotePlayHandle( this, time.frames( engine::framesPerTick() ),
typeInfo<f_cnt_t>::max() / 2,
note( MidiTime(), MidiTime(), event.key(), event.volume() ),
NULL, false, event.channel(),
notePlayHandle::OriginMidiInput );
NotePlayHandle::OriginMidiInput );
if( engine::mixer()->addPlayHandle( nph ) )
{
m_notes[event.key()] = nph;
@@ -404,7 +404,7 @@ void InstrumentTrack::silenceAllNotes()
f_cnt_t InstrumentTrack::beatLen( notePlayHandle * _n ) const
f_cnt_t InstrumentTrack::beatLen( NotePlayHandle * _n ) const
{
if( m_instrument != NULL )
{
@@ -420,7 +420,7 @@ f_cnt_t InstrumentTrack::beatLen( notePlayHandle * _n ) const
void InstrumentTrack::playNote( notePlayHandle * _n,
void InstrumentTrack::playNote( NotePlayHandle * _n,
sampleFrame * _working_buffer )
{
// arpeggio- and chord-widget has to do its work -> adding sub-notes
@@ -450,7 +450,7 @@ QString InstrumentTrack::instrumentName() const
void InstrumentTrack::deleteNotePluginData( notePlayHandle* n )
void InstrumentTrack::deleteNotePluginData( NotePlayHandle* n )
{
if( m_instrument != NULL )
{
@@ -642,24 +642,20 @@ bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames,
cur_note->length().frames(
frames_per_tick );
notePlayHandle * note_play_handle =
new notePlayHandle( this, _offset,
note_frames,
*cur_note );
note_play_handle->setBBTrack( bb_track );
NotePlayHandle* notePlayHandle = new NotePlayHandle( this, _offset, note_frames, *cur_note );
notePlayHandle->setBBTrack( bb_track );
// are we playing global song?
if( _tco_num < 0 )
{
// then set song-global offset of pattern in order to
// properly perform the note detuning
note_play_handle->setSongGlobalParentOffset( p->startPosition() );
notePlayHandle->setSongGlobalParentOffset( p->startPosition() );
}
#if LMMS_SINGERBOT_SUPPORT
note_play_handle->setPatternIndex( note_idx );
notePlayHandle->setPatternIndex( note_idx );
#endif
engine::mixer()->addPlayHandle(
note_play_handle );
engine::mixer()->addPlayHandle( notePlayHandle );
played_a_note = true;
#if LMMS_SINGERBOT_SUPPORT
++note_idx;

View File

@@ -422,7 +422,7 @@ bool SampleTrack::play( const MidiTime & _start, const fpp_t _frames,
SampleTCO * st = dynamic_cast<SampleTCO *>( tco );
if( !st->isMuted() )
{
playHandle * handle;
PlayHandle* handle;
if( st->isRecord() )
{
if( !engine::getSong()->isRecording() )