Quote includes for control_protocol.
[ardour.git] / libs / rubberband / src / rubberband-c.cpp
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 #include "rubberband-c.h"
16 #include "RubberBandStretcher.h"
17
18 struct RubberBandState_
19 {
20     RubberBand::RubberBandStretcher *m_s;
21 };
22
23 RubberBandState rubberband_new(unsigned int sampleRate,
24                                unsigned int channels,
25                                RubberBandOptions options,
26                                double initialTimeRatio,
27                                double initialPitchScale)
28 {
29     RubberBandState_ *state = new RubberBandState_();
30     state->m_s = new RubberBand::RubberBandStretcher
31         (sampleRate, channels, options,
32          initialTimeRatio, initialPitchScale);
33     return state;
34 }
35
36 void rubberband_delete(RubberBandState state)
37 {
38     delete state->m_s;
39     delete state;
40 }
41
42 void rubberband_reset(RubberBandState state)
43 {
44     state->m_s->reset();
45 }
46
47 void rubberband_set_time_ratio(RubberBandState state, double ratio)
48 {
49     state->m_s->setTimeRatio(ratio);
50 }
51
52 void rubberband_set_pitch_scale(RubberBandState state, double scale)
53 {
54     state->m_s->setPitchScale(scale);
55 }
56
57 double rubberband_get_time_ratio(const RubberBandState state) 
58 {
59     return state->m_s->getTimeRatio();
60 }
61
62 double rubberband_get_pitch_scale(const RubberBandState state)
63 {
64     return state->m_s->getPitchScale();
65 }
66
67 unsigned int rubberband_get_latency(const RubberBandState state) 
68 {
69     return state->m_s->getLatency();
70 }
71
72 void rubberband_set_transients_option(RubberBandState state, RubberBandOptions options)
73 {
74     state->m_s->setTransientsOption(options);
75 }
76
77 void rubberband_set_phase_option(RubberBandState state, RubberBandOptions options)
78 {
79     state->m_s->setPhaseOption(options);
80 }
81
82 void rubberband_set_formant_option(RubberBandState state, RubberBandOptions options)
83 {
84     state->m_s->setFormantOption(options);
85 }
86
87 void rubberband_set_pitch_option(RubberBandState state, RubberBandOptions options)
88 {
89     state->m_s->setPitchOption(options);
90 }
91
92 void rubberband_set_expected_input_duration(RubberBandState state, unsigned int samples)
93 {
94     state->m_s->setExpectedInputDuration(samples);
95 }
96
97 unsigned int rubberband_get_samples_required(const RubberBandState state)
98 {
99     return state->m_s->getSamplesRequired();
100 }
101
102 void rubberband_set_max_process_size(RubberBandState state, unsigned int samples)
103 {
104     state->m_s->setMaxProcessSize(samples);
105 }
106
107 void rubberband_study(RubberBandState state, const float *const *input, unsigned int samples, int final)
108 {
109     state->m_s->study(input, samples, final != 0);
110 }
111
112 void rubberband_process(RubberBandState state, const float *const *input, unsigned int samples, int final)
113 {
114     state->m_s->process(input, samples, final != 0);
115 }
116
117 int rubberband_available(const RubberBandState state)
118 {
119     return state->m_s->available();
120 }
121
122 unsigned int rubberband_retrieve(const RubberBandState state, float *const *output, unsigned int samples)
123 {
124     return state->m_s->retrieve(output, samples);
125 }
126
127 unsigned int rubberband_get_channel_count(const RubberBandState state)
128 {
129     return state->m_s->getChannelCount();
130 }
131
132 void rubberband_calculate_stretch(RubberBandState state)
133 {
134     state->m_s->calculateStretch();
135 }
136
137 void rubberband_set_debug_level(RubberBandState state, int level)
138 {
139     state->m_s->setDebugLevel(level);
140 }
141
142 void rubberband_set_default_debug_level(int level)
143 {
144     RubberBand::RubberBandStretcher::setDefaultDebugLevel(level);
145 }
146