summaryrefslogtreecommitdiffstats
path: root/noatun-plugins/pitchablespeed
diff options
context:
space:
mode:
Diffstat (limited to 'noatun-plugins/pitchablespeed')
-rw-r--r--noatun-plugins/pitchablespeed/Makefile.am15
-rw-r--r--noatun-plugins/pitchablespeed/pitchablespeed.cpp167
-rw-r--r--noatun-plugins/pitchablespeed/pitchablespeed.h63
-rw-r--r--noatun-plugins/pitchablespeed/pitchablespeed.plugin113
-rw-r--r--noatun-plugins/pitchablespeed/speedtuner.ui195
5 files changed, 553 insertions, 0 deletions
diff --git a/noatun-plugins/pitchablespeed/Makefile.am b/noatun-plugins/pitchablespeed/Makefile.am
new file mode 100644
index 0000000..b994d98
--- /dev/null
+++ b/noatun-plugins/pitchablespeed/Makefile.am
@@ -0,0 +1,15 @@
+INCLUDES= -I$(kde_includes)/arts $(all_includes)
+
+kde_module_LTLIBRARIES = noatunpitchablespeed.la
+noatunpitchablespeed_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
+noatunpitchablespeed_la_LIBADD = $(LIB_KFILE) -lnoatun -lm -lartsmodules
+
+noatunpitchablespeed_la_SOURCES = pitchablespeed.cpp speedtuner.ui
+noatunpitchablespeed_la_METASOURCES = AUTO
+noinst_HEADERS = pitchablespeed.h
+
+noatun_DATA = pitchablespeed.plugin
+noatundir = $(kde_datadir)/noatun
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/pitchablespeed.pot
diff --git a/noatun-plugins/pitchablespeed/pitchablespeed.cpp b/noatun-plugins/pitchablespeed/pitchablespeed.cpp
new file mode 100644
index 0000000..f091c72
--- /dev/null
+++ b/noatun-plugins/pitchablespeed/pitchablespeed.cpp
@@ -0,0 +1,167 @@
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+// (c) 2001 hans_meine@gmx.net
+
+#include "pitchablespeed.h"
+#include <arts/reference.h>
+#include <arts/soundserver.h>
+#include <arts/kmedia2.h>
+#include <noatun/app.h>
+#include <noatun/player.h>
+#include <noatun/engine.h>
+#include <noatun/noatunarts.h>
+#include <qslider.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <klocale.h>
+#include <knuminput.h>
+
+extern "C"
+{
+ Plugin *create_plugin()
+ {
+ KGlobal::locale()->insertCatalogue("pitchablespeed");
+ return new PitchableSpeed();
+ }
+}
+
+const int PitchableSpeed::DEFAULT_OFFSET = 5;
+const int PitchableSpeed::DEFAULT_RANGE = 10;
+
+PitchableSpeed::PitchableSpeed() : Plugin(),
+ offset(DEFAULT_OFFSET),
+ range(DEFAULT_RANGE)
+, frequenciesPreserved(false)
+{
+
+ rangeInput->setRange(2,150,1,false);
+ rangeInput->setValue(range);
+ offsetInput->setRange(-5,15,1,false);
+ offsetInput->setValue(offset);
+ setupSliderRange();
+ connect(napp->player(), SIGNAL(changed()),
+ this, SLOT(newSong()));
+ connect(preserveFrequencies, SIGNAL(toggled(bool)),
+ this, SLOT(preserveFrequenciesChanged(bool)));
+ //show();
+}
+
+PitchableSpeed::~PitchableSpeed()
+{
+ napp->pluginMenuRemove(pluginMenuItem);
+
+ Arts::PlayObject playobject= napp->player()->engine()->playObject();
+ Arts::PitchablePlayObject pitchable= Arts::DynamicCast(playobject);
+ if (!pitchable.isNull())
+ pitchable.speed(1.0);
+
+ if (frequenciesPreserved)
+ napp->player()->engine()->effectStack()->remove(pitchShiftEffectID);
+}
+
+void PitchableSpeed::newSong()
+{
+ setSpeed();
+
+ Arts::PlayObject playobject= napp->player()->engine()->playObject();
+ Arts::PitchablePlayObject pitchable= Arts::DynamicCast(playobject);
+ slider->setEnabled(!pitchable.isNull());
+}
+
+float PitchableSpeed::sliderSpeed()
+{
+ return 1.0f - slider->value()/1000.0f;
+}
+
+void PitchableSpeed::setSpeed()
+{
+ Arts::PlayObject playobject= napp->player()->engine()->playObject();
+ Arts::PitchablePlayObject pitchable= Arts::DynamicCast(playobject);
+ float newSpeed= 1.0f;
+ if (!pitchable.isNull())
+ {
+ newSpeed= sliderSpeed();
+ pitchable.speed(newSpeed);
+ if (frequenciesPreserved)
+ pitchShift.speed(1.f/newSpeed);
+ }
+
+ QString percentStr;
+ percentStr.setNum((newSpeed-1.f)*100.f,'f',1);
+ if (newSpeed<=0) percentStr.prepend('+').append(' ').append('%');
+ currentValEdit->setText(percentStr);
+}
+
+void PitchableSpeed::setupSliderRange()
+{
+ int min= (-offset+range)<99 ? (-offset+range)*10 : 990;
+ slider->setRange((-offset-range)*10,min);
+ slider->setTickInterval(10);
+}
+
+void PitchableSpeed::speedChanged(int )
+{
+ setSpeed();
+}
+
+void PitchableSpeed::offsetChanged(int newOffset)
+{
+ offset= newOffset;
+ setupSliderRange();
+}
+
+void PitchableSpeed::rangeChanged(int newRange)
+{
+ range= newRange;
+ setupSliderRange();
+}
+
+void PitchableSpeed::preserveFrequenciesChanged(bool preserveNow)
+{
+ if (preserveNow==frequenciesPreserved)
+ return;
+ if (preserveNow)
+ {
+ pitchShift = Arts::DynamicCast(napp->player()->engine()->server()->
+ createObject("Arts::Synth_STEREO_PITCH_SHIFT"));
+ pitchShift.frequency(10.f); // TODO: might have to experiment a bit with this
+ pitchShift.speed(1.f/sliderSpeed());
+ pitchShift.start();
+ pitchShiftEffectID= napp->player()->engine()->effectStack()->
+ insertTop(pitchShift, "correcting pitch shift");
+ }
+ else
+ {
+ napp->player()->engine()->effectStack()->remove(pitchShiftEffectID);
+ pitchShift.stop();
+ pitchShift = Arts::Synth_STEREO_PITCH_SHIFT::null();
+ }
+ frequenciesPreserved= preserveNow;
+}
+
+void PitchableSpeed::init()
+{
+ pluginMenuItem = napp->pluginMenuAdd(i18n("Toggle Speed Slider"),
+ this, SLOT(toggle(void)));
+}
+
+void PitchableSpeed::toggle(void)
+{
+ show();
+ raise();
+}
+
+void PitchableSpeed::closeEvent(QCloseEvent *)
+{
+ hide();
+}
+
+#include "pitchablespeed.moc"
+
diff --git a/noatun-plugins/pitchablespeed/pitchablespeed.h b/noatun-plugins/pitchablespeed/pitchablespeed.h
new file mode 100644
index 0000000..d11a7cc
--- /dev/null
+++ b/noatun-plugins/pitchablespeed/pitchablespeed.h
@@ -0,0 +1,63 @@
+#ifndef PITCHABLESPEED_H
+#define PITCHABLESPEED_H
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+// (c) 2001 hans_meine@gmx.net
+
+#include <noatun/plugin.h>
+#include <arts/artsmodules.h>
+#include "speedtuner.h"
+
+class QSlider;
+
+class PitchableSpeed : public SpeedTuner, public Plugin
+{
+Q_OBJECT
+
+public:
+ PitchableSpeed();
+ virtual ~PitchableSpeed();
+
+ void init();
+
+public slots:
+ void toggle(void);
+
+ void newSong();
+
+protected:
+ virtual void closeEvent(QCloseEvent *);
+
+ void setupSliderRange();
+ void setSpeed();
+ float sliderSpeed();
+
+protected slots:
+ void speedChanged(int);
+ void offsetChanged(int);
+ void rangeChanged(int);
+
+ void preserveFrequenciesChanged(bool);
+
+private:
+ static const int DEFAULT_OFFSET;
+ static const int DEFAULT_RANGE;
+
+ int offset, range; // in percent, defaults 5% offset +-10% range
+
+ bool frequenciesPreserved;
+ Arts::Synth_STEREO_PITCH_SHIFT pitchShift;
+ long pitchShiftEffectID;
+
+ int pluginMenuItem;
+};
+
+#endif // PITCHABLESPEED_H
diff --git a/noatun-plugins/pitchablespeed/pitchablespeed.plugin b/noatun-plugins/pitchablespeed/pitchablespeed.plugin
new file mode 100644
index 0000000..8b1dded
--- /dev/null
+++ b/noatun-plugins/pitchablespeed/pitchablespeed.plugin
@@ -0,0 +1,113 @@
+Filename=noatunpitchablespeed.la
+Author=Hans Meine
+Site=http://noatun.kde.org/
+Email=hans@meine.de
+Type=other
+License=GPL
+Name=Pitchable Playing Speed
+Name[az]=Dəyişdirilə Bilən Çalma Sür'əti
+Name[bs]=Prilagodljiva brzina sviranja
+Name[ca]=Velocitat de reproducció canviant
+Name[cs]=Přizpůsobitelná rychlost přehrávání
+Name[cy]=Cyflymder Chwarae Addasu Traw
+Name[da]=Indstillelig afspilningshastighed
+Name[de]=Anpassbare Abspielgeschwindigkeit
+Name[el]=Ρυθμιζόμενη ταχύτητα αναπαραγωγής
+Name[eo]=Altigebla ludrapideco
+Name[es]=Velocidad de juego ajustable
+Name[et]=Esituskiiruse muutja
+Name[eu]=Erreprodukzio abiadura aldagarria
+Name[fa]=زیروبمی سرعت پخش
+Name[fi]=Muutettava soittonopeus
+Name[fr]=Vitesse de lecture variable
+Name[fy]=Oanpasbere ôfspylsnelheid
+Name[gl]=Velocidade Variábel de Reprodución
+Name[he]=התאמת מהירות
+Name[hi]=पिचेबल प्लेइंग स्पीड
+Name[hr]=Promjenjiva brzina
+Name[hu]=Változtatható lejátszási sebesség
+Name[is]=Stillanlegur afspilunarhraði
+Name[it]=Modificatore di velocità di riproduzione
+Name[ka]=რეგულირებადი დაკვრის სიჩქარე
+Name[kk]=Орындау жылдамдығын басқару
+Name[km]=ល្បឿន​ចាក់​ដែល​អាច​កំណត់​កម្ពស់​​សំឡេង​​បាន
+Name[lt]=Keičiamo tono grojimo greitis
+Name[mk]=Приспособлива брзина на изведба
+Name[nb]=Tonehøyde-spillehastighet
+Name[nds]=Afspeelgauheit ännern
+Name[ne]=पीचयोग्य प्ले गति
+Name[nl]=Aanpasbare afspeelsnelheid
+Name[nn]=Tonehøgde-spelesnøggleik
+Name[pl]=Zmiana szybkości odtwarzania
+Name[pt]=Velocidade Variável de Reprodução
+Name[pt_BR]=Velocidade de Reprodução
+Name[ro]=Viteză de redare variabilă
+Name[ru]=Регулирование скорости проигрывания
+Name[sk]=Nastaviteľná rýchlosť prehrávania
+Name[sl]=Hitrost predvajanja
+Name[sr]=Подесива брзина пуштања
+Name[sr@Latn]=Podesiva brzina puštanja
+Name[sv]=Anpassningsbar uppspelningshastighet
+Name[ta]=அடர்வு வாசிப்பு வேகம்
+Name[tg]=Танзими суръати ба кор андохтан
+Name[tr]=Ayarlanabilir Çalma Hızı
+Name[uk]=Довільна швидкість програвання
+Name[vi]=Tốc độ phát có giọng
+Name[xh]=Isantya Sokudlala Esingabasezantsi Okanye phezulu
+Name[zh_CN]=可设定基准的播放速度
+Name[zh_TW]=可調整播放速度
+Comment=Makes playing speed adjustable with a slider
+Comment[az]=Çalma sür'ətini bir qulp ilə dəyişdirmə imkanı verir
+Comment[bg]=Регулиране скоростта на изпълнение чрез плъзгач
+Comment[bs]=Omogućuje prilagođavanje brzine sviranja pomoću klizača
+Comment[ca]=Fa que es puga variar la velocitat de reproducció amb un cursor
+Comment[cs]=Umožní měnit rychlost přehrávání pomocí posuvníku
+Comment[cy]=Newid cyflymder chwarae efo llithrydd
+Comment[da]=Gør afspilningshastigheden indstillelig med en skyder
+Comment[de]=Macht die Abspielgeschwindigkeit mit einem Schieberegler einstellbar
+Comment[el]=Κάνει την ταχύτητα αναπαραγωγής να ρυθμίζεται μέσω ενός ολισθητή
+Comment[eo]=Agordebligas ludrapidecon per rolumilo
+Comment[es]=Permite ajustar la velocidad de reproducción con un botón deslizante
+Comment[et]=Muudab mängimiskiiruse liuguriga kohandatavaks
+Comment[eu]=Erreprodukzio abiadura botoi irristagarri baten bitartez doitzen du
+Comment[fa]=سرعت پخش را توسط یک لغزان قابل تنظیم می‌سازد
+Comment[fi]=Voit muuttaa soittonopeutta liukusäätimellä
+Comment[fr]=Rend la vitesse de lecture ajustable avec un curseur
+Comment[fy]=Makket de ôfspylsnelheid ynstelber mei in skúfregelder
+Comment[gl]=Torna a velocidade de reproduición axustábel cunha barra
+Comment[he]=מאפשר התאמה של מהירות הניגון בעזרת מחוון
+Comment[hi]=प्लेइंग स्पीड एक स्लाइडर के द्वारा समायोजन योग्य बनाता है
+Comment[hr]=Omogućuje promjenu brzine sviranja pomoću klizača
+Comment[hu]=Változtatható lejátszási sebességet tesz lehetővé
+Comment[is]=Gerir afspilunarhraðan stillanlegan með rennislá
+Comment[it]=Permette di modificare la velocità di riproduzione tramite una barra
+Comment[ja]=再生スピードをスライダーで調節させる
+Comment[ka]=საშუალებას იძლევა დაკვრის სიჩქარე სოსიით შეცვალოთ
+Comment[kk]=Орындау жылдамдығын жүгірткі арқылы басқару
+Comment[km]=ធ្វើ​ឲ្យ​ល្បឿន​ការ​ចាក់អាច​លៃតម្រូវ​​បាន​ដោយ​ប្រើ​​គ្រាប់​រំកិល
+Comment[lt]=Leidžia keisti grojimo greitį su šliaužikliu
+Comment[mk]=Ја прави брзината на изведба на музиката приспособлива со потенциометар
+Comment[ms]=Menjadikan kelajuan pemain boleh laras dengan slider
+Comment[nb]=Gjør avspillingsfarten justerbar med en skyver
+Comment[nds]=De Afspeelgauheit mit en Schuver topassen
+Comment[ne]=स्लाइडरबाट प्ले गति समायोजनयोग्य बनाउछ
+Comment[nl]=Maakt de afspeelsnelheid instelbaar met een schuifregelaar
+Comment[nn]=Gjer spelefarten justerbar med ein skyvar
+Comment[pl]=Umożliwia łatwą zmianę szybkości odtwarzania
+Comment[pt]=Torna a velocidade de reprodução ajustável com uma barra
+Comment[pt_BR]=Torna a velocidade reprodução ajustável com uma barra deslizante
+Comment[ro]=Permite ajustarea vitezei de redare cu un potenţiometru
+Comment[ru]=Регулирование скорости проигрывания через бегунок
+Comment[sk]=Umožňuje zmeniť rýchlosť prehrávania pomocou posúvadla
+Comment[sl]=Naredi hitrost predvajanja prilagodljivo z drsnikom
+Comment[sr]=Чини брзину пуштања подесивом помоћу клизача
+Comment[sr@Latn]=Čini brzinu puštanja podesivom pomoću klizača
+Comment[sv]=Gör uppspelningshastigheten justerbar med ett skjutreglage
+Comment[ta]=ஸ்லைடருடன் வாசிப்பு வேகத்தை சரிபார்க்க கூடிய வகையில் அமைக்கிறது
+Comment[tg]=Танзими суръати ба кор андохтан бо даванда
+Comment[tr]=Bir kaydırma çubuğuyla oynatma hızını ayarlanabilir yapar
+Comment[uk]=Дозволяє змінювати швидкість програвання за допомогою повзунка
+Comment[vi]=Cung cấp khả năng điều chỉnh tốc độ phát bằng con trượt
+Comment[xh]=Yenza isantya sokudlalo sikwazi ukucutheka ngesityibilikisi
+Comment[zh_CN]=使播放速度可以使用滑动条来调整
+Comment[zh_TW]=讓播放速度可經由滑動器調整
diff --git a/noatun-plugins/pitchablespeed/speedtuner.ui b/noatun-plugins/pitchablespeed/speedtuner.ui
new file mode 100644
index 0000000..79844c4
--- /dev/null
+++ b/noatun-plugins/pitchablespeed/speedtuner.ui
@@ -0,0 +1,195 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>SpeedTuner</class>
+<author>Hans Meine &lt;hans@meine.de&gt;</author>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>SpeedTuner</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>269</width>
+ <height>316</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Adjust Playing Speed</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QSlider">
+ <property name="name">
+ <cstring>slider</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>Both</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>currentValEdit</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="font">
+ <font>
+ <family>Sans Serif</family>
+ <pointsize>24</pointsize>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property name="frame">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>AlignHCenter</set>
+ </property>
+ <property name="hAlign" stdset="0">
+ </property>
+ </widget>
+ <spacer>
+ <property name="name" stdset="0">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout2</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>rangeLabel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Range:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>rangeInput</cstring>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="0" column="1">
+ <property name="name">
+ <cstring>rangeInput</cstring>
+ </property>
+ <property name="value">
+ <number>10</number>
+ </property>
+ <property name="suffix">
+ <string> %</string>
+ </property>
+ <property name="prefix">
+ <string>+/- </string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>offsetLabel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Offset:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>offsetInput</cstring>
+ </property>
+ </widget>
+ <widget class="KIntNumInput" row="1" column="1">
+ <property name="name">
+ <cstring>offsetInput</cstring>
+ </property>
+ <property name="value">
+ <number>5</number>
+ </property>
+ <property name="suffix">
+ <string> %</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>preserveFrequencies</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Preserve frequencies</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+</widget>
+<connections>
+ <connection>
+ <sender>slider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SpeedTuner</receiver>
+ <slot>speedChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>rangeInput</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SpeedTuner</receiver>
+ <slot>rangeChanged(int)</slot>
+ </connection>
+ <connection>
+ <sender>offsetInput</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>SpeedTuner</receiver>
+ <slot>offsetChanged(int)</slot>
+ </connection>
+</connections>
+<slots>
+ <slot access="protected">speedChanged(int)</slot>
+ <slot access="protected">offsetChanged(int)</slot>
+ <slot access="protected">rangeChanged(int)</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>