diff options
Diffstat (limited to 'noatun-plugins/wavecapture')
-rw-r--r-- | noatun-plugins/wavecapture/Makefile.am | 18 | ||||
-rw-r--r-- | noatun-plugins/wavecapture/wavecapture.cpp | 197 | ||||
-rw-r--r-- | noatun-plugins/wavecapture/wavecapture.h | 72 | ||||
-rw-r--r-- | noatun-plugins/wavecapture/wavecapture.plugin | 112 |
4 files changed, 399 insertions, 0 deletions
diff --git a/noatun-plugins/wavecapture/Makefile.am b/noatun-plugins/wavecapture/Makefile.am new file mode 100644 index 0000000..0ffa449 --- /dev/null +++ b/noatun-plugins/wavecapture/Makefile.am @@ -0,0 +1,18 @@ +# $Id$ + +INCLUDES = -I$(kde_includes)/arts $(all_includes) +kde_module_LTLIBRARIES = noatunwavecapture.la + + +noatunwavecapture_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +noatunwavecapture_la_LIBADD = $(LIB_KFILE) -lnoatun -lm -lartsmodules + +noatunwavecapture_la_SOURCES = wavecapture.cpp +noatunwavecapture_la_METASOURCES = AUTO +noinst_HEADERS = wavecapture.h + +noatun_DATA = wavecapture.plugin +noatundir = $(kde_datadir)/noatun + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/wavecapture.pot diff --git a/noatun-plugins/wavecapture/wavecapture.cpp b/noatun-plugins/wavecapture/wavecapture.cpp new file mode 100644 index 0000000..b95d3ce --- /dev/null +++ b/noatun-plugins/wavecapture/wavecapture.cpp @@ -0,0 +1,197 @@ +/* + Copyright (C) 2001 Matthias Kretz <kretz@kde.org> + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +/* $Id$ */ +#include "wavecapture.h" + +#include <noatun/player.h> +#include <noatun/app.h> +#include <noatun/engine.h> +#include <noatun/noatunarts.h> + +#include <arts/soundserver.h> +#include <arts/mcoputils.h> + +#include <klocale.h> +#include <kpopupmenu.h> +#include <kfiledialog.h> +#include <kurl.h> +#include <krecentdocument.h> +#include <kio/job.h> +#include <kio/jobclasses.h> + +#include <qfile.h> +#include <qstring.h> +#include <qtimer.h> + +#include <string> + +extern "C" +{ + Plugin *create_plugin() + { + KGlobal::locale()->insertCatalogue("wavecapture"); + return new WaveCapture(); + } +} + +WaveCapture::WaveCapture() : QObject(0,0), Plugin(), + _enabled( false ), + _status( STOPPED ), + _capture( Arts::DynamicCast( napp->player()->engine()->server()->createObject( "Arts::Effect_WAVECAPTURE" ) ) ), + _count( 0 ), + _id( 0 ), + _filename( "" ), + _timer( new QTimer( this ) ), + m_job( 0 ) +{ + NOATUNPLUGINC(WaveCapture); + + if( napp->player()->isPlaying() ) + _status = PLAYING; + else if( napp->player()->isPaused() ) + _status = PAUSED; + + newSong(); + + connect( _timer, SIGNAL( timeout() ), SLOT( saveAs() ) ); + + connect(napp->player(), SIGNAL(changed()), SLOT(newSong())); + connect(napp->player(), SIGNAL(stopped()), SLOT(stopped())); + connect(napp->player(), SIGNAL(playing()), SLOT(playing())); + connect(napp->player(), SIGNAL( paused()), SLOT( paused())); +} + +WaveCapture::~WaveCapture() +{ + napp->pluginMenuRemove(pluginMenuItem); + if( _enabled ) + { + if( PLAYING == _status ) + stop(); + QString filename = QFile::decodeName( (Arts::MCOPUtils::createFilePath( _filename ) + ".wav").c_str() ); + QFile::remove( filename ); + } + delete m_job; +} + +void WaveCapture::init() +{ + pluginMenuItem = napp->pluginMenuAdd( i18n( "Wave Capture" ), this, SLOT( toggle() ) ); + napp->pluginMenu()->setCheckable( true ); +} + +void WaveCapture::toggle() +{ + _enabled = ! _enabled; + if( PLAYING == _status ) + { + if( _enabled ) + start(); + else + { + stop(); + QString filename = QFile::decodeName( (Arts::MCOPUtils::createFilePath( _filename ) + ".wav").c_str() ); + QFile::remove( filename ); + } + } + napp->pluginMenu()->setItemChecked( pluginMenuItem, _enabled ); +} + +void WaveCapture::newSong() +{ + if( napp->player()->current() ) + { + QString title = napp->player()->current().title(); + _capture.filename( std::string( QFile::encodeName( title ) ) ); + } + _timer->start( 0, true ); +} + +void WaveCapture::saveAs() +{ + // this could be a candidate for a race condition - but unlikely and harmless + std::string filename = _filename; + _filename = _capture.filename().c_str(); + if( _enabled && ( !filename.empty() ) ) + { + KFileDialog dlg( ":savedir", "*.wav", 0, "filedialog", true ); + dlg.setCaption( i18n( "Save Last Wave File As" ) ); + dlg.setOperationMode( KFileDialog::Saving ); + dlg.setSelection( QFile::decodeName( filename.c_str() ) + ".wav" ); + + QString filename2 = QFile::decodeName( (Arts::MCOPUtils::createFilePath( filename ) + ".wav").c_str() ); + if( dlg.exec() ) + { + KURL url = dlg.selectedURL(); + if (url.isValid()) + KRecentDocument::add( url ); + + m_job = KIO::file_move( KURL( filename2 ), url, -1, true ); + connect( m_job, SIGNAL( result( KIO::Job* ) ), SLOT( copyFinished( KIO::Job* ) ) ); + } + else + { + QFile::remove( filename2 ); + } + } +} + +void WaveCapture::stopped() +{ + if( _enabled && PLAYING == _status ) + stop(); + _status = STOPPED; + _capture.filename( std::string( "" ) ); +} + +void WaveCapture::playing() +{ + if( _enabled && PLAYING != _status ) + start(); + _status = PLAYING; +} + +void WaveCapture::paused() +{ + if( _enabled && PLAYING == _status ) + stop(); + _status = PAUSED; +} + +void WaveCapture::start() +{ + _capture.start(); + _id = napp->player()->engine()->globalEffectStack()->insertBottom( _capture, "capture too wave" ); +} + +void WaveCapture::stop() +{ + napp->player()->engine()->globalEffectStack()->remove( _id ); + _capture.stop(); + _timer->start( 0, true ); +} + +void WaveCapture::copyFinished( KIO::Job* job ) +{ + if( job == m_job ) + m_job = 0; +} + +#include "wavecapture.moc" + +// vim:ts=4:sw=4 diff --git a/noatun-plugins/wavecapture/wavecapture.h b/noatun-plugins/wavecapture/wavecapture.h new file mode 100644 index 0000000..f5d894f --- /dev/null +++ b/noatun-plugins/wavecapture/wavecapture.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 2001 Matthias Kretz <kretz@kde.org> + + 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +/* $Id$ */ + +#ifndef WAVECAPTURE_H +#define WAVECAPTURE_H + +#include <noatun/plugin.h> +#include <artsmodules.h> + +#include <string> + +class QTimer; +namespace KIO { class Job; } + +class WaveCapture : public QObject, public Plugin +{ +Q_OBJECT +NOATUNPLUGIND + +public: + WaveCapture(); + virtual ~WaveCapture(); + + void init(); + +protected slots: + void toggle(); + void newSong(); + void stopped(); + void playing(); + void paused(); + void saveAs(); + void copyFinished( KIO::Job* ); + +private: + void start(); + void stop(); + + int pluginMenuItem; + + bool _enabled; + enum Status { PAUSED, STOPPED, PLAYING }; + Status _status; + + Arts::Effect_WAVECAPTURE _capture; + int _count; + long _id; + std::string _filename; + + QTimer* _timer; + KIO::Job* m_job; +}; + +#endif + +// vim:ts=4:sw=4 diff --git a/noatun-plugins/wavecapture/wavecapture.plugin b/noatun-plugins/wavecapture/wavecapture.plugin new file mode 100644 index 0000000..50d7dcc --- /dev/null +++ b/noatun-plugins/wavecapture/wavecapture.plugin @@ -0,0 +1,112 @@ +Filename=noatunwavecapture.la +Author=Matthias Kretz +Site=http://noatun.kde.org/ +Email=kretz@kde.org +Type=no idea +License=GPL +Name=Wave Capture +Name[af]=Golf Vang +Name[az]=Səs Yaxalama +Name[ca]=Captura wave +Name[cs]=Zachycení do WAV +Name[cy]=Dal Tonnau +Name[da]=Wave-indfanger +Name[de]=wav-Rekorder +Name[el]=Σύλληψη wave +Name[eo]=Onda kaptado +Name[es]=Captura de onda +Name[et]=Wave-faili salvestaja +Name[eu]=Uhin harrapatzailea +Name[fa]=گیراندازی Wave +Name[fi]=Äänen kaappaus +Name[fr]=Capture wave +Name[fy]=Weach-heiner +Name[gl]=Captura como WAVE +Name[he]=לכידת Wave +Name[hi]=वेव केप्चर +Name[hr]=Wave snimanje +Name[hu]=Hangfelvétel +Name[it]=Cattura in wav +Name[ja]=Wave キャプチャ +Name[ka]=ტალღათა ჩამწერი +Name[km]=ចាប់យក wave +Name[lt]=Wave įrašymas +Name[mk]=Снимање звук +Name[nb]=Wave-opptak +Name[nds]=Wave-Datei opnehmen +Name[ne]=वेभ ग्रहण +Name[nl]=Wave-vanger +Name[nn]=Wave-opptak +Name[nso]=Tshwaro ya Lephoto +Name[pa]=ਤਰੰਗ ਪ੍ਰਾਪਤੀ +Name[pl]=Zgrywanie do pliku WAV +Name[pt]=Captura para WAVE +Name[ro]=Captură WAV +Name[ru]=Сохранение в wav +Name[sk]=Uložiť wave +Name[sl]=Zajem WAV +Name[sv]=Vågformslagring +Name[ta]=அலை கவர்தல் +Name[tg]=Захира кардан дар wav +Name[tr]=Dalga Yakalayıcı +Name[uk]=Збереження у Wave +Name[vi]=Bắt WAV +Name[xh]=Ubamba Amaza +Name[zh_CN]=声波抓取 +Comment=Capture to wave file +Comment[af]=Vang na golf lêer +Comment[az]=Yaxala və wave faylına qeyd et +Comment[bg]=Аудио запис във файл във формат wave +Comment[bs]=Hvata melodiju u wave datoteku +Comment[ca]=Captura a un fitxer wave +Comment[cs]=Zachycení do WAV souboru +Comment[cy]=Dal i ffeil wave +Comment[da]=Indfang til wave-fil +Comment[de]=Aufnehmen als wav-Datei +Comment[el]=Σύλληψη σε αρχείο wave +Comment[eo]=Kaptu al onda dosiero +Comment[es]=Crea un archivo de ondas +Comment[et]=Salvestab wave-failiks +Comment[eu]=Uhin fitxategira harrapatzen du +Comment[fa]=گیراندازی پروندۀ wave +Comment[fi]=Kaappaa äänitiedosto +Comment[fr]=Capturer vers un fichier wave +Comment[fy]=Opnimme as weach-triem +Comment[ga]=Gabháil i gcomhad toinne +Comment[gl]=Capturar a un ficheiro WAVE +Comment[he]=לכידה לקובץ wave +Comment[hi]=वेव फ़ाइल में केप्चर करता है +Comment[hr]=Snimanje u wav datoteku +Comment[hu]=Mentés WAV fájlba +Comment[is]=Vista hljóð í wave skrár +Comment[it]=Cattura su di file wave +Comment[ja]=wave ファイルに保存 +Comment[ka]=ტალღის ფაილში ჩაწერა +Comment[kk]=Дыбысты қағып алып сақтау +Comment[km]=ចាប់យកឯកសារ wave +Comment[lt]=Užfiksuoti wave byloje +Comment[mk]=Снимање во wave-датотека +Comment[ms]=Cekup ke fail wave +Comment[nb]=Opptak til wav-file +Comment[nds]=Wave-Datei opnehmen +Comment[ne]=वेभ फाइलमा अभिग्रहण गर्नुहोस् +Comment[nl]=Opnemen als wave-bestand +Comment[nn]=Opptak til wave-file +Comment[pl]=Zgrywanie do pliku WAV +Comment[pt]=Capturar para um ficheiro WAVE +Comment[pt_BR]=captura e transforma para arquivos wave +Comment[ro]=Capturează sunetul într-un fişier WAV +Comment[ru]=Сохранение произведения в формате wav +Comment[sk]=Uložiť wave do súboru +Comment[sl]=Zajem v datoteko WAV +Comment[sr]=Зароби у wave фајл +Comment[sr@Latn]=Zarobi u wave fajl +Comment[sv]=Lagra till vågformsfil +Comment[ta]= அலைக்கோப்புக்கு கவர்தல் +Comment[tg]=Захирашавии баромад дар формати wav +Comment[tr]=Bir dalga dosyasına yakala +Comment[uk]=Збереження в файл wave +Comment[vi]=Bắt vào tập tin WAV +Comment[xh]=Ibanjwe kwifayile yamaza +Comment[zh_CN]=抓取到声波文件 +Comment[zh_TW]=抓取 wave 檔 |