stretcher.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <kprocess.h>
00022 #include <kdebug.h>
00023
00024
00025 #include "stretcher.h"
00026 #include "stretcher.moc"
00027
00031 Stretcher::Stretcher(QObject *parent, const char *name) :
00032 QObject(parent, name)
00033 {
00034 m_state = 0;
00035 m_stretchProc = 0;
00036 }
00037
00041 Stretcher::~Stretcher()
00042 {
00043 delete m_stretchProc;
00044 }
00045
00053 bool Stretcher::stretch(const QString &inFilename, const QString &outFilename, const float stretchFactor)
00054 {
00055 if (m_stretchProc) return false;
00056 m_outFilename = outFilename;
00057 m_stretchProc = new KProcess;
00058 QString stretchStr = QString("%1").arg(stretchFactor, 0, 'f', 3);
00059 *m_stretchProc << "sox" << inFilename << outFilename << "stretch" << stretchStr;
00060 connect(m_stretchProc, SIGNAL(processExited(KProcess*)),
00061 this, SLOT(slotProcessExited(KProcess*)));
00062 if (!m_stretchProc->start(KProcess::NotifyOnExit, KProcess::NoCommunication))
00063 {
00064 kdDebug() << "Stretcher::stretch: Error starting audio stretcher process. Is sox installed?" << endl;
00065 return false;
00066 }
00067 m_state = ssStretching;
00068 return true;
00069 }
00070
00071 void Stretcher::slotProcessExited(KProcess*)
00072 {
00073 m_stretchProc->deleteLater();
00074 m_stretchProc = 0;
00075 m_state = ssFinished;
00076 emit stretchFinished();
00077 }
00078
00082 int Stretcher::getState() { return m_state; }
00083
00087 QString Stretcher::getOutFilename() { return m_outFilename; }
00088
00092 void Stretcher::ackFinished() { m_state = ssIdle; }
00093
This file is part of the documentation for kttsd Library Version 3.3.90.