fix up start-in-source values from regions created as sections of another region...
[ardour.git] / libs / rubberband / src / ladspa / RubberBandPitchShifter.h
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2
3 /*
4     Rubber Band
5     An audio time-stretching and pitch-shifting library.
6     Copyright 2007-2008 Chris Cannam.
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
15 #ifndef _RUBBERBAND_PITCH_SHIFTER_H_
16 #define _RUBBERBAND_PITCH_SHIFTER_H_
17
18 #include <ladspa.h>
19
20 #include "RingBuffer.h"
21
22 namespace RubberBand {
23 class RubberBandStretcher;
24 }
25
26 class RubberBandPitchShifter
27 {
28 public:
29     static const LADSPA_Descriptor *getDescriptor(unsigned long index);
30     
31 protected:
32     RubberBandPitchShifter(int sampleRate, size_t channels);
33     ~RubberBandPitchShifter();
34
35     enum {
36         LatencyPort      = 0,
37         OctavesPort      = 1,
38         SemitonesPort    = 2,
39         CentsPort        = 3,
40         CrispnessPort    = 4,
41         FormantPort      = 5,
42         FastPort         = 6,
43         InputPort1       = 7,
44         OutputPort1      = 8,
45         PortCountMono    = OutputPort1 + 1,
46         InputPort2       = 9,
47         OutputPort2      = 10,
48         PortCountStereo  = OutputPort2 + 1
49     };
50
51     static const char *const portNamesMono[PortCountMono];
52     static const LADSPA_PortDescriptor portsMono[PortCountMono];
53     static const LADSPA_PortRangeHint hintsMono[PortCountMono];
54
55     static const char *const portNamesStereo[PortCountStereo];
56     static const LADSPA_PortDescriptor portsStereo[PortCountStereo];
57     static const LADSPA_PortRangeHint hintsStereo[PortCountStereo];
58
59     static const LADSPA_Properties properties;
60
61     static const LADSPA_Descriptor ladspaDescriptorMono;
62     static const LADSPA_Descriptor ladspaDescriptorStereo;
63
64     static LADSPA_Handle instantiate(const LADSPA_Descriptor *, unsigned long);
65     static void connectPort(LADSPA_Handle, unsigned long, LADSPA_Data *);
66     static void activate(LADSPA_Handle);
67     static void run(LADSPA_Handle, unsigned long);
68     static void deactivate(LADSPA_Handle);
69     static void cleanup(LADSPA_Handle);
70
71     void activateImpl();
72     void runImpl(unsigned long);
73     void runImpl(unsigned long, unsigned long offset);
74     void updateRatio();
75     void updateCrispness();
76     void updateFormant();
77     void updateFast();
78
79     float *m_input[2];
80     float *m_output[2];
81     float *m_latency;
82     float *m_cents;
83     float *m_semitones;
84     float *m_octaves;
85     float *m_crispness;
86     float *m_formant;
87     float *m_fast;
88     double m_ratio;
89     double m_prevRatio;
90     int m_currentCrispness;
91     bool m_currentFormant;
92     bool m_currentFast;
93
94     size_t m_blockSize;
95     size_t m_reserve;
96     size_t m_minfill;
97
98     RubberBand::RubberBandStretcher *m_stretcher;
99     RubberBand::RingBuffer<float> *m_outputBuffer[2];
100     float *m_scratch[2];
101
102     int m_sampleRate;
103     size_t m_channels;
104 };
105
106
107 #endif