comparison src/rubberband-1.8.1/ladspa/RubberBandPitchShifter.h @ 95:89f5e221ed7b

Add FFTW3
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 20 Mar 2013 15:35:50 +0000
parents
children
comparison
equal deleted inserted replaced
94:d278df1123f9 95:89f5e221ed7b
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Rubber Band Library
5 An audio time-stretching and pitch-shifting library.
6 Copyright 2007-2012 Particular Programs Ltd.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
13
14 Alternatively, if you have a valid commercial licence for the
15 Rubber Band Library obtained by agreement with the copyright
16 holders, you may redistribute and/or modify it under the terms
17 described in that licence.
18
19 If you wish to distribute code using the Rubber Band Library
20 under terms other than those of the GNU General Public License,
21 you must obtain a valid commercial licence before doing so.
22 */
23
24 #ifndef _RUBBERBAND_PITCH_SHIFTER_H_
25 #define _RUBBERBAND_PITCH_SHIFTER_H_
26
27 #include <ladspa.h>
28
29 #include "base/RingBuffer.h"
30
31 namespace RubberBand {
32 class RubberBandStretcher;
33 }
34
35 class RubberBandPitchShifter
36 {
37 public:
38 static const LADSPA_Descriptor *getDescriptor(unsigned long index);
39
40 protected:
41 RubberBandPitchShifter(int sampleRate, size_t channels);
42 ~RubberBandPitchShifter();
43
44 enum {
45 LatencyPort = 0,
46 OctavesPort = 1,
47 SemitonesPort = 2,
48 CentsPort = 3,
49 CrispnessPort = 4,
50 FormantPort = 5,
51 FastPort = 6,
52 InputPort1 = 7,
53 OutputPort1 = 8,
54 PortCountMono = OutputPort1 + 1,
55 InputPort2 = 9,
56 OutputPort2 = 10,
57 PortCountStereo = OutputPort2 + 1
58 };
59
60 static const char *const portNamesMono[PortCountMono];
61 static const LADSPA_PortDescriptor portsMono[PortCountMono];
62 static const LADSPA_PortRangeHint hintsMono[PortCountMono];
63
64 static const char *const portNamesStereo[PortCountStereo];
65 static const LADSPA_PortDescriptor portsStereo[PortCountStereo];
66 static const LADSPA_PortRangeHint hintsStereo[PortCountStereo];
67
68 static const LADSPA_Properties properties;
69
70 static const LADSPA_Descriptor ladspaDescriptorMono;
71 static const LADSPA_Descriptor ladspaDescriptorStereo;
72
73 static LADSPA_Handle instantiate(const LADSPA_Descriptor *, unsigned long);
74 static void connectPort(LADSPA_Handle, unsigned long, LADSPA_Data *);
75 static void activate(LADSPA_Handle);
76 static void run(LADSPA_Handle, unsigned long);
77 static void deactivate(LADSPA_Handle);
78 static void cleanup(LADSPA_Handle);
79
80 void activateImpl();
81 void runImpl(unsigned long);
82 void runImpl(unsigned long, unsigned long offset);
83 void updateRatio();
84 void updateCrispness();
85 void updateFormant();
86 void updateFast();
87
88 float *m_input[2];
89 float *m_output[2];
90 float *m_latency;
91 float *m_cents;
92 float *m_semitones;
93 float *m_octaves;
94 float *m_crispness;
95 float *m_formant;
96 float *m_fast;
97 double m_ratio;
98 double m_prevRatio;
99 int m_currentCrispness;
100 bool m_currentFormant;
101 bool m_currentFast;
102
103 size_t m_blockSize;
104 size_t m_reserve;
105 size_t m_minfill;
106
107 RubberBand::RubberBandStretcher *m_stretcher;
108 RubberBand::RingBuffer<float> *m_outputBuffer[2];
109 float *m_scratch[2];
110
111 int m_sampleRate;
112 size_t m_channels;
113 };
114
115
116 #endif