diff options
Diffstat (limited to 'krec')
57 files changed, 5089 insertions, 0 deletions
diff --git a/krec/Makefile.am b/krec/Makefile.am new file mode 100644 index 00000000..25e652e1 --- /dev/null +++ b/krec/Makefile.am @@ -0,0 +1,95 @@ + +if compile_ogg_export +OGGEXPORTDIR=ogg_export +endif + +if compile_mp3_export +MP3EXPORTDIR=mp3_export +endif + +SUBDIRS = . pics $(OGGEXPORTDIR) $(MP3EXPORTDIR) + +INCLUDES= \ + -I$(top_builddir)/arts/gui/common \ + -I$(top_builddir)/arts/midi \ + -I$(top_builddir)/arts/modules/common \ + -I$(top_builddir)/arts/modules/synth \ + -I$(top_builddir)/arts/modules/effects \ + -I$(top_srcdir)/arts/gui/kde \ + -I$(top_srcdir)/arts/tools \ + -I$(top_builddir)/arts/modules/effects \ + -I$(top_builddir)/arts/modules/common \ + -I$(top_builddir)/arts/modules/synth \ + -I$(top_builddir)/arts/midi \ + -I$(arts_includes) $(all_includes) + +METASOURCES = AUTO + +bin_PROGRAMS = +lib_LTLIBRARIES = +kdeinit_LTLIBRARIES = krec.la + +kde_module_LTLIBRARIES = kcm_krec.la kcm_krec_files.la libkrecexport_wave.la + +noinst_LTLIBRARIES = lib_krec_common.la + +krec_la_SOURCES = \ + krecnewproperties.cpp \ + krecfile.cpp \ + krecfileview.cpp \ + krecfileviewhelpers.cpp \ + krecfilewidgets.cpp \ + main.cpp \ + krecord.cpp + +krec_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +krec_la_LIBADD = \ + lib_krec_common.la \ + $(top_builddir)/arts/gui/kde/libartsgui_kde.la \ + $(top_builddir)/arts/tools/libartscontrolsupport.la \ + -lartskde $(LIBDL) $(LIB_KIO) $(LIB_KDEUI) $(LIB_KUTILS) + +kcm_krec_la_SOURCES = krecconfigure.cpp +kcm_krec_la_LDFLAGS = -module -avoid-version -no-undefined $(all_libraries) +kcm_krec_la_LIBADD = lib_krec_common.la $(LIB_KUTILS) + +kcm_krec_files_la_SOURCES = krecconfig_files.cpp +kcm_krec_files_la_LDFLAGS = -module -avoid-version -no-undefined $(all_libraries) +kcm_krec_files_la_LIBADD = lib_krec_common.la $(LIB_KUTILS) + +lib_krec_common_la_SOURCES = \ + krecglobal.cpp \ + krecexport_template.cpp \ + krecconfig_fileswidget.cpp + +lib_krec_common_la_LDFLAGS = -module -avoid-version -no-undefined $(all_libraries) +lib_krec_common_la_LIBADD = $(LIB_KDEUI) $(LIB_KIO) + +libkrecexport_wave_la_SOURCES = krecexport_wave.cpp +libkrecexport_wave_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +libkrecexport_wave_la_LIBADD = lib_krec_common.la + +rcdir = $(kde_datadir)/krec +rc_DATA = krecui.rc + +xdg_apps_DATA = krec.desktop +xdg_configdir = $(kde_servicesdir) +xdg_config_DATA = kcm_krec.desktop kcm_krec_files.desktop + +messages: rc.cpp + rm -f tips.cpp + $(PREPARETIPS) > tips.cpp + $(XGETTEXT) */*.cpp *.cpp *.h -o $(podir)/krec.pot + rm -f tips.cpp + +KDE_ICON = krec + +appsdatadir=$(kde_datadir)/krec +appsdata_DATA=tips + +kde_servicetypes_DATA=krec_exportitem.desktop + +kde_services_DATA=krec_exportwave.desktop + +krecord.lo: ../arts/gui/common/artsgui.h ../arts/modules/effects/artsmoduleseffects.h ../arts/modules/common/artsmodulescommon.h ../arts/midi/artsmidi.h ../arts/modules/synth/artsmodulessynth.h + diff --git a/krec/configure.in.in b/krec/configure.in.in new file mode 100644 index 00000000..092ca0ca --- /dev/null +++ b/krec/configure.in.in @@ -0,0 +1,3 @@ +if test "x$build_arts" = "xno"; then + DO_NOT_COMPILE="$DO_NOT_COMPILE krec" +fi diff --git a/krec/globals.h b/krec/globals.h new file mode 100644 index 00000000..4c95768c --- /dev/null +++ b/krec/globals.h @@ -0,0 +1,36 @@ +/* + + Copyright (C) 2003 Nikolas Zimmermann <wildfox@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef GLOBALS_H +#define GLOBALS_H + +// Global reader + writer settings +// FIXME: Check endian! +#define GLOBAL_SWAP false + +// Global reader settings +#define GLOBAL_BUFFERSIZE 8192 + +// Global writer settings +#define GLOBAL_RATE 44100 +#define GLOBAL_CHANNELS 2 + +#endif diff --git a/krec/hi128-app-krec.png b/krec/hi128-app-krec.png Binary files differnew file mode 100644 index 00000000..67b5bf79 --- /dev/null +++ b/krec/hi128-app-krec.png diff --git a/krec/hi16-app-krec.png b/krec/hi16-app-krec.png Binary files differnew file mode 100644 index 00000000..16635f55 --- /dev/null +++ b/krec/hi16-app-krec.png diff --git a/krec/hi22-app-krec.png b/krec/hi22-app-krec.png Binary files differnew file mode 100644 index 00000000..9585321e --- /dev/null +++ b/krec/hi22-app-krec.png diff --git a/krec/hi32-app-krec.png b/krec/hi32-app-krec.png Binary files differnew file mode 100644 index 00000000..0aa41e11 --- /dev/null +++ b/krec/hi32-app-krec.png diff --git a/krec/hi48-app-krec.png b/krec/hi48-app-krec.png Binary files differnew file mode 100644 index 00000000..bf1afefa --- /dev/null +++ b/krec/hi48-app-krec.png diff --git a/krec/hi64-app-krec.png b/krec/hi64-app-krec.png Binary files differnew file mode 100644 index 00000000..872cb4e9 --- /dev/null +++ b/krec/hi64-app-krec.png diff --git a/krec/kcm_krec.desktop b/krec/kcm_krec.desktop new file mode 100644 index 00000000..a4ae874c --- /dev/null +++ b/krec/kcm_krec.desktop @@ -0,0 +1,108 @@ +[Desktop Entry] +Icon=krec +Type=Service +ServiceTypes=KCModule + +X-KDE-ModuleType=Library +X-KDE-Library=krec +X-KDE-FactoryName=KRecConfigGeneralFactory +X-KDE-ParentApp=krec +X-KDE-ParentComponents=krec + +Name=Global +Name[bg]=Общи +Name[bn]=গ্লোবাল +Name[br]=Hollek +Name[bs]=Globalno +Name[cs]=Globální +Name[cy]=Eang +Name[el]=Καθολικές +Name[eo]=Tutprograma +Name[et]=Globaalne +Name[eu]=Globala +Name[fa]=سراسری +Name[fi]=Yleiset +Name[he]=כללי +Name[hi]=वैश्विक +Name[hu]=Globális +Name[is]=Algilt +Name[it]=Globale +Name[ja]=グローバル +Name[kk]=Жалпы +Name[km]=សកល +Name[ko]=전역 +Name[lt]=Globalinė +Name[mk]=Општо +Name[nds]=Globaal +Name[ne]=विश्वव्यापी +Name[nl]=Globaal +Name[pa]=ਗਲੋਬਲ +Name[pl]=Ogólne +Name[ru]=Глобальные +Name[sk]=Globálne +Name[sl]=Splošno +Name[sr]=Глобално +Name[sr@Latn]=Globalno +Name[ta]=உலகலாவிய +Name[tg]=Саросарӣ +Name[th]=โดยรวม +Name[tr]=Evrensel +Name[uk]=Глобальні +Name[uz@cyrillic]=Глобал +Name[zh_CN]=全局 +Name[zh_HK]=通用 +Name[zh_TW]=全域 +Comment=Global Configuration +Comment[bg]=Общи настройки +Comment[bn]=গ্লোবাল কনফিগারেশন +Comment[br]=Kefluniadur hollek +Comment[bs]=Globalne postavke +Comment[ca]=Configuració global +Comment[cs]=Globální nastavení +Comment[cy]=Ffurfweddiad Eang +Comment[da]=Global indstilling +Comment[de]=Globale Einstellungen +Comment[el]=Καθολική ρύθμιση +Comment[eo]=Tutprograma Agordo +Comment[es]=Configuración global +Comment[et]=Globaalne seadistamine +Comment[eu]=Konfigurazio globala +Comment[fa]=پیکربندی سراسری +Comment[fi]=Yleiset asetukset +Comment[fr]=Configuration globale +Comment[ga]=Cumraíocht Chomhchoiteann +Comment[gl]=Configuración Global +Comment[he]=הגדרות כלליות +Comment[hu]=Globális beállítások +Comment[is]=Algildar stillingar +Comment[it]=Configurazione globale +Comment[ja]=グローバル設定 +Comment[kk]=Жалпы баптаулары +Comment[km]=ការកំណត់រចនាសម្ព័ន្ធសកល +Comment[ko]=전역 설정 +Comment[lt]=Globalinė konfigūracija +Comment[mk]=Глобална конфигурација +Comment[nb]=Globalt oppsett +Comment[nds]=Globaal Instellen +Comment[ne]=विश्वव्यापी कन्फिगरेसन +Comment[nl]=Globale configuratie +Comment[nn]=Globalt oppsett +Comment[pa]=ਗਲੋਬਲ ਸੰਰਚਨਾ +Comment[pl]=Globalna konfiguracja +Comment[pt]=Configuração Global +Comment[pt_BR]=Configuração global +Comment[ro]=Configurare globală +Comment[ru]=Общие параметры +Comment[sk]=Globálne nastavenie +Comment[sl]=Splošne nastavitve +Comment[sr]=Опште подешавање +Comment[sr@Latn]=Opšte podešavanje +Comment[sv]=Global inställning +Comment[ta]=KRec இன் உலகலாவிய வடிவமைப்பு +Comment[th]=ปรับแต่งโดยรวม +Comment[tr]=Genel Yapılandırma +Comment[uk]=Глобальні налаштування +Comment[zh_CN]=全局配置 +Comment[zh_HK]=通用設定 +Comment[zh_TW]=全域設定 + diff --git a/krec/kcm_krec_files.desktop b/krec/kcm_krec_files.desktop new file mode 100644 index 00000000..d946330f --- /dev/null +++ b/krec/kcm_krec_files.desktop @@ -0,0 +1,127 @@ +[Desktop Entry] +Icon=filenew +Type=Service +ServiceTypes=KCModule + +X-KDE-ModuleType=Library +X-KDE-Library=krec_files +X-KDE-FactoryName=KRecConfigFileFactory +X-KDE-ParentApp=krec +X-KDE-ParentComponents=krec + +Name=New Files +Name[ar]=الملفات الجديدة +Name[bg]=Нови файлове +Name[bn]=নতুন ফাইল +Name[br]=Restroù nevez +Name[bs]=Nove datoteke +Name[ca]=Nous fitxers +Name[cs]=Nové soubory +Name[cy]=Ffeiliau Newydd +Name[da]=Nye filer +Name[de]=Neue Dateien +Name[el]=Νέα αρχεία +Name[eo]=Novaj dosieroj +Name[es]=Nuevos archivos +Name[et]=Uued failid +Name[eu]=Fitxategi berriak +Name[fa]=پروندههای جدید +Name[fi]=Uudet tiedostot +Name[fr]=Nouveaux fichiers +Name[ga]=Comhaid Nua +Name[gl]=Novos Ficheiros +Name[he]=קבצים חדשים +Name[hi]=नई फ़ाइलें +Name[hu]=Új fájlok +Name[is]=Nýjar skrár +Name[it]=Nuovi file +Name[ja]=新規ファイル +Name[kk]=Жаңа файдар +Name[km]=ឯកសារថ្មី +Name[ko]=새 파일 +Name[lt]=Naujos bylos +Name[mk]=Нови датотеки +Name[nb]=Nye filer +Name[nds]=Niege Dateien +Name[ne]=नयाँ फाइल +Name[nl]=Nieuwe bestanden +Name[nn]=Nye filer +Name[pa]=ਨਵੀਆਂ ਫਾਇਲਾਂ +Name[pl]=Nowe pliki +Name[pt]=Novos Ficheiros +Name[pt_BR]=Novos Arquivos +Name[ro]=Fişiere noi +Name[ru]=Новые файлы +Name[sk]=Nové súbory +Name[sl]=Nove datoteke +Name[sr]=Нови фајлови +Name[sr@Latn]=Novi fajlovi +Name[sv]=Nya filer +Name[ta]=புது கோப்புகள் +Name[tg]=Файли Нав +Name[th]=แฟ้มใหม่ +Name[tr]=Yeni Dosyalar +Name[uk]=Нові файли +Name[uz]=Yangi fayllar +Name[uz@cyrillic]=Янги файллар +Name[wa]=Noveas fitchîs +Name[zh_CN]=新建文件 +Name[zh_HK]=新檔案 +Name[zh_TW]=新檔案 +Comment=Default Properties for New Files +Comment[ar]=الخصائص الإفتراضية للملفات الجديدة +Comment[bg]=Настройки на създаване на нови файлове +Comment[br]=Dibaboù dre ziouer evit ar restroù nevez +Comment[bs]=Podrazumijevane postavke za nove datoteke +Comment[ca]=Propietats per omissió dels nous fitxers +Comment[cs]=Výchozí nastavení pro nové soubory +Comment[cy]=Priodweddau Rhagosod ar gyfer Ffeiliau Newydd +Comment[da]=Standardegenskaber for nye filer +Comment[de]=Standardeinstellungen für neue Dateien +Comment[el]=Προκαθορισμένες ιδιότητες για νέα αρχεία +Comment[eo]=Aprioraj ecoj por novaj dosieroj +Comment[es]=Propiedades predeterminadas para nuevos archivos +Comment[et]=Uute failide vaikimisi omadused +Comment[eu]=Fitxategi berrientzako lehenetsitako propietateak. +Comment[fa]=ویژگیهای پیشفرض برای پروندههای جدید +Comment[fi]=Oletusasetukset uusille tiedostoille +Comment[fr]=Propriétés par défaut pour les nouveaux fichiers +Comment[gl]=Propiedades por Defecto para os Novos Ficheiros +Comment[he]=מאפייני ברירת המחדל עבור קבצים חדשים +Comment[hi]=नई फ़ाइलों के लिए डिफ़ॉल्ट गुण +Comment[hu]=Az alapértelmezett tulajdonságok új fájloknál +Comment[is]=Sjálfgefnir eiginleikar nýrra skráa +Comment[it]=Impostazioni predefinite per i nuovi file +Comment[ja]=新規ファイルのデフォルト設定 +Comment[kk]=Жаңа файлдардың әдеттегі қасиеттері +Comment[km]=លក្ខណៈសម្បត្តិលំនាំដើម សម្រាប់ឯកសារថ្មី +Comment[ko]=새 파일의 기본 속성 +Comment[lt]=Numatytieji naujų bylų nustatymai +Comment[mk]=Почетни својства за новите датотеки +Comment[nb]=Standard egenskaper for nye filer +Comment[nds]=Standardegenschappen för niege Dateien +Comment[ne]=नयाँ फाइलका लागि पूर्वनिर्धारित गुण +Comment[nl]=Standaardeigenschappen voor nieuwe bestanden +Comment[nn]=Standardeigenskapar for nye filer +Comment[pa]=ਨਵੀਆਂ ਫਾਇਲਾਂ ਲਈ ਮੂਲ ਵਿਸ਼ੇਸ਼ਤਾ +Comment[pl]=Domyślne ustawienia dla nowych plików +Comment[pt]=Propriedades por Omissão para Novos Ficheiros +Comment[pt_BR]=Propriedades padrão para novos arquivos +Comment[ro]=Proprietăţi implicite pentru fişiere noi +Comment[ru]=Параметры по умолчанию для новых файлов +Comment[sk]=Štandardné vlastnosti pre nové súbory +Comment[sl]=Privzete lastnosti za nove datoteke +Comment[sr]=Подразумевана својства за нове фајлове +Comment[sr@Latn]=Podrazumevana svojstva za nove fajlove +Comment[sv]=Standardegenskaper för nya filer +Comment[ta]=புது கோப்புகளுக்கான முன்னிருப்பு பண்புகள் +Comment[tg]=Хусусиятҳо бо Нобаёнӣ барои Файлҳои Нав +Comment[th]=ค่าคุณสมบัติโดยปริยายสำหรับแฟ้มใหม่ +Comment[tr]=Yeni Dosyalar İçin Öntanımlı Özellikler +Comment[uk]=Типові властивості для нових файлів +Comment[uz]=Yangi fayllarning andoza xossalari +Comment[uz@cyrillic]=Янги файлларнинг андоза хоссалари +Comment[zh_CN]=新文件的默认属性 +Comment[zh_HK]=新檔案的預設值 +Comment[zh_TW]=新檔案的預設內容 + diff --git a/krec/krec.desktop b/krec/krec.desktop new file mode 100644 index 00000000..047f95b5 --- /dev/null +++ b/krec/krec.desktop @@ -0,0 +1,80 @@ +[Desktop Entry] +Type=Application +Exec=krec %i %m -caption "%c" +Icon=krec +Path= +DocPath=krec/index.html +Terminal=false +GenericName=Recording Tool +GenericName[af]=Opneem Program +GenericName[ar]=أداة التسجيل +GenericName[bg]=Аудио запис +GenericName[br]=Ostilh enrollañ +GenericName[bs]=Alat za snimanje +GenericName[ca]=Eina per gravar +GenericName[cs]=Nástroj pro nahrávání +GenericName[cy]=Erfyn Recordio +GenericName[da]=Indspilningsværktøj +GenericName[de]=Aufnahmeprogramm +GenericName[el]=Εργαλείο εγγραφής +GenericName[eo]=Sonregistrilo +GenericName[es]=Herramienta de grabación +GenericName[et]=Salvestamise rakendus +GenericName[eu]=Grabaketa tresna +GenericName[fa]=ابزار ضبط +GenericName[fi]=Nauhoitustyökalu +GenericName[fr]=Outil d'enregistrement +GenericName[ga]=Uirlis Taifeadta +GenericName[gl]=Ferramenta de Gravación +GenericName[he]=כלי הקלטה +GenericName[hi]=रेकॉर्डिंग औज़ार +GenericName[hu]=Hangrögzítő +GenericName[is]=Hljóðupptökutól +GenericName[it]=Strumento di registrazione +GenericName[ja]=録音ツール +GenericName[kk]=Жазып алу құралы +GenericName[km]=ឧបករណ៍ថត +GenericName[ko]=녹음 도구 +GenericName[lt]=Įrašinėjimo priemonė +GenericName[mk]=Алатка за снимање +GenericName[ms]=Alat Perekod +GenericName[nb]=Opptaksverktøy +GenericName[nds]=Opnehm-Warktüüch +GenericName[ne]=रेकर्डिङ उपकरण +GenericName[nl]=Opnameprogramma +GenericName[nn]=Opptaksverktøy +GenericName[pa]=ਰਿਕਾਰਡਿੰਗ ਸੰਦ +GenericName[pl]=Narzędzie do nagrywania +GenericName[pt]=Ferramenta de Gravação +GenericName[pt_BR]=Ferramenta de Gravação +GenericName[ro]=Utilitar de înregistrare sunet +GenericName[ru]=Звукозапись +GenericName[se]=Báddenreaidu +GenericName[sk]=Nahrávací nástroj +GenericName[sl]=Orodje za snemanje +GenericName[sr]=Алат за снимање звука +GenericName[sr@Latn]=Alat za snimanje zvuka +GenericName[sv]=Inspelningsverktyg +GenericName[ta]=பதிவுக் கருவி +GenericName[tg]=Асбоби Сабткунӣ +GenericName[th]=เครื่องมือบันทึกเสียง +GenericName[tr]=Ses Kaydedici +GenericName[uk]=Засіб для запису +GenericName[uz]=Tovush yozish vositasi +GenericName[uz@cyrillic]=Товуш ёзиш воситаси +GenericName[ven]=Tshishumiswa tshau rekhoda +GenericName[wa]=Usteye eredjîstresse di sons +GenericName[xh]=Isixhobo Sokubhala phantsi +GenericName[zh_CN]=录音工具 +GenericName[zh_HK]=錄製工具 +GenericName[zh_TW]=錄製工具 +GenericName[zu]=Ithuluzi Lokuqopha +Name=KRec +Name[bn]=কে-রেক +Name[hi]=के-रेक +Name[sv]=Krec +Name[tg]=KСабт +Name[zh_TW]=KRec 錄音機 +X-KDE-StartupNotify=true +X-DCOP-ServiceType=Multi +Categories=Qt;KDE;AudioVideo; diff --git a/krec/krec_exportitem.desktop b/krec/krec_exportitem.desktop new file mode 100644 index 00000000..042cb52c --- /dev/null +++ b/krec/krec_exportitem.desktop @@ -0,0 +1,61 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KRec/exportplugin +Comment=Exportplugin for KRec +Comment[bg]=Приставка за KRec +Comment[br]=Lugent ezporh evit KRec +Comment[bs]=Exportplugin za KRec +Comment[ca]=Connector d'exportació per a KRec +Comment[cs]=Exportní modul pro KRec +Comment[cy]=Ategyn Allforio ar gyfer KRec +Comment[da]=Eksportplugin for KRec +Comment[de]=Export-Modul für KRec +Comment[el]=Πρόσθετο εξαγωγής για το KRec +Comment[eo]=Eksportkromaĵo por KRec +Comment[es]=Accesorio de exportación para KRec +Comment[et]=KReci eksportplugin +Comment[eu]=Esportazio plugin-a KRec-entzat +Comment[fa]=وصلۀ صادرات برای KRec +Comment[fi]=Vientiliitännäinen KRec-ohjelmalle +Comment[fr]=Module externe d'exportation pour KRec +Comment[ga]=Breiseán easpórtála le haghaidh KRec +Comment[gl]=Extensión de exportacións para KRec +Comment[he]=תוסף יצוא עבור KRec +Comment[hi]=के-रेक के लिए निर्यात प्लगइन +Comment[hu]=Exportálási bővítőmodul a KRec-hez +Comment[is]=Útflutningsíforrit fyrir KRec +Comment[it]=Plugin di esportazione per KRec +Comment[ja]=KRec のエクスポートプラグイン +Comment[kk]=KRec-тің экспорттау плагин модулі +Comment[km]=កម្មវិធីជំនួយការនាំចេញសម្រាប់ KRec +Comment[ko]=KRec 내보내기 플러그인 +Comment[lt]=KRec eksporto priedas +Comment[mk]=Приклучок за изнесување за KRec +Comment[nb]=Programtillegg for eksport i KRec +Comment[nds]=Export-Moduul för KRec +Comment[ne]=KRec का लागि निर्यात प्लगइन +Comment[nl]=Exportplugin voor KRec +Comment[nn]=Eksporttillegg for KRec +Comment[pl]=Wtyczka eksportu dla KRec +Comment[pt]='Plugin' de exportação para o KRec +Comment[pt_BR]=Um Plugin de exportação para o KRec +Comment[ro]=Modul de export pentru KRec +Comment[ru]=Модуль экспорта файла для KRec +Comment[sk]=Exportný modul pre KRec +Comment[sl]=Izvozni vstavek za KRec +Comment[sr]=KRec-ов прикључак за извоз +Comment[sr@Latn]=KRec-ov priključak za izvoz +Comment[sv]=Exportinsticksmodul för Krec +Comment[ta]=KRecற்கான ஏற்றுமதிசொருகுப்பொருள் +Comment[tg]=Модули содирот барои KСабт +Comment[th]=ปลั๊กอินส่งออกสำหรับ KRec +Comment[tr]=KRec için aktarma eklentisi +Comment[uk]=Втулок експорту для KRec +Comment[uz]=KRec uchun eksport plagini +Comment[uz@cyrillic]=KRec учун экспорт плагини +Comment[zh_CN]=KRec 导出插件 +Comment[zh_HK]=用於 KRec 的 匯出插件 +Comment[zh_TW]=KRec 匯出外掛 + +[PropertyDef::X-KDE-ExportSuffix] +Type=QStringList diff --git a/krec/krec_exportwave.desktop b/krec/krec_exportwave.desktop new file mode 100644 index 00000000..5a486ad5 --- /dev/null +++ b/krec/krec_exportwave.desktop @@ -0,0 +1,57 @@ +[Desktop Entry] +Type=Service +Name=Wave-Export +Name[bg]=Експортиране в Wave +Name[bn]=ওয়েভ-রপ্তানি +Name[br]=Ezporhz Wave +Name[ca]=Exportació d'ones +Name[cs]=Export do WAV +Name[cy]=Allforio Ton +Name[da]=Wave-Eksport +Name[el]=Εξαγωγή wave +Name[eo]=Wave-Eksporto +Name[es]=Exportador de Wave +Name[et]=Wave-eksport +Name[eu]=Wave-esportazioa +Name[fa]=صادرات موج +Name[fi]=Wave-tiedoston vienti +Name[fr]=Exportation en Wave +Name[gl]=Exportación a Wav +Name[he]=יצוא Wave +Name[hi]=Wave-निर्यात +Name[hu]=Exportálás - WAV +Name[is]=Wave útflutningur +Name[it]=Esporta-Wave +Name[ja]=Wave エクスポート +Name[kk]=Wave-экспорттау +Name[km]=នាំចេញ-Wave +Name[ko]=Wave 추출 +Name[lt]=Wave eksportas +Name[mk]=Wave-изнесување +Name[nb]=Wave-eksport +Name[ne]=तरङ-निर्यात +Name[nl]=Wave-export +Name[nn]=Wave-eksport +Name[pl]=Eksport wave +Name[pt]=Exportação de Wave +Name[pt_BR]=Exportar-Onda +Name[ro]=Exportare WAV +Name[ru]=Экспорт в wav +Name[sk]=Export do Wave +Name[sl]=Izvoz v WAV +Name[sr]=Извоз у Wave +Name[sr@Latn]=Izvoz u Wave +Name[sv]=Wave-export +Name[ta]=அலை-ஏற்றுமதி +Name[tg]=Содироти Мавҷ +Name[th]=ส่งออกแฟ้ม Wave +Name[tr]=Wave Aktarma +Name[uk]=Експорт Wave +Name[uz]=Wave eksport +Name[uz@cyrillic]=Wave экспорт +Name[zh_CN]=声波-导出 +Name[zh_HK]=Wave-匯出 +Name[zh_TW]=Wave 匯出 +X-KDE-Library=libkrecexport_wave +ServiceTypes=KRec/exportplugin +X-KDE-ExportSuffix=wav,WAV diff --git a/krec/krecconfig_files.cpp b/krec/krecconfig_files.cpp new file mode 100644 index 00000000..a741c8e9 --- /dev/null +++ b/krec/krecconfig_files.cpp @@ -0,0 +1,85 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecconfig_files.h" +#include "krecconfig_files.moc" + +#include "krecconfig_fileswidget.h" + +#include <kgenericfactory.h> +#include <kdebug.h> +#include <qlayout.h> +#include <qbuttongroup.h> +#include <qradiobutton.h> +#include <qlineedit.h> +#include <qhbox.h> +#include <qlabel.h> +#include <kapplication.h> +#include <kconfig.h> +#include <klocale.h> + +typedef KGenericFactory<KRecConfigFiles, QWidget> KRecConfigFilesFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_krec_files, KRecConfigFilesFactory( "krec" ) ) + +KRecConfigFiles::KRecConfigFiles( QWidget* p, const char*, const QStringList& s ) + : KCModule( KRecConfigFilesFactory::instance(), p, s ) + , _layout( 0 ) + , _filewidget( 0 ) +{ + _layout = new QBoxLayout( this, QBoxLayout::TopToBottom ); + + _layout->addSpacing( 10 ); + + _filewidget = new KRecConfigFilesWidget( this ); + connect( _filewidget, SIGNAL( sRateChanged( int ) ), this, SLOT( ratechanged( int ) ) ); + connect( _filewidget, SIGNAL( sChannelsChanged( int ) ), this, SLOT( channelschanged( int ) ) ); + connect( _filewidget, SIGNAL( sBitsChanged( int ) ), this, SLOT( bitschanged( int ) ) ); + connect( _filewidget, SIGNAL( sUseDefaultsChanged( bool ) ), this, SLOT( usedefaultschanged( bool ) ) ); + _layout->addWidget( _filewidget ); + + _layout->addStretch( 100 ); + + load(); +} + +KRecConfigFiles::~KRecConfigFiles() { +} + +void KRecConfigFiles::load() { +kdDebug( 60005 ) << k_funcinfo << endl; + defaults(); + _filewidget->load(); +} + +void KRecConfigFiles::save() { + _filewidget->save(); + emit changed( false ); +} + +void KRecConfigFiles::defaults() { + _filewidget->defaults(); +} + +void KRecConfigFiles::ratechanged( int ) { + emit changed( true ); +} +void KRecConfigFiles::channelschanged( int ) { + emit changed( true ); +} +void KRecConfigFiles::bitschanged( int ) { + emit changed( true ); +} +void KRecConfigFiles::usedefaultschanged( bool ) { + emit changed( true ); +} + diff --git a/krec/krecconfig_files.h b/krec/krecconfig_files.h new file mode 100644 index 00000000..0ef74b49 --- /dev/null +++ b/krec/krecconfig_files.h @@ -0,0 +1,52 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KREC_CONFIGURE_FILES_H +#define KREC_CONFIGURE_FILES_H + +#include <kcmodule.h> +#include <qstringlist.h> +#include <qstring.h> + +class QBoxLayout; +class QRadioButton; +class QButtonGroup; +class QLineEdit; +class QHBox; +class QLabel; + +class KRecConfigFilesWidget; + +class KRecConfigFiles : public KCModule { + Q_OBJECT +public: + KRecConfigFiles( QWidget*, const char* =0, const QStringList& = QStringList() ); + ~KRecConfigFiles(); + + void load(); + void save(); + void defaults(); +private slots: + void ratechanged( int ); + void channelschanged( int ); + void bitschanged( int ); + void usedefaultschanged( bool ); + +private: + QBoxLayout *_layout; + KRecConfigFilesWidget *_filewidget; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecconfig_fileswidget.cpp b/krec/krecconfig_fileswidget.cpp new file mode 100644 index 00000000..5df6693d --- /dev/null +++ b/krec/krecconfig_fileswidget.cpp @@ -0,0 +1,147 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecconfig_fileswidget.h" +#include "krecconfig_fileswidget.moc" + +#include "krecglobal.h" + +#include <kdebug.h> +#include <qbuttongroup.h> +#include <qradiobutton.h> +#include <qcheckbox.h> +#include <qlineedit.h> +#include <kapplication.h> +#include <kconfig.h> +#include <klocale.h> +#include <qlabel.h> + +KRecConfigFilesWidget::KRecConfigFilesWidget( QWidget* p, const char* n ) + : QVBox( p,n ) + , _hbox( new QHBox( this ) ) + , _ratebox( 0 ), _channelsbox( 0 ), _bitsbox( 0 ) + , _rate48( 0 ), _rate44( 0 ), _rate22( 0 ), _rate11( 0 ), _rateother( 0 ) + , _rateotherbox( 0 ), _rateotherlabel( 0 ), _rateotherline( 0 ) + , _channels2( 0 ), _channels1( 0 ) + , _bits16( 0 ), _bits8( 0 ) + , _samplingRate( 44100 ), _channels( 2 ), _bits( 16 ) +{ + _ratebox = new QButtonGroup( 1, Qt::Horizontal, i18n( "Sampling Rate" ), _hbox ); + connect( _ratebox, SIGNAL( clicked( int ) ), this, SLOT( ratechanged( int ) ) ); + _rate48 = new QRadioButton( i18n( "48000 Hz" ), _ratebox ); + _rate44 = new QRadioButton( i18n( "44100 Hz" ), _ratebox ); + _rate22 = new QRadioButton( i18n( "22050 Hz" ), _ratebox ); + _rate11 = new QRadioButton( i18n( "11025 Hz" ), _ratebox ); + _rateother = new QRadioButton( i18n( "Other" ), _ratebox ); + _rateotherbox = new QHBox( _ratebox ); + _rateotherbox->setSpacing( 2 ); + _rateotherlabel = new QLabel( i18n( "Other:" ), _rateotherbox ); + _rateotherline = new QLineEdit( _rateotherbox ); + _rateotherline->setMaxLength( 10 ); + _rateotherline->setFrame( true ); + _rateotherbox->setEnabled( false ); + connect( _rateotherline, SIGNAL( textChanged( const QString& ) ), this, SLOT( rateotherchanged( const QString& ) ) ); + _channelsbox = new QButtonGroup( 1, Qt::Horizontal, i18n( "Channels" ), _hbox ); + connect( _channelsbox, SIGNAL( clicked( int ) ), this, SLOT( channelschanged( int ) ) ); + _channels2 = new QRadioButton( i18n( "Stereo (2 channels)" ), _channelsbox ); + _channels1 = new QRadioButton( i18n( "Mono (1 channel)" ), _channelsbox ); + _bitsbox = new QButtonGroup( 1, Qt::Horizontal, i18n( "Bits" ), _hbox ); + connect( _bitsbox, SIGNAL( clicked( int ) ), this, SLOT( bitschanged( int ) ) ); + _bits16 = new QRadioButton( i18n( "16 bit" ), _bitsbox ); + _bits8 = new QRadioButton( i18n( "8 bit" ), _bitsbox ); + + _usedefaults = new QCheckBox( i18n( "Use defaults for creating new files" ), this ); + connect( _usedefaults, SIGNAL( toggled( bool ) ), this, SLOT( usedefaultschanged( bool ) ) ); + + setSpacing( 5 ); + + load(); +} + +KRecConfigFilesWidget::~KRecConfigFilesWidget() { +} + +void KRecConfigFilesWidget::load() { +kdDebug( 60005 ) << k_funcinfo << endl; + defaults(); + kapp->config()->setGroup( "FileDefaults" ); + _samplingRate = kapp->config()->readNumEntry( "SamplingRate", 44100 ); + switch ( _samplingRate ) { + case 48000: _rate48->setChecked( true ); break; + case 44100: _rate44->setChecked( true ); break; + case 22050: _rate22->setChecked( true ); break; + case 11025: _rate11->setChecked( true ); break; + default: + _rateother->setChecked( true ); + _rateotherbox->setEnabled( true ); + _rateotherline->setText( QString::number( _samplingRate ) ); + break; + }; + _channels = kapp->config()->readNumEntry( "Channels", 2 ); + switch ( _channels ) { + default: + case 2: _channels2->setChecked( true ); break; + case 1: _channels1->setChecked( true ); break; + }; + _bits = kapp->config()->readNumEntry( "Bits", 16 ); + switch ( _bits ) { + default: + case 16: _bits16->setChecked( true ); break; + case 8: _bits8->setChecked( true ); break; + }; + _usedefaults->setChecked( kapp->config()->readBoolEntry( "UseDefaults", false ) ); +} + +void KRecConfigFilesWidget::save() { + kapp->config()->setGroup( "FileDefaults" ); + kapp->config()->writeEntry( "SamplingRate", _samplingRate ); + kapp->config()->writeEntry( "Channels", _channels ); + kapp->config()->writeEntry( "Bits", _bits ); + kapp->config()->writeEntry( "UseDefaults", _usedefaults->isOn() ); + + kapp->config()->sync(); +} + +void KRecConfigFilesWidget::defaults() { + _rate44->setChecked( true ); + _channels2->setChecked( true ); + _bits16->setChecked( true ); +} + +void KRecConfigFilesWidget::ratechanged( int index ) { + if ( _ratebox->find( index ) == _rateother ) _rateotherbox->setEnabled( true ); + else _rateotherbox->setEnabled( false ); + if ( _ratebox->find( index ) == _rate48 ) _samplingRate = 48000; + if ( _ratebox->find( index ) == _rate44 ) _samplingRate = 44100; + if ( _ratebox->find( index ) == _rate22 ) _samplingRate = 22050; + if ( _ratebox->find( index ) == _rate11 ) _samplingRate = 11025; + emit sRateChanged( _samplingRate ); +} +void KRecConfigFilesWidget::rateotherchanged( const QString& text ) { + _samplingRate = text.toInt(); + emit sRateChanged( _samplingRate ); +} +void KRecConfigFilesWidget::channelschanged( int index ) { + if ( _channelsbox->find( index ) == _channels2 ) _channels = 2; + if ( _channelsbox->find( index ) == _channels1 ) _channels = 1; + emit sChannelsChanged( _channels ); +} +void KRecConfigFilesWidget::bitschanged( int index ) { + if ( _bitsbox->find( index ) == _bits16 ) _bits = 16; + if ( _bitsbox->find( index ) == _bits8 ) _bits = 8; + emit sBitsChanged( _bits ); +} + +void KRecConfigFilesWidget::usedefaultschanged( bool n ) { + emit sUseDefaultsChanged( n ); +} diff --git a/krec/krecconfig_fileswidget.h b/krec/krecconfig_fileswidget.h new file mode 100644 index 00000000..2095ce33 --- /dev/null +++ b/krec/krecconfig_fileswidget.h @@ -0,0 +1,68 @@ +/*************************************************************************** + krecconfig_fileswidget.h - description + ------------------- + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KREC_CONFIGURE_FILESWIDGET_H +#define KREC_CONFIGURE_FILESWIDGET_H + +#include <qhbox.h> +#include <qvbox.h> +#include <qstringlist.h> +#include <qstring.h> + +class QRadioButton; +class QCheckBox; +class QButtonGroup; +class QLineEdit; +class QLabel; + +class KRecConfigFilesWidget : public QVBox { + Q_OBJECT +public: + KRecConfigFilesWidget( QWidget*, const char* =0 ); + ~KRecConfigFilesWidget(); + + void load(); + void save(); + void defaults(); +signals: + void sRateChanged( int ); + void sChannelsChanged( int ); + void sBitsChanged( int ); + void sUseDefaultsChanged( bool ); +private slots: + void ratechanged( int ); + void rateotherchanged( const QString& ); + void channelschanged( int ); + void bitschanged( int ); + void usedefaultschanged( bool ); + +private: + QHBox *_hbox; + QButtonGroup *_ratebox, *_channelsbox, *_bitsbox; + QRadioButton *_rate48, *_rate44, *_rate22, *_rate11, *_rateother; + QHBox *_rateotherbox; + QLabel *_rateotherlabel; + QLineEdit *_rateotherline; + QRadioButton *_channels2, *_channels1; + QRadioButton *_bits16, *_bits8; + + QCheckBox *_usedefaults; + + int _samplingRate, _channels, _bits; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecconfigure.cpp b/krec/krecconfigure.cpp new file mode 100644 index 00000000..76d949f4 --- /dev/null +++ b/krec/krecconfigure.cpp @@ -0,0 +1,192 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecconfigure.h" +#include "krecconfigure.moc" + +#include "krecglobal.h" + +#include <kgenericfactory.h> +#include <kdebug.h> +#include <qlayout.h> +#include <qbuttongroup.h> +#include <qradiobutton.h> +#include <qcheckbox.h> +#include <qlineedit.h> +#include <qhbox.h> +#include <qlabel.h> +#include <kapplication.h> +#include <kconfig.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kpushbutton.h> + +typedef KGenericFactory<KRecConfigGeneral, QWidget> KRecConfigGeneralFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_krec, KRecConfigGeneralFactory( "krec" ) ) + +KRecConfigGeneral::KRecConfigGeneral( QWidget* p, const char*, const QStringList& s ) + : KCModule( KRecConfigGeneralFactory::instance(), p, s ) + , _layout( 0 ), _layout_display( 0 ) + , _display_title( 0 ) + , _displaybox( 0 ), _framebasebox( 0 ) + , _display0( 0 ), _display1( 0 ), _display2( 0 ), _display3( 0 ) + , _framebase30( 0 ), _framebase25( 0 ), _framebase75( 0 ), _framebaseother( 0 ) + , _framebaseotherbox( 0 ), _framebaseotherlabel( 0 ), _framebaseotherline( 0 ) + , _displaymode( 0 ), _framebase( 25 ) +{ + _layout = new QBoxLayout( this, QBoxLayout::TopToBottom ); + + _layout->addSpacing( 10 ); + _display_title = new QLabel( i18n( "<qt><b>Timedisplay Related Settings</b></qt>" ), this ); + _layout->addWidget( _display_title, -100 ); + + _layout_display = new QBoxLayout( _layout, QBoxLayout::LeftToRight ); + _layout->setStretchFactor( _layout_display, -100 ); + + _displaybox = new QButtonGroup( 1, Qt::Horizontal, i18n( "Timedisplay Style" ), this ); + _layout_display->addWidget( _displaybox, 100 ); + connect( _displaybox, SIGNAL( clicked( int ) ), this, SLOT( displaychanged( int ) ) ); + _display0 = new QRadioButton( i18n( "Plain samples" ), _displaybox ); + _display1 = new QRadioButton( i18n( "[hours:]mins:secs:samples" ), _displaybox ); + _display2 = new QRadioButton( i18n( "[hours:]mins:secs:frames" ), _displaybox ); + _display3 = new QRadioButton( i18n( "MByte.KByte" ), _displaybox ); + _framebasebox = new QButtonGroup( 1, Qt::Horizontal, i18n( "Framebase" ), this ); + _layout_display->addWidget( _framebasebox, 100 ); + connect( _framebasebox, SIGNAL( clicked( int ) ), this, SLOT( framebasechanged( int ) ) ); + _framebase30 = new QRadioButton( i18n( "30 frames per second (American TV)" ), _framebasebox ); + _framebase25 = new QRadioButton( i18n( "25 frames per second (European TV)" ), _framebasebox ); + _framebase75 = new QRadioButton( i18n( "75 frames per second (CD)" ), _framebasebox ); + _framebaseother = new QRadioButton( i18n( "Other" ), _framebasebox ); + _framebaseotherbox = new QHBox( _framebasebox ); + _framebaseotherbox->setSpacing( 2 ); + _framebaseotherlabel = new QLabel( i18n( "Other" ), _framebaseotherbox ); + _framebaseotherline = new QLineEdit( _framebaseotherbox ); + _framebaseotherline->setMaxLength( 10 ); + _framebaseotherbox->setEnabled( false ); + connect( _framebaseotherline, SIGNAL( textChanged( const QString& ) ), this, SLOT( framebaseotherchanged( const QString& ) ) ); + + _layout->addSpacing( 5 ); + _verboseDisplayMode = new QCheckBox( i18n( "Show verbose times ( XXmins:XXsecs:XXframes instead of XX:XX::XX )" ), this ); + connect( _verboseDisplayMode, SIGNAL( toggled( bool ) ), this, SLOT( verboseDisplayChanged( bool ) ) ); + _layout->addWidget( _verboseDisplayMode ); + + _layout->addSpacing( 10 ); + _other_title = new QLabel( i18n( "<qt><b>Miscellaneous Settings</b></qt>" ), this ); + _layout->addWidget( _other_title ); + + _tipofday = new QCheckBox( i18n( "Show tip of the day at startup" ), this ); + connect( _tipofday, SIGNAL( toggled( bool ) ), this, SLOT( tipofdaychanged( bool ) ) ); + _layout->addWidget( _tipofday ); + QBoxLayout* _tmplayout = new QBoxLayout( this, QBoxLayout::LeftToRight ); + _enableAllMessages = new KPushButton( i18n( "Enable All Hidden Messages" ), this ); + connect( _enableAllMessages, SIGNAL( clicked() ), this, SLOT( enableallmessagesclicked() ) ); + _tmplayout->addWidget( _enableAllMessages ); + QLabel* _tmplbl = new QLabel( i18n( "<qt><i>All messages with the \"Don't show this message again\" option are shown again after selecting this button.</i></qt>" ), this ); + _tmplayout->addWidget( _tmplbl ); + _layout->addLayout( _tmplayout ); + + _layout->addStretch( 100 ); + + load(); +} + +KRecConfigGeneral::~KRecConfigGeneral() { +} + +void KRecConfigGeneral::load() { +kdDebug( 60005 ) << k_funcinfo << endl; + defaults(); + _displaymode = KRecGlobal::the()->timeFormatMode(); + switch ( _displaymode % 100 ) { + default: + case 0: _display0->setChecked( true ); break; + case 1: _display1->setChecked( true ); break; + case 2: _display2->setChecked( true ); break; + case 3: _display3->setChecked( true ); break; + }; + _verboseDisplayMode->setChecked( ( _displaymode / 100 == 1 ) ); + + _framebase = KRecGlobal::the()->frameBase(); + switch ( _framebase ) { + case 30: _framebase30->setChecked( true ); break; + case 25: _framebase25->setChecked( true ); break; + case 75: _framebase75->setChecked( true ); break; + default: + _framebaseother->setChecked( true ); + _framebaseotherbox->setEnabled( true ); + _framebaseotherline->setText( QString::number( _framebase ) ); + break; + }; + kapp->config()->setGroup( "TipOfDay" ); + _tip = kapp->config()->readBoolEntry( "RunOnStart", true ); + _tipofday->setChecked( _tip ); +} + +void KRecConfigGeneral::save() { + KRecGlobal::the()->setTimeFormatMode( _displaymode ); + KRecGlobal::the()->setFrameBase( _framebase ); +kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl; + + kapp->config()->setGroup( "TipOfDay" ); + kapp->config()->writeEntry( "RunOnStart", _tip ); + + kapp->config()->sync(); + emit changed( false ); +} + +void KRecConfigGeneral::defaults() { + _display0->setChecked( true ); + _framebase25->setChecked( true ); +} + +void KRecConfigGeneral::displaychanged( int index ) { + int verbose = _displaymode / 100; + if ( _displaybox->find( index ) == _display0 ) _displaymode = 0 + verbose * 100; + if ( _displaybox->find( index ) == _display1 ) _displaymode = 1 + verbose * 100; + if ( _displaybox->find( index ) == _display2 ) _displaymode = 2 + verbose * 100; + if ( _displaybox->find( index ) == _display3 ) _displaymode = 3 + verbose * 100; + emit changed( true ); +} +void KRecConfigGeneral::framebasechanged( int index ) { + if ( _framebasebox->find( index ) == _framebase30 ) _framebase = 30; + if ( _framebasebox->find( index ) == _framebase25 ) _framebase = 25; + if ( _framebasebox->find( index ) == _framebase75 ) _framebase = 75; + if ( _framebasebox->find( index ) == _framebaseother ) { + _framebaseotherbox->setEnabled( true ); + _framebase = _framebaseotherline->text().toInt(); +kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl; + } else + _framebaseotherbox->setEnabled( false ); + emit changed( true ); +} +void KRecConfigGeneral::framebaseotherchanged( const QString& text ) { + _framebase = text.toInt(); +kdDebug(60005) << k_funcinfo << "Framebase=" << _framebase << endl; + emit changed( true ); +} +void KRecConfigGeneral::verboseDisplayChanged( bool n ) { + if ( n && _displaymode < 100 ) _displaymode += 100; + if ( !n && _displaymode >= 100 ) _displaymode -= 100; + emit changed( true ); +} + +void KRecConfigGeneral::tipofdaychanged( bool n ) { + _tip = n; + emit changed( true ); +} + +void KRecConfigGeneral::enableallmessagesclicked() { +kdDebug(60005) << k_funcinfo << endl; + KMessageBox::enableAllMessages(); +} + diff --git a/krec/krecconfigure.h b/krec/krecconfigure.h new file mode 100644 index 00000000..13416c44 --- /dev/null +++ b/krec/krecconfigure.h @@ -0,0 +1,67 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KREC_CONFIGURE_H +#define KREC_CONFIGURE_H + +#include <kcmodule.h> +#include <qstringlist.h> +#include <qstring.h> + +class QBoxLayout; +class QRadioButton; +class QButtonGroup; +class QLineEdit; +class QHBox; +class QLabel; +class QCheckBox; +class KPushButton; + +class KRecConfigGeneral : public KCModule { + Q_OBJECT +public: + KRecConfigGeneral( QWidget*, const char* =0, const QStringList& = QStringList() ); + ~KRecConfigGeneral(); + + void load(); + void save(); + void defaults(); +private slots: + + void displaychanged( int ); + void framebasechanged( int ); + void framebaseotherchanged( const QString& ); + void verboseDisplayChanged( bool ); + + void tipofdaychanged( bool ); + void enableallmessagesclicked(); +private: + QBoxLayout *_layout, *_layout_display; + QLabel *_display_title, *_other_title; + QButtonGroup *_displaybox, *_framebasebox; + QRadioButton *_display0, *_display1, *_display2, *_display3; + QRadioButton *_framebase30, *_framebase25, *_framebase75, *_framebaseother; + QHBox *_framebaseotherbox; + QLabel *_framebaseotherlabel; + QLineEdit *_framebaseotherline; + + QCheckBox *_tipofday, *_verboseDisplayMode; + KPushButton *_enableAllMessages; + + int _displaymode, _framebase; + bool _tip; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecexport_template.cpp b/krec/krecexport_template.cpp new file mode 100644 index 00000000..43fa023c --- /dev/null +++ b/krec/krecexport_template.cpp @@ -0,0 +1,89 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecexport_template.h" +#include "krecexport_template.moc" + +#include "krecglobal.h" + +#include <qtimer.h> +#include <kdebug.h> + +KRecExportItem::KRecExportItem( QObject* p, const char* n, const QStringList& ) : QObject( p,n ), _running( false ) { + //kdDebug( 60005 ) << k_funcinfo << endl; +} +KRecExportItem::~KRecExportItem() { + //kdDebug( 60005 ) << k_funcinfo << endl; +} +int KRecExportItem::samplingRate() const { + //kdDebug( 60005 ) << k_funcinfo << _samplingRate << endl; + return _samplingRate; +} +int KRecExportItem::bits() const { + //kdDebug( 60005 ) << k_funcinfo << _bits << endl; + return _bits; +} +int KRecExportItem::channels() const { + //kdDebug( 60005 ) << k_funcinfo << _channels << endl; + return _channels; +} + +void KRecExportItem::registerAtGlobal( KRecExportItem* item ) { + //kdDebug( 60005 ) << k_funcinfo << endl; + bool registered = false; + if ( !registered ) registered = KRecGlobal::the()->registerExport( item ); + //if ( registered ) kdDebug( 60005 ) << "Register successful!" << endl; + // else kdDebug( 60005 ) << "Register NOT successful!" << endl; +} + +void KRecExportItem::initialize( int samplingRate, int bits, int channels ) { +kdDebug( 60005 ) << k_funcinfo << "samplingRate:" << samplingRate << " bits:" << bits << " channels:" << channels << endl; + _samplingRate = samplingRate; + _bits = bits; + _channels = channels; +} +bool KRecExportItem::start() { +kdDebug( 60005 ) << k_funcinfo << endl; + if ( !running() ) { + if ( process() ) { + _running = true; + QTimer::singleShot( 0, this, SLOT( process() ) ); + emit running( running() ); + } + return true; + } else return false; +} + +void KRecExportItem::stop() { +kdDebug( 60005 ) << k_funcinfo << endl; + _running = false; + emit running( running() ); +} + +Q_INT16 KRecExportItem::read16( char* array, int index ) { + Q_INT16 tmp; + tmp = array[ index ] + ( array[ index + 1 ] << 8 ) & 0xff; + return tmp; +} +/// Helper: writes an integer into an char* formated for wave-files +void KRecExportItem::write16( char* array, Q_INT16 value, int index ) { + array[ index ] = ( value >> 0 ) & 0xff; + array[ index + 1 ] = ( value >> 8 ) & 0xff; +} +void KRecExportItem::write32( char* array, Q_INT32 value, int index ) { + write16( array, value, index ); + array[ index + 2 ] = ( value >> 16 ) & 0xff; + array[ index + 3 ] = ( value >> 24 ) & 0xff; +} + +// vim:sw=4:ts=4 diff --git a/krec/krecexport_template.h b/krec/krecexport_template.h new file mode 100644 index 00000000..8a1c4a03 --- /dev/null +++ b/krec/krecexport_template.h @@ -0,0 +1,99 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KREC_EXPORT_TEMPLATE_H +#define KREC_EXPORT_TEMPLATE_H + +#include <qobject.h> + +#include <qstring.h> +#include <qstringlist.h> +#include <qcstring.h> +#include <arts/common.h> + +/** + * This class is the template for all exportitems in KRec. + * + * To register your ExportItem you have to do @code registerAtGlobal( this ); @code + * at the end of your constructor. + * + * @author Arnold Krille <arnold@arnoldarts.de> +*/ +class KRecExportItem : public QObject { + Q_OBJECT +private: + /// Controls wether an export is running, or not... + bool _running; + int _samplingRate, _bits, _channels; +protected: + KRecExportItem( QObject*, const char* =0, const QStringList& =0 ); + + /** + * This registers this class at the KRecGlobal. + */ + static void registerAtGlobal( KRecExportItem* ); + + int samplingRate() const; + int bits() const; + int channels() const; + + /// Helpers for reading and writing to an char-array + Q_INT16 read16( char* array, int index ); + void write16( char* array, Q_INT16 value, int index ); + void write32( char* array, Q_INT32 value, int index ); +public: + ~KRecExportItem(); + + /** + * Returns a new Item for your export. + */ + virtual KRecExportItem* newItem()=0; + + /// Returns a list with the extensions. + virtual QStringList extensions()=0; + /// Returns the export format. + virtual QString exportFormat()=0; + + bool running() const { return _running; } +public slots: + /** + * Initializes the sound-settings. + * Has to be called before the initialize( const QString & ) function. + */ + void initialize( int samplingRate, int bits, int channels ); + /// Initializes the export. + virtual bool initialize( const QString &filename )=0; + /** + * Start the real export (including the emission of @see getData() while running=true). + * Best way to do this is to use @see QTimer::singleShot() since then the events are + * put at the end of the EventLoop not blocking the gui and everything else. + */ + bool start(); + virtual bool process() =0; + + /// Stops the export by setting running=false. + void stop(); + /// Finish the export. + virtual bool finalize()=0; + //virtual void data( QByteArray& ); +signals: + /// Is emitted when this Item wants data to export. + void getData( QByteArray& ); + + void running( bool ); +}; + + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecexport_wave.cpp b/krec/krecexport_wave.cpp new file mode 100644 index 00000000..80ea63d7 --- /dev/null +++ b/krec/krecexport_wave.cpp @@ -0,0 +1,135 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecexport_wave.h" +#include "krecexport_wave.moc" + +#include "krecglobal.h" + +#include <kdebug.h> +#include <ktempfile.h> +#include <qfile.h> +#include <qtimer.h> +#include <kgenericfactory.h> + +K_EXPORT_COMPONENT_FACTORY( libkrecexport_wave, KGenericFactory<KRecExport_Wave> ) + +KRecExport_Wave krecExportWave( 0 ); + +KRecExport_Wave::KRecExport_Wave( QObject* p, const char* n, const QStringList& ) + : KRecExportItem( p,n ) + , _file( 0 ) +{ +kdDebug( 60005 ) << k_funcinfo << endl; + registerAtGlobal( this ); +kdDebug( 60005 ) << "Registered Exports: " << KRecGlobal::the()->exportFormats() << endl; +} +KRecExport_Wave::~KRecExport_Wave() { +kdDebug( 60005 ) << k_funcinfo << endl; +} + +KRecExport_Wave* KRecExport_Wave::newItem() { +kdDebug( 60005 ) << k_funcinfo << endl; + return new KRecExport_Wave( 0 ); +} + +QStringList KRecExport_Wave::extensions() { + //kdDebug( 60005 ) << k_funcinfo << endl; + QStringList tmp; + tmp << "*.wav" << "*.WAV"; + return tmp; +} + +bool KRecExport_Wave::initialize( const QString &filename ) { +kdDebug( 60005 ) << k_funcinfo << endl; + if ( !_file ) { + _file = new QFile( filename ); + if ( _file->open( IO_Raw|IO_WriteOnly ) ) { + /// Write an empty Wave-header... + for ( int i=0; i<44; i++ ) + _file->putch( 0 ); + } else return false; + return true; + } else return false; +} +bool KRecExport_Wave::process() { + //kdDebug( 60005 ) << k_funcinfo << running << endl; + if ( _file ) { + if ( running() ) { + QByteArray bytearray( 4096 ); + emit getData( bytearray ); + _file->writeBlock( bytearray ); + QTimer::singleShot( 10, this, SLOT( process() ) ); + } + return true; + } else return false; +} +bool KRecExport_Wave::finalize() { +kdDebug( 60005 ) << k_funcinfo << endl; + if ( _file ) { + // PCM-Compatible WAVE Header + // bytes variable description + // 0 - 3 'RIFF' + // 4 - 7 wRiffLength length of file minus the 8 byte riff header + // 8 - 11 'WAVE' + // 12 - 15 'fmt ' + // 16 - 19 wFmtSize length of format chunk minus 8 byte header + // 20 - 21 wFormatTag identifies PCM, ULAW etc + // 22 - 23 wChannels number of channels + // 24 - 27 dwSamplesPerSecond samples per second per channel + // 28 - 31 dwAvgBytesPerSec non-trivial for compressed formats + // 32 - 33 wBlockAlign basic block size + // 34 - 35 wBitsPerSample non-trivial for compressed formats + // 36 - 39 'data' + // 40 - 43 dwDataLength length of data chunk minus 8 byte header + // 44 - (dwDataLength + 43) the data + + // Basic 16b,2c,44kHz Wave-Header + char riffHeader[] = + { + 0x52, 0x49, 0x46, 0x46, // 0 "AIFF" + 0x00, 0x00, 0x00, 0x00, // 4 wavSize + 0x57, 0x41, 0x56, 0x45, // 8 "WAVE" + 0x66, 0x6d, 0x74, 0x20, // 12 "fmt " + 0x10, 0x00, 0x00, 0x00, // 16 + 0x01, 0x00, 0x02, 0x00, // 20 + 0x44, 0xac, 0x00, 0x00, // 24 + 0x10, 0xb1, 0x02, 0x00, // 28 + 0x04, 0x00, 0x10, 0x00, // 32 + 0x64, 0x61, 0x74, 0x61, // 36 "data" + 0x00, 0x00, 0x00, 0x00 // 40 byteCount + }; + + long wavSize = _file->size() - 8; + write32( riffHeader, wavSize, 4 ); + + write16( riffHeader, channels(), 22 ); + write32( riffHeader, samplingRate(), 24 ); + write16( riffHeader, bits(), 34 ); + + long byteCount = wavSize - 44; + write32( riffHeader, byteCount, 40 ); + + _file->at( 0 ); + _file->writeBlock( riffHeader, 44 ); + _file->at( _file->size() ); + + _file->close(); + delete _file; + _file = 0; + + return true; + } else return false; +} + +// vim:sw=4:ts=4 diff --git a/krec/krecexport_wave.h b/krec/krecexport_wave.h new file mode 100644 index 00000000..f1336970 --- /dev/null +++ b/krec/krecexport_wave.h @@ -0,0 +1,43 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KREC_EXPORT_WAVE_H +#define KREC_EXPORT_WAVE_H + +#include "krecexport_template.h" + +class KTempFile; +class QFile; + +class KRecExport_Wave : public KRecExportItem { + Q_OBJECT +public: + KRecExport_Wave( QObject*, const char* =0, const QStringList& =0 ); + ~KRecExport_Wave(); + + KRecExport_Wave* newItem(); + + QStringList extensions(); + QString exportFormat() { return QString( "Wave" ); } +public slots: + bool initialize( const QString & ); + bool process(); + bool finalize(); + +private: + QFile* _file; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecfile.cpp b/krec/krecfile.cpp new file mode 100644 index 00000000..6e4b2b8f --- /dev/null +++ b/krec/krecfile.cpp @@ -0,0 +1,457 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecfile.h" +#include "krecfile.moc" + +#include "krecglobal.h" + +#include "krecnewproperties.h" + +#include <kdebug.h> +#include <kapplication.h> +#include <ktempdir.h> +#include <ktempfile.h> +#include <ktar.h> +#include <kio/job.h> +#include <klocale.h> +#include <ksimpleconfig.h> +#include <qdir.h> +#include <qfileinfo.h> +#include <kmessagebox.h> +#include <qtimer.h> + +#include <qdatastream.h> +#include <math.h> + +void KRecFile::init() { + _pos = 0; + _size = 0; + _filename = QString::null; + _currentBuffer = 0; + _dir = new KTempDir(); + _config = new KSimpleConfig( _dir->name()+"project.rc", false ); +} + +KRecFile::KRecFile( QObject* p, const char* n ) + : QObject( p,n ) + , _saved( false ) +{ + init(); + kdDebug( 60005 ) << k_funcinfo << "_dir->name(): " << _dir->name() << endl; + _dir->setAutoDelete( true ); + KRecNewProperties* dialog = new KRecNewProperties( KRecGlobal::the()->mainWidget() ); + + if ( dialog->usedefaults() ) + KRecGlobal::the()->message( i18n( "Using default properties for the new file" ) ); + else + dialog->exec(); + + _samplerate = dialog->samplerate(); + _channels = dialog->channels(); + _bits = dialog->bits(); + + saveProps(); + + delete dialog; +} +KRecFile::KRecFile( const QString &filename, QObject* p, const char* n ) + : QObject( p,n ) + , _saved( true ) +{ + init(); + _filename = filename; + kdDebug( 60005 ) << k_funcinfo << "_dir->name(): " << _dir->name() << endl; + _dir->setAutoDelete( true ); + + KTar *tar = new KTar( _filename, "application/x-gzip" ); + tar->open( IO_ReadOnly ); + int i=0; while ( _filename.find( '/', i ) != -1 ) i++; // Find last '/' + QString basename = _filename.right( _filename.length()-i ); + basename = basename.left( basename.length()-5 ); + + const KArchiveDirectory *dir = dynamic_cast<const KArchiveDirectory*>( tar->directory()->entry( basename ) ); + + dir->copyTo( _dir->name() ); + + delete _config; + _config = new KSimpleConfig( _dir->name()+"project.rc", false ); + loadProps(); + int c = _config->readNumEntry( "Files" ); + //kdDebug( 60005 ) << c << " Files to load" << endl; + for ( int i=0; i<c; i++ ) { + //kdDebug( 60005 ) << "Loading file " << i << endl; + _config->setGroup( "File-" + QString::number( i ) ); + newBuffer( KRecBuffer::fromConfig( _config, _dir->qDir(), this ) ); + } + KRecGlobal::the()->message( i18n( "\'%1\' loaded." ).arg( filename ) ); + + delete tar; + + _saved = true; + //kdDebug( 60005 ) << "Buffers opened: " << _buffers.count() << endl; +} +KRecFile::~KRecFile() { + kdDebug( 60005 ) << k_funcinfo << endl; + QValueList<KRecBuffer*>::iterator it; + for ( it = _buffers.begin(); it != _buffers.end(); ++it ) + delete ( *it ); + _buffers.clear(); + delete _dir; + delete _config; + //kdDebug( 60005 ) << k_funcinfo << "done." << endl; +} + +QString KRecFile::filename() { return _filename; } +void KRecFile::filename( const QString &n ) { + if ( _filename!=n ) { + _filename = n; + emit filenameChanged( _filename ); + } +} + +void KRecFile::writeData( Arts::mcopbyte* /*data*/, uint /*length*/ ) { + kdDebug( 60005 ) << k_funcinfo << endl; +} +void KRecFile::writeData( QByteArray* data ) { + kdDebug( 60005 ) << k_funcinfo << endl; + if ( _currentBuffer!=-1 ) _buffers[ _currentBuffer ]->writeData( data ); + _saved = false; +} +void KRecFile::writeData( QByteArray& data ) { + if ( _currentBuffer!=-1 ) _buffers[ _currentBuffer ]->writeData( data ); + _saved = false; +} + +void KRecFile::save( const QString &fname ) { + QString filetosave = fname; + + //kdDebug( 60005 ) << k_funcinfo << filename << endl; + if ( saved() ) { + KRecGlobal::the()->message( i18n( "No need to save." ) ); + return; + } + + KRecGlobal::the()->message( i18n( "Saving in progress..." ) ); + filename( fname ); + QString tmpname; + { + KTempFile *tmp = new KTempFile(); + tmp->setAutoDelete( true ); + tmpname = tmp->name(); + delete tmp; + } + saveProps(); + + KTar *tar = new KTar( tmpname, "application/x-gzip" ); + tar->open( IO_WriteOnly ); + int i=0; while ( fname.find( '/', i ) != -1 ) i++; // Find last '/' + QString basename = fname.right( fname.length()-i ); + if ( basename.endsWith( ".krec" ) ) + basename = basename.left( basename.length()-5 ); + else { + filetosave = fname + ".krec"; + filename( filetosave ); + } + tar->addLocalDirectory( _dir->name(), basename ); + + delete tar; + KIO::file_move( tmpname, filetosave, -1, true, false, true ); + + KRecGlobal::the()->message( i18n( "Saving \"%1\" was successful." ).arg( filename() ) ); + _saved = true; +} + +void KRecFile::exportwave( const QString &filename ) { + kdDebug( 60005 ) << k_funcinfo << filename << endl; +} + +QByteArray* KRecFile::getData( int ) { + kdDebug( 60005 ) << k_funcinfo << endl; + return 0; +} + +void KRecFile::getData( QByteArray& data ) { + KRecBuffer* current = getTopBuffer_buffer( _pos ); + if ( current ) { + //kdDebug( 60005 ) << "_pos=" << _pos << "(" << samplesToOffset( _pos ) << ") current->startpos()=" << current->startpos() << "(" << samplesToOffset( current->startpos() ) << ") that is " << samplesToOffset( _pos - current->startpos() ) << endl; + current->setPos( samplesToOffset( _pos - current->startpos() ) ); + current->getData( data ); + } else { + for ( uint i=0; i<data.size(); i++ ) + data[ i ] = 0; + } + newPos( _pos + offsetToSamples( data.size() ) ); + if ( position() >= size() ) emit endReached(); +} + + +// * * * Position * * * +void KRecFile::newPos( int p ) { + if ( _pos != p ) { + _pos = p; + emit posChanged( _pos ); + } +} +void KRecFile::newPos( KRecBuffer* buffer, QIODevice::Offset p ) { + newPos( buffer->startpos() + offsetToSamples( p ) ); +} +void KRecFile::newSize( KRecBuffer* buffer, QIODevice::Offset p ) { + if ( buffer->startpos() + offsetToSamples( p ) > _size ) { + _size = buffer->startpos() + offsetToSamples( p ); + } + emit sizeChanged( _size ); +} + + +/// * * * Frames <-> Offset and more * * * +int KRecFile::offsetToSamples( QIODevice::Offset n ) const { + int out = n / channels(); + if ( bits() == 16 ) out /= 2; + return out; +} +QIODevice::Offset KRecFile::samplesToOffset( int n ) const { + QIODevice::Offset out = n * channels(); + if ( bits() == 16 ) out *= 2; + return out; +} + +/// * * * Properties <-> KConfig * * * +void KRecFile::saveProps() { + kdDebug( 60005 ) << k_funcinfo << endl; + _config->setGroup( "General" ); + _config->writeEntry( "Samplerate", _samplerate ); + _config->writeEntry( "Bits", _bits ); + _config->writeEntry( "Channels", _channels ); + + _config->writeEntry( "Files", _buffers.count() ); + for ( uint i=0; i<_buffers.count(); i++ ) { + //kdDebug( 60005 ) << "Writing config " << i << endl; + _config->setGroup( "File-" + QString::number( i ) ); + _buffers[ i ]->writeConfig( _config ); + } + _config->sync(); +} +void KRecFile::loadProps() { + kdDebug( 60005 ) << k_funcinfo << endl; + _config->setGroup( "General" ); + _samplerate = _config->readNumEntry( "Samplerate", 44100 ); + _bits = _config->readNumEntry( "Bits", 16 ); + _channels = _config->readNumEntry( "Channels", 2 ); +} + + +/// * * * NewBuffer * * * +void KRecFile::newBuffer( const QString &filename ) { + kdDebug( 60005 ) << k_funcinfo << filename << endl; + newBuffer( new KRecBuffer( filename, _pos, true, this ) ); +} +void KRecFile::newBuffer( KRecBuffer* buffer ) { + kdDebug( 60005 ) << k_funcinfo << endl; + connect( buffer, SIGNAL( posChanged( KRecBuffer*, QIODevice::Offset ) ), this, SLOT( newPos( KRecBuffer*, QIODevice::Offset ) ) ); + connect( buffer, SIGNAL( sizeChanged( KRecBuffer*, QIODevice::Offset ) ), this, SLOT( newSize( KRecBuffer*, QIODevice::Offset ) ) ); + connect( buffer, SIGNAL( deleteSelf( KRecBuffer* ) ), this, SLOT( deleteBuffer( KRecBuffer* ) ) ); + _buffers.append( buffer ); + newSize( buffer, buffer->size() ); + _currentBuffer = _buffers.findIndex( buffer ); + emit sNewBuffer( buffer ); + _saved = false; +} +void KRecFile::newBuffer() { + kdDebug( 60005 ) << k_funcinfo << endl; + newBuffer( _dir->name() + "file" + QString::number( _buffers.count() ) + ".raw" ); +} + +void KRecFile::deleteBuffer( KRecBuffer* b ) { + kdDebug( 60005 ) << k_funcinfo << b << endl; + emit sDeleteBuffer( b ); + delete b; + if ( _buffers.remove( b ) ) + _currentBuffer = -1; + KRecGlobal::the()->message( i18n( "Part deleted." ) ); + _saved = false; +} + +/// * * * helper * * * +KRecBuffer* KRecFile::getTopBuffer_buffer( int pos ) { + //kdDebug( 60005 ) << k_funcinfo << pos << endl; + QValueList<KRecBuffer*>::iterator it = _buffers.begin(); + KRecBuffer* out = 0; + while ( it != _buffers.end() ) { + if ( ( *it )->startpos() <= pos && offsetToSamples( ( *it )->size() ) + ( *it )->startpos() > pos && ( *it )->active() ) + out = ( *it ); + ++it; + } + return out; +} +int KRecFile::getTopBuffer_int( int pos ) { + return _buffers.findIndex( getTopBuffer_buffer( pos ) ); +} + + +/// * * * KRecBuffer * * * +KRecBuffer::KRecBuffer( const QString &filename, int startpos, bool a, KRecFile* p, const char* n ) + : QObject( p,n ) + , _krecfile( p ) + , _file( new QFile( filename ) ) + , _stream( new QDataStream( _file ) ) + , _fileinfo( new QFileInfo( filename ) ) + , _active( a ) + , _pos( 0 ), _start( startpos ) + , _title( _fileinfo->fileName() ) + , _comment( QString::null ) +{ + kdDebug( 60005 ) << k_funcinfo << filename << " " << startpos << endl; + _open = _file->open( IO_Raw | IO_ReadWrite ); + setPos( _file->at() ); + if ( _open ) kdDebug( 60005 ) << k_funcinfo << "Open successfull!" << endl; + else kdDebug( 60005 ) << endl << k_funcinfo << "Could not open file!" << endl << endl; +} +KRecBuffer::~KRecBuffer() { + kdDebug( 60005 ) << k_funcinfo << endl; + if ( _open ) { + _file->close(); + _open = false; + _file->remove(); + } + //kdDebug( 60005 ) << k_funcinfo << "done." << endl; +} + +void KRecBuffer::writeConfig( KConfig* config ) { + //kdDebug( 60005 ) << k_funcinfo << config << endl; + config->writeEntry( "Filename", _fileinfo->fileName() ); + config->writeEntry( "StartPos", _start ); + config->writeEntry( "Activated", _active ); + config->writeEntry( "Title", _title ); + config->writeEntry( "Comment", _comment ); +} + +KRecBuffer* KRecBuffer::fromConfig( KConfig* config, QDir* dir, KRecFile* p, const char* n ) { + kdDebug( 60005 ) << k_funcinfo << config << endl; + KRecBuffer* tmp = new KRecBuffer( dir->path() + "/" + config->readEntry( "Filename" ), + config->readNumEntry( "StartPos" ), + config->readBoolEntry( "Activated", true ), + p, n ); + tmp->setTitle( config->readEntry( "Title", tmp->filename() ) ); + tmp->setComment( config->readEntry( "Comment", QString::null ) ); + return tmp; +} + +void KRecBuffer::writeData( Arts::mcopbyte* /*data*/, uint /*length*/ ) { + kdDebug( 60005 ) << k_funcinfo << endl; +} +void KRecBuffer::writeData( QByteArray* data ) { +kdDebug( 60005 ) << k_funcinfo << endl; + writeData( *data ); +/* if ( _open ) { + _file->at( _pos ); + _file->writeBlock( *data ); + setPos( _file->at() ); + emit sizeChanged( this, size() ); + }*/ +} +void KRecBuffer::writeData( QByteArray& data ) { + //kdDebug( 60005 ) << k_funcinfo << endl; + if ( _open ) { + _file->at( _pos ); + _file->writeBlock( data ); + setPos( _file->at() ); + emit sizeChanged( this, size() ); + } +} + +void KRecBuffer::getData( QByteArray& data ) { + //kdDebug( 60005 ) << k_funcinfo << "data.size()" << data.size() << " _pos" << _pos << endl; + if ( _pos > _file->size() ) + kdWarning() << "Trying to access behind file!" << endl; + else { + if ( _open ) { + _file->at( _pos ); + //kdDebug( 60005 ) << "Reading " << _file->readBlock( ( char* )data.data(), data.size() ) << "bytes into data." << endl; + //kdDebug( 60005 ) << "data.size()" << data.size() << endl; + for ( uint i=0; i<data.size(); i++ ) { + if ( !_file->atEnd() ) + data.data()[ i ] = _file->getch(); + else + data.data()[ i ] = 0; + } + //setPos( _file->at() ); + } + } +} + +void KRecBuffer::setPos( QIODevice::Offset p ) { + if ( p!=_pos ) { + _pos = p; + emit posChanged( this, _pos ); +//kdDebug( 60005 ) << k_funcinfo << _pos << endl; + } +} + +int KRecBuffer::startpos() const { return _start; } +QIODevice::Offset KRecBuffer::size() const { return _file->size(); } + +QString KRecBuffer::filename() const { return _fileinfo->fileName(); } +QString KRecBuffer::title() const { return _title; } +QString KRecBuffer::comment() const { return _comment; } + +void KRecBuffer::setTitle( const QString &n ) { + if ( _title != n ) { + _title = n; + emit somethingChanged(); + } +} + +void KRecBuffer::setComment( const QString &n ) { + if ( _comment != n ) { + _comment = n; + emit somethingChanged(); + } +} + +bool KRecBuffer::active() const { return _active; } +void KRecBuffer::setActive( bool n ) { + if ( _active != n ) { + _active = n; + emit activeChanged( _active ); + emit somethingChanged(); + } +} + +void KRecBuffer::deleteBuffer() { + if ( KMessageBox::warningContinueCancel( KRecGlobal::the()->mainWidget(), i18n( "Do you really want to delete the selected part '%1'?" ).arg( filename() ), i18n("Delete Part?"), KStdGuiItem::del() ) == KMessageBox::Continue ) + _krecfile->deleteBuffer( this ); +} + +float KRecBuffer::getSample( int pos, int /*channel*/ ) { + Q_INT16 tmp16; + Q_INT8 tmp8; + float out; + _file->at( _krecfile->samplesToOffset( pos ) ); + if ( _krecfile->bits() == 16 ) { + *_stream >> tmp16; + out = tmp16 / 65535.0; + } + else { + *_stream >> tmp8; + out = tmp8 / 65535.0; + } + return out; +} +float* KRecBuffer::getsamples( int start, int end, int channel ) { + float* tmp = new float[ end-start ]; + for ( int i=start; i<end; ++i ) + tmp[ i ] = getSample( i, channel ); + return tmp; +} + diff --git a/krec/krecfile.h b/krec/krecfile.h new file mode 100644 index 00000000..ba307838 --- /dev/null +++ b/krec/krecfile.h @@ -0,0 +1,201 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KRECFILE_H +#define KRECFILE_H + +#include <qobject.h> +#include <qstring.h> +#include <qvaluelist.h> + +#include <arts/common.h> + +class KRecBuffer; +class KTempDir; +class KSimpleConfig; +class QFile; +class KRecFileViewWidget; + +class KRecFile : virtual public QObject { + Q_OBJECT + friend class KRecFileWidget; +public: + KRecFile( QObject*, const char* =0 ); + KRecFile( const QString &, QObject*, const char* =0 ); + ~KRecFile(); + + QString filename(); + void filename( const QString &); + + bool saved() const { return _saved; } + int samplerate() const { return _samplerate; } + int channels() const { return _channels; } + int bits() const { return _bits; } + + QIODevice::Offset offsetSize() const { return samplesToOffset( _size ); } + QIODevice::Offset offsetPosition() const { return samplesToOffset( _pos ); } + + int size() const { return _size; } + int position() const { return _pos; } + + /// Calculates an offset into a frames-value depending on the files settings (channels and bits) + int offsetToSamples( QIODevice::Offset ) const; + QIODevice::Offset samplesToOffset( int ) const; +public slots: + /// Creates a new empty buffer and marks it for recording. + void newBuffer(); + + /// Deletes the buffer from the file. + void deleteBuffer( KRecBuffer* =0 ); + + void writeData( Arts::mcopbyte* data, uint length ); + void writeData( QByteArray* ); + void writeData( QByteArray& ); + + void save( const QString & ); + void exportwave( const QString & ); + + /// Fills a QByteArray with values from the specified Offset. + QByteArray* getData( int ); + + void getData( QByteArray& ); + + void newPos( int ); + +private slots: + void newPos( KRecBuffer*, QIODevice::Offset ); + void newSize( KRecBuffer*, QIODevice::Offset ); +signals: + /// Position signals + void posChanged( int ); + void sizeChanged( int ); + /// The end of the file is reached, you should stop reading. + void endReached(); + + /// GUI-Signals + void sNewBuffer( KRecBuffer* ); + void sDeleteBuffer( KRecBuffer* ); + + void filenameChanged( const QString & ); +private: + void saveProps(); + void loadProps(); + /** + Creates a new buffer for a given file + @param filename Name of the file + */ + void newBuffer( const QString &filename ); + /** + Adds buffer to the buffers. + @param buffer The to be added buffer + */ + void newBuffer( KRecBuffer* buffer ); + + /// Get the top-most-buffer at the specified position. + int getTopBuffer_int( int ); + KRecBuffer* getTopBuffer_buffer( int ); + + bool _saved; + QString _filename; + int _samplerate, _channels, _bits; + int _currentBuffer; + QValueList<KRecBuffer*> _buffers; + KTempDir *_dir; + KSimpleConfig *_config; + int _pos, _size; + + void init(); +}; + +class QFile; +class QDir; +class QFileInfo; +class KConfig; +class QDataStream; + +class KRecBuffer : virtual public QObject { + Q_OBJECT +public: + KRecBuffer( const QString &, int, bool, KRecFile*, const char* =0 ); + ~KRecBuffer(); + + // After how many samples in the File this Buffer starts... + int startpos() const; + + QIODevice::Offset size() const; + int sizeInSamples() const { return _krecfile->offsetToSamples( size() ); } + + /** + Writes out its Config + It doesn't set the group. + @param config the KConfig where the data gets written + */ + void writeConfig( KConfig* config ); + + /** + restores a KRecBuffer from Config + The group has to be set the right way. + @param config The configuration thats read + @param dir The directory where the file is saved + */ + static KRecBuffer* fromConfig( KConfig* config, QDir* dir, KRecFile* p, const char* n=0 ); + + QString filename() const; + + bool active() const; + + QString title() const; + QString comment() const; +public slots: + /// writes the data into the buffer + void writeData( Arts::mcopbyte* data, uint length ); + void writeData( QByteArray* ); + void writeData( QByteArray& ); + /// gets the data from the stream + void getData( QByteArray& ); + + void setPos( QIODevice::Offset ); + + void setActive( bool ); + + void deleteBuffer(); + + void setTitle( const QString & ); + void setComment( const QString & ); + + /// Returns the sample at the specified position and channel. + float getSample( int pos, int channel ); + float* getsamples( int start, int end, int channel ); +signals: + void posChanged( KRecBuffer*, QIODevice::Offset ); + void sizeChanged( KRecBuffer*, QIODevice::Offset ); + void activeChanged( bool ); + + /// Is emitted when something has changed. + void somethingChanged(); + + void deleteSelf( KRecBuffer* ); +private: + KRecFile* _krecfile; + QFile* _file; + QDataStream* _stream; + QFileInfo* _fileinfo; + bool _open, _active; + QIODevice::Offset _pos; + int _start; + QString _title, _comment; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecfileview.cpp b/krec/krecfileview.cpp new file mode 100644 index 00000000..b3604412 --- /dev/null +++ b/krec/krecfileview.cpp @@ -0,0 +1,89 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecfileview.h" +#include "krecfileview.moc" + +#include "krecfilewidgets.h" +#include "krecfileviewhelpers.h" +#include "krecfile.h" +#include "krecglobal.h" + +#include <kdebug.h> +#include <klocale.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qpainter.h> +#include <qpointarray.h> +#include <qlineedit.h> + +KRecFileView::KRecFileView( QWidget* p, const char* n ) + : QWidget( p,n ) +{ +kdDebug( 60005 ) << k_funcinfo << endl; + _layout_td = new QBoxLayout( this, QBoxLayout::TopToBottom, 5, 5 ); + _filename = new QLabel( i18n( "<no file>" ), this ); + _layout_td->addWidget( _filename, 1 ); + _fileview = new KRecFileWidget( 0, this ); + _layout_td->addWidget( _fileview, 100 ); + _timebar = new KRecTimeBar( this ); + _layout_td->addWidget( _timebar, 50 ); + _layout_lr = new QBoxLayout( this, QBoxLayout::LeftToRight, 5, 5 ); + _layout_td->addLayout( _layout_lr, 1 ); + _layout_lr->addStretch( 20 ); + _timedisplay = new KRecTimeDisplay( this ); + _layout_td->addWidget( _timedisplay, 1 ); + _file = 0; +} +KRecFileView::~KRecFileView() { +kdDebug( 60005 ) << k_funcinfo << endl; +} + +void KRecFileView::setFile( KRecFile* file ) { +kdDebug( 60005 ) << k_funcinfo << file << endl; + if ( _file != file ) { + _file = file; + _fileview->setFile( _file ); + if ( _file ) { + if ( !_file->filename().isNull() ) setFilename( _file->filename() ); + else _filename->setText( i18n( "file with no name" ) ); + connect( _file, SIGNAL( posChanged( int ) ), this, SLOT( setPos( int ) ) ); + connect( _file, SIGNAL( posChanged( int ) ), _timebar, SLOT( newPos( int ) ) ); + connect( _file, SIGNAL( posChanged( int ) ), _timedisplay, SLOT( newPos( int ) ) ); + connect( _file, SIGNAL( sizeChanged( int ) ), this, SLOT( setSize( int ) ) ); + connect( _file, SIGNAL( sizeChanged( int ) ), _timebar, SLOT( newSize( int ) ) ); + connect( _file, SIGNAL( sizeChanged( int ) ), _timedisplay, SLOT( newSize( int ) ) ); + connect( _file, SIGNAL( filenameChanged( const QString &) ), this, SLOT( setFilename( const QString &) ) ); + connect( _file, SIGNAL( filenameChanged( const QString &) ), _timedisplay, SLOT( newFilename( const QString &) ) ); + connect( _timebar, SIGNAL( sNewPos( int ) ), _file, SLOT( newPos( int ) ) ); + _timebar->newPos( _file->position() ); + _timebar->newSize( _file->size() ); + _timedisplay->newSamplingRate( _file->samplerate() ); + _timedisplay->newChannels( _file->channels() ); + _timedisplay->newBits( _file->bits() ); + _timedisplay->newFilename( _file->filename() ); + _timedisplay->newPos( _file->position() ); + _timedisplay->newSize( _file->size() ); + } else { + disconnect( this, SLOT( setPos( QIODevice::Offset ) ) ); + _filename->setText( i18n( "<no file>" ) ); + _timedisplay->newFilename( QString::null ); + } + } +} + +void KRecFileView::updateGUI() { _fileview->resizeEvent(); } +void KRecFileView::setPos( int ) {} +void KRecFileView::setSize( int ) {} +void KRecFileView::setFilename( const QString &n ) { _filename->setText( n );} + diff --git a/krec/krecfileview.h b/krec/krecfileview.h new file mode 100644 index 00000000..a445316f --- /dev/null +++ b/krec/krecfileview.h @@ -0,0 +1,56 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KRECFILEVIEW_H +#define KRECFILEVIEW_H + +#include <qwidget.h> + +class KRecFile; +class KRecBuffer; +class QBoxLayout; +class QLabel; +class QLineEdit; + +class KRecFileWidget; +class KRecBufferWidget; +class KRecTimeBar; +class KRecTimeDisplay; + +class KRecFileView : virtual public QWidget { + Q_OBJECT +public: + KRecFileView( QWidget*, const char* =0 ); + ~KRecFileView(); + + void setFile( KRecFile* ); +public slots: + /// Mainly calls resize() on the KRecFileWidget. + void updateGUI(); +private slots: + void setPos( int ); + void setSize( int ); + void setFilename( const QString & ); +private: + QBoxLayout *_layout_td, *_layout_lr; + QLabel *_filename; + + KRecFile *_file; + KRecFileWidget *_fileview; + KRecTimeBar *_timebar; + KRecTimeDisplay *_timedisplay; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecfileviewhelpers.cpp b/krec/krecfileviewhelpers.cpp new file mode 100644 index 00000000..8025f576 --- /dev/null +++ b/krec/krecfileviewhelpers.cpp @@ -0,0 +1,268 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecfileviewhelpers.h" +#include "krecfileviewhelpers.moc" + +#include "krecglobal.h" + +#include <kdebug.h> +#include <klocale.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qpainter.h> +#include <qpointarray.h> +#include <qpopupmenu.h> +#include <kpopupmenu.h> + +KRecTimeBar::KRecTimeBar( QWidget* p, const char* n ) : QFrame( p,n ) + ,_size(10), _pos(0) + { + //kdDebug( 60005 ) << k_funcinfo << endl; + setMinimumSize( 10,10 ); + setFrameStyle( QFrame::Panel|QFrame::Plain ); + setLineWidth( 1 ); +} + +KRecTimeBar::~KRecTimeBar() { + //kdDebug( 60005 ) << k_funcinfo << endl; +} + +void KRecTimeBar::drawContents( QPainter* p ) { + int w = contentsRect().width(); + int h = contentsRect().height(); + int t = contentsRect().top(); + int l = contentsRect().left(); + p->setPen( QColor( 255,0,0 ) ); + if ( _pos < _size ) { + int x = int( l + w * float( _pos ) / _size ); + p->drawLine( x, t, x, int( t+h/2 ) ); + } else { + QPointArray tmp; + tmp.putPoints( 0, 4, l+w-3,t+h/4, l+w-3,t+h/4*3, l+w,t+h/2, l+w-3,t+h/4 ); + p->drawPolyline( tmp ); + } +} + +void KRecTimeBar::mouseReleaseEvent( QMouseEvent* qme ) { + QIODevice::Offset pos = 0; + if ( _size > 0 ) + pos = int( float( qme->x() - contentsRect().left() ) / contentsRect().width() * _size ); + //kdDebug( 60005 ) << k_funcinfo << "New Position: " << pos << endl; + emit sNewPos( pos ); +} + +void KRecTimeBar::newPos( int n ) { + _pos = n; + repaint(); +} + +void KRecTimeBar::newSize( int n ) { + _size = n; + repaint(); +} + + +KRecTimeDisplay::KRecTimeDisplay( QWidget* p, const char* n ) + : QFrame( p,n ) + , _posmenu( 0 ), _sizemenu( 0 ) + , _sizevalue( 0 ), _posvalue( 0 ) + , _samplingRate( 44100 ), _bits( 16 ), _channels( 2 ) +{ + _position = new AKLabel( this ); + connect( _position, SIGNAL( showContextMenu( const QPoint & ) ), this, SLOT( timeContextMenu( const QPoint &) ) ); + _size = new AKLabel( this ); + connect( _size, SIGNAL( showContextMenu( const QPoint &) ), this, SLOT( sizeContextMenu( const QPoint &) ) ); + + _layout = new QBoxLayout( this, QBoxLayout::LeftToRight, 0, 2 ); + _layout->addStretch( 100 ); + _layout->addWidget( _position ); + _layout->addSpacing( 2 ); + _layout->addWidget( _size ); + + reset(); +} +KRecTimeDisplay::~KRecTimeDisplay() { +} + +void KRecTimeDisplay::reset() { + _position->setText( positionText( 0, 0 ) ); + _size->setText( sizeText( 0, 0 ) ); + _position->setFrameStyle( QFrame::Panel|QFrame::Sunken ); + _position->setLineWidth( 1 ); + _position->setMargin( 2 ); + _size->setFrameStyle( QFrame::Panel|QFrame::Sunken ); + _size->setLineWidth( 1 ); + _size->setMargin( 2 ); +} + +void KRecTimeDisplay::newPos( int n ) { + _posvalue = n; + _position->setText( positionText( KRecGlobal::the()->timeFormatMode(), _posvalue ) ); + static int timeformat = KRecGlobal::the()->timeFormatMode(); + if ( timeformat != KRecGlobal::the()->timeFormatMode() ) { + timeformat = KRecGlobal::the()->timeFormatMode(); + newSize( _sizevalue ); + } +} +void KRecTimeDisplay::newSize( int n ) { + _sizevalue = n; + _size->setText( sizeText( KRecGlobal::the()->timeFormatMode(), n ) ); +} +void KRecTimeDisplay::newFilename( const QString &n ) { + _filename = n; + if ( _filename.isNull() ) { + newPos( 0 ); + newSize( 0 ); + } +} + +QString KRecTimeDisplay::formatTime( const int mode, const int sample ) const { + QString text; + bool verbose = mode / 100; + switch ( mode % 100 ) { + case 3: + { + int bytes = sample * ( _bits/8 ) * _channels / 1024; + int kbyte = bytes % 1024; + bytes /= 1024; + int mbyte = bytes % 1024; + text += QString::number( mbyte ); + if ( verbose ) text += i18n( "MB" ); + text += "."; + if ( kbyte < 1000 ) text += "0"; + if ( kbyte < 100 ) text += "0"; + if ( kbyte < 10 ) text += "0"; + text += QString::number( kbyte ); + if ( verbose ) text += i18n( "kB" ); + } + break; + case 2: + { + int value = sample / ( _samplingRate / KRecGlobal::the()->frameBase() ); // overall frames + int frames = value % KRecGlobal::the()->frameBase(); + value = value / KRecGlobal::the()->frameBase(); + int secs = value % 60; + value = value / 60; + int mins = value % 60; + value = value / 60; + if ( value ) { + text += QString::number( value ); + if ( verbose ) text += i18n( "hours" ); + text += ":"; + } + if ( mins<10 ) text += "0"; + text += QString::number( mins ); + if ( verbose ) text += i18n( "mins" ); + text += ":"; + if ( secs<10 ) text += "0"; + text += QString::number( secs ); + if ( verbose ) text += i18n( "secs" ); + text += "."; + if ( frames < 10 ) text += "0"; + text += QString::number( frames ); + if ( verbose ) text += i18n( "frames" ); + } + break; + case 1: + { + int value = sample; // overall samples + int samples = value % ( _samplingRate / 60 ); + value = value / ( _samplingRate / 60 ); + int secs = value % 60; + value = value / 60; + int mins = value % 60; + value = value / 60; + if ( value ) { + text += QString::number( value ); + if ( verbose ) text += i18n( "hours" ); + text += ":"; + } + if ( mins<10 ) text += "0"; + text += QString::number( mins ); + if ( verbose ) text += i18n( "mins" ); + text += ":"; + if ( secs<10 ) text += "0"; + text += QString::number( secs ); + if ( verbose ) text += i18n( "secs" ); + text += "."; + if ( samples < 10000 && ( _samplingRate / 60 > 10000 ) ) text += "0"; + if ( samples < 1000 ) text += "0"; + if ( samples < 100 ) text += "0"; + if ( samples < 10 ) text += "0"; + text += QString::number( samples ); + if ( verbose ) text += i18n( "samples" ); + } + break; + case 0: + default: + text = QString::number( sample ); + if ( verbose ) text += i18n( "samples" ); + break; + }; + return text; +} + +void KRecTimeDisplay::timeContextMenu( QPopupMenu* menu ) { + if ( !_filename.isNull() ) { + menu->insertSeparator( 0 ); + menu->insertItem( i18n( "kByte: %1" ).arg( formatTime( 3, _posvalue ) ), -1, 0 ); + menu->insertItem( i18n( "[h:]m:s.f %1" ).arg( formatTime( 2, _posvalue ) ), -1, 0 ); + menu->insertItem( i18n( "[h:]m:s.s %1" ).arg( formatTime( 1, _posvalue ) ), -1, 0 ); + menu->insertItem( i18n( "%1 Samples" ).arg( formatTime( 0, _posvalue ) ), -1, 0 ); + KPopupTitle *tmp = new KPopupTitle( menu ); + tmp->setTitle( i18n( "Position" ) ); + menu->insertItem( tmp, -1, 0 ); + } else + menu->insertItem( i18n( "<no file>" ), -1, 0 ); +} +void KRecTimeDisplay::timeContextMenu( const QPoint &point ) { + if ( _posmenu ) delete _posmenu; + _posmenu = new KPopupMenu( this ); + timeContextMenu( _posmenu ); + _posmenu->exec( point ); +} +void KRecTimeDisplay::sizeContextMenu( QPopupMenu* menu ) { + if ( !_filename.isNull() ) { + menu->insertSeparator( 0 ); + menu->insertItem( i18n( "kByte: %1" ).arg( formatTime( 3, _sizevalue ) ), -1, 0 ); + menu->insertItem( i18n( "[h:]m:s.f %1" ).arg( formatTime( 2, _sizevalue ) ), -1, 0 ); + menu->insertItem( i18n( "[h:]m:s.s %1" ).arg( formatTime( 1, _sizevalue ) ), -1, 0 ); + menu->insertItem( i18n( "%1 Samples" ).arg( formatTime( 0, _sizevalue ) ), -1, 0 ); + KPopupTitle *tmp = new KPopupTitle( menu ); + tmp->setTitle( i18n( "Size" ) ); + menu->insertItem( tmp, -1, 0 ); + } else + menu->insertItem( i18n( "<no file>" ), -1, 0 ); +} +void KRecTimeDisplay::sizeContextMenu( const QPoint &point ) { + if ( _sizemenu ) delete _sizemenu; + _sizemenu = new KPopupMenu( this ); + sizeContextMenu( _sizemenu ); + _sizemenu->exec( point ); +} +void KRecTimeDisplay::jumpToTime() { +} + +QString KRecTimeDisplay::positionText( int m, int n ) { + return i18n( "Position: %1" ).arg( formatTime( m,n ) ); +} +QString KRecTimeDisplay::sizeText( int m, int n ) { + return i18n( "Size: %1" ).arg( formatTime( m,n ) ); +} + +void AKLabel::mousePressEvent( QMouseEvent* qme ) { + if ( qme->button() == Qt::RightButton ) + emit showContextMenu( qme->globalPos() ); +} + diff --git a/krec/krecfileviewhelpers.h b/krec/krecfileviewhelpers.h new file mode 100644 index 00000000..71881f1e --- /dev/null +++ b/krec/krecfileviewhelpers.h @@ -0,0 +1,110 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KRECFILEVIEWHELPERS_H +#define KRECFILEVIEWHELPERS_H + +#include <qframe.h> +#include <qlabel.h> +#include <qstring.h> +#include <qpoint.h> +#include <kglobalsettings.h> + +class QBoxLayout; +class AKLabel; +class QPopupMenu; +class KPopupMenu; + +class KRecTimeBar : public QFrame { + Q_OBJECT +public: + KRecTimeBar( QWidget*, const char* =0 ); + ~KRecTimeBar(); + + void drawContents( QPainter* ); + + void mouseReleaseEvent( QMouseEvent* ); + +public slots: + void newPos( int ); + void newSize( int ); +signals: + void sNewPos( int ); +private: + int _pos, _size; +}; + +/** + * Modes are: + * 0 - Just samples + * 1 - [hours:]mins:secs:samples + * 2 - [hours:]mins:secs:frames ( framebase from global ) + * 3 - [hours:]mins:secs:msecs + * + * +100 - verbose ( [XXhours:]XXmins:XXsecs:... ) +*/ + +class KRecTimeDisplay : public QFrame { + Q_OBJECT +public: + KRecTimeDisplay( QWidget*, const char* =0 ); + ~KRecTimeDisplay(); + + /// Resets the display to its defaultvalues + void reset(); +public slots: + void newPos( int ); + void newSize( int ); + void newFilename( const QString & ); + void newSamplingRate( int n ) { _samplingRate = n; } + void newChannels( int n ) { _channels = n; } + void newBits( int n ) { _bits = n; } +signals: + void sNewPos( int ); +private slots: + void timeContextMenu( QPopupMenu* ); + void timeContextMenu( const QPoint &); + void sizeContextMenu( QPopupMenu* ); + void sizeContextMenu( const QPoint &); + void jumpToTime(); +private: + QString positionText( int, int ); + QString sizeText( int, int ); + QString formatTime( const int mode, const int samples ) const; + QString _filename; + QBoxLayout *_layout; + AKLabel *_position, *_size; + KPopupMenu *_posmenu, *_sizemenu; + int _sizevalue, _posvalue; + int _samplingRate, _bits, _channels; +}; + + +class AKLabel : public QLabel { + Q_OBJECT +public: + AKLabel( QWidget* p, const char* n=0, WFlags f=0 ) : QLabel( p, n, f ) { init(); } + AKLabel( const QString& s, QWidget* p, const char* n=0, WFlags f=0 ) : QLabel( s, p, n, f ) { init(); } + AKLabel( QWidget* w, const QString& s, QWidget* p, const char* n=0, WFlags f=0 ) : QLabel( w,s,p,n,f ) { init(); } + + void mousePressEvent( QMouseEvent* ); +signals: + void showContextMenu( const QPoint & ); +private: + void init() { + setFont( KGlobalSettings::fixedFont() ); + } +}; +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecfilewidgets.cpp b/krec/krecfilewidgets.cpp new file mode 100644 index 00000000..44fd6a4e --- /dev/null +++ b/krec/krecfilewidgets.cpp @@ -0,0 +1,313 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecfilewidgets.h" +#include "krecfilewidgets.moc" + +#include "krecfile.h" +#include "krecglobal.h" + +#include <kdebug.h> +#include <klocale.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qpainter.h> +#include <qpointarray.h> +#include <qlineedit.h> +#include <kinputdialog.h> +#include <qregion.h> +#include <qrect.h> +#include <qfont.h> +#include <qfontmetrics.h> +#include <kpopupmenu.h> +#include <kactionclasses.h> +#include <kaction.h> + +KRecFileWidget::KRecFileWidget( KRecFile* file, QWidget* p, const char* n ) + : QFrame( p,n ) + , _file( 0 ) +{ + kdDebug( 60005 ) << k_funcinfo << file << endl; + setFrameStyle( QFrame::Panel|QFrame::Sunken ); + setLineWidth( 1 ); + setMinimumHeight( 20 ); + + setFile( file ); +} +KRecFileWidget::~KRecFileWidget() { + kdDebug( 60005 ) << k_funcinfo << endl; +} + +void KRecFileWidget::setFile( KRecFile* file ) { +kdDebug( 60005 ) << k_funcinfo << file << endl; + if ( _file != file ) { + _file = file; + //kdDebug( 60005 ) << "Removing widgets" << endl; + QValueList<KRecBufferWidget*>::iterator it = bufferwidgets.begin(); + while ( it != bufferwidgets.end() ) { + delete ( *it ); + ++it; + } + bufferwidgets.clear(); + resizeEvent(); + if ( _file ) { + for ( QValueList<KRecBuffer*>::iterator it = _file->_buffers.begin(); it != _file->_buffers.end(); ++it ) { + newBuffer( ( *it ) ); + } + connect( _file, SIGNAL( sNewBuffer( KRecBuffer* ) ), this, SLOT( newBuffer( KRecBuffer* ) ) ); + connect( _file, SIGNAL( sDeleteBuffer( KRecBuffer* ) ), this, SLOT( deleteBuffer( KRecBuffer* ) ) ); + //kdDebug( 60005 ) << _file->_currentBuffer << endl; + } + } +} + +void KRecFileWidget::resizeEvent( QResizeEvent* /*qre*/ ) { + //kdDebug( 60005 ) << k_funcinfo << endl; + if ( _file ) { + int w = contentsRect().width(); + int h = contentsRect().height(); + QValueList<KRecBufferWidget*>::iterator it; + for ( it = bufferwidgets.begin(); it != bufferwidgets.end(); ++it ) { + int width, x; + if ( !_file->offsetSize()==0 && !( *it )->buffer()->size()==0 ) { + width = int ( float( ( *it )->buffer()->size() ) / _file->offsetSize() * w ); + x = int( float( ( *it )->buffer()->startpos() ) / _file->size() * w ) + contentsRect().left() ; + } else { + width = 5; + x = contentsRect().left(); + } + ( *it )->setGeometry( x, contentsRect().top(), width, h ); + } + } +} + +void KRecFileWidget::mouseReleaseEvent( QMouseEvent* qme ) { + kdDebug( 60005 ) << k_funcinfo << "(" << qme->x() << "|" << qme->y() << ")" << endl; +} + +void KRecFileWidget::newBuffer( KRecBuffer* buffer ) { + //kdDebug( 60005 ) << k_funcinfo << buffer << endl; + KRecBufferWidget *tmp = new KRecBufferWidget( buffer, this ); + connect( tmp, SIGNAL( popupMenu( KRecBufferWidget*, QPoint ) ), this, SLOT( popupMenu( KRecBufferWidget*, QPoint ) ) ); + bufferwidgets.append( tmp ); + tmp->show(); + resizeEvent(); +} +void KRecFileWidget::deleteBuffer( KRecBuffer* buffer ) { + //kdDebug( 60005 ) << k_funcinfo << buffer << endl; + QValueList<KRecBufferWidget*>::iterator it = bufferwidgets.begin(); + KRecBufferWidget* tmp = 0; + while ( it != bufferwidgets.end() ) { + if ( ( *it )->buffer() == buffer ) tmp = ( *it ); + ++it; + } + if ( tmp != 0 ) { + delete tmp; + bufferwidgets.remove( tmp ); + } +} + +void KRecFileWidget::popupMenu( KRecBufferWidget* bw, QPoint pos ) { + KPopupMenu tmp( this ); + KToggleAction* _activeaction = new KToggleAction( i18n( "Toggle Active/Disabled State" ), KShortcut(), this ); + _activeaction->setChecked( bw->buffer()->active() ); + connect( _activeaction, SIGNAL( toggled( bool ) ), bw->buffer(), SLOT( setActive( bool ) ) ); + KAction* _removeaction = new KAction( i18n( "Remove This Part" ), "fileremove", KShortcut(), bw->buffer(), SLOT( deleteBuffer() ), this ); + KAction* _changetitle = new KAction( i18n( "Change Title of This Part" ), KShortcut(), bw, SLOT( changeTitle() ), this ); + KAction* _changecomment = new KAction( i18n( "Change Comment of This Part" ), KShortcut(), bw, SLOT( changeComment() ), this ); + _activeaction->plug( &tmp ); + _changetitle->plug( &tmp ); + _changecomment->plug( &tmp ); + tmp.insertSeparator(); + _removeaction->plug( &tmp ); + + tmp.exec( pos ); + + delete _removeaction; + delete _changecomment; + delete _changetitle; + delete _activeaction; +} + + + +KRecBufferWidget::KRecBufferWidget( KRecBuffer* buffer, QWidget* p, const char* n ) + : QFrame( p,n ) + , _buffer( buffer ) + , _main_region( 0 ), _title_region( 0 ), _fileend_region( 0 ) + , alreadyreadsize( 0 ) +{ + connect( _buffer, SIGNAL( somethingChanged() ), this, SLOT( update() ) ); + kdDebug( 60005 ) << k_funcinfo << endl; +} +KRecBufferWidget::~KRecBufferWidget() { + kdDebug( 60005 ) << k_funcinfo << endl; +} + +void KRecBufferWidget::resizeEvent( QResizeEvent* ) { + //kdDebug( 60005 ) << k_funcinfo << endl; +} + +void KRecBufferWidget::initLayout() { + _title_height = fontMetrics().boundingRect( _buffer->filename() ).height() + 4; + if( height()/5 > _title_height ) _title_height = height()/5; + int _title_width = fontMetrics().boundingRect( _buffer->filename() ).width() + 10; + if ( _title_width > width() ) _title_width = width(); + if ( _main_region ) delete _main_region; + _main_region = new QRegion( QRect( 0, _title_height, width(), height()-_title_height ) ); + if ( _title_region ) delete _title_region; + if ( _buffer->active() ) + _title_region = new QRegion( QRect( 0, 0, _title_width, _title_height ) ); + else + _title_region = new QRegion( QRect( 0, _title_height/2, _title_width, _title_height/2 ) ); + if ( _fileend_region ) { delete _fileend_region; _fileend_region=0; } + if ( _buffer->active() ) + _fileend_region = new QRegion( QRect( width()-4, _title_height/2, 4, _title_height/2 ) ); + else + _fileend_region = new QRegion( QRect( width()-4, _title_height/4*3, 4, _title_height/4 ) ); + + setMask( _main_region->unite( *_title_region ).unite( *_fileend_region ) ); + + _topleft = _title_region->boundingRect().topLeft(); + _bottomleft = _main_region->boundingRect().bottomLeft(); + _bottomright = _main_region->boundingRect().bottomRight(); + _topright = _main_region->boundingRect().topRight(); + _bottommiddle = _title_region->boundingRect().bottomRight(); + _bottommiddle += QPoint( 0, 1 ); + _topmiddle = _title_region->boundingRect().topRight(); +} +void KRecBufferWidget::drawFrame( QPainter* p ) { + //kdDebug( 60005 ) << k_funcinfo << endl; + if ( _buffer->active() ) + p->setBrush( colorGroup().highlight() ); + else + p->setBrush( colorGroup().highlight().dark() ); + p->setPen( QPen( colorGroup().dark(), 1 ) ); + p->drawRect( _title_region->boundingRect() ); + p->drawRect( _fileend_region->boundingRect() ); + + p->setBrush( QBrush() ); + p->setPen( QPen( colorGroup().dark(), 1 ) ); + p->drawRect( _main_region->boundingRect() ); + + p->setPen( QPen( colorGroup().highlightedText() ) ); + p->drawText( _title_region->boundingRect(), Qt::AlignCenter, _buffer->title() ); + +} +void KRecBufferWidget::drawContents( QPainter* p ) { + //kdDebug( 60005 ) << k_funcinfo << endl; + initSamples(); + int space = ( _main_region->boundingRect().height() - 2 ) / 2; + int xoffset = _main_region->boundingRect().top() + space + 1; + p->setPen( QPen( QColor( 0,0,255 ) ) ); + for ( uint i=0; i<samples1.count(); i++ ) + p->drawPoint( i, int( samples1[ i ]->getMax() * space + xoffset ) ); + for ( uint i=0; i<samples1.count(); i++ ) + p->drawPoint( i, int( samples1[ i ]->getMin() * space + xoffset ) ); + p->setPen( QPen( QColor( 255,0,0 ) ) ); + for ( uint i=0; i<samples1.count(); i++ ) + p->drawPoint( i, int( samples1[ i ]->getValue() * space + xoffset ) ); + p->setPen( QPen( QColor( 0,0,0 ) ) ); + QString comment = _buffer->comment(); + if ( comment.isNull() ) comment = i18n( "Lots of Data" ); + p->drawText( _main_region->boundingRect(), Qt::AlignCenter, comment ); +} +void KRecBufferWidget::paintEvent( QPaintEvent* ) { + initLayout(); + QPainter *p = new QPainter( this ); + drawFrame( p ); + drawContents( p ); + delete p; +} + +void KRecBufferWidget::mousePressEvent( QMouseEvent* qme ) { + kdDebug( 60005 ) << k_funcinfo << endl; + if ( _main_region->contains( qme->pos() ) || _title_region->contains( qme->pos() ) ) + if ( qme->button() == Qt::RightButton ) + emit popupMenu( this, qme->globalPos() ); +} +void KRecBufferWidget::mouseDoubleClickEvent( QMouseEvent* qme ) { + if ( _title_region->contains( qme->pos() ) ) + _buffer->setActive( !_buffer->active() ); +} + +void KRecBufferWidget::initSamples() { +#if 0 + /** + * Experimental. + * + * Doesn't really work since the conversion from char8/char16 to float in + * krecfile.cpp isn't working. + */ + //kdDebug( 60005 ) << k_funcinfo << endl; + if ( alreadyreadsize != _buffer->size() ) { + kdDebug( 60005 ) << k_funcinfo << "something to do" << endl; + while ( samples1.count() > 0 ) { + delete samples1.first(); + samples1.pop_front(); + } + while ( samples2.count() > 0 ) { + delete samples2.first(); + samples2.pop_front(); + } + Sample* tmp = new Sample(); + samples1.append( tmp ); + int j=0; + for ( int i=0; i<= _buffer->sizeInSamples(); ++i ) { + //for ( int i=0; i<= 10000; ++i ) { + if ( j/128 ) { + //kdDebug(60005) << "sample " << i << ": creating new Sample" << endl; + tmp = new Sample(); + samples1.append( tmp ); + j=0; + } + tmp->addValue( _buffer->getSample( i, 0 ) ); + //kdDebug(60005) << "Getting value " << _buffer->getSample( i,0 ) << endl; + ++j; + } + + tmp = new Sample; + samples2.append( tmp ); + j=0; + for ( uint i=0; i<samples1.count(); ++i ) { + if ( j/128 ) { + tmp = new Sample(); + samples2.append( tmp ); + j=0; + } + tmp->addValue( samples1[ i ]->getValue() ); + ++j; + } + +// for ( uint i=0; i<samples1.count(); ++i ) +// kdDebug(60005) << i << ": " << samples1[ i ]->getMin() << " < " << samples1[ i ]->getValue() << " < " << samples1[ i ]->getMax() << endl; + for ( uint i=0; i<samples2.count(); ++i ) + kdDebug(60005) << i << ": " << samples2[ i ]->getMin() << " < " << samples2[ i ]->getValue() << " < " << samples2[ i ]->getMax() << endl; + + alreadyreadsize = _buffer->size(); + } +#endif +} + + +void KRecBufferWidget::changeTitle() { + QString tmp = KInputDialog::getText( i18n( "New Title" ), i18n( "Enter new part title:" ), _buffer->title() ); + if ( !tmp.isNull() ) + _buffer->setTitle( tmp ); +} +void KRecBufferWidget::changeComment() { + QString tmp = KInputDialog::getText( i18n( "New Comment" ), i18n( "Enter new part comment:" ), _buffer->comment() ); + if ( !tmp.isNull() ) + _buffer->setComment( tmp ); +} + diff --git a/krec/krecfilewidgets.h b/krec/krecfilewidgets.h new file mode 100644 index 00000000..cca78907 --- /dev/null +++ b/krec/krecfilewidgets.h @@ -0,0 +1,110 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KRECFILEWIDGETS_H +#define KRECFILEWIDGETS_H + +#include <qframe.h> +#include <qvaluelist.h> +#include <qpoint.h> + +class KRecFile; +class KRecBuffer; +class TimeDisplay; +class QBoxLayout; +class QLabel; +class QLineEdit; + +class KRecFileWidget; +class KRecBufferWidget; +class KRecTimeBar; +class KRecTimeDisplay; + +class QRegion; +class QPainter; +class KAction; +class KToggleAction; + +class KRecFileWidget : public QFrame { + Q_OBJECT +public: + KRecFileWidget( KRecFile*, QWidget*, const char* =0 ); + ~KRecFileWidget(); + + void setFile( KRecFile* ); + + void resizeEvent( QResizeEvent* =0 ); + void mouseReleaseEvent( QMouseEvent* ); +public slots: + void newBuffer( KRecBuffer* ); + void deleteBuffer( KRecBuffer* ); +private slots: + void popupMenu( KRecBufferWidget*, QPoint ); +private: + KRecFile *_file; + QValueList<KRecBufferWidget*> bufferwidgets; +}; + +class Sample : public QObject { + Q_OBJECT +public: + Sample() : _values( 0 ), _min( 0 ), _max( 0 ) {} + + void addValue( float n ) { _values += n; ++_count; addMin( n ); addMax( n ); } + void addMin( float n ) { if ( n < _min ) _min = n; } + void addMax( float n ) { if ( n > _max ) _max = n; } + + float getValue() const { return _values / _count; } + float getMax() const { return ( _max>1 )?1:_max; } + float getMin() const { return ( _min<-1 )?-1:_min; } + int getCount() const { return _count; } +private: + float _values, _min, _max; + int _count; +}; + +class KRecBufferWidget : public QFrame { + Q_OBJECT +public: + KRecBufferWidget( KRecBuffer*, QWidget*, const char* =0 ); + ~KRecBufferWidget(); + + const KRecBuffer* buffer() { return _buffer; } + + void resizeEvent( QResizeEvent* ); + + void drawFrame( QPainter* ); + void drawContents( QPainter* ); + void paintEvent( QPaintEvent* ); + + void mousePressEvent( QMouseEvent* ); + void mouseDoubleClickEvent( QMouseEvent* ); +signals: + void popupMenu( KRecBufferWidget*, QPoint ); +private slots: + void initSamples(); + void changeTitle(); + void changeComment(); +private: + void initLayout(); + KRecBuffer *_buffer; + QRegion *_main_region, *_title_region, *_fileend_region; + QPoint _topleft, _bottomleft, _bottomright, _topright, _topmiddle, _bottommiddle; + int _title_height; + QValueList <Sample*> samples1, samples2; + uint alreadyreadsize; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecglobal.cpp b/krec/krecglobal.cpp new file mode 100644 index 00000000..94683995 --- /dev/null +++ b/krec/krecglobal.cpp @@ -0,0 +1,130 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecglobal.h" +#include "krecglobal.moc" + +#include "krecexport_template.h" + +#include <kconfig.h> +#include <qwidget.h> +#include <kapplication.h> +#include <kstatusbar.h> + +#include <ktrader.h> +#include <kparts/componentfactory.h> +#include <qvaluelist.h> +#include <kservice.h> + +#include <kdebug.h> + +KRecGlobal::KRecGlobal( QObject* p, const char* n ) + : QObject( p,n ) + , _qwidget( 0 ) + , _statusbar( 0 ) + , _timeformatcache( -1 ) + , _framebasecache( -1 ) +{ + //kdDebug( 60005 ) << k_funcinfo << endl; + _exports = new QDict<KRecExportItem>; +} +KRecGlobal::~KRecGlobal() { + //kdDebug( 60005 ) << k_funcinfo << endl; +} + +KRecGlobal* KRecGlobal::the() { + //kdDebug( 60005 ) << k_funcinfo << endl; + static KRecGlobal* object = new KRecGlobal(); + return object; +} + +void KRecGlobal::setMainWidget( QWidget* n ) { _qwidget = n; } +QWidget* KRecGlobal::mainWidget() { return _qwidget; } + +KConfig* KRecGlobal::kconfig() { return kapp->config(); } + +void KRecGlobal::setStatusBar( KStatusBar *bar ) { _statusbar = bar; } +void KRecGlobal::message( const QString &text ) { if ( _statusbar ) _statusbar->message( text, 2000 ); } + +bool KRecGlobal::registerExport( KRecExportItem* item ) { + //kdDebug( 60005 ) << k_funcinfo << "About to register ExportItem for \"" << item->exportFormat() << "\" extensions:\"" << item->extensions() << "\"" << endl; + if ( !the()->_exports->find( item->exportFormat() ) ) { + the()->_exports->insert( item->exportFormat(), item ); + the()->_exportformats << item->exportFormat(); + } + return true; +} + +KRecExportItem* KRecGlobal::getExportItem( const QString &exportFormat ) { + KRecExportItem *tmp = _exports->find( exportFormat ); + return tmp->newItem(); +} + +QStringList KRecGlobal::exportFormats() const { + return _exportformats; +} + +QString KRecGlobal::exportFormatEndings() const { + QString out; + + KTrader::OfferList offers = KTrader::self()->query( "KRec/exportplugin" ); + KTrader::OfferList::iterator it = offers.begin(); + while ( it!=offers.end() ) { + out += " *."; + out += ( *it )->property( "X-KDE-ExportSuffix" ).toStringList().join( " *." ); + ++it; + } + + return out; +} + +KRecExportItem* KRecGlobal::getExportItemForEnding( const QString &ending ) { + KTrader::OfferList offers = KTrader::self()->query( "KRec/exportplugin" ); + KTrader::OfferList::iterator it = offers.begin(); + while ( it!=offers.end() ) { + kdDebug(60005) << ( *it )->property( "X-KDE-ExportSuffix" ).toStringList() << endl; + if ( ( *it )->property( "X-KDE-ExportSuffix" ).toStringList().grep( ending ).count() ) { + kdDebug(60005) << "Ending(" << ending << ") found" << endl; + return KParts::ComponentFactory::createInstanceFromService<KRecExportItem>( ( *it ), this, "exportplugin" ); + } else kdDebug(60005) << "Doesn't contain " << ending << endl; + ++it; + } + return 0; +} + +int KRecGlobal::timeFormatMode() { + if ( _timeformatcache < 0 ) { + kapp->config()->setGroup( "General" ); + _timeformatcache = kapp->config()->readNumEntry( "TimeFormat", 0 ); + } + return _timeformatcache; +} +void KRecGlobal::setTimeFormatMode( int n ) { + kapp->config()->setGroup( "General" ); + kapp->config()->writeEntry( "TimeFormat", n ); + _timeformatcache = n; +} + +int KRecGlobal::frameBase() { + if ( _framebasecache < 0 ) { + kapp->config()->setGroup( "General" ); + _framebasecache = kapp->config()->readNumEntry( "FrameBase", 25 ); + } + return _framebasecache; +} +void KRecGlobal::setFrameBase( int n ) { + kapp->config()->setGroup( "General" ); + kapp->config()->writeEntry( "FrameBase", n ); + _framebasecache = n; +} + diff --git a/krec/krecglobal.h b/krec/krecglobal.h new file mode 100644 index 00000000..6955eb14 --- /dev/null +++ b/krec/krecglobal.h @@ -0,0 +1,97 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KREC_GLOBAL_H +#define KREC_GLOBAL_H + +#include <qobject.h> +#include <qstring.h> +#include <qstringlist.h> +#include <qdict.h> + +class KConfig; +class QWidget; +class KStatusBar; + +class KRecExportItem; + +class KRecGlobal : public QObject { + Q_OBJECT +private: + KRecGlobal( QObject* =0, const char* =0 ); + ~KRecGlobal(); + +public: + + /** + * @return Returns a pointer to the global KRecGlobal. + */ + static KRecGlobal* the(); + + /** + * Sets the MainWidget. + */ + void setMainWidget( QWidget* ); + /** + * Returns a pointer to the mainwidget. + * Usefull to display Messageboxes, etc correctly without beeing a + * QWidget or knowing about a parent QWidget. + */ + QWidget* mainWidget(); + + /// @return kapp->config() + static KConfig* kconfig(); + + /// Sets the Statusbar. + void setStatusBar( KStatusBar* ); + /** + * Puts a message into the statusbar. + * Usefull for showing messages without knowing about the Statusbar. + */ + void message( const QString & ); + + /// Registers a KRecExportItem + static bool registerExport( KRecExportItem* ); + /** + * Returns a new KRecExportItem for the specified exportFormat. + * If now Item can be found the return value is 0. + */ + KRecExportItem* getExportItem( const QString &exportFormat ); + /// + KRecExportItem* getExportItemForEnding( const QString & ); + /// Returns a list of exportFormats. + QStringList exportFormats() const; + /// Returns a list of fileendings. + QString exportFormatEndings() const; + + /** + * Gets/Sets the actual mode for formating time values. + * + * For description see krecfileview.h + */ + int timeFormatMode(); + void setTimeFormatMode( int ); + /// The framebase (how many frames per second) (25/30 for movies, 75 for CDs) + int frameBase(); + void setFrameBase( int ); +private: + QWidget *_qwidget; + KStatusBar *_statusbar; + QDict <KRecExportItem> *_exports; + QStringList _exportformats; + int _timeformatcache, _framebasecache; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecnewproperties.cpp b/krec/krecnewproperties.cpp new file mode 100644 index 00000000..b63cd032 --- /dev/null +++ b/krec/krecnewproperties.cpp @@ -0,0 +1,102 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecnewproperties.h" +#include "krecnewproperties.moc" + +#include "krecglobal.h" +#include "krecconfig_fileswidget.h" + +#include <kconfig.h> +#include <qbuttongroup.h> +#include <qvbuttongroup.h> +#include <qradiobutton.h> +#include <qlayout.h> +#include <kseparator.h> +#include <kpushbutton.h> +#include <kstdguiitem.h> +#include <qlabel.h> +#include <qhbox.h> +#include <qvbox.h> +#include <qfont.h> + +#include <kdebug.h> +#include <klocale.h> + +KRecNewProperties::KRecNewProperties( QWidget* p, const char* n ) + : QDialog( p,n, 0, Qt::WType_Dialog|Qt::WStyle_Customize|Qt::WStyle_DialogBorder ) + , _filename( QString::null ) + , _samplerate( 44100 ), _channels( 2 ), _bits( 16 ) +{ +kdDebug( 60005 ) << k_funcinfo << endl; + KConfig *config = KRecGlobal::kconfig(); + config->setGroup( "FileDefaults" ); + _samplerate = config->readNumEntry( "SamplingRate", 44100 ); + _channels = config->readNumEntry( "Channels", 2 ); + _bits = config->readNumEntry( "Bits", 16 ); + _usedefaults = config->readBoolEntry( "UseDefaults", false ); + + _layout = new QVBoxLayout( this, 5, 5 ); + + QLabel *captionlabel = new QLabel( this ); + QFont labelfont( captionlabel->font() ); + labelfont.setPointSize( labelfont.pointSize()*3/2 ); + captionlabel->setFont( labelfont ); + captionlabel->setText( i18n( "Properties for the new File" ) ); + captionlabel->setAlignment( AlignCenter ); + _layout->addWidget( captionlabel ); + + _filewidget = new KRecConfigFilesWidget( this ); + connect( _filewidget, SIGNAL( sRateChanged( int ) ), this, SLOT( ratechanged( int ) ) ); + connect( _filewidget, SIGNAL( sChannelsChanged( int ) ), this, SLOT( channelschanged( int ) ) ); + connect( _filewidget, SIGNAL( sBitsChanged( int ) ), this, SLOT( bitschanged( int ) ) ); + connect( _filewidget, SIGNAL( sUseDefaultsChanged( bool ) ), this, SLOT( usedefaultschanged( bool ) ) ); + + QWidget *_btnWidget = new QWidget( this ); + _layoutbuttons = new QHBoxLayout( _btnWidget ); + _layoutbuttons->addStretch( 100 ); + _btnok = new KPushButton( KStdGuiItem::ok(), _btnWidget ); + connect( _btnok, SIGNAL( clicked() ), this, SLOT( accept() ) ); + _layoutbuttons->addWidget( _btnok, 0 ); + + _layout->addWidget( new KSeparator( KSeparator::HLine, this ) ); + _layout->addWidget( _filewidget ); + _layout->addWidget( new KSeparator( KSeparator::HLine, this ) ); + _layout->addWidget( _btnWidget ); + + setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); +} +KRecNewProperties::~KRecNewProperties() { +kdDebug( 60005 ) << k_funcinfo << endl; +} + +QString KRecNewProperties::filename() { return _filename; } +int KRecNewProperties::samplerate() { return _samplerate; } +int KRecNewProperties::channels() { return _channels; } +int KRecNewProperties::bits() { return _bits; } +bool KRecNewProperties::usedefaults() { return _usedefaults; } + +void KRecNewProperties::ratechanged( int rate ) { _samplerate = rate; } +void KRecNewProperties::channelschanged( int channels ) { _channels = channels; } +void KRecNewProperties::bitschanged( int bits ) { _bits = bits; } +void KRecNewProperties::usedefaultschanged( bool n ) { + _usedefaults = n; + KRecGlobal::kconfig()->setGroup( "FileDefaults" ); + KRecGlobal::kconfig()->writeEntry( "UseDefaults", _usedefaults ); +} + +void KRecNewProperties::done( int r ) { +kdDebug( 60005 ) << k_funcinfo << endl; + QDialog::done( r ); +} + diff --git a/krec/krecnewproperties.h b/krec/krecnewproperties.h new file mode 100644 index 00000000..f398033b --- /dev/null +++ b/krec/krecnewproperties.h @@ -0,0 +1,60 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KREC_NEW_PROPERTIES_H +#define KREC_NEW_PROPERTIES_H + +#include <qdialog.h> + +class KConfig; +class QBoxLayout; +class QButtonGroup; +class QRadioButton; +class KPushButton; +class QHBox; +class QVBox; + +class KRecConfigFilesWidget; + +class KRecNewProperties : public QDialog { + Q_OBJECT +public: + KRecNewProperties( QWidget*, const char* =0 ); + ~KRecNewProperties(); + + QString filename(); + int samplerate(); + int channels(); + int bits(); + bool usedefaults(); + + void done( int ); +private slots: + void ratechanged( int ); + void channelschanged( int ); + void bitschanged( int ); + void usedefaultschanged( bool ); +private: + QString _filename; + KRecConfigFilesWidget *_filewidget; + + int _samplerate, _channels, _bits; + bool _usedefaults; + + QBoxLayout *_layout, *_layoutbuttons; + KPushButton *_btnok; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecord.cpp b/krec/krecord.cpp new file mode 100644 index 00000000..72fbde7c --- /dev/null +++ b/krec/krecord.cpp @@ -0,0 +1,407 @@ +/*************************************************************************** + begin : Mon Jun 17 2002 + copyright : (C) 2002 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecord.h" +#include "krecord_private.h" + +#include "artsactions.h" +// VolumeControl +#include "artsmoduleseffects.h" + +#include "krecfile.h" +#include "krecglobal.h" +#include "krecexport_template.h" + +#include <arts/kaudioplaystream.h> +#include <arts/kaudiorecordstream.h> +#include <kfiledialog.h> +#include <kmessagebox.h> +#include <klocale.h> +#include <kdebug.h> +#include <kapplication.h> +#include <kaction.h> +#include <kconfig.h> +#include <qlayout.h> +#include <qtimer.h> +#include <ksettings/dialog.h> +#include <ktip.h> + +KRecPrivate::KRecPrivate( KRecord* p, const char* n ) + : QObject( p,n ) + , _confdlg( 0 ) + , server( new KArtsServer( 0 ) ) + , dispatcher( new KArtsDispatcher( 0 ) ) + , m_playStream( new KAudioPlayStream( server, "KRec::Out", server ) ) + , m_recStream( new KAudioRecordStream( server, "KRec::In", server ) ) + , w( 0 ) + , b_arts( true ), b_comp( true ) + , _impl( p ) + , mainwidget( new KRecMainWidget( p ) ) + , _currentFile( 0 ) + , _exportitem( 0 ) +{ + //kdDebug( 60005 ) << k_funcinfo << endl; + m_recStream->usePolling( false ); + if( m_recStream->effectStack().isNull() ) + kdFatal() << "Couldn't get Object 'StereoEffectStack' from KAudioRecordStream!!!" << endl; + volumecontrol = Arts::DynamicCast( server->server().createObject( "Arts::StereoVolumeControl" ) ); + if( volumecontrol.isNull() ) + kdFatal()<<"Couldn't create Object 'StereoVolumeControl' !!!"<<endl; + comp = Arts::DynamicCast( server->server().createObject( "Arts::Synth_STEREO_COMPRESSOR" ) ); + if( comp.isNull() ) + b_comp = false; + + volumecontrol.start(); + if( b_comp ) comp.start(); + vc_id = m_recStream->effectStack().insertBottom( volumecontrol, "VolumeControl" ); + if( b_comp ) comp_id = m_recStream->effectStack().insertTop( comp, "Compressor" ); + + Arts::StereoVolumeControlGui gui = Arts::StereoVolumeControlGui( volumecontrol ); + gui.title( i18n( "Recording level" ).utf8().data() ); + mainwidget->_artswidget = gui; + mainwidget->_kaw_volumecontrol->setContent( mainwidget->_artswidget ); + +} + +KRecPrivate::~KRecPrivate() { + //kdDebug( 60005 ) << k_funcinfo << endl; + mainwidget->_artswidget = Arts::StereoVolumeControlGui::null(); + delete _currentFile; + _currentFile = 0; + //kdDebug( 60005 ) << k_funcinfo << "done." << endl; +} + +void KRecPrivate::showConfDialog() { + if ( !_confdlg ) + _confdlg = new KSettings::Dialog( _impl ); + _confdlg->show(); +} + +void KRecPrivate::newFile() { + //kdDebug( 60005 ) << k_funcinfo << endl; + if ( _currentFile ) closeFile(); + if ( !_currentFile ) { + pNewFile( new KRecFile( this ) ); + } +} +void KRecPrivate::openFile() { + //kdDebug( 60005 ) << k_funcinfo << endl; + if ( _currentFile ) closeFile(); + if ( !_currentFile ) { + QString filename = KFileDialog::getOpenFileName( "", "*.krec", _impl ); + //kdDebug( 60005 ) << k_funcinfo << filename << endl; + if ( !filename.isNull() ) + pNewFile( new KRecFile( filename, this ) ); + } +} +void KRecPrivate::pNewFile( KRecFile* file ) { + _currentFile = file; + connect( m_recStream, SIGNAL( data( QByteArray& ) ), _currentFile, SLOT( writeData( QByteArray& ) ) ); + connect( m_playStream, SIGNAL( requestData( QByteArray& ) ), _currentFile, SLOT( getData( QByteArray& ) ) ); + mainwidget->_fileview->setFile( _currentFile ); + checkActions(); +} + +void KRecPrivate::saveFile() { + //kdDebug( 60005 ) << k_funcinfo << endl; + if ( _currentFile ) pSaveFile( _currentFile->filename() ); +} +void KRecPrivate::saveAsFile() { + //kdDebug( 60005 ) << k_funcinfo << endl; + if ( _currentFile ) pSaveFile( QString::null ); +} +void KRecPrivate::pSaveFile( const QString &filename ) { + if ( !_currentFile ) + return; + + if ( !filename.isNull() ) + _currentFile->save( filename ); + else { + QString userFilename = KFileDialog::getSaveFileName( "", "*.krec", _impl, i18n( "Save File As" ) ); + if ( !userFilename.isNull() ) + _currentFile->save( userFilename ); + } +} + +bool KRecPrivate::closeFile() { + //kdDebug( 60005 ) << k_funcinfo << endl; + if ( _currentFile ) { + if ( !_currentFile->saved() ) { + int choice = KMessageBox::questionYesNoCancel( _impl, i18n( "The document \"%1\" has been modified.\nDo you want to save it?" ).arg( _currentFile->filename() ), QString::null, KStdGuiItem::save(), KStdGuiItem::discard() ); + if ( choice == KMessageBox::Yes ) saveFile(); + if ( choice == KMessageBox::Cancel ) return false; + // go on if KMessageBox::No + } + delete _currentFile; + _currentFile = 0; + mainwidget->_fileview->setFile( _currentFile ); + } + checkActions(); + return true; +} + +void KRecPrivate::exportFile() { + kdDebug( 60005 ) << k_funcinfo << endl; + if ( _currentFile ) { + QString filename = KFileDialog::getSaveFileName( "", KRecGlobal::the()->exportFormatEndings(), _impl, "Export File As" ); + if ( !filename.isNull() ) { + int lastdot = filename.find( '.', -5 ); + QString ending = filename.right( filename.length()-lastdot-1 ); + _exportitem = KRecGlobal::the()->getExportItemForEnding( ending ); + if ( _exportitem ) { + _exportitem->initialize( _currentFile->samplerate(), _currentFile->bits(), _currentFile->channels() ); + if ( _exportitem->initialize( filename ) ) { + connect( _exportitem, SIGNAL( getData( QByteArray& ) ), _currentFile, SLOT( getData( QByteArray& ) ) ); + connect( _currentFile, SIGNAL( endReached() ), _exportitem, SLOT( stop() ) ); + connect( _currentFile, SIGNAL( endReached() ), this, SLOT( endExportFile() ) ); + _exportitem->start(); + } + } else + KMessageBox::detailedSorry( _impl, + i18n( "Sorry, an encoding method could not be determined." ), + i18n( "<qt>This can have several reasons:<ul>" \ + "<li>You did not specify an ending.</li>" \ + "<li>You specified an ending but there is no plugin available " \ + "for this ending. In both cases be sure to choose an ending of " \ + "the list presented in the previous dialog.</li>" \ + "<li>The plugin loading mechanism isn't working. If you are sure " \ + "you did everything right, please file a bugreport saying what " \ + "you where about to do and please quote the following line:<br />" \ + "%1</li>" \ + "</ul></qt>" ).arg( KRecGlobal::the()->exportFormatEndings() ), + i18n( "Could not determine encodingmethod" ) ); + } + } else KRecGlobal::the()->message( i18n( "There is nothing to export." ) ); + checkActions(); +} +void KRecPrivate::endExportFile() { QTimer::singleShot( 20, this, SLOT( endExportFile2() ) ); } +void KRecPrivate::endExportFile2() { + _exportitem->finalize(); + disconnect( _currentFile, 0, _exportitem, 0 ); + disconnect( _exportitem, 0, 0, 0 ); + checkActions(); +} + +void KRecPrivate::playthru( bool yes ){ + kdDebug( 60005 ) << k_funcinfo << yes << endl; + if(yes) { + Arts::connect( m_recStream->effectStack(), m_playStream->effectStack() ); + kdDebug( 60005 ) << "Making a connection between recStream and playStream :-)" << endl; + } else { + Arts::disconnect( m_recStream->effectStack(), m_playStream->effectStack() ); + kdDebug( 60005 ) << "Disconnecting recStream and playStream :-(" << endl; + } +} + +void KRecPrivate::checkActions(){ + _impl->actionCollection()->action( "player_record" )->setEnabled( false ); + _impl->actionCollection()->action( "player_play" )->setEnabled( false ); + _impl->actionCollection()->action( "player_stop" )->setEnabled( false ); + _impl->actionCollection()->action( "player_gobegin" )->setEnabled( false ); + _impl->actionCollection()->action( "player_goend" )->setEnabled( false ); + _impl->actionCollection()->action( "export_file" )->setEnabled( false ); + _impl->actionCollection()->action( "file_save" )->setEnabled( false ); + _impl->actionCollection()->action( "file_save_as" )->setEnabled( false ); + _impl->actionCollection()->action( "file_close" )->setEnabled( false ); + if ( _currentFile ) { + if ( !_exportitem || ( _exportitem && !_exportitem->running() ) ) { + if ( !m_recStream->running() && !m_playStream->running() ) { + _impl->actionCollection()->action( "player_record" )->setEnabled( true ); + _impl->actionCollection()->action( "player_play" )->setEnabled( true ); + } + if ( m_playStream->running() || m_recStream->running() ) + _impl->actionCollection()->action( "player_stop" )->setEnabled( true ); + if ( _currentFile->position() != 0 ) + _impl->actionCollection()->action( "player_gobegin" )->setEnabled( true ); + if ( _currentFile->position() != _currentFile->size() ) + _impl->actionCollection()->action( "player_goend" )->setEnabled( true ); + } + _impl->actionCollection()->action( "export_file" )->setEnabled( true ); + _impl->actionCollection()->action( "file_close" )->setEnabled( true ); + //if ( !_currentFile->saved() ) { + _impl->actionCollection()->action( "file_save" )->setEnabled( true ); + _impl->actionCollection()->action( "file_save_as" )->setEnabled( true ); + //} + } +} + +void KRecPrivate::toBegin() { + if ( _currentFile ) + _currentFile->newPos( 0 ); + checkActions(); +} +void KRecPrivate::toEnd() { + if ( _currentFile ) + _currentFile->newPos( _currentFile->size() ); + checkActions(); +} + +void KRecPrivate::forceTipOfDay() { + KTipDialog::showTip( _impl, QString::null, true ); +} + +void KRecPrivate::execaRtsControl() { + kapp->kdeinitExec( "artscontrol" ); +} +void KRecPrivate::execKMix() { + kapp->kdeinitExec( "kmix" ); +} + +/** + + KRecord: + +*/ + +KRecord::KRecord(QWidget *parent, const char *name ) + : KMainWindow(parent,name) + , d( new KRecPrivate( this ) ) +{ + kdDebug( 60005 ) << k_funcinfo << endl; + //kdDebug( 60005 )<<"KRecord::KRecord( QWidget *"<<parent<<", const char* "<<name<<" )"<<endl; // (DEBUG) + + KRecGlobal::the()->setMainWidget( this ); + KRecGlobal::the()->setStatusBar( statusBar() ); + + // * * * Startup-Window * * * + KTipDialog::showTip( this ); + + // * * * Mainwidget * * * + setCentralWidget( d->mainwidget ); + + // * * * Actions * * * + d->artsactions = new ArtsActions( d->server, actionCollection(), this ); + + KStdAction::preferences( d, SLOT( showConfDialog() ), actionCollection() ); + + KStdAction::openNew( d, SLOT( newFile() ), actionCollection() ); + KStdAction::open( d, SLOT( openFile() ), actionCollection() ); + KStdAction::save( d, SLOT( saveFile() ), actionCollection() ); + KStdAction::saveAs( d, SLOT( saveAsFile() ), actionCollection() ); + KStdAction::close( d, SLOT( closeFile() ), actionCollection() ); + KStdAction::quit( this, SLOT( close() ), actionCollection() ); + + KStdAction::tipOfDay( d, SLOT( forceTipOfDay() ), actionCollection() ); + + d->aExportFile = new KAction( i18n( "Export..." ), KShortcut(), + d, SLOT( exportFile() ), actionCollection(), "export_file" ); + + d->aRecord = new KAction( i18n( "&Record" ), KShortcut( Key_R ), + this, SLOT( startRec() ), actionCollection(), "player_record" ); + d->aPlay = new KAction( i18n( "&Play" ), KShortcut( Key_P ), + this, SLOT( startPlay() ), actionCollection(), "player_play" ); + d->aStop = new KAction( i18n( "&Stop" ), KShortcut( Key_S ), + this, SLOT( stopRec() ), actionCollection(), "player_stop" ); + d->aThru = new KToggleAction( i18n( "Play Through" ), KShortcut( CTRL + Key_P), actionCollection(), "play_thru" ); + connect( d->aThru, SIGNAL( toggled( bool ) ), d, SLOT( playthru( bool ) ) ); + + d->aBegin = new KAction( i18n( "Go to &Beginning" ), KShortcut( SHIFT + Key_Left ), + d, SLOT( toBegin() ), actionCollection(), "player_gobegin" ); + d->aEnd = new KAction( i18n( "Go to &End" ), KShortcut( SHIFT + Key_Right ), + d, SLOT( toEnd() ), actionCollection(), "player_goend" ); + + ( void* ) d->artsactions->actionAudioManager(); + + d->aExecaRtsControl = new KAction( i18n( "Start aRts Control Tool" ), KShortcut(), + d, SLOT( execaRtsControl() ), actionCollection(), "exec_artscontrol" ); + d->aExecKMix = new KAction( i18n( "Start KMix" ), KShortcut(), + d, SLOT( execKMix() ), actionCollection(), "exec_kmix" ); + + // * * * GUI * * * + // TODO Fix toolbar config so this line can just be setupGUI() + setupGUI(KMainWindow::Keys | StatusBar | Save | Create ); + setStandardToolBarMenuEnabled( true ); + // TODO Fix the arts toolbar to know it own minium size, this app shouldn't care! + setMinimumWidth( 400 ); + + if( d->b_comp ) + { + Arts::GenericGuiFactory factory; + Arts::Widget aw = factory.createGui( d->comp ); + d->w = new KArtsWidget( aw, toolBar("compressor") ); + d->w->setName( "kde toolbar widget" ); + + toolBar( "compressor" )->insertWidget( 1, 400, d->w ); + toolBar( "compressor" )->setBarPos( KToolBar::Bottom ); + } + else + { + toolBar( "compressor" )->close(); + KMessageBox::detailedSorry( this, + i18n( "Your system is missing the Synth_STEREO_COMPRESSOR aRts module.\nYou will be able to use KRec but without the great functions of the compressor." ), + i18n( "Possible reasons are:\n- You installed KRec on its own without the rest of kdemultimedia.\n- You installed everything correctly, but did not restart the aRts daemon\n and therefore it is not aware of the new effects.\n- This is a bug." ), + i18n( "Unable to Find Compressor" ) ); + } + + d->checkActions(); +} + +KRecord::~KRecord(){ + kdDebug( 60005 ) << k_funcinfo << endl; // (DEBUG) + stopRec(); + + d->m_recStream->effectStack().remove( d->vc_id ); + if( d->b_comp ) d->m_recStream->effectStack().remove( d->comp_id ); + d->volumecontrol.stop(); + if( d->b_comp ) d->comp.stop(); + + d->volumecontrol = Arts::StereoVolumeControl::null(); + if( d->b_comp ) d->comp = Arts::StereoEffect::null(); + + KRecGlobal::kconfig()->sync(); + delete d; + kdDebug( 60005 ) << k_funcinfo << "done. Bye!" << endl; +} + +void KRecord::startRec(){ + if( !d->m_recStream->running() && d->_currentFile ) { + //kdDebug( 60005 )<<"KRecord::startRec()"<<endl; // (DEBUG) + d->_currentFile->newBuffer(); + d->m_recStream->start( d->_currentFile->samplerate(), + d->_currentFile->bits(), + d->_currentFile->channels() ); + } + d->checkActions(); + d->mainwidget->_fileview->updateGUI(); +} + +void KRecord::startPlay(){ + if ( !d->m_playStream->running() && d->_currentFile ) { + d->m_playStream->start( d->_currentFile->samplerate(), + d->_currentFile->bits(), + d->_currentFile->channels() ); + } + d->checkActions(); + d->mainwidget->_fileview->updateGUI(); +} + +void KRecord::stopRec(){ + if ( d->m_recStream->running() ) + d->m_recStream->stop(); + if ( d->m_playStream->running() ) + d->m_playStream->stop(); + d->checkActions(); + d->mainwidget->_fileview->updateGUI(); +} + + +bool KRecord::queryClose() { + kdDebug( 60005 ) << k_funcinfo << endl; + return d->closeFile(); +} + +#include "krecord.moc" +#include "krecord_private.moc" + +// vim:sw=4:ts=4 diff --git a/krec/krecord.h b/krec/krecord.h new file mode 100644 index 00000000..3e127cc4 --- /dev/null +++ b/krec/krecord.h @@ -0,0 +1,60 @@ +/*************************************************************************** + begin : Mon Jun 17 2002 + copyright : (C) 2002 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KRECORD_H +#define KRECORD_H + +#include <kmainwindow.h> + +class KRecPrivate; + +/// KDE Recording GUI. + +/** + Presents a GUI for Recording. + + Supports various takes, Play-Thru and Playing of previous takes. + + @author Arnold Krille + */ + +class KRecord : public KMainWindow { + Q_OBJECT +public: + /// Constructor + KRecord( QWidget* /*parent*/=0, const char* /*name*/=0 ); + /// Destructor + ~KRecord(); +public slots: + /// Does nothing. + void nothing() { } + /// Starts Recording. + void startRec(); + /// Starts Playback. + void startPlay(); + /// Stops Recording. + void stopRec(); + +protected slots: + /// Checks all the Actions and sets Enabled/Disabled. + //void checkActions(); +protected: + bool queryClose(); +private: + KRecPrivate *d; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecord_private.h b/krec/krecord_private.h new file mode 100644 index 00000000..8c157f41 --- /dev/null +++ b/krec/krecord_private.h @@ -0,0 +1,148 @@ +/*************************************************************************** + begin : Mon Jun 17 2002 + copyright : (C) 2002 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KRECORD_PRIVATE_H +#define KRECORD_PRIVATE_H + +#include <qobject.h> + +#include <kartsserver.h> +#include <kartsdispatcher.h> +#include <artsflow.h> +#include <artsgui.h> +#include <kartswidget.h> +#include <kurl.h> +#include <qlayout.h> + +#include "krecfileview.h" + +class KRecord; +class KRecMainWidget; +class KRecFile; +class KRecExportItem; + +class KAudioRecordStream; +class KAudioPlayStream; +class KConfig; +class ArtsActions; +class KAction; +class KActionMenu; +class KToggleAction; +class KRecentFilesAction; + +namespace KSettings { class Dialog; } + +class KRecPrivate : public QObject { + Q_OBJECT +public: + /// Constructor + KRecPrivate( KRecord*, const char* =0 ); + /// Destructor + ~KRecPrivate(); +public slots: +/* /// Does nothing. + void nothing() { } + /// Starts Recording. + void startRec(); + /// Starts Playback. + void startPlay(); + /// ByteStreamSender informs of his playing. + void playIsRunning() { playing=true; checkActions(); } + /// ByteStreamSender informs of his playing. + void playStops() { playing=false; checkActions(); } + /// Stops Recording. + void stopRec(); + + /// If we can play or not. + void canPlay( bool b ) { _canplay = b; checkActions(); } + /// If we can record or not. + void canRecord( bool b ) { _canrecord = b; checkActions(); } +*/ + +// void startUpWindow( bool on ); + + void showConfDialog(); + + /// Checks all the Actions and sets Enabled/Disabled. + void checkActions(); + + /// Enables Play-thru from the AMAN_RECORD to the AMAN_PLAY. + void playthru( bool ); + + void newFile(); + void openFile(); + void saveFile(); + void saveAsFile(); + bool closeFile(); + void exportFile(); + void endExportFile(); + void endExportFile2(); + + void toBegin(); + void toEnd(); + + void forceTipOfDay(); + void execaRtsControl(); + void execKMix(); +private: + void pNewFile( KRecFile* ); + void pSaveFile( const QString &); +public: + KAction *aRecord, *aPlay, *aStop, *aExportFile; + KAction *aBegin, *aEnd; + KToggleAction *aThru, *aStartUpWindow; + KAction *aExecaRtsControl, *aExecKMix; + + KSettings::Dialog *_confdlg; + + KArtsServer *server; + KArtsDispatcher *dispatcher; + KAudioPlayStream *m_playStream; + KAudioRecordStream * m_recStream; + + Arts::StereoVolumeControl volumecontrol; + Arts::StereoEffect comp; + KArtsWidget *w; + long vc_id, comp_id; + ArtsActions *artsactions; + + bool b_arts, b_comp; + + KRecord *_impl; + KRecMainWidget *mainwidget; + + KRecFile *_currentFile; + + KRecExportItem *_exportitem; +}; + +class KRecMainWidget : public QWidget { + Q_OBJECT +public: + KRecMainWidget( QWidget* p, const char* n=0 ) : QWidget( p,n ) { + _layout = new QBoxLayout( this, QBoxLayout::LeftToRight, 2 ); + _kaw_volumecontrol = new KArtsWidget( this ); + _layout->addWidget( _kaw_volumecontrol, 0 ); + _fileview = new KRecFileView( this ); + _layout->addWidget( _fileview, 500 ); + } + QBoxLayout *_layout; + KArtsWidget *_kaw_volumecontrol; + Arts::Widget _artswidget; + KRecFileView *_fileview; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/krecui.rc b/krec/krecui.rc new file mode 100644 index 00000000..169670bd --- /dev/null +++ b/krec/krecui.rc @@ -0,0 +1,57 @@ +<!DOCTYPE kpartgui ><kpartgui name="krec" version="1"> +<MenuBar> + <Menu name="file"> + <Action name="export_file" /> + <Separator /> + </Menu> + <Menu name="play"> + <text>&Play</text> + <Action name="player_play" /> + <Action name="player_record" /> + <Action name="player_stop" /> + <Separator /> + <Action name="player_gobegin" /> + <Action name="player_goend" /> + <Separator /> + <Action name="play_thru" /> + </Menu> + <Menu name="tools"> + <Action name="artssupport_view_audiomanager" /> + <Separator /> + <Action name="exec_artscontrol" /> + <Action name="exec_kmix" /> + </Menu> + <Menu name="settings"> + </Menu> +</MenuBar> +<ToolBar name="mainToolBar"> + <text>Main Toolbar</text> + <Action name="file_save_as" /> + <Action name="export_file" /> + <Separator /> + <Action name="file_close" /> +</ToolBar> +<ToolBar name="play"> + <text>Play</text> + <Action name="player_play" /> + <Action name="player_record" /> + <Action name="player_stop" /> + <Action name="player_gobegin" /> + <Action name="player_goend" /> +</ToolBar> +<ToolBar name="compressor"> + <text>Compressor</text> +</ToolBar> +<ActionProperties> + <Action name="export_file" icon="fileexport" /> + <Action name="player_play" icon="player_play" /> + <Action name="player_record" icon="krec_record" /> + <Action name="player_stop" icon="player_stop" /> + <Action name="play_thru" icon="kmix" /> + <Action name="player_gobegin" icon="player_start" /> + <Action name="player_goend" icon="player_end" /> + <Action name="settings_startup" icon="wizard" /> + <Action name="exec_artscontrol" icon="artscontrol" /> + <Action name="exec_kmix" icon="kmix" /> +</ActionProperties> +</kpartgui> diff --git a/krec/main.cpp b/krec/main.cpp new file mode 100644 index 00000000..6e752817 --- /dev/null +++ b/krec/main.cpp @@ -0,0 +1,68 @@ +/*************************************************************************** + begin : Mon Jun 17 2002 + copyright : (C) 2002 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +// Should stay here because I use it for Start-/Stop-Info (see below) +//#include <iostream> + +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kaboutdata.h> +#include <klocale.h> + +#include "krecord.h" + +#include <qobject.h> + +using namespace std; + +static const char description[] = + I18N_NOOP("\ +This is a recording tool for KDE.\n\ +It uses aRts, just look at the audiomanager\n\ +and you will find it there accepting sound\n\ +for recording." + ); + +static KCmdLineOptions options[] = +{ + KCmdLineLastOption + // INSERT YOUR COMMANDLINE OPTIONS HERE +}; + +extern "C" KDE_EXPORT int kdemain( int argc, char* argv[] ) +{ + //cout<<endl<<"Starting kRec..."<<endl; + + KAboutData aboutData( "krec", I18N_NOOP("KRec"), + "0.5.1", description, KAboutData::License_GPL, + "(c) 2002, 2003 Arnold Krille" ); + aboutData.addAuthor("Arnold Krille", I18N_NOOP( "Creator \nLook at the website www.arnoldarts.de \nfor other good stuff." ), "arnold@arnoldarts.de"); + aboutData.addCredit( "Matthias Kretz", I18N_NOOP( "Helped where he was asked" ), "kretz@kde.org" ); + aboutData.addCredit( "Stefan Asserhaell", I18N_NOOP( "Made some minor improvements" ) ); + aboutData.addCredit( "Stefan Asserhaell & Nikolas Zimmermann", I18N_NOOP( "They indirectly wrote the exports. At least I learned from their files and patches." ) ); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. + + KApplication app; + KRecord *w = new KRecord(); + w->show(); + app.setMainWidget(w); + + int quit = app.exec(); + //cout<<"Quitting with "<<quit<<endl; + return quit; +} + +// vim:sw=4:ts=4 + diff --git a/krec/mp3_export/Makefile.am b/krec/mp3_export/Makefile.am new file mode 100644 index 00000000..191d7db3 --- /dev/null +++ b/krec/mp3_export/Makefile.am @@ -0,0 +1,22 @@ + +INCLUDES= \ + -I$(top_builddir)/arts/gui/common \ + -I$(top_builddir)/arts/midi \ + -I$(top_builddir)/arts/modules/common \ + -I$(top_builddir)/arts/modules/synth \ + -I$(top_builddir)/arts/modules/effects \ + -I$(top_srcdir)/arts/gui/kde \ + -I$(top_srcdir)/arts/tools \ + -I$(top_srcdir)/krec \ + -I$(arts_includes) $(all_includes) + +METASOURCES = AUTO + +kde_module_LTLIBRARIES = libkrecexport_mp3.la + +libkrecexport_mp3_la_SOURCES = krecexport_mp3.cpp +libkrecexport_mp3_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(KDE_RPATH) +libkrecexport_mp3_la_LIBADD = ../lib_krec_common.la $(LAME_LIBS) + +kde_services_DATA = krec_exportmp3.desktop + diff --git a/krec/mp3_export/krec_exportmp3.desktop b/krec/mp3_export/krec_exportmp3.desktop new file mode 100644 index 00000000..18d097c5 --- /dev/null +++ b/krec/mp3_export/krec_exportmp3.desktop @@ -0,0 +1,59 @@ +[Desktop Entry] +Type=Service +Name=MP3-Export +Name[bg]=Експортиране в MP3 +Name[bn]=এম-পি-৩ রপ্তানি +Name[br]=Ezporzh MP3 +Name[ca]=Exportació MP3 +Name[cs]=Export do MP3 +Name[cy]=Allforio MP3 +Name[da]=MP3-Eksport +Name[el]=Εξαγωγή MP3 +Name[eo]=MP3-Eksporto +Name[es]=Exportador de MP3 +Name[et]=MP3-eksport +Name[eu]=MP3-esportazioa +Name[fa]=صادرات MP3 +Name[fi]=MP3-vienti +Name[fr]=Exportation en MP3 +Name[ga]=Easpórtáil MP3 +Name[gl]=Exportación a MP3 +Name[he]=יצוא MP3 +Name[hi]=MP3-निर्यात +Name[hu]=Exportálás - MP3 +Name[is]=MP3 útflutningur +Name[it]=Esporta-MP3 +Name[ja]=MP3 エクスポート +Name[kk]=MP3-экспорттау +Name[km]=នាំចេញ-MP3 +Name[ko]=MP3 추출 +Name[lt]=MP3 eksportas +Name[mk]=MP3-изнесување +Name[nb]=MP3-eksport +Name[ne]=MP3-निर्यात +Name[nl]=MP3-export +Name[nn]=MP3-eksport +Name[pa]=MP3-ਨਿਰਯਾਤ +Name[pl]=Eksport MP3 +Name[pt]=Exportação de MP3 +Name[pt_BR]=Exportar-MP3 +Name[ro]=Exportare MP3 +Name[ru]=Экспорт в mp3 +Name[sk]=Export do MP3 +Name[sl]=Izvoz v MP3 +Name[sr]=Извоз у MP3 +Name[sr@Latn]=Izvoz u MP3 +Name[sv]=MP3-export +Name[ta]=MP3-ஏற்றுமதி +Name[tg]=Содироти MP3 +Name[th]=ส่งออกเป็น MP3 +Name[tr]=MP3 Aktarımı +Name[uk]=Експорт MP3 +Name[uz]=MP3 eksport +Name[uz@cyrillic]=MP3 экспорт +Name[zh_CN]=MP3-导出 +Name[zh_HK]=MP3-匯出 +Name[zh_TW]=MP3 匯出 +X-KDE-Library=libkrecexport_mp3 +ServiceTypes=KRec/exportplugin +X-KDE-ExportSuffix=mp3,MP3 diff --git a/krec/mp3_export/krecexport_mp3.cpp b/krec/mp3_export/krecexport_mp3.cpp new file mode 100644 index 00000000..85418688 --- /dev/null +++ b/krec/mp3_export/krecexport_mp3.cpp @@ -0,0 +1,234 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include "krecexport_mp3.h" +#include "krecexport_mp3.moc" + +#include "krecglobal.h" + +#include <kdebug.h> +#include <ktempfile.h> +#include <qfile.h> +#include <qtimer.h> +#include <kgenericfactory.h> +#include <stdlib.h> +#include <time.h> +#include <qdatetime.h> +#include <kmessagebox.h> +#include <kconfig.h> +#include <kmessagebox.h> + +// Error code definitions from lame.h +static const char *lame_error[] = +{ + I18N_NOOP( "Unknown encoding error." ), + I18N_NOOP( "Buffer was too small." ), + I18N_NOOP( "Memory allocation problem." ), + I18N_NOOP( "Parameter initialisation not performed." ), + I18N_NOOP( "Psycho acoustic problems." ), + I18N_NOOP( "OGG cleanup encoding error." ), + I18N_NOOP( "OGG frame encoding error" ) +}; + +K_EXPORT_COMPONENT_FACTORY( libkrecexport_mp3, KGenericFactory<KRecExport_MP3> ) + +KRecExport_MP3 krecExportMP3( 0 ); + +KRecExport_MP3::KRecExport_MP3( QObject* p, const char* n, const QStringList& ) + : KRecExportItem( p,n ) + , _file( 0 ) + , error_occurred( false ) + , init_done( false ) +{ +kdDebug( 60005 ) << k_funcinfo << endl; + registerAtGlobal( this ); +kdDebug( 60005 ) << "Registered Exports: " << KRecGlobal::the()->exportFormats() << endl; +} +KRecExport_MP3::~KRecExport_MP3() { +kdDebug( 60005 ) << k_funcinfo << endl; +} + +KRecExport_MP3* KRecExport_MP3::newItem() { +kdDebug( 60005 ) << k_funcinfo << endl; + return new KRecExport_MP3( 0 ); +} + +QStringList KRecExport_MP3::extensions() { + //kdDebug( 60005 ) << k_funcinfo << endl; + QStringList tmp; + tmp << "*.wav" << "*.WAV"; + return tmp; +} + +bool KRecExport_MP3::initialize( const QString &filename ) { +kdDebug( 60005 ) << k_funcinfo << endl; + if ( !_file && + !( bits()!=16 && channels()!=2 && + KMessageBox::warningContinueCancel( KRecGlobal::the()->mainWidget(), + i18n( "At this time MP3-Export only supports files in stereo and 16bit." ) + ) == KMessageBox::Cancel + ) + ) { + KMessageBox::information( KRecGlobal::the()->mainWidget(), + i18n( "Please note that this plugin takes its qualitysettings from" \ + " the corresponding section of the Audio CDs Control Center module" \ + " configuration. Make use" \ + " of the Control Center to configure these settings." ), + i18n( "Quality Configuration" ), "qualityinfo_mp3" ); + _file = new QFile( filename ); + if ( _file->open( IO_Raw|IO_WriteOnly ) ) { + if ( ! init_done ) { + gfp = lame_init(); + setLameParameters(); + if ( write_id3 ) { + id3tag_init( gfp ); + id3tag_v1_only ( gfp ); + id3tag_set_album ( gfp, "" ); + id3tag_set_artist ( gfp, "" ); + id3tag_set_title ( gfp, "" ); + id3tag_set_comment( gfp, "krec" ); + } + /// Set input parameters right + lame_set_in_samplerate( gfp, this->samplingRate() ); + lame_set_num_channels( gfp, this->channels() ); + lame_init_params( gfp ); + } + if ( _file->size() >= 128 ) + _file->at( _file->size() - 128 ); + else + _file->at( _file->size() ); + } else return false; + return true; + } else return false; +} +bool KRecExport_MP3::process() { + //kdDebug( 60005 ) << k_funcinfo << running << endl; + if ( _file ) { + if ( running() ) { + QByteArray bytearray( 4096 ); + emit getData( bytearray ); + int mp3bytes = lame_encode_buffer_interleaved( gfp, + reinterpret_cast<short int *>( bytearray.data() ), + bytearray.size() >> 2, mp3buf, sizeof( mp3buf ) ); + if ( mp3bytes > 0 ) + _file->writeBlock( reinterpret_cast<char *>( mp3buf ), mp3bytes ); + if ( mp3bytes < 0 && ! error_occurred ) { + int code = ( mp3bytes < -6 ) ? 0 : -mp3bytes; + KMessageBox::detailedError( 0, i18n( "MP3 encoding error." ), + i18n( lame_error[ code ] ) ); + error_occurred = true; + } + QTimer::singleShot( 10, this, SLOT( process() ) ); + } + return true; + } else return false; +} +bool KRecExport_MP3::finalize() { +kdDebug( 60005 ) << k_funcinfo << endl; + if ( _file ) { + int mp3bytes = lame_encode_flush( gfp, mp3buf, sizeof( mp3buf ) ); + if ( mp3bytes > 0 ) + _file->writeBlock( reinterpret_cast<char *>( mp3buf ), mp3bytes ); + if ( mp3bytes < 0 && ! error_occurred ) { + int code = ( mp3bytes < -6 ) ? 0 : -mp3bytes; + KMessageBox::detailedError( 0, i18n( "MP3 encoding error." ), + i18n( lame_error[ code ] ) ); + error_occurred = true; + } + lame_close( gfp ); + + _file->close(); + delete _file; + _file = 0; + + return true; + } else return false; +} + +// Derived from kdemultimedia/kioslave/audiocd/audiocd.cpp. +// We use the encoding settings from kcmaudiocd. +void KRecExport_MP3::setLameParameters() { + KConfig *config; + config = new KConfig( "kcmaudiocdrc" ); + + config->setGroup( "MP3" ); + + int quality = config->readNumEntry( "quality",2 ); + + if ( quality < 0 ) quality = 0; + if ( quality > 9 ) quality = 9; + + int method = config->readNumEntry( "encmethod",0 ); + if ( method == 0 ) { + // Constant Bitrate Encoding + lame_set_VBR( gfp, vbr_off ); + lame_set_brate( gfp,config->readNumEntry( "cbrbitrate",160 ) ); + lame_set_quality( gfp, quality ); + } else { + // Variable Bitrate Encoding + if ( config->readBoolEntry( "set_vbr_avr",true ) ) { + lame_set_VBR( gfp,vbr_abr ); + lame_set_VBR_mean_bitrate_kbps( gfp, + config->readNumEntry( "vbr_average_bitrate",0 ) ); + } else { + if ( lame_get_VBR( gfp ) == vbr_off ) lame_set_VBR( gfp, vbr_default ); + if ( config->readBoolEntry( "set_vbr_min",true ) ) + lame_set_VBR_min_bitrate_kbps( gfp, + config->readNumEntry( "vbr_min_bitrate",0 ) ); + if ( config->readBoolEntry( "vbr_min_hard",true ) ) + lame_set_VBR_hard_min( gfp, 1 ); + if ( config->readBoolEntry( "set_vbr_max",true ) ) + lame_set_VBR_max_bitrate_kbps( gfp, + config->readNumEntry( "vbr_max_bitrate",0 ) ); + lame_set_VBR_q( gfp, quality ); + } + + if ( config->readBoolEntry( "write_xing_tag",true ) ) + lame_set_bWriteVbrTag( gfp, 1 ); + } + + switch ( config->readNumEntry( "mode",0 ) ) { + case 0: lame_set_mode( gfp, STEREO ); break; + case 1: lame_set_mode( gfp, JOINT_STEREO ); break; + case 2: lame_set_mode( gfp, DUAL_CHANNEL ); break; + case 3: lame_set_mode( gfp, MONO ); break; + default: lame_set_mode( gfp,STEREO ); break; + } + + lame_set_copyright( gfp, config->readBoolEntry( "copyright",false ) ); + lame_set_original( gfp, config->readBoolEntry( "original",true ) ); + lame_set_strict_ISO( gfp, config->readBoolEntry( "iso",false ) ); + lame_set_error_protection( gfp, config->readBoolEntry( "crc",false ) ); + + write_id3 = config->readBoolEntry( "id3",true ); + + if ( config->readBoolEntry( "enable_lowpassfilter",false ) ) { + lame_set_lowpassfreq( gfp, + config->readNumEntry( "lowpassfilter_freq",0 ) ); + if ( config->readBoolEntry( "set_lowpassfilter_width",false ) ) + lame_set_lowpasswidth( gfp, + config->readNumEntry( "lowpassfilter_width",0 ) ); + } + + if ( config->readBoolEntry( "enable_highpassfilter",false ) ) { + lame_set_highpassfreq( gfp, + config->readNumEntry( "highpassfilter_freq",0 ) ); + if ( config->readBoolEntry( "set_highpassfilter_width",false ) ) + lame_set_highpasswidth( gfp, + config->readNumEntry( "highpassfilter_width",0 ) ); + } + + delete config; +} + +// vim:sw=4:ts=4 diff --git a/krec/mp3_export/krecexport_mp3.h b/krec/mp3_export/krecexport_mp3.h new file mode 100644 index 00000000..8bf243b3 --- /dev/null +++ b/krec/mp3_export/krecexport_mp3.h @@ -0,0 +1,52 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KREC_EXPORT_MP3_H +#define KREC_EXPORT_MP3_H + +#include "krecexport_template.h" + +#include <lame/lame.h> + +class KTempFile; +class QFile; + +class KRecExport_MP3 : public KRecExportItem { + Q_OBJECT +public: + KRecExport_MP3( QObject*, const char* =0, const QStringList& =0 ); + ~KRecExport_MP3(); + + KRecExport_MP3* newItem(); + + QStringList extensions(); + QString exportFormat() { return QString( "Wave" ); } +public slots: + bool initialize( const QString & ); + bool process(); + bool finalize(); + +private: + QFile* _file; + // Lame MP3 encoder + void setLameParameters(); + lame_global_flags *gfp; + unsigned char mp3buf[ LAME_MAXMP3BUFFER ]; + bool error_occurred; + bool write_id3; + bool init_done; +}; + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/ogg_export/Makefile.am b/krec/ogg_export/Makefile.am new file mode 100644 index 00000000..a54940c7 --- /dev/null +++ b/krec/ogg_export/Makefile.am @@ -0,0 +1,22 @@ + +INCLUDES= \ + -I$(top_builddir)/arts/gui/common \ + -I$(top_builddir)/arts/midi \ + -I$(top_builddir)/arts/modules/common \ + -I$(top_builddir)/arts/modules/synth \ + -I$(top_builddir)/arts/modules/effects \ + -I$(top_srcdir)/arts/gui/kde \ + -I$(top_srcdir)/arts/tools \ + -I$(top_srcdir)/krec \ + -I$(arts_includes) $(all_includes) + +METASOURCES = AUTO + +kde_module_LTLIBRARIES = libkrecexport_ogg.la + +libkrecexport_ogg_la_SOURCES = krecexport_ogg.cpp +libkrecexport_ogg_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(KDE_RPATH) +libkrecexport_ogg_la_LIBADD = ../lib_krec_common.la $(VORBISENC_LIBS) $(VORBIS_LIBS) + +kde_services_DATA = krec_exportogg.desktop + diff --git a/krec/ogg_export/krec_exportogg.desktop b/krec/ogg_export/krec_exportogg.desktop new file mode 100644 index 00000000..5c2baf90 --- /dev/null +++ b/krec/ogg_export/krec_exportogg.desktop @@ -0,0 +1,60 @@ +[Desktop Entry] +Type=Service +Name=OGG-Export +Name[bg]=Експортиране в OGG +Name[bn]=অগ-রপ্তানি +Name[br]=Ezporzh OGG +Name[ca]=Exportació OGG +Name[cs]=Export do OGG +Name[cy]=Allforio OGG +Name[da]=OGG-Eksport +Name[el]=Εξαγωγή OGG +Name[eo]=OGG-Eksporto +Name[es]=Exportador de OGG +Name[et]=OGG-eksport +Name[eu]=OGG-esportazioa +Name[fa]=صادرات OGG +Name[fi]=OGG-vienti +Name[fr]=Exportation en OGG +Name[ga]=Easpórtáil OGG +Name[gl]=Exportación a OGG +Name[he]=יצוא OGG +Name[hi]=OGG-निर्यात +Name[hu]=Exportálás - OGG +Name[is]=OGG útflutningur +Name[it]=Esporta-OGG +Name[ja]=OGG エクスポート +Name[kk]=OGG-экспорттау +Name[km]=នាំចេញ-OGG +Name[ko]=OGG 추출 +Name[lt]=OGG eksportavimas +Name[mk]=OGG-изнесување +Name[nb]=OGG-eksport +Name[nds]=Ogg-Export +Name[ne]=OGG-निर्यात +Name[nl]=OGG-export +Name[nn]=OGG-eksport +Name[pa]=OGG-ਨਿਰਯਾਤ +Name[pl]=Eksport OGG +Name[pt]=Exportação de OGG +Name[pt_BR]=Exportar-OGG +Name[ro]=Exportare OGG +Name[ru]=Экспорт в ogg +Name[sk]=Export do OGG +Name[sl]=Izvoz v OGG +Name[sr]=Извоз у OGG +Name[sr@Latn]=Izvoz u OGG +Name[sv]=Ogg-export +Name[ta]=OGG-ஏற்றுமதி +Name[tg]=Содироти OGG +Name[th]=ส่งออกเป็น OGG +Name[tr]=OGG Aktarımı +Name[uk]=Експорт OGG +Name[uz]=OGG eksport +Name[uz@cyrillic]=OGG экспорт +Name[zh_CN]=OGG 导出 +Name[zh_HK]=OGG-匯出 +Name[zh_TW]=OGG 匯出 +X-KDE-Library=libkrecexport_ogg +ServiceTypes=KRec/exportplugin +X-KDE-ExportSuffix=ogg,OGG diff --git a/krec/ogg_export/krecexport_ogg.cpp b/krec/ogg_export/krecexport_ogg.cpp new file mode 100644 index 00000000..6a5d5735 --- /dev/null +++ b/krec/ogg_export/krecexport_ogg.cpp @@ -0,0 +1,254 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#include <config.h> + +#ifdef HAVE_VORBIS + +#include "krecexport_ogg.h" +#include "krecexport_ogg.moc" + +#include "krecglobal.h" + +#include <kdebug.h> +#include <ktempfile.h> +#include <qfile.h> +#include <qtimer.h> +#include <kconfig.h> +#include <stdlib.h> +#include <time.h> +#include <qdatetime.h> +#include <kgenericfactory.h> +#include <klocale.h> +#include <kmessagebox.h> + +K_EXPORT_COMPONENT_FACTORY( libkrecexport_ogg, KGenericFactory<KRecExport_OGG> ) + +KRecExport_OGG krecExportOGG( 0 ); + +KRecExport_OGG::KRecExport_OGG( QObject* p, const char* n, const QStringList& ) + : KRecExportItem( p,n ) + , _file( 0 ) + , init_done( false ) +{ +kdDebug( 60005 ) << k_funcinfo << endl; + registerAtGlobal( this ); +kdDebug( 60005 ) << "Registered Exports: " << KRecGlobal::the()->exportFormats() << endl; +} +KRecExport_OGG::~KRecExport_OGG() { +kdDebug( 60005 ) << k_funcinfo << endl; +} + +KRecExport_OGG* KRecExport_OGG::newItem() { +kdDebug( 60005 ) << k_funcinfo << endl; + return new KRecExport_OGG( 0 ); +} + +QStringList KRecExport_OGG::extensions() { + //kdDebug( 60005 ) << k_funcinfo << endl; + QStringList tmp; + tmp << "*.ogg" << "*.OGG"; + return tmp; +} + +bool KRecExport_OGG::initialize( const QString &filename ) { +kdDebug( 60005 ) << k_funcinfo << endl; + if ( !_file && + !( samplingRate()!=44100 && bits()!=16 && channels()!=2 && + KMessageBox::warningContinueCancel( KRecGlobal::the()->mainWidget(), + i18n( "At this time OGG-export only supports files in 44kHz " \ + "samplingrate, 16bit and 2 channels." ) + ) == KMessageBox::Cancel + ) + ) { + KMessageBox::information( KRecGlobal::the()->mainWidget(), + i18n( "Please note that this plugin takes its qualitysettings from" \ + " the corresponding section of the audiocd:/ configuration. Make use" \ + " of the Control Center to configure these settings." ), + i18n( "Quality Configuration" ), "qualityinfo_ogg" ); + _file = new QFile( filename ); + if ( _file->open( IO_Raw|IO_WriteOnly ) ) { + if ( ! init_done ) { + setOggParameters(); + vorbis_analysis_init( &vd, &vi ); + vorbis_block_init( &vd, &vb ); + + srand( time( NULL ) ); + ogg_stream_init( &os, rand() ); + } + if ( _file->size() == 0 ) { + ogg_packet header; + ogg_packet header_comm; + ogg_packet header_code; + + vorbis_comment_init( &vc ); + vorbis_comment_add_tag ( &vc, const_cast<char *>( "kde-encoder" ), + const_cast<char *>( "KRec" ) ); + if ( write_vorbis_comments ) { + QDateTime dt = QDateTime::currentDateTime(); + vorbis_comment_add_tag ( &vc, const_cast<char *>( "title" ), + const_cast<char *>( "" ) ); + vorbis_comment_add_tag ( &vc, const_cast<char *>( "artist" ), + const_cast<char *>( "" ) ); + vorbis_comment_add_tag ( &vc, const_cast<char *>( "album" ), + const_cast<char *>( "" ) ); + vorbis_comment_add_tag ( &vc, const_cast<char *>( "genre" ), + const_cast<char *>( "" ) ); + vorbis_comment_add_tag ( &vc, const_cast<char *>( "tracknumber" ), + const_cast<char *>( "" ) ); + vorbis_comment_add_tag ( &vc, const_cast<char *>( "date" ), + const_cast<char *>( dt.toString( "yyyy-MM-dd hh:mm:ss" ).utf8().data() ) ); + } + vorbis_analysis_headerout( &vd, &vc, &header, &header_comm, &header_code ); + + ogg_stream_packetin( &os, &header ); + ogg_stream_packetin( &os, &header_comm ); + ogg_stream_packetin( &os, &header_code ); + + while ( ogg_stream_flush( &os, &og ) ) { + //kdDebug( 60005 ) << "Writing Ogg/Vorbis Header." << endl; + _file->writeBlock( reinterpret_cast<char *>( og.header ), og.header_len ); + _file->writeBlock( reinterpret_cast<char *>( og.body ), og.body_len ); + } + } else + _file->at( _file->size() ); + init_done = true; + } else return false; + return true; + } + return false; +} +bool KRecExport_OGG::process() { + //kdDebug( 60005 ) << k_funcinfo << endl; + if ( _file ) { + if ( running() ) { + QByteArray bytearray( 4096 ); + emit getData( bytearray ); + float **buffer = vorbis_analysis_buffer( &vd, bytearray.size() >> 2 ); + + // uninterleave samples + unsigned int i; + int index = 0; + int16_t sample; + unsigned char *packet = reinterpret_cast<unsigned char *>( bytearray.data() ); + for ( i = 0; i < ( bytearray.size() >> 2 ); i++ ) { + sample = packet[ index ] | ( packet[ index + 1 ] << 8 ); + index += 2; + buffer[ 0 ][ i ] = sample / 32768.0; + sample = packet[ index ] | ( packet[ index + 1 ] << 8 ); + index += 2; + buffer[ 1 ][ i ] = sample / 32768.0; + } + + vorbis_analysis_wrote( &vd, i ); + + while ( vorbis_analysis_blockout( &vd, &vb ) == 1 ) { +#if HAVE_VORBIS >= 2 + vorbis_analysis( &vb, NULL ); + vorbis_bitrate_addblock( &vb ); + while ( vorbis_bitrate_flushpacket( &vd, &op ) ) { +#else + // Support for very old libvorbis + vorbis_analysis( &vb, &op ); + { +#endif + ogg_stream_packetin( &os, &op ); + while ( ogg_stream_pageout( &os, &og ) ) { + _file->writeBlock( reinterpret_cast<char *>( og.header ), og.header_len ); + _file->writeBlock( reinterpret_cast<char *>( og.body ), og.body_len ); + } + } + } + QTimer::singleShot( 10, this, SLOT( process() ) ); + } + return true; + } else return false; +} +bool KRecExport_OGG::finalize() { +kdDebug( 60005 ) << k_funcinfo << endl; + if ( _file ) { + ogg_stream_clear( &os ); + vorbis_block_clear( &vb ); + vorbis_dsp_clear( &vd ); + vorbis_info_clear( &vi ); + + _file->close(); + delete _file; + _file = 0; + + return true; + } else return false; +} + + +// Derived from kdemultimedia/kioslave/audiocd/audiocd.cpp. +// We use the encoding settings from kcmaudiocd. +void KRecExport_OGG::setOggParameters() { +kdDebug( 60005 ) << k_funcinfo << endl; + KConfig *config; + config = new KConfig( "kcmaudiocdrc" ); + + config->setGroup( "Vorbis" ); + + // 0 for quality, 1 for managed bitrate + int vorbis_encode_method = config->readNumEntry( "encmethod", 0 ); + // default quality level of 3, to match oggenc + double vorbis_quality = config->readDoubleNumEntry( "quality",3.0 ); + + int vorbis_bitrate_lower = -1; + if ( config->readBoolEntry( "set_vorbis_min_bitrate",false ) ) + vorbis_bitrate_lower = config->readNumEntry( "vorbis_min_bitrate",40 ) * 1000; + + int vorbis_bitrate_upper = -1; + if ( config->readBoolEntry( "set_vorbis_max_bitrate",false ) ) + vorbis_bitrate_upper = config->readNumEntry( "vorbis_max_bitrate",350 ) * 1000; + + // this is such a hack! + int vorbis_bitrate; + if ( vorbis_bitrate_upper != -1 && vorbis_bitrate_lower != -1 ) + vorbis_bitrate = 104000; // empirically determined ...?! + else + vorbis_bitrate = 160 * 1000; + + int vorbis_bitrate_nominal = -1; + if ( config->readBoolEntry( "set_vorbis_nominal_bitrate",true ) ) { + vorbis_bitrate_nominal = config->readNumEntry( "vorbis_nominal_bitrate",160 ) * 1000; + vorbis_bitrate = vorbis_bitrate_nominal; + } + + write_vorbis_comments = config->readBoolEntry( "vorbis_comments",true ); + + vorbis_info_init( &vi ); + switch ( vorbis_encode_method ) { + case 0: + // Support very old libvorbis by simply falling through +#if HAVE_VORBIS >= 2 + vorbis_encode_init_vbr( &vi, 2/*this->channels()*/, + 44100/*this->samplingRate()*/, + vorbis_quality/10.0 ); + break; +#endif + case 1: + vorbis_encode_init( &vi, 2/*this->channels()*/, + 44100/*this->samplingRate()*/, + vorbis_bitrate_upper, vorbis_bitrate_nominal, + vorbis_bitrate_lower ); + break; + } + + delete config; +} + +#endif // vorbis + +// vim:sw=4:ts=4 diff --git a/krec/ogg_export/krecexport_ogg.h b/krec/ogg_export/krecexport_ogg.h new file mode 100644 index 00000000..43b79d54 --- /dev/null +++ b/krec/ogg_export/krecexport_ogg.h @@ -0,0 +1,63 @@ +/*************************************************************************** + copyright : (C) 2003 by Arnold Krille + email : arnold@arnoldarts.de + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + +#ifndef KREC_EXPORT_OGG_H +#define KREC_EXPORT_OGG_H + +#include <config.h> + +#ifdef HAVE_VORBIS + +#include "krecexport_template.h" + +#include <vorbis/vorbisenc.h> + +class KTempFile; +class QFile; + +class KRecExport_OGG : public KRecExportItem { + Q_OBJECT +public: + KRecExport_OGG( QObject*, const char* =0, const QStringList& =0 ); + ~KRecExport_OGG(); + + KRecExport_OGG* newItem(); + + QStringList extensions(); + QString exportFormat() { return QString( "OGG-Vorbis" ); } +public slots: + bool initialize( const QString & ); + bool process(); + bool finalize(); + +private: + QFile* _file; + + bool init_done; + + void setOggParameters(); + ogg_stream_state os; // take physical pages, weld into a logical stream of packets + ogg_page og; // one Ogg bitstream page. Vorbis packets are inside + ogg_packet op; // one raw packet of data for decode + vorbis_info vi; // struct that stores all the static vorbis bitstream settings + vorbis_comment vc; // struct that stores all the user comments + vorbis_dsp_state vd; // central working state for the packet->PCM decoder + vorbis_block vb; // local working space for packet->PCM decode + bool write_vorbis_comments; +}; + +#endif + +#endif + +// vim:sw=4:ts=4 diff --git a/krec/pics/Makefile.am b/krec/pics/Makefile.am new file mode 100644 index 00000000..e92a80f3 --- /dev/null +++ b/krec/pics/Makefile.am @@ -0,0 +1,2 @@ +kreciconsdir = $(kde_datadir)/krec/icons +krecicons_ICON = AUTO diff --git a/krec/pics/cr16-action-krec_record.png b/krec/pics/cr16-action-krec_record.png Binary files differnew file mode 100644 index 00000000..b808b652 --- /dev/null +++ b/krec/pics/cr16-action-krec_record.png diff --git a/krec/pics/cr22-action-krec_record.png b/krec/pics/cr22-action-krec_record.png Binary files differnew file mode 100644 index 00000000..6adff511 --- /dev/null +++ b/krec/pics/cr22-action-krec_record.png diff --git a/krec/pics/cr32-action-krec_record.png b/krec/pics/cr32-action-krec_record.png Binary files differnew file mode 100644 index 00000000..831561fc --- /dev/null +++ b/krec/pics/cr32-action-krec_record.png diff --git a/krec/pics/cr32-mime-krec_fileempty.png b/krec/pics/cr32-mime-krec_fileempty.png Binary files differnew file mode 100644 index 00000000..0d5c334f --- /dev/null +++ b/krec/pics/cr32-mime-krec_fileempty.png diff --git a/krec/pics/cr32-mime-krec_fileplay.png b/krec/pics/cr32-mime-krec_fileplay.png Binary files differnew file mode 100644 index 00000000..6bb24c65 --- /dev/null +++ b/krec/pics/cr32-mime-krec_fileplay.png diff --git a/krec/pics/cr32-mime-krec_filerec.png b/krec/pics/cr32-mime-krec_filerec.png Binary files differnew file mode 100644 index 00000000..e26cd05c --- /dev/null +++ b/krec/pics/cr32-mime-krec_filerec.png diff --git a/krec/tips b/krec/tips new file mode 100644 index 00000000..d376a743 --- /dev/null +++ b/krec/tips @@ -0,0 +1,44 @@ +<tip category="KRec"> +<html> +<h4>...that KRec does non-destructive Recording?</h4> +<p> +That means if you have a recording and want to record only a part for a second (third or more) time, your first (and second and later) version is still on disc and can still be restored. Only for Playback/Export the old version is overlayed by the newer one. +</p> +</html> +</tip> + +<tip category="KRec"> +<html> +<h4>...which event caused the first version of KRec?</h4> +<p> +Some friends of mine asked me whether I could do the recordings for a radioplay for them. So I was searching for an easy-to-use recording tool running on my favorite OS. After some searching (without finding something suitable) I started a first version of KRec. +</p> +</html> +</tip> + +<tip category="KRec"> +<html> +<h4>...that developers are very happy to hear from the users?</h4> +<p> +Most developers are very happy to see their applications used by other people. So if you want to say "Thank you" or you have some problems, don't hesitate to mail us/me. You can find the email addresses of the author in the "Help"-menu under "About KRec". +</p> +</html> +</tip> + +<tip category="KRec"> +<html> +<h4>...that you are invited to report bugs?</h4> +<p> +Altough a lot of testing is done, our capabilities of catching every possible event/configuration are limited. So if you find a bug use "Report Bug" in the "Help"-menu or go directly to http://bugs.kde.org. +</p> +</html> +</tip> + +<tip category="KRec"> +<html> +<h4>...that KRec is far from complete?</h4> +<p> +So if you have a nice feature you think KRec should incorporate please tell us! To avoid duplicates and improve productivity please do it via bugs.kde.org or the bug reporting tools and us wishlist as severity. +</p> +</html> +</tip> |