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

@@ -41,7 +41,7 @@ class QPixmap;
class QScrollBar;
class comboBox;
class notePlayHandle;
class NotePlayHandle;
class timeLine;
class toolButton;

View File

@@ -42,7 +42,7 @@ public:
{
}
virtual void playNote( notePlayHandle *, bool, sampleFrame * )
virtual void playNote( NotePlayHandle *, bool, sampleFrame * )
{
}

View File

@@ -37,7 +37,7 @@ class InstrumentTrack;
class InstrumentView;
class MidiEvent;
class MidiTime;
class notePlayHandle;
class NotePlayHandle;
class track;
@@ -58,7 +58,7 @@ public:
virtual void play( sampleFrame * _working_buffer );
// to be implemented by actual plugin
virtual void playNote( notePlayHandle * /* _note_to_play */,
virtual void playNote( NotePlayHandle * /* _note_to_play */,
sampleFrame * /* _working_buf */ )
{
}
@@ -66,13 +66,13 @@ public:
// needed for deleting plugin-specific-data of a note - plugin has to
// cast void-ptr so that the plugin-data is deleted properly
// (call of dtor if it's a class etc.)
virtual void deleteNotePluginData( notePlayHandle * _note_to_play );
virtual void deleteNotePluginData( NotePlayHandle * _note_to_play );
// Get number of sample-frames that should be used when playing beat
// (note with unspecified length)
// Per default this function returns 0. In this case, channel is using
// the length of the longest envelope (if one active).
virtual f_cnt_t beatLen( notePlayHandle * _n ) const;
virtual f_cnt_t beatLen( NotePlayHandle * _n ) const;
// some instruments need a certain number of release-frames even
@@ -127,7 +127,7 @@ protected:
// instruments may use this to apply a soft fade out at the end of
// notes - method does this only if really less or equal
// desiredReleaseFrames() frames are left
void applyRelease( sampleFrame * buf, const notePlayHandle * _n );
void applyRelease( sampleFrame * buf, const NotePlayHandle * _n );
private:

View File

@@ -33,7 +33,7 @@
class InstrumentTrack;
class notePlayHandle;
class NotePlayHandle;
@@ -51,7 +51,7 @@ public:
InstrumentFunctionNoteStacking( Model * _parent );
virtual ~InstrumentFunctionNoteStacking();
void processNote( notePlayHandle * _n );
void processNote( NotePlayHandle* n );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
@@ -172,7 +172,7 @@ public:
InstrumentFunctionArpeggio( Model * _parent );
virtual ~InstrumentFunctionArpeggio();
void processNote( notePlayHandle * _n );
void processNote( NotePlayHandle* n );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );

View File

@@ -25,16 +25,16 @@
#ifndef _INSTRUMENT_PLAY_HANDLE_H
#define _INSTRUMENT_PLAY_HANDLE_H
#include "play_handle.h"
#include "PlayHandle.h"
#include "Instrument.h"
class InstrumentPlayHandle : public playHandle
class InstrumentPlayHandle : public PlayHandle
{
public:
InstrumentPlayHandle( Instrument * _instrument ) :
playHandle( playHandle::InstrumentPlayHandle ),
m_instrument( _instrument )
InstrumentPlayHandle( Instrument* instrument ) :
PlayHandle( TypeInstrumentPlayHandle ),
m_instrument( instrument )
{
}
@@ -48,21 +48,20 @@ public:
m_instrument->play( _working_buffer );
}
virtual bool done() const
virtual bool isFinished() const
{
return false;
}
virtual bool isFromTrack( const track * _track ) const
virtual bool isFromTrack( const track* _track ) const
{
return m_instrument->isFromTrack( _track );
}
private:
Instrument * m_instrument;
Instrument* m_instrument;
} ;
#endif

View File

@@ -31,7 +31,7 @@
class InstrumentTrack;
class EnvelopeAndLfoParameters;
class notePlayHandle;
class NotePlayHandle;
class InstrumentSoundShaping : public Model, public JournallingObject
@@ -42,7 +42,7 @@ public:
virtual ~InstrumentSoundShaping();
void processAudioBuffer( sampleFrame * _ab, const fpp_t _frames,
notePlayHandle * _n );
NotePlayHandle * _n );
enum Targets
{
@@ -55,7 +55,7 @@ public:
f_cnt_t envFrames( const bool _only_vol = false ) const;
f_cnt_t releaseFrames() const;
float volumeLevel( notePlayHandle * _n, const f_cnt_t _frame );
float volumeLevel( NotePlayHandle * _n, const f_cnt_t _frame );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );

View File

