summaryrefslogtreecommitdiffstats
path: root/kttsd/libkttsd/stretcher.h
blob: 975e9d95dbb346df828bacb13262dd933136e535 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
  Description: 
     Speeds up or slows down an audio file by stretching the audio stream.
     Uses the sox program to do the stretching.

  Copyright:
  (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net>
  -------------------
  Original author: Gary Cramblitt <garycramblitt@comcast.net>

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ******************************************************************************/

#ifndef _STRETCHER_H_
#define _STRETCHER_H_

#include <kdemacros.h>
#include "kdeexportfix.h"

class TDEProcess;

class KDE_EXPORT Stretcher : public TQObject{
    TQ_OBJECT
  

    public:
        /**
         * Constructor.
         */
        Stretcher(TQObject *parent = 0, const char *name = 0);

        /**
         * Destructor.
         */
        ~Stretcher();

        enum StretcherState {
            ssIdle = 0,             // Not doing anything.  Ready to stretch.
            ssStretching = 1,       // Stretching.
            ssFinished = 2          // Stretching finished.
        };

        /**
         * Stretch the given input file to an output file.
         * @param inFilename        Name of input audio file.
         * @param outFilename       Name of output audio file.
         * @param stretchFactor     Amount to stretch.  2.0 is twice as slow.  0.5 is twice as fast.
         */
        bool stretch(const TQString &inFilename, const TQString &outFilename, float stretchFactor);

        /**
        * Returns the state of the Stretcher.
        */
        int getState();

        /**
         * Returns the output filename (as given in call to stretch).
         */
        TQString getOutFilename();

        /**
        * Acknowledges the finished stretching.
        */
        void ackFinished();

    signals:
        /**
         * Emitted whenever stretching is completed.
         */
        void stretchFinished();

    private slots:
        void slotProcessExited(TDEProcess* proc);

    private:
        // Stretcher state.
        int m_state;

        // Sox process.
        TDEProcess* m_stretchProc;

        // Output file name.
        TQString m_outFilename;
};

#endif      // _STRETCHER_H_