1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
5 An audio time-stretching and pitch-shifting library.
6 Copyright 2007-2008 Chris Cannam.
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.
15 #include "rubberband-c.h"
16 #include "RubberBandStretcher.h"
18 struct RubberBandState_
20 RubberBand::RubberBandStretcher *m_s;
23 RubberBandState rubberband_new(unsigned int sampleRate,
24 unsigned int channels,
25 RubberBandOptions options,
26 double initialTimeRatio,
27 double initialPitchScale)
29 RubberBandState_ *state = new RubberBandState_();
30 state->m_s = new RubberBand::RubberBandStretcher
31 (sampleRate, channels, options,
32 initialTimeRatio, initialPitchScale);
36 void rubberband_delete(RubberBandState state)
42 void rubberband_reset(RubberBandState state)
47 void rubberband_set_time_ratio(RubberBandState state, double ratio)
49 state->m_s->setTimeRatio(ratio);
52 void rubberband_set_pitch_scale(RubberBandState state, double scale)
54 state->m_s->setPitchScale(scale);
57 double rubberband_get_time_ratio(const RubberBandState state)
59 return state->m_s->getTimeRatio();
62 double rubberband_get_pitch_scale(const RubberBandState state)
64 return state->m_s->getPitchScale();
67 unsigned int rubberband_get_latency(const RubberBandState state)
69 return state->m_s->getLatency();
72 void rubberband_set_transients_option(RubberBandState state, RubberBandOptions options)
74 state->m_s->setTransientsOption(options);
77 void rubberband_set_phase_option(RubberBandState state, RubberBandOptions options)
79 state->m_s->setPhaseOption(options);
82 void rubberband_set_formant_option(RubberBandState state, RubberBandOptions options)
84 state->m_s->setFormantOption(options);
87 void rubberband_set_pitch_option(RubberBandState state, RubberBandOptions options)
89 state->m_s->setPitchOption(options);
92 void rubberband_set_expected_input_duration(RubberBandState state, unsigned int samples)
94 state->m_s->setExpectedInputDuration(samples);
97 unsigned int rubberband_get_samples_required(const RubberBandState state)
99 return state->m_s->getSamplesRequired();
102 void rubberband_set_max_process_size(RubberBandState state, unsigned int samples)
104 state->m_s->setMaxProcessSize(samples);
107 void rubberband_study(RubberBandState state, const float *const *input, unsigned int samples, int final)
109 state->m_s->study(input, samples, final != 0);
112 void rubberband_process(RubberBandState state, const float *const *input, unsigned int samples, int final)
114 state->m_s->process(input, samples, final != 0);
117 int rubberband_available(const RubberBandState state)
119 return state->m_s->available();
122 unsigned int rubberband_retrieve(const RubberBandState state, float *const *output, unsigned int samples)
124 return state->m_s->retrieve(output, samples);
127 unsigned int rubberband_get_channel_count(const RubberBandState state)
129 return state->m_s->getChannelCount();
132 void rubberband_calculate_stretch(RubberBandState state)
134 state->m_s->calculateStretch();
137 void rubberband_set_debug_level(RubberBandState state, int level)
139 state->m_s->setDebugLevel(level);
142 void rubberband_set_default_debug_level(int level)
144 RubberBand::RubberBandStretcher::setDefaultDebugLevel(level);