@@ -31,7 +31,7 @@
#include "InstrumentSoundShaping.h"
#include "MidiEventProcessor.h"
#include "MidiPort.h"
#include "note_play_handle.h"
#include "NotePlayHandle.h"
#include "Piano.h"
#include "PianoView.h"
#include "Pitch.h"
@@ -52,7 +52,6 @@ class knob;
class lcdSpinBox;
class midiPortMenu;
class multimediaProject;
class notePlayHandle;
class PluginView;
class tabWidget;
class trackLabelButton;
@@ -68,7 +67,7 @@ public:
// used by instrument
void processAudioBuffer( sampleFrame * _buf, const fpp_t _frames,
notePlayHandle * _n );
NotePlayHandle * _n );
MidiEvent applyMasterKey( const MidiEvent& event );
@@ -82,12 +81,12 @@ public:
return m_sustainPedalPressed;
}
f_cnt_t beatLen( notePlayHandle * _n ) const;
f_cnt_t beatLen( NotePlayHandle * _n ) const;
// for capturing note-play-events -> need that for arpeggio,
// filter and so on
void playNote( notePlayHandle * _n, sampleFrame * _working_buffer );
void playNote( NotePlayHandle * _n, sampleFrame * _working_buffer );
QString instrumentName() const;
const Instrument *instrument() const
@@ -100,7 +99,7 @@ public:
return m_instrument;
}
void deleteNotePluginData( notePlayHandle * _n );
void deleteNotePluginData( NotePlayHandle * _n );
// name-stuff
virtual void setName( const QString & _new_name );
@@ -226,7 +225,7 @@ private:
AudioPort m_audioPort;
MidiPort m_midiPort;
notePlayHandle * m_notes[NumKeys];
NotePlayHandle* m_notes[NumKeys];
int m_runningMidiNotes[NumKeys];
bool m_sustainPedalPressed;
@@ -251,7 +250,7 @@ private:
friend class InstrumentTrackView;
friend class InstrumentTrackWindow;
friend class notePlayHandle;
friend class NotePlayHandle;
friend class FlpImport;
} ;

View File

@@ -69,7 +69,7 @@ const Keys BaseKey = Key_A;
const Octaves BaseOctave = DefaultOctave;
#include "play_handle.h"
#include "PlayHandle.h"
class MixerWorkerThread;
@@ -218,22 +218,24 @@ public:
// play-handle stuff
inline bool addPlayHandle( playHandle * _ph )
bool addPlayHandle( PlayHandle* handle )
{
if( criticalXRuns() == false )
{
lock();
m_playHandles.push_back( _ph );
m_playHandles.push_back( handle );
unlock();
return true;
}
delete _ph;
delete handle;
return false;
}
void removePlayHandle( playHandle * _ph );
void removePlayHandle( PlayHandle* handle );
inline PlayHandleList & playHandles()
inline PlayHandleList& playHandles()
{
return m_playHandles;
}

View File

