kwave
18.07.70
|
#include <Plugin.h>
Public Slots | |
virtual void | setProgressDialogEnabled (bool enable) |
virtual void | updateProgress (qreal progress) |
virtual void | cancel () |
virtual void | close () |
void | release () |
Signals | |
void | sigRunning (Kwave::Plugin *plugin) |
void | sigDone (Kwave::Plugin *plugin) |
void | sigClosed (Kwave::Plugin *p) |
void | sigCommand (const QString &command) |
void | setProgressText (const QString &text) |
Public Member Functions | |
Plugin (QObject *parent, const QVariantList &args) | |
virtual | ~Plugin () Q_DECL_OVERRIDE |
virtual QString | name () const |
virtual QString | description () const |
virtual QString | progressText () |
virtual bool | canClose () const |
bool | isRunning () const |
bool | shouldStop () const |
virtual void | load (QStringList ¶ms) |
virtual void | unload () |
virtual QStringList * | setup (QStringList &previous_params) |
virtual int | start (QStringList ¶ms) |
virtual int | stop () |
virtual void | run (QStringList params) |
Kwave::PluginManager & | manager () const |
Kwave::SignalManager & | signalManager () |
QWidget * | parentWidget () const |
QString | signalName () |
virtual sample_index_t | signalLength () |
virtual double | signalRate () |
virtual const QList< unsigned int > | selectedTracks () |
virtual sample_index_t | selection (QList< unsigned int > *tracks=Q_NULLPTR, sample_index_t *left=Q_NULLPTR, sample_index_t *right=Q_NULLPTR, bool expand_if_empty=false) |
virtual void | selectRange (sample_index_t offset, sample_index_t length) |
virtual void | migrateToActiveContext () |
![]() | |
virtual | ~Runnable () |
Protected Member Functions | |
int | execute (QStringList ¶ms) |
void | emitCommand (const QString &command) |
void | use () |
void | setPluginManager (Kwave::PluginManager *new_plugin_manager) |
virtual void | run_wrapper (const QVariant ¶ms) Q_DECL_OVERRIDE |
Private Slots | |
void | closeProgressDialog (Kwave::Plugin *) |
void | updateProgressTick () |
Private Attributes | |
Kwave::PluginManager * | m_plugin_manager |
QString | m_name |
QString | m_description |
Kwave::WorkerThread * | m_thread |
QMutex | m_thread_lock |
bool | m_progress_enabled |
QAtomicInt | m_stop |
QProgressDialog * | m_progress |
Kwave::ConfirmCancelProxy * | m_confirm_cancel |
unsigned int | m_usage_count |
QMutex | m_usage_lock |
QTimer | m_progress_timer |
qreal | m_current_progress |
QMutex | m_progress_lock |
Friends | |
class | Kwave::PluginManager |
class | Kwave::WorkerThread |
Generic class that should be used for all types of Kwave plugins. This interface is the only one that should be used, it provides all necessary functions to access the functionality of the main Kwave program.
Kwave::Plugin::Plugin | ( | QObject * | parent, |
const QVariantList & | args | ||
) |
Constructor
parent | pointer to our plugin manager |
args | argument list for initializing the plugin |
Definition at line 71 of file Plugin.cpp.
References Kwave::connect(), m_plugin_manager, m_progress_timer, and updateProgressTick().
|
virtual |
Destructor.
Definition at line 96 of file Plugin.cpp.
References close(), closeProgressDialog(), m_thread, m_thread_lock, m_usage_lock, and Kwave::WorkerThread::stop().
|
virtualslot |
called when the user has pressed "Cancel" in the progress dialog and also has confirmed the cancel confirmation message box.
Definition at line 325 of file Plugin.cpp.
References m_stop.
Referenced by start(), stop(), Kwave::PlayBackPlugin::testPlayBack(), and Kwave::SonagramPlugin::windowDestroyed().
|
virtual |
Returns true if the plugin can be closed. The default implementation returns "!isRunning()"
Definition at line 351 of file Plugin.cpp.
References isRunning().
|
virtualslot |
Called to close the plugin. This will be called from the plugin manager and can as well be used from inside the plugin if it wishes to close itself.
Definition at line 394 of file Plugin.cpp.
References closeProgressDialog(), m_thread, and stop().
Referenced by Kwave::SonagramPlugin::start(), Kwave::PlayBackPlugin::testPlayBack(), and ~Plugin().
|
privateslot |
closes the progress dialog and the confirm/cancel proxy
Definition at line 293 of file Plugin.cpp.
References m_confirm_cancel, m_progress, m_progress_lock, and m_progress_timer.
Referenced by close(), start(), and ~Plugin().
|
virtual |
Returns the description of the plugin (already translated).
Definition at line 202 of file Plugin.cpp.
References m_description.
Referenced by Kwave::SaveBlocksPlugin::setup(), and Kwave::K3BExportPlugin::setup().
|
protected |
emits a sigCommand()
Definition at line 510 of file Plugin.cpp.
References Kwave::PluginManager::enqueueCommand(), and manager().
Referenced by Kwave::FileInfoPlugin::apply(), Kwave::MP3CodecPlugin::load(), Kwave::StringEnterPlugin::load(), Kwave::K3BExportPlugin::load(), Kwave::RecordPlugin::resetRecording(), Kwave::NewSignalPlugin::setup(), Kwave::SaveBlocksPlugin::setup(), Kwave::AmplifyFreePlugin::setup(), Kwave::SelectRangePlugin::setup(), Kwave::GotoPluginBase::setup(), Kwave::StringEnterPlugin::setup(), Kwave::K3BExportPlugin::setup(), Kwave::GotoPluginBase::start(), and Kwave::RecordPlugin::startRecording().
|
protected |
Gets called to execute the plugin's run function in a separate thread.
params | list of strings with parameters |
Definition at line 331 of file Plugin.cpp.
References m_stop, m_thread, m_thread_lock, Kwave::WorkerThread::start(), and use().
Referenced by Kwave::FilterPlugin::startPreListen(), and Kwave::PlayBackPlugin::testPlayBack().
bool Kwave::Plugin::isRunning | ( | ) | const |
Returns true if the plugin has a running thread.
Definition at line 357 of file Plugin.cpp.
References m_thread.
Referenced by canClose(), and Kwave::PlayBackPlugin::testPlayBack().
|
virtual |
Called after the plugin has been loaded into memory. This is useful for plugins that don't use start() and execute(), maybe for some persistent plugins like playback and record. The default implementation does nothing.
Reimplemented in Kwave::K3BExportPlugin, Kwave::PlayBackPlugin, Kwave::CodecPlugin, Kwave::MemoryPlugin, Kwave::DebugPlugin, Kwave::StringEnterPlugin, and Kwave::MP3CodecPlugin.
Definition at line 124 of file Plugin.cpp.
Kwave::PluginManager & Kwave::Plugin::manager | ( | ) | const |
Returns a reference to the manager of this plugin.
Definition at line 437 of file Plugin.cpp.
References m_plugin_manager.
Referenced by Kwave::NoisePlugin::createDialog(), emitCommand(), migrateToActiveContext(), parentWidget(), Kwave::RecordPlugin::resetRecording(), Kwave::ReversePlugin::run(), Kwave::K3BExportPlugin::saveBlocks(), selection(), selectRange(), Kwave::VolumePlugin::setup(), Kwave::SelectRangePlugin::setup(), Kwave::RecordPlugin::setup(), Kwave::PlayBackPlugin::setup(), signalLength(), signalManager(), signalRate(), Kwave::AboutPlugin::start(), Kwave::SonagramPlugin::start(), Kwave::FilterPlugin::startPreListen(), and Kwave::PlayBackPlugin::testPlayBack().
|
virtual |
Migrates this plugin instance to the currently active file context. This might be necessary for plugins that create a new file context and then expect that all operations are executed in the context of that new file context. Example: the record plugin creates a new context and does recording into that new created file context.
Definition at line 516 of file Plugin.cpp.
References manager(), and Kwave::PluginManager::migratePluginToActiveContext().
Referenced by Kwave::RecordPlugin::resetRecording(), and Kwave::RecordPlugin::startRecording().
|
virtual |
Returns the name of the plugin.
Reimplemented in Kwave::AboutPlugin.
Definition at line 196 of file Plugin.cpp.
References m_name.
Referenced by Kwave::RecordPlugin::changeCompression(), Kwave::K3BExportPlugin::createFileName(), Kwave::SaveBlocksPlugin::findBase(), Kwave::SaveBlocksPlugin::firstIndex(), progressText(), run_wrapper(), Kwave::RecordPlugin::setDevice(), Kwave::RecordPlugin::setMethod(), Kwave::SaveBlocksPlugin::setup(), Kwave::RecordPlugin::setup(), Kwave::K3BExportPlugin::setup(), Kwave::SaveBlocksPlugin::start(), Kwave::K3BExportPlugin::start(), stop(), and Kwave::UndoTransactionGuard::UndoTransactionGuard().
QWidget * Kwave::Plugin::parentWidget | ( | ) | const |
Returns the parent widget of the plugin. This normally should be a TopWidget of the Kwave main program.
Definition at line 450 of file Plugin.cpp.
References manager(), and Kwave::PluginManager::parentWidget().
Referenced by Kwave::FileInfoPlugin::apply(), Kwave::NoisePlugin::createDialog(), Kwave::DebugPlugin::findWidget(), Kwave::RecordPlugin::setDevice(), Kwave::FileInfoPlugin::setup(), Kwave::NewSignalPlugin::setup(), Kwave::VolumePlugin::setup(), Kwave::SaveBlocksPlugin::setup(), Kwave::MP3CodecPlugin::setup(), Kwave::SelectRangePlugin::setup(), Kwave::GotoPluginBase::setup(), Kwave::AmplifyFreePlugin::setup(), Kwave::StringEnterPlugin::setup(), Kwave::MemoryPlugin::setup(), Kwave::DebugPlugin::setup(), Kwave::RecordPlugin::setup(), Kwave::K3BExportPlugin::setup(), Kwave::FilterPlugin::setup(), Kwave::AboutPlugin::start(), Kwave::SaveBlocksPlugin::start(), Kwave::K3BExportPlugin::start(), Kwave::SonagramPlugin::start(), and start().
|
virtual |
Returns a text for the progress dialog if enabled. (already be localized)
Reimplemented in Kwave::FilterPlugin, and Kwave::AmplifyFreePlugin.
Definition at line 208 of file Plugin.cpp.
References name().
Referenced by start().
|
slot |
decrements the usage counter
Definition at line 420 of file Plugin.cpp.
References m_usage_count, m_usage_lock, and sigClosed().
Referenced by Kwave::PluginManager::pluginDone(), run_wrapper(), Kwave::PluginManager::setupPlugin(), Kwave::PlayBackPlugin::unload(), Kwave::CodecPlugin::unload(), and Kwave::SonagramPlugin::windowDestroyed().
|
virtual |
Gets called from the plugin's execute function and should be overwritten to perform some action. This function runs in a separate thread!
params | list of strings with parameters |
Reimplemented in Kwave::SonagramPlugin, Kwave::FilterPlugin, Kwave::PlayBackPlugin, Kwave::DebugPlugin, Kwave::NormalizePlugin, Kwave::AmplifyFreePlugin, Kwave::VolumePlugin, Kwave::ReversePlugin, Kwave::ZeroPlugin, and Kwave::SampleRatePlugin.
Definition at line 363 of file Plugin.cpp.
Referenced by run_wrapper().
|
protectedvirtual |
Wrapper for run() that contains a call to release()
Implements Kwave::Runnable.
Definition at line 369 of file Plugin.cpp.
References DBG, m_stop, name(), release(), run(), sigDone(), and sigRunning().
|
virtual |
Returns an array of indices of currently selected channels.
Definition at line 474 of file Plugin.cpp.
References Kwave::SignalManager::selectedTracks(), and signalManager().
Referenced by Kwave::VolumePlugin::run(), Kwave::AmplifyFreePlugin::run(), and Kwave::FilterPlugin::startPreListen().
|
virtual |
Returns the left and right sample index of the current selection in samples from 1 to (size-1). The left and right samples are included in the selection and might be equal. The left is always less or equal than the right. Note that there is always at least one sample selected!
tracks | received a list of selected tracks (optional or null-pointer) |
left | receives the first selected sample (optional or null-pointer) |
right | receives the last selected sample (optional or null-pointer) |
expand_if_empty | if set to true, the selection will be made equal to the whole signal if left==right |
Definition at line 480 of file Plugin.cpp.
References manager(), Kwave::SignalManager::selectedTracks(), Kwave::PluginManager::selectionEnd(), Kwave::PluginManager::selectionStart(), Kwave::PluginManager::signalLength(), and signalManager().
Referenced by Kwave::NoisePlugin::createDialog(), Kwave::SampleRatePlugin::run(), Kwave::ReversePlugin::run(), Kwave::ZeroPlugin::run(), Kwave::VolumePlugin::run(), Kwave::AmplifyFreePlugin::run(), Kwave::NormalizePlugin::run(), Kwave::FilterPlugin::run(), Kwave::SaveBlocksPlugin::scanBlocksToSave(), Kwave::VolumePlugin::setup(), Kwave::SaveBlocksPlugin::setup(), Kwave::K3BExportPlugin::setup(), Kwave::SaveBlocksPlugin::start(), Kwave::K3BExportPlugin::start(), Kwave::SonagramPlugin::start(), and start().
|
virtual |
Sets the current start and length of the selection to new values.
offset | index of the first sample |
length | number of samples |
Definition at line 504 of file Plugin.cpp.
References manager(), and Kwave::PluginManager::selectRange().
Referenced by Kwave::SaveBlocksPlugin::start(), and Kwave::SelectRangePlugin::start().
|
protected |
assign this plugin to a new plugin manager (when migrating)
Definition at line 522 of file Plugin.cpp.
References m_confirm_cancel, m_plugin_manager, m_progress, and Kwave::PluginManager::parentWidget().
Referenced by Kwave::PluginManager::migratePluginToActiveContext().
|
virtualslot |
Switches the support for a progress dialog on [default] or off
Definition at line 254 of file Plugin.cpp.
References m_progress_enabled.
Referenced by Kwave::FilterPlugin::startPreListen(), and Kwave::FilterPlugin::stopPreListen().
|
signal |
Sets the text of the progress dialog
text | new progress bar text, already be localized |
Referenced by Kwave::SampleRatePlugin::run(), Kwave::NormalizePlugin::run(), and start().
|
virtual |
Sets up all necessary parameters for executing the plugin. Could be overwritten and show a dialog box. This only will be called if currently no parameters are given from the function that loads the plugin (the normal case) but not in the context of replaying a previously recorded macro.
previous_params | the parameters of a previous call, could be used to initialize the controls of a setup dialog |
Reimplemented in Kwave::SonagramPlugin, Kwave::FilterPlugin, Kwave::K3BExportPlugin, Kwave::PlayBackPlugin, Kwave::RecordPlugin, Kwave::DebugPlugin, Kwave::MemoryPlugin, Kwave::StringEnterPlugin, Kwave::AmplifyFreePlugin, Kwave::GotoPluginBase, Kwave::SelectRangePlugin, Kwave::MP3CodecPlugin, Kwave::SaveBlocksPlugin, Kwave::VolumePlugin, Kwave::NewSignalPlugin, and Kwave::FileInfoPlugin.
Definition at line 134 of file Plugin.cpp.
Referenced by Kwave::PluginManager::setupPlugin().
|
inline |
Returns true if the plugin should stop, e.g. when the user has pressed "cancel"
Definition at line 120 of file Plugin.h.
Referenced by Kwave::NormalizePlugin::getMaxPower(), Kwave::SonagramPlugin::makeAllValid(), Kwave::SampleRatePlugin::run(), Kwave::ZeroPlugin::run(), Kwave::ReversePlugin::run(), Kwave::VolumePlugin::run(), Kwave::AmplifyFreePlugin::run(), Kwave::NormalizePlugin::run(), Kwave::DebugPlugin::run(), Kwave::PlayBackPlugin::run(), and Kwave::FilterPlugin::run().
|
signal |
will be emitted in the plugin's destructor
Referenced by release(), and Kwave::SonagramPlugin::start().
|
signal |
can be used by plugins to execute toplevel commands
|
signal |
will be emitted when the "run" function has finished
Referenced by run_wrapper(), Kwave::FilterPlugin::setup(), start(), and Kwave::PlayBackPlugin::testPlayBack().
|
virtual |
Returns the length of the current signal in samples. If no signal is present the return value will be zero.
Definition at line 462 of file Plugin.cpp.
References manager(), and Kwave::PluginManager::signalLength().
Referenced by Kwave::RecordPlugin::recordStopped(), Kwave::SampleRatePlugin::run(), Kwave::ZeroPlugin::run(), Kwave::DebugPlugin::run(), Kwave::SaveBlocksPlugin::scanBlocksToSave(), Kwave::K3BExportPlugin::scanBlocksToSave(), Kwave::SaveBlocksPlugin::setup(), Kwave::GotoPluginBase::setup(), Kwave::SelectRangePlugin::setup(), Kwave::K3BExportPlugin::setup(), Kwave::SaveBlocksPlugin::start(), Kwave::GotoPluginBase::start(), Kwave::SelectRangePlugin::start(), and Kwave::K3BExportPlugin::start().
Kwave::SignalManager & Kwave::Plugin::signalManager | ( | ) |
Returns a reference to the current signal manager
Definition at line 444 of file Plugin.cpp.
References manager(), and Kwave::PluginManager::signalManager().
Referenced by Kwave::FileInfoPlugin::apply(), Kwave::PlayBackPlugin::createDevice(), Kwave::SaveBlocksPlugin::createFileName(), Kwave::NormalizePlugin::getMaxPower(), Kwave::SonagramPlugin::makeAllValid(), Kwave::RecordPlugin::recordStopped(), Kwave::ReversePlugin::reverseSlice(), Kwave::SampleRatePlugin::run(), Kwave::ReversePlugin::run(), Kwave::ZeroPlugin::run(), Kwave::VolumePlugin::run(), Kwave::AmplifyFreePlugin::run(), Kwave::NormalizePlugin::run(), Kwave::DebugPlugin::run(), Kwave::FilterPlugin::run(), Kwave::K3BExportPlugin::saveBlocks(), Kwave::K3BExportPlugin::saveDocumentData(), Kwave::SaveBlocksPlugin::scanBlocksToSave(), Kwave::K3BExportPlugin::scanBlocksToSave(), selectedTracks(), selection(), Kwave::FileInfoPlugin::setup(), Kwave::RecordPlugin::setup(), Kwave::PlayBackPlugin::setup(), signalName(), Kwave::SaveBlocksPlugin::start(), Kwave::SonagramPlugin::start(), and Kwave::RecordPlugin::startRecording().
QString Kwave::Plugin::signalName | ( | ) |
Returns the name of the current signal. This can be used to set the caption of a plugin's main window. If no signal is currently loaded the returned string is empty.
Definition at line 456 of file Plugin.cpp.
References signalManager(), and Kwave::SignalManager::signalName().
Referenced by Kwave::SaveBlocksPlugin::setup(), Kwave::K3BExportPlugin::setup(), and Kwave::SonagramPlugin::start().
|
virtual |
Returns the sample rate of the current signal. If no signal is present the return value will be zero.
Definition at line 468 of file Plugin.cpp.
References manager(), and Kwave::PluginManager::signalRate().
Referenced by Kwave::BandPassPlugin::createDialog(), Kwave::NotchFilterPlugin::createDialog(), Kwave::LowPassPlugin::createDialog(), Kwave::ZeroPlugin::run(), Kwave::DebugPlugin::run(), Kwave::GotoPluginBase::setup(), Kwave::SelectRangePlugin::setup(), Kwave::GotoPluginBase::start(), Kwave::SelectRangePlugin::start(), Kwave::SonagramPlugin::start(), Kwave::BandPassPlugin::updateFilter(), Kwave::NotchFilterPlugin::updateFilter(), Kwave::PitchShiftPlugin::updateFilter(), and Kwave::LowPassPlugin::updateFilter().
|
signal |
will be emitted when the "run" function starts
Referenced by run_wrapper().
|
virtual |
Is called from the main program before the run() function and can be overwritten to show a window or initialize some things before the run() function gets called.
params | list of strings with parameters |
Reimplemented in Kwave::SonagramPlugin, Kwave::K3BExportPlugin, Kwave::AmplifyFreePlugin, Kwave::SelectRangePlugin, Kwave::GotoPluginBase, Kwave::SaveBlocksPlugin, and Kwave::AboutPlugin.
Definition at line 142 of file Plugin.cpp.
References cancel(), closeProgressDialog(), Kwave::connect(), m_confirm_cancel, m_progress, m_progress_enabled, m_stop, m_thread_lock, parentWidget(), PROGRESS_MAXIMUM, progressText(), selection(), setProgressText(), and sigDone().
Referenced by Kwave::AmplifyFreePlugin::start().
|
virtual |
Stops any threads and is called from the close() function and the plugin's destructor.
Definition at line 214 of file Plugin.cpp.
References cancel(), DBG, m_thread, m_thread_lock, name(), and Kwave::WorkerThread::stop().
Referenced by close(), Kwave::FilterPlugin::stopPreListen(), and Kwave::PlayBackPlugin::testPlayBack().
|
virtual |
Called before the plugin gets unloaded. Can be used by a plugin to do some cleanup tasks before it gets unloaded from memory.
Reimplemented in Kwave::CodecPlugin, and Kwave::PlayBackPlugin.
Definition at line 129 of file Plugin.cpp.
|
virtualslot |
update the progress dialog
progress | the current progress in percent [0...100] |
Definition at line 260 of file Plugin.cpp.
References m_current_progress, m_progress, m_progress_lock, m_progress_timer, PROGRESS_MAXIMUM, and PROGRESS_UPDATES_PER_SECOND.
Referenced by Kwave::SampleRatePlugin::run(), Kwave::ZeroPlugin::run(), Kwave::VolumePlugin::run(), Kwave::AmplifyFreePlugin::run(), Kwave::NormalizePlugin::run(), Kwave::DebugPlugin::run(), Kwave::FilterPlugin::run(), and Kwave::ReversePlugin::updateProgress().
|
privateslot |
updates the progress bar, triggered by timer
Definition at line 281 of file Plugin.cpp.
References m_current_progress, m_progress, m_progress_lock, PROGRESS_MAXIMUM, and Kwave::toInt().
Referenced by Plugin().
|
protected |
increments the usage counter
Definition at line 412 of file Plugin.cpp.
References m_usage_count, and m_usage_lock.
Referenced by execute(), Kwave::CodecPlugin::load(), Kwave::PlayBackPlugin::load(), Kwave::PluginManager::pluginStarted(), and Kwave::SonagramPlugin::start().
|
friend |
|
friend |
|
private |
proxy dialog that asks for confirmation if the user pressed cancel in the progress dialog
Definition at line 376 of file Plugin.h.
Referenced by closeProgressDialog(), setPluginManager(), and start().
|
private |
latest progress value [percent]
Definition at line 388 of file Plugin.h.
Referenced by updateProgress(), and updateProgressTick().
|
private |
description of the plugin, for GUI purposes, captions etc
Definition at line 353 of file Plugin.h.
Referenced by description().
|
private |
|
private |
reference to the plugin manager
Definition at line 347 of file Plugin.h.
Referenced by manager(), Plugin(), and setPluginManager().
|
private |
a progress dialog, if the audio processing takes longer...
Definition at line 370 of file Plugin.h.
Referenced by closeProgressDialog(), setPluginManager(), start(), updateProgress(), and updateProgressTick().
|
private |
determines whether a progress dialog should be used in run()
Definition at line 364 of file Plugin.h.
Referenced by setProgressDialogEnabled(), and start().
|
private |
Mutex for locking the progress bar
Definition at line 391 of file Plugin.h.
Referenced by closeProgressDialog(), updateProgress(), and updateProgressTick().
|
private |
timer for updating the progress dialog
Definition at line 385 of file Plugin.h.
Referenced by closeProgressDialog(), Plugin(), and updateProgress().
|
private |
|
private |
|
private |
|
private |
|
private |