PresetPreviewPlayHandle: removed

Removed unused class PresetPreviewPlayHandle with all its sub- and
helper-classes. Lots of dirty code this way gets cleaned up/removed.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Tobias Doerffel
2009-06-29 13:16:11 +02:00
parent 3c5c5f9cb3
commit 81721b6524
4 changed files with 6 additions and 342 deletions

View File

@@ -1,63 +0,0 @@
/*
* preset_preview_play_handle.h - play-handle for playing a short preview-sound
* of a preset or a file processed by a plugin
*
* Copyright (c) 2005-2008 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
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _PRESET_PREVIEW_PLAY_HANDLE_H
#define _PRESET_PREVIEW_PLAY_HANDLE_H
#include "note_play_handle.h"
class instrumentTrack;
class previewTrackContainer;
class presetPreviewPlayHandle : public playHandle
{
public:
presetPreviewPlayHandle( const QString & _preset_file,
bool _load_by_plugin = false );
virtual ~presetPreviewPlayHandle();
virtual void play( sampleFrame * _working_buffer );
virtual bool done( void ) const;
virtual bool isFromTrack( const track * _track ) const;
static void init( void );
static void cleanup( void );
static ConstNotePlayHandleList nphsOfInstrumentTrack(
const instrumentTrack * _ct );
private:
static previewTrackContainer * s_previewTC;
notePlayHandle * m_previewNote;
} ;
#endif

View File

@@ -1,5 +1,3 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* engine.cpp - implementation of LMMS' engine-system
*
@@ -42,7 +40,6 @@
#include "mixer.h"
#include "pattern.h"
#include "piano_roll.h"
#include "preset_preview_play_handle.h"
#include "project_journal.h"
#include "project_notes.h"
#include "plugin.h"
@@ -140,7 +137,6 @@ void engine::init( const bool _has_gui )
s_mainWindow->finalize();
}
presetPreviewPlayHandle::init();
s_dummyTC = new dummyTrackContainer;
s_mixer->startProcessing();
@@ -169,7 +165,6 @@ void engine::destroy( void )
delete s_fxMixerView;
s_fxMixerView = NULL;
presetPreviewPlayHandle::cleanup();
instrumentTrackView::cleanupWindowPool();
s_song->clearProject();
@@ -224,13 +219,11 @@ void engine::initPluginFileHandling( void )
{
if( it->type == plugin::Instrument )
{
const QStringList & ext =
QString( it->supportedFileTypes ).
split( QChar( ',' ) );
for( QStringList::const_iterator itExt = ext.begin();
itExt != ext.end(); ++itExt )
const char * * suppFileTypes = it->supportedFileTypes;
while( suppFileTypes && *suppFileTypes != NULL )
{
s_pluginFileHandling[*itExt] = it->name;
s_pluginFileHandling[*suppFileTypes] = it->name;
++suppFileTypes;
}
}
}
@@ -256,6 +249,3 @@ void engine::saveConfiguration( QDomDocument & doc )
}
#endif

View File

@@ -1,5 +1,3 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* instrument_functions.cpp - models for instrument-function-tab
*
@@ -33,7 +31,6 @@
#include "engine.h"
#include "instrument_track.h"
#include "note_play_handle.h"
#include "preset_preview_play_handle.h"
@@ -309,15 +306,7 @@ void arpeggiator::processNote( notePlayHandle * _n )
_n->getInstrumentTrack() );
if( m_arpModeModel.value() != FreeMode && cnphv.size() == 0 )
{
// maybe we're playing only a preset-preview-note?
cnphv = presetPreviewPlayHandle::nphsOfInstrumentTrack(
_n->getInstrumentTrack() );
if( cnphv.size() == 0 )
{
// still nothing found here, so lets return
//return;
cnphv.push_back( _n );
}
cnphv.push_back( _n );
}
const int cur_chord_size = chordCreator::getChordSize(
@@ -494,6 +483,6 @@ void arpeggiator::loadSettings( const QDomElement & _this )
}
#include "moc_instrument_functions.cxx"
#endif

View File

@@ -1,252 +0,0 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* preset_preview_play_handle.cpp - implementation of class
* presetPreviewPlayHandle
*
* Copyright (c) 2005-2009 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
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#include <QtCore/QFileInfo>
#include <QtCore/QMutexLocker>
#include "preset_preview_play_handle.h"
#include "debug.h"
#include "engine.h"
#include "instrument.h"
#include "instrument_track.h"
#include "midi_port.h"
#include "mmp.h"
#include "note_play_handle.h"
#include "project_journal.h"
#include "track_container.h"
// invisible track-container which is needed as parent for preview-channels
class previewTrackContainer : public trackContainer
{
public:
previewTrackContainer( void ) :
m_previewInstrumentTrack( NULL ),
m_previewNote( NULL ),
m_dataMutex()
{
setJournalling( FALSE );
m_previewInstrumentTrack = dynamic_cast<instrumentTrack *>(
track::create( track::InstrumentTrack,
this ) );
m_previewInstrumentTrack->setJournalling( FALSE );
}
virtual ~previewTrackContainer()
{
}
virtual QString nodeName( void ) const
{
return( "bbtrackcontainer" );
}
instrumentTrack * previewInstrumentTrack( void )
{
return( m_previewInstrumentTrack );
}
notePlayHandle * previewNote( void )
{
return( m_previewNote );
}
void setPreviewNote( notePlayHandle * _note )
{
m_previewNote = _note;
}
void lockData( void )
{
m_dataMutex.lock();
}
void unlockData( void )
{
m_dataMutex.unlock();
}
private:
instrumentTrack * m_previewInstrumentTrack;
notePlayHandle * m_previewNote;
QMutex m_dataMutex;
} ;
previewTrackContainer * presetPreviewPlayHandle::s_previewTC;
presetPreviewPlayHandle::presetPreviewPlayHandle( const QString & _preset_file,
bool _load_by_plugin ) :
playHandle( PresetPreviewHandle ),
m_previewNote( NULL )
{
s_previewTC->lockData();
if( s_previewTC->previewNote() != NULL )
{
s_previewTC->previewNote()->mute();
}
const bool j = engine::getProjectJournal()->isJournalling();
engine::getProjectJournal()->setJournalling( FALSE );
engine::setSuppressMessages( true );
if( _load_by_plugin )
{
instrument * i = s_previewTC->previewInstrumentTrack()->
getInstrument();
const QString ext = QFileInfo( _preset_file ).
suffix().toLower();
if( i == NULL || !i->getDescriptor()->supportsFileType( ext ) )
{
i = s_previewTC->previewInstrumentTrack()->
loadInstrument(
engine::pluginFileHandling()[ext] );
}
if( i != NULL )
{
i->loadFile( _preset_file );
}
}
else
{
multimediaProject mmp( _preset_file );
s_previewTC->previewInstrumentTrack()->
loadTrackSpecificSettings(
mmp.content().firstChild().toElement() );
}
engine::setSuppressMessages( false );
// make sure, our preset-preview-track does not appear in any MIDI-
// devices list, so just disable receiving/sending MIDI-events at all
s_previewTC->previewInstrumentTrack()->
getMidiPort()->setMode( midiPort::Disabled );
// create note-play-handle for it
m_previewNote = new notePlayHandle(
s_previewTC->previewInstrumentTrack(), 0,
typeInfo<f_cnt_t>::max() / 2,
note( 0, 0, DefaultKey, 100 ) );
s_previewTC->setPreviewNote( m_previewNote );
s_previewTC->unlockData();
engine::getProjectJournal()->setJournalling( j );
}
presetPreviewPlayHandle::~presetPreviewPlayHandle()
{
s_previewTC->lockData();
// not muted by other preset-preview-handle?
if( !m_previewNote->isMuted() )
{
// then set according state
s_previewTC->setPreviewNote( NULL );
}
delete m_previewNote;
s_previewTC->unlockData();
}
void presetPreviewPlayHandle::play( sampleFrame * _working_buffer )
{
m_previewNote->play( _working_buffer );
}
bool presetPreviewPlayHandle::done( void ) const
{
return( m_previewNote->isMuted() );
}
bool presetPreviewPlayHandle::isFromTrack( const track * _track ) const
{
return( s_previewTC->previewInstrumentTrack() == _track );
}
void presetPreviewPlayHandle::init( void )
{
if( !s_previewTC )
{
s_previewTC = new previewTrackContainer;
}
}
void presetPreviewPlayHandle::cleanup( void )
{
delete s_previewTC;
s_previewTC = NULL;
}
ConstNotePlayHandleList presetPreviewPlayHandle::nphsOfInstrumentTrack(
const instrumentTrack * _it )
{
ConstNotePlayHandleList cnphv;
s_previewTC->lockData();
if( s_previewTC->previewNote() != NULL &&
s_previewTC->previewNote()->getInstrumentTrack() == _it )
{
cnphv.push_back( s_previewTC->previewNote() );
}
s_previewTC->unlockData();
return( cnphv );
}
#endif