Nsound  0.9.4
Stretcher.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // $Id: Stretcher.h 874 2014-09-08 02:21:29Z weegreenblobbie $
4 //
5 // Nsound is a C++ library and Python module for audio synthesis featuring
6 // dynamic digital filters. Nsound lets you easily shape waveforms and write
7 // to disk or plot them. Nsound aims to be as powerful as Csound but easy to
8 // use.
9 //
10 // Copyright (c) 2009 to Present Nick Hilton
11 //
12 // weegreenblobbie_yahoo_com (replace '_' with '@' and '.')
13 //
14 // Based on WSOLA.
15 //
16 //-----------------------------------------------------------------------------
17 
18 //-----------------------------------------------------------------------------
19 //
20 // This program is free software; you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation; either version 2 of the License, or
23 // (at your option) any later version.
24 //
25 // This program is distributed in the hope that it will be useful,
26 // but WITHOUT ANY WARRANTY; without even the implied warranty of
27 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 // GNU Library General Public License for more details.
29 //
30 // You should have received a copy of the GNU General Public License
31 // along with this program; if not, write to the Free Software
32 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 //
34 //-----------------------------------------------------------------------------
35 #ifndef _NSOUND_STRETCHER_H_
36 #define _NSOUND_STRETCHER_H_
37 
38 #include <Nsound/Nsound.h>
39 
40 namespace Nsound
41 {
42 
43 class AudioStream;
44 class Buffer;
45 class FFTChunk;
46 
47 //-----------------------------------------------------------------------------
49 class Stretcher
50 {
51  public:
52 
54  //
58  Stretcher(
59  const float64 & sample_rate,
60  const float64 & window_size_seconds = 0.08,
61  const float64 & max_delta_window = 0.25);
62 
64  Stretcher(const Stretcher & copy);
65 
67  virtual ~Stretcher();
68 
70  Stretcher &
71  operator=(const Stretcher & rhs);
72 
74  pitchShift(const AudioStream & x, const float64 & factor);
75 
77  pitchShift(const AudioStream & x, const Buffer & factor);
78 
79  Buffer
80  pitchShift(const Buffer & x, const float64 & factor);
81 
82  Buffer
83  pitchShift(const Buffer & x, const Buffer & factor);
84 
85  void
86  showProgress(boolean flag){show_progress_ = flag;};
87 
89  timeShift(const AudioStream & x, const float64 & factor);
90 
92  timeShift(const AudioStream & x, const Buffer & factor);
93 
94  Buffer
95  timeShift(const Buffer & x, const float64 & factor);
96 
97  Buffer
98  timeShift(const Buffer & x, const Buffer & factor);
99 
100  protected:
101 
102  void
103  analyize(const Buffer & input, const float64 & factor);
104 
105  void
106  analyize(const Buffer & input, const Buffer & factor);
107 
108  uint32
110  const Buffer & input,
111  uint32 source_index,
112  uint32 search_index) const;
113 
114  Buffer
115  overlapAdd(const Buffer & input) const;
116 
122  boolean show_progress_;
123 
124 };
125 
126 } // namespace
127 
128 #endif
129 // :mode=c++: jEdit modeline
130 
unsigned int uint32
Definition: Nsound.h:153
Buffer * window_
Definition: Stretcher.h:119
AudioStream pitchShift(const AudioStream &x, const float64 &factor)
Definition: Stretcher.cc:338
uint32 searchForBestMatch(const Buffer &input, uint32 source_index, uint32 search_index) const
Definition: Stretcher.cc:209
Stretcher & operator=(const Stretcher &rhs)
Assignment.
Definition: Stretcher.cc:103
double float64
Definition: Nsound.h:146
Buffer overlapAdd(const Buffer &input) const
Definition: Stretcher.cc:281
virtual ~Stretcher()
Destructor.
Definition: Stretcher.cc:94
uint32 window_length_
Definition: Stretcher.h:120
Buffer * frames_
Definition: Stretcher.h:117
void showProgress(boolean flag)
Definition: Stretcher.h:86
boolean show_progress_
Definition: Stretcher.h:122
AudioStream timeShift(const AudioStream &x, const float64 &factor)
Definition: Stretcher.cc:396
A Buffer for storing audio samples.
Definition: Buffer.h:60
float64 sample_rate_
Definition: Stretcher.h:118
void analyize(const Buffer &input, const float64 &factor)
Definition: Stretcher.cc:119
Stretcher(const float64 &sample_rate, const float64 &window_size_seconds=0.08, const float64 &max_delta_window=0.25)
Default Constructor.
Definition: Stretcher.cc:54