@@ -1,9 +1,9 @@
/*
* note_play_handle.h - declaration of class notePlayHandle which is needed
* by LMMS-Play-Engine
* NotePlayHandle.h - declaration of class NotePlayHandle which manages
* playback of a single note by an instrument
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -23,26 +23,24 @@
*
*/
#ifndef _NOTE_PLAY_HANDLE_H
#define _NOTE_PLAY_HANDLE_H
#ifndef NOTE_PLAY_HANDLE_H
#define NOTE_PLAY_HANDLE_H
#include "lmmsconfig.h"
#include "Mixer.h"
#include "note.h"
#include "engine.h"
#include "PlayHandle.h"
#include "track.h"
class InstrumentTrack;
class notePlayHandle;
class NotePlayHandle;
template<ch_cnt_t=DEFAULT_CHANNELS> class basicFilters;
typedef QList<notePlayHandle *> NotePlayHandleList;
typedef QList<const notePlayHandle *> ConstNotePlayHandleList;
typedef QList<NotePlayHandle *> NotePlayHandleList;
typedef QList<const NotePlayHandle *> ConstNotePlayHandleList;
class EXPORT notePlayHandle : public playHandle, public note
class EXPORT NotePlayHandle : public PlayHandle, public note
{
public:
void * m_pluginData;
@@ -57,14 +55,15 @@ public:
};
typedef Origins Origin;
notePlayHandle( InstrumentTrack * _instrument_track,
const f_cnt_t _offset,
const f_cnt_t _frames, const note & _n,
notePlayHandle * _parent = NULL,
const bool _part_of_arp = false,
NotePlayHandle( InstrumentTrack* instrumentTrack,
const f_cnt_t offset,
const f_cnt_t frames,
const note& noteToPlay,
NotePlayHandle* parent = NULL,
const bool isPartOfArp = false,
int midiEventChannel = -1,
Origin origin = OriginPattern );
virtual ~notePlayHandle();
virtual ~NotePlayHandle();
virtual void setVolume( const volume_t volume = DefaultVolume );
virtual void setPanning( const panning_t panning = DefaultPanning );
@@ -76,144 +75,159 @@ public:
return m_midiChannel;
}
const float & frequency() const
const float& frequency() const
{
return m_frequency;
}
void updateFrequency();
// returns frequency without pitch-wheel influence
/*! Returns frequency without pitch wheel influence */
float unpitchedFrequency() const
{
return m_unpitchedFrequency;
}
virtual void play( sampleFrame * _working_buffer );
/*! Renders one chunk using the attached instrument into the buffer */
virtual void play( sampleFrame* buffer );
virtual inline bool done() const
/*! Returns whether playback of note is finished and thus handle can be deleted */
virtual bool isFinished() const
{
return m_released && framesLeft() <= 0;
}
/*! Returns number of frames left for playback */
f_cnt_t framesLeft() const;
inline fpp_t framesLeftForCurrentPeriod() const
{
return (fpp_t) qMin<f_cnt_t>( framesLeft(),
engine::mixer()->framesPerPeriod() );
}
/*! Returns how many frames have to be rendered in current period */
fpp_t framesLeftForCurrentPeriod() const;
/*! Returns whether the play handle plays on a certain track */
virtual bool isFromTrack( const track* _track ) const;
virtual bool isFromTrack( const track * _track ) const;
/*! Releases the note (and plays release frames */
void noteOff( const f_cnt_t offset = 0 );
void noteOff( const f_cnt_t _s = 0 );
inline f_cnt_t framesBeforeRelease() const
/*! Returns number of frames to be played until the note is going to be released */
f_cnt_t framesBeforeRelease() const
{
return m_framesBeforeRelease;
}
inline f_cnt_t releaseFramesDone() const
/*! Returns how many frames were played since release */
f_cnt_t releaseFramesDone() const
{
return m_releaseFramesDone;
}
/*! Returns the number of frames to be played after release according to
the release times in the envelopes */
f_cnt_t actualReleaseFramesToDo() const;
// returns total numbers of frames to play
inline f_cnt_t frames() const
/*! Returns total numbers of frames to play (including release frames) */
f_cnt_t frames() const
{
return m_frames;
}
/*! Sets the total number of frames to play (including release frames) */
void setFrames( const f_cnt_t _frames );
// returns whether note was released
inline bool released() const
/*! Returns whether note was released */
bool isReleased() const
{
return m_released;
}
// returns total numbers of played frames
inline f_cnt_t totalFramesPlayed() const
/*! Returns total numbers of frames played so far */
f_cnt_t totalFramesPlayed() const
{
return m_totalFramesPlayed;
}
// returns volume-level at frame _frame (envelope/LFO)
float volumeLevel( const f_cnt_t _frame );
/*! Returns volume level at given frame (envelope/LFO) */
float volumeLevel( const f_cnt_t frame );
// returns instrument-track this note-play-handle plays
const InstrumentTrack *instrumentTrack() const
/*! Returns instrument track which is being played by this handle (const version) */
const InstrumentTrack* instrumentTrack() const
{
return m_instrumentTrack;
}
InstrumentTrack *instrumentTrack()
/*! Returns instrument track which is being played by this handle */
InstrumentTrack* instrumentTrack()
{
return m_instrumentTrack;
}
// returns whether note is a top note, e.g. is not part of an arpeggio
// or a chord
inline bool isTopNote() const
/*! Returns whether note is a top note, e.g. is not part of an arpeggio or a chord */
bool isTopNote() const
{
return m_topNote;
}
inline bool isPartOfArpeggio() const
/*! Returns whether note is part of an arpeggio playback */
bool isPartOfArpeggio() const
{
return m_partOfArpeggio;
}
inline void setPartOfArpeggio( const bool _on )
/*! Sets whether note is part of an arpeggio playback */
void setPartOfArpeggio( const bool _on )
{
m_partOfArpeggio = _on;
}
// returns whether note is base-note for arpeggio
/*! Returns whether note is base note for arpeggio */
bool isArpeggioBaseNote() const;
inline bool isMuted() const
/*! Returns whether note is muted */
bool isMuted() const
{
return m_muted;
}
/*! Mutes playback of note */
void mute();
// returns index of note-play-handle in vector of note-play-handles
// belonging to this instrument-track - used by arpeggiator
/*! Returns index of NotePlayHandle in vector of note-play-handles
belonging to this instrument track - used by arpeggiator */
int index() const;
// note-play-handles belonging to given channel, if _all_ph = true,
// also released note-play-handles are returned
static ConstNotePlayHandleList nphsOfInstrumentTrack(
const InstrumentTrack * _ct, bool _all_ph = false );
/*! returns list of note-play-handles belonging to given instrument track,
if allPlayHandles = true, also released note-play-handles are returned */
static ConstNotePlayHandleList nphsOfInstrumentTrack( const InstrumentTrack* track, bool allPlayHandles = false );
// return whether given note-play-handle is equal to *this
bool operator==( const notePlayHandle & _nph ) const;
/*! Returns whether given NotePlayHandle instance is equal to *this */
bool operator==( const NotePlayHandle & _nph ) const;
inline bool bbTrackMuted()
/*! Returns whether NotePlayHandle belongs to BB track and BB track is muted */
bool isBbTrackMuted()
{
return m_bbTrack && m_bbTrack->isMuted();
}
void setBBTrack( track * _bb_track )
/*! Sets attached BB track */
void setBBTrack( track* t )
{
m_bbTrack = _bb_track;
m_bbTrack = t;
}
void processMidiTime( const MidiTime & _time );
void resize( const bpm_t _new_tempo );
/*! Process note detuning automation */
void processMidiTime( const MidiTime& time );
void setSongGlobalParentOffset( const MidiTime &offset )
/*! Updates total length (m_frames) depending on a new tempo */
void resize( const bpm_t newTempo );
/*! Set song-global offset (relative to containing pattern) in order to properly perform the note detuning */
void setSongGlobalParentOffset( const MidiTime& offset )
{
m_songGlobalParentOffset = offset;
}
const MidiTime &songGlobalParentOffset() const
/*! Returns song-global offset */
const MidiTime& songGlobalParentOffset() const
{
return m_songGlobalParentOffset;
}
@@ -235,7 +249,7 @@ private:
class BaseDetuning
{
public:
BaseDetuning( DetuningHelper *detuning );
BaseDetuning( DetuningHelper* detuning );
void setValue( float val )
{
@@ -253,7 +267,7 @@ private:
} ;
InstrumentTrack * m_instrumentTrack; // needed for calling
InstrumentTrack* m_instrumentTrack; // needed for calling
// InstrumentTrack::playNote
f_cnt_t m_frames; // total frames to play
f_cnt_t m_totalFramesPlayed; // total frame-counter - used for
@@ -273,7 +287,7 @@ private:
// an arpeggio (either base-note or
// sub-note)
bool m_muted; // indicates whether note is muted
track * m_bbTrack; // related BB track
track* m_bbTrack; // related BB track
#ifdef LMMS_SINGERBOT_SUPPORT
int m_patternIndex; // position among relevant notes
#endif
@@ -287,7 +301,7 @@ private:
float m_frequency;
float m_unpitchedFrequency;
BaseDetuning * m_baseDetuning;
BaseDetuning* m_baseDetuning;
MidiTime m_songGlobalParentOffset;
const int m_midiChannel;

View File

@@ -1,7 +1,7 @@
/*
* play_handle.h - base-class playHandle - core of rendering engine
* PlayHandle.h - base class PlayHandle - core of rendering engine
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -22,8 +22,8 @@
*
*/
#ifndef _PLAY_HANDLE_H
#define _PLAY_HANDLE_H
#ifndef PLAY_HANDLE_H
#define PLAY_HANDLE_H
#include <QtCore/QThread>
#include <QtCore/QVector>
@@ -33,54 +33,56 @@
class track;
class playHandle
class PlayHandle
{
public:
enum types
enum Types
{
NotePlayHandle,
InstrumentPlayHandle,
SamplePlayHandle,
PresetPreviewHandle
TypeNotePlayHandle,
TypeInstrumentPlayHandle,
TypeSamplePlayHandle,
TypePresetPreviewHandle,
TypeCount
} ;
typedef Types Type;
playHandle( const types _type, f_cnt_t _offset = 0 ) :
m_type( _type ),
m_offset( _offset ),
PlayHandle( const Type type, f_cnt_t offset = 0 ) :
m_type( type ),
m_offset( offset ),
m_affinity( QThread::currentThread() )
{
}
virtual inline ~playHandle()
virtual ~PlayHandle()
{
}
virtual inline bool affinityMatters( void ) const
virtual bool affinityMatters() const
{
return false;
}
const QThread * affinity( void ) const
const QThread* affinity() const
{
return m_affinity;
}
inline types type( void ) const
Type type() const
{
return m_type;
}
virtual void play( sampleFrame * _working_buffer ) = 0;
virtual bool done( void ) const = 0;
virtual void play( sampleFrame* buffer ) = 0;
virtual bool isFinished( void ) const = 0;
// returns how many frames this play-handle is aligned ahead, i.e.
// at which position it is inserted in the according buffer
inline f_cnt_t offset( void ) const
f_cnt_t offset() const
{
return m_offset;
}
inline void setOffset( f_cnt_t _offset )
void setOffset( f_cnt_t _offset )
{
m_offset = _offset;
}
@@ -90,15 +92,15 @@ public:
private:
types m_type;
Type m_type;
f_cnt_t m_offset;
const QThread * m_affinity;
const QThread* m_affinity;
} ;
typedef QList<playHandle *> PlayHandleList;
typedef QList<const playHandle *> ConstPlayHandleList;
typedef QList<PlayHandle *> PlayHandleList;
typedef QList<const PlayHandle *> ConstPlayHandleList;
#endif

View File

@@ -1,9 +1,9 @@
/*
* preset_preview_play_handle.h - play-handle for playing a short preview-sound
* of a preset or a file processed by a plugin
* PresetPreviewPlayHandle.h - a PlayHandle specialization for playback of a short
* preview of a preset or a file processed by a plugin
*
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -23,41 +23,37 @@
*
*/
#ifndef _PRESET_PREVIEW_PLAY_HANDLE_H
#define _PRESET_PREVIEW_PLAY_HANDLE_H
#include "note_play_handle.h"
#include "NotePlayHandle.h"
class InstrumentTrack;
class previewTrackContainer;
class PreviewTrackContainer;
class EXPORT presetPreviewPlayHandle : public playHandle
class EXPORT PresetPreviewPlayHandle : public PlayHandle
{
public:
presetPreviewPlayHandle( const QString & _preset_file,
bool _load_by_plugin = false );
virtual ~presetPreviewPlayHandle();
PresetPreviewPlayHandle( const QString& presetFile, bool loadByPlugin = false );
virtual ~PresetPreviewPlayHandle();
virtual void play( sampleFrame * _working_buffer );
virtual bool done( void ) const;
virtual void play( sampleFrame* buffer );
virtual bool isFinished() const;
virtual bool isFromTrack( const track * _track ) const;
static void init( void );
static void cleanup( void );
static ConstNotePlayHandleList nphsOfInstrumentTrack(
const InstrumentTrack * _ct );
static void init();
static void cleanup();
static ConstNotePlayHandleList nphsOfInstrumentTrack( const InstrumentTrack* instrumentTrack );
static bool isPreviewing();
private:
static previewTrackContainer * s_previewTC;
static PreviewTrackContainer* s_previewTC;
notePlayHandle * m_previewNote;
NotePlayHandle* m_previewNote;
} ;

View File

@@ -36,7 +36,7 @@ class track;
class AudioPort;
class SamplePlayHandle : public playHandle
class SamplePlayHandle : public PlayHandle
{
public:
SamplePlayHandle( const QString& sampleFile );
@@ -52,7 +52,7 @@ public:
virtual void play( sampleFrame * _working_buffer );
virtual bool done() const;
virtual bool isFinished() const;
virtual bool isFromTrack( const track * _track ) const;

View File

@@ -28,7 +28,6 @@
#include <QtCore/QList>
#include <QtCore/QPair>
#include <qobject.h>
#include "Mixer.h"
#include "SampleBuffer.h"
@@ -39,14 +38,14 @@ class SampleTCO;
class track;
class SampleRecordHandle : public playHandle
class SampleRecordHandle : public PlayHandle
{
public:
SampleRecordHandle( SampleTCO* tco );
virtual ~SampleRecordHandle();
virtual void play( sampleFrame * _working_buffer );
virtual bool done() const;
virtual bool isFinished() const;
virtual bool isFromTrack( const track * _track ) const;

View File

@@ -39,7 +39,7 @@ class QLineEdit;
class fileItem;
class InstrumentTrack;
class fileBrowserTreeWidget;
class playHandle;
class PlayHandle;
class TrackContainer;
@@ -102,7 +102,7 @@ private:
bool m_mousePressed;
QPoint m_pressPos;
playHandle * m_previewPlayHandle;
PlayHandle* m_previewPlayHandle;
QMutex m_pphMutex;
fileItem * m_contextMenuItem;

View File

@@ -45,7 +45,7 @@ class QMenu;
class QSignalMapper;
class comboBox;
class notePlayHandle;
class NotePlayHandle;
class pattern;
class timeLine;
class toolButton;