mirror of
https://github.com/LMMS/lmms.git
synced 2026-01-22 21:38:12 -05:00
* Move m_key member of Effect into Plugin * Pass key to Instrument ctors and instantiaters * Add pluginKeys to all plugin selector widgets, and let them pass the keys when instantiating the instruments; or, if the keys must be passed over threads, pass the keys to the Engine using `Engine::setDndPluginKey()` * As instrument plugin libraries now also need to get their key passed, their second argument, which was always the same as the first, is now used to pass the sub plugin keys. This affects *all* instrument plugins. * Plugin.h: Add more virtuals to `SubPluginFeatures` in order to draw logos and images into instrument selector widgets * LadspaSubPluginFeatures: Implement the `displayName` virtual because the new behaviour to resolve displayNames is to first look at the SubPluginFeatures, which, without override, returns the superior plugin's name (Plugin.cpp) Additional: * PluginFactory.h: Allow setting up search paths without discovering plugins yet * Plugin.h: Add full documentation (should be checked)
115 lines
2.7 KiB
C++
115 lines
2.7 KiB
C++
/*
|
|
* Instrument.cpp - base-class for all instrument-plugins (synths, samplers etc)
|
|
*
|
|
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
|
*
|
|
* This file is part of LMMS - https://lmms.io
|
|
*
|
|
* 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 "Instrument.h"
|
|
#include "InstrumentTrack.h"
|
|
#include "DummyInstrument.h"
|
|
|
|
|
|
Instrument::Instrument(InstrumentTrack * _instrument_track,
|
|
const Descriptor * _descriptor,
|
|
const Descriptor::SubPluginFeatures::Key *key) :
|
|
Plugin(_descriptor, NULL/* _instrument_track*/, key),
|
|
m_instrumentTrack( _instrument_track )
|
|
{
|
|
}
|
|
|
|
void Instrument::play( sampleFrame * )
|
|
{
|
|
}
|
|
|
|
|
|
|
|
|
|
void Instrument::deleteNotePluginData( NotePlayHandle * )
|
|
{
|
|
}
|
|
|
|
|
|
|
|
|
|
f_cnt_t Instrument::beatLen( NotePlayHandle * ) const
|
|
{
|
|
return( 0 );
|
|
}
|
|
|
|
|
|
|
|
|
|
Instrument *Instrument::instantiate(const QString &_plugin_name,
|
|
InstrumentTrack *_instrument_track, const Descriptor::SubPluginFeatures::Key *key, bool keyFromDnd)
|
|
{
|
|
if(keyFromDnd)
|
|
Q_ASSERT(!key);
|
|
// copy from above // TODO! common cleaner func
|
|
Plugin * p = Plugin::instantiateWithKey(_plugin_name, _instrument_track, key, keyFromDnd);
|
|
if(dynamic_cast<Instrument *>(p))
|
|
return dynamic_cast<Instrument *>(p);
|
|
delete p;
|
|
return( new DummyInstrument( _instrument_track ) );
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Instrument::isFromTrack( const Track * _track ) const
|
|
{
|
|
return( m_instrumentTrack == _track );
|
|
}
|
|
|
|
|
|
|
|
|
|
void Instrument::applyRelease( sampleFrame * buf, const NotePlayHandle * _n )
|
|
{
|
|
const fpp_t frames = _n->framesLeftForCurrentPeriod();
|
|
const fpp_t fpp = Engine::mixer()->framesPerPeriod();
|
|
const f_cnt_t fl = _n->framesLeft();
|
|
if( fl <= desiredReleaseFrames()+fpp )
|
|
{
|
|
for( fpp_t f = (fpp_t)( ( fl > desiredReleaseFrames() ) ?
|
|
( qMax( fpp - desiredReleaseFrames(), 0 ) +
|
|
fl % fpp ) : 0 ); f < frames; ++f )
|
|
{
|
|
const float fac = (float)( fl-f-1 ) /
|
|
desiredReleaseFrames();
|
|
for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch )
|
|
{
|
|
buf[f][ch] *= fac;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Instrument::fullDisplayName() const
|
|
{
|
|
return instrumentTrack()->displayName();
|
|
}
|
|
|
|
|
|
|