diff options
Diffstat (limited to 'noatun/modules/voiceprint')
-rw-r--r-- | noatun/modules/voiceprint/Makefile.am | 14 | ||||
-rw-r--r-- | noatun/modules/voiceprint/prefs.cpp | 67 | ||||
-rw-r--r-- | noatun/modules/voiceprint/prefs.h | 22 | ||||
-rw-r--r-- | noatun/modules/voiceprint/voiceprint.cpp | 126 | ||||
-rw-r--r-- | noatun/modules/voiceprint/voiceprint.h | 33 | ||||
-rw-r--r-- | noatun/modules/voiceprint/voiceprint.plugin | 92 |
6 files changed, 354 insertions, 0 deletions
diff --git a/noatun/modules/voiceprint/Makefile.am b/noatun/modules/voiceprint/Makefile.am new file mode 100644 index 00000000..22c3f65c --- /dev/null +++ b/noatun/modules/voiceprint/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES= -I$(top_srcdir)/noatun/library $(all_includes) +kde_module_LTLIBRARIES = noatun_voiceprint.la + +noatun_voiceprint_la_SOURCES = voiceprint.cpp prefs.cpp + +noatun_voiceprint_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +noatun_voiceprint_la_LIBADD = $(LIB_KFILE) $(top_builddir)/noatun/library/libnoatun.la -lm + +noatun_voiceprint_la_METASOURCES = AUTO + +noinst_HEADERS = voiceprint.h prefs.h + +noatun_modules_voiceprint_DATA = voiceprint.plugin +noatun_modules_voiceprintdir = $(kde_datadir)/noatun diff --git a/noatun/modules/voiceprint/prefs.cpp b/noatun/modules/voiceprint/prefs.cpp new file mode 100644 index 00000000..48998680 --- /dev/null +++ b/noatun/modules/voiceprint/prefs.cpp @@ -0,0 +1,67 @@ +#include "prefs.h" +#include "voiceprint.h" + +#include <klocale.h> +#include <kglobal.h> +#include <qlabel.h> +#include <qlayout.h> +#include <kcolorbutton.h> +#include <kconfig.h> + +Prefs::Prefs(QObject* parent) + : CModule(i18n("Voiceprint"), i18n("Options for the Voiceprint Visualization"), "xapp", parent) +{ + QVBoxLayout *king=new QVBoxLayout(this); + QHBoxLayout *minor; + + QLabel *label; + mForeground=new KColorButton(this); + label=new QLabel(mForeground, i18n("&Foreground color:"), this); + minor=new QHBoxLayout(king); + minor->addWidget(label); + minor->addWidget(mForeground); + + mBackground=new KColorButton(this); + label=new QLabel(mBackground, i18n("&Background color:"), this); + minor=new QHBoxLayout(king); + minor->addWidget(label); + minor->addWidget(mBackground); + + mLine=new KColorButton(this); + label=new QLabel(mForeground, i18n("&Sweep color:"), this); + minor=new QHBoxLayout(king); + minor->addWidget(label); + minor->addWidget(mLine); + + king->addStretch(); +} + +void Prefs::reopen() +{ + KConfig *config=KGlobal::config(); + config->setGroup("VoicePrint"); + QColor black(0, 0, 0); + QColor blue(0, 0, 222); + mBackground->setColor(config->readColorEntry("Background", &black)); + mForeground->setColor(config->readColorEntry("Foreground", &blue)); + mLine->setColor(config->readColorEntry("Line", &black)); +} + +void Prefs::save() +{ + KConfig *config=KGlobal::config(); + config->setGroup("VoicePrint"); + config->writeEntry("Background", mBackground->color()); + config->writeEntry("Foreground", mForeground->color()); + config->writeEntry("Line", mLine->color()); + + config->sync(); + + VoicePrint *l=VoicePrint::voicePrint; + if (l) + l->setColors(mBackground->color(), mForeground->color(), mLine->color()); + +} + +#include "prefs.moc" + diff --git a/noatun/modules/voiceprint/prefs.h b/noatun/modules/voiceprint/prefs.h new file mode 100644 index 00000000..6541b4de --- /dev/null +++ b/noatun/modules/voiceprint/prefs.h @@ -0,0 +1,22 @@ +#ifndef PREFS_H +#define PREFS_H + +#include <qwidget.h> +#include <noatun/pref.h> + +class KColorButton; + +class Prefs : public CModule +{ +Q_OBJECT +public: + Prefs(QObject* parent); + virtual void save(); + virtual void reopen(); + +private: + KColorButton *mForeground, *mBackground, *mLine; +}; + +#endif + diff --git a/noatun/modules/voiceprint/voiceprint.cpp b/noatun/modules/voiceprint/voiceprint.cpp new file mode 100644 index 00000000..4f6c7aea --- /dev/null +++ b/noatun/modules/voiceprint/voiceprint.cpp @@ -0,0 +1,126 @@ +#include "voiceprint.h" +#include <noatun/player.h> +#include <noatun/app.h> +#include <math.h> +#include <qpainter.h> +#include "prefs.h" +#include <klocale.h> +#include <stdio.h> + +extern "C" +{ + KDE_EXPORT Plugin *create_plugin() + { + return new VoicePrint(); + } +} + +VoicePrint *VoicePrint::voicePrint=0; + +VoicePrint::VoicePrint() : QWidget(0,0,WRepaintNoErase), MonoFFTScope(50), Plugin() +{ + voicePrint=this; + mOffset=0; + mSegmentWidth=2; + setCaption(i18n("Voiceprint")); + resize(320, 240); + MonoFFTScope::start(); + show(); + setMaximumHeight(1024); +} + +VoicePrint::~VoicePrint() +{ +} + +void VoicePrint::init() +{ + Prefs *p=new Prefs(this); + p->reopen(); + p->save(); + resizeEvent(0); +} + +void VoicePrint::setColors(const QColor &bg, const QColor &fg, const QColor &l) +{ + mProgress=l; + mLowColor=bg.rgb(); + mHighColor=fg.rgb(); + setBackgroundColor(mLowColor); +} + +void VoicePrint::closeEvent(QCloseEvent *) +{ + unload(); +} + +void VoicePrint::resizeEvent(QResizeEvent *) +{ + mOffset=0; + mBuffer.resize(size()); + QPainter paint(&mBuffer); + paint.fillRect(QRect(0,0, QWidget::width(), height()), QColor(mLowColor)); + setBands(magic(height()/mSegmentWidth)); +} + +#define COLOR(color, bgcolor, fgcolor, foctet) \ + (int)( color(bgcolor) + (foctet) * (color(fgcolor) - color(bgcolor)) ) + +inline static QRgb averageByIntensity(QRgb bgcolor, QRgb fgcolor, int octet) +{ + float foctet = octet / 255.0; + + return qRgb(COLOR(qRed, bgcolor, fgcolor, foctet), + COLOR(qGreen, bgcolor, fgcolor, foctet), + COLOR(qBlue, bgcolor, fgcolor, foctet) + ); +} + +#undef COLOR + +void VoicePrint::paintEvent(QPaintEvent *e) +{ + bitBlt(this, e->rect().topLeft(), &mBuffer, e->rect(), Qt::CopyROP); +} + +void VoicePrint::scopeEvent(float *data, int bands) +{ + // save cpu + if(isHidden()) return; + + QPainter paint(&mBuffer); + // each square has a width of mSegmentWidth + float brightness = float(bands * mSegmentWidth); + for (int i=0; i<bands ; i++) + { + float b=data[bands-i-1]+1.0; + // the more bands there are, the dimmer each becomes + b=log10(b)/log(2) * 16 * brightness; + int band=int(b); + if (band>255) band=255; + else if (band<0) band=0; + + QColor area(averageByIntensity(mLowColor, mHighColor, band)); + + int bandTop=i*height()/bands, bandBottom=(i+1)*height()/bands; + paint.fillRect(mOffset, bandTop, mSegmentWidth,bandBottom-bandTop,area); + } + + int newOffset = mOffset+mSegmentWidth; + if (newOffset>QWidget::width()) newOffset=0; + paint.fillRect(newOffset, 0, mSegmentWidth, height(), mProgress); + + // redraw changes with the minimum amount of work + if(newOffset != 0) + { + repaint(mOffset,0,mSegmentWidth*2,height(),false); + } + else + { + repaint(mOffset,0,mSegmentWidth,height(),false); + repaint(newOffset,0,mSegmentWidth,height(),false); + } + mOffset = newOffset; +} + +#include "voiceprint.moc" diff --git a/noatun/modules/voiceprint/voiceprint.h b/noatun/modules/voiceprint/voiceprint.h new file mode 100644 index 00000000..ab5af69d --- /dev/null +++ b/noatun/modules/voiceprint/voiceprint.h @@ -0,0 +1,33 @@ +#ifndef VOICEPRINT_H +#define VOICEPRINT_H + +#include <noatun/plugin.h> + +class VoicePrint : public QWidget, public MonoFFTScope, public Plugin +{ +Q_OBJECT + +public: + VoicePrint(); + virtual ~VoicePrint(); + + void setColors(const QColor &bg, const QColor &fg, const QColor &l); + void init(); + +protected: + virtual void closeEvent(QCloseEvent *); + virtual void scopeEvent(float *data, int bands); + virtual void resizeEvent(QResizeEvent *); + virtual void paintEvent(QPaintEvent *); + +public: + static VoicePrint* voicePrint; + +private: + QColor mProgress; + QPixmap mBuffer; + QRgb mLowColor, mHighColor; + int mOffset, mSegmentWidth; +}; +#endif + diff --git a/noatun/modules/voiceprint/voiceprint.plugin b/noatun/modules/voiceprint/voiceprint.plugin new file mode 100644 index 00000000..b7bca4f4 --- /dev/null +++ b/noatun/modules/voiceprint/voiceprint.plugin @@ -0,0 +1,92 @@ +Filename=noatun_voiceprint.la +Author=Charles Samuels +Site=http://noatun.derkarl.org/ +Email=charles@kde.org +Type=visualization +License=Artistic +Name=Voiceprint +Name[af]=Stem afdruk +Name[az]=Səs gözləyici +Name[ca]=Empremta de veu +Name[cy]=Argraff Lais +Name[el]=Φωνητικό αποτύπωμα +Name[eo]=Voĉvidigilo +Name[es]=Huella de voz +Name[et]=Visuaalne signaal +Name[fi]=Äänikuva +Name[ga]=Guthlorg +Name[hi]=वाइसप्रिंट +Name[hr]=Otisak glasa +Name[hu]=Hanglenyomat +Name[is]=Raddrit +Name[it]=Impronta vocale +Name[ja]=ボイスプリント +Name[km]=បង្ហាញសំឡេង +Name[ko]=성문 +Name[lt]=Balso antspaudas +Name[lv]=Balssdruka +Name[mt]=Stampavuċi +Name[ne]=आवाज मुद्रण +Name[nl]=Stemafdruk +Name[pl]=Zapis głosu +Name[pt]=Impressão Vocal +Name[ro]=Amprentă vocală +Name[sl]=Galsovni zapis +Name[sv]=Röstavtryck +Name[ta]=குரல் அச்சு +Name[tr]=Ses Gözlemcisi +Name[ven]=U phirintha ha Mukosi +Name[xh]=Ushicilelo lelizwi +Name[zh_CN]=声波纹 +Name[zh_HK]=聲波紋 +Name[zh_TW]=聲波紋 +Name[zu]=Ushicilelo lelizwi +Comment=A voiceprint visualizer +Comment[bg]=Визуализатор Voiceprint +Comment[bs]=Vizualizacija sa ispisom glasa +Comment[ca]=Un visualitzador d'empremta de veu +Comment[cs]=Vizualizátor hlasu +Comment[cy]=Gweledydd argraff lais +Comment[da]=En voiceprint-visualisering +Comment[de]=Klangvisualisierung +Comment[el]=Μια αναπαράσταση αποτυπώματος φωνής +Comment[en_GB]=A voiceprint visualiser +Comment[eo]=Voĉo-vidigilo +Comment[es]=Un visualizador de huellas de voz +Comment[et]=Signaali visualiseerimise plugin +Comment[eu]=Voiceprint ikustailea +Comment[fa]=یک تجسمکننده voiceprint +Comment[fi]=Äänikuvavisualisoija +Comment[fr]=Un afficheur Voiceprint +Comment[gl]=Visualizador voiceprint +Comment[he]=ממחיש טביעות קול +Comment[hu]=Hanglenyomat-analizáló +Comment[is]=Raddritsskjár +Comment[it]=Visualizzatore di impronta vocale +Comment[ja]=声紋の視覚効果 +Comment[kk]=Дыбыс таңба бейнекөрінісі +Comment[km]=ម៉ាកែតសម្រាប់បង្ហាញសំឡេង +Comment[ko]=성문 비주얼라이저 +Comment[lt]=Balso antspaudo vaizdavimo priemonė +Comment[nb]=Voiceprint-fremvisar +Comment[nds]=Stimmafdruck-Filmmaker +Comment[ne]=आवाज मुद्रण भिजुलाइजर +Comment[nl]=Stemafdruk visualisatie +Comment[nn]=Voiceprint-framvisar +Comment[pl]=Wizualizacja śladu głosu +Comment[pt]=Um visualizador do comportamento vocal +Comment[pt_BR]=Um visualizador voiceprint +Comment[ro]=Vizualizor de amprentă vocală +Comment[ru]=визуализация voiceprint +Comment[sk]=Vizualizátor voiceprint +Comment[sl]=Predstavitelj glasovnega zapisa +Comment[sr]=Визуализатор гласовног отиска +Comment[sr@Latn]=Vizualizator glasovnog otiska +Comment[sv]=En röstavtrycksvisare +Comment[ta]=குரல் அச்சு படக்காட்சி +Comment[th]=โปรแกรมสร้างวิฌวลไลเซอร์ voiceprint +Comment[tr]=Ses Dökümü İzleme Programı +Comment[uk]=Візуаліатор voiseprint +Comment[zh_CN]=声波纹视觉效果 +Comment[zh_HK]=聲波紋顯示程式 +Comment[zh_TW]=聲波紋顯示程式 |