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 #ifndef _RUBBERBAND_C_API_H_
16 #define _RUBBERBAND_C_API_H_
22 #define RUBBERBAND_VERSION "1.3.0-gpl"
23 #define RUBBERBAND_API_MAJOR_VERSION 2
24 #define RUBBERBAND_API_MINOR_VERSION 0
27 * This is a C-linkage interface to the Rubber Band time stretcher.
29 * This is a wrapper interface: the primary interface is in C++ and is
30 * defined and documented in RubberBandStretcher.h. The library
31 * itself is implemented in C++, and requires C++ standard library
32 * support even when using the C-linkage API.
34 * Please see RubberBandStretcher.h for documentation.
36 * If you are writing to the C++ API, do not include this header.
39 enum RubberBandOption
{
41 RubberBandOptionProcessOffline
= 0x00000000,
42 RubberBandOptionProcessRealTime
= 0x00000001,
44 RubberBandOptionStretchElastic
= 0x00000000,
45 RubberBandOptionStretchPrecise
= 0x00000010,
47 RubberBandOptionTransientsCrisp
= 0x00000000,
48 RubberBandOptionTransientsMixed
= 0x00000100,
49 RubberBandOptionTransientsSmooth
= 0x00000200,
51 RubberBandOptionPhaseLaminar
= 0x00000000,
52 RubberBandOptionPhaseIndependent
= 0x00002000,
54 RubberBandOptionThreadingAuto
= 0x00000000,
55 RubberBandOptionThreadingNever
= 0x00010000,
56 RubberBandOptionThreadingAlways
= 0x00020000,
58 RubberBandOptionWindowStandard
= 0x00000000,
59 RubberBandOptionWindowShort
= 0x00100000,
60 RubberBandOptionWindowLong
= 0x00200000,
62 RubberBandOptionFormantShifted
= 0x00000000,
63 RubberBandOptionFormantPreserved
= 0x01000000,
65 RubberBandOptionPitchHighQuality
= 0x00000000,
66 RubberBandOptionPitchHighSpeed
= 0x02000000,
67 RubberBandOptionPitchHighConsistency
= 0x04000000
70 typedef int RubberBandOptions
;
72 struct RubberBandState_
;
73 typedef struct RubberBandState_
*RubberBandState
;
75 extern RubberBandState
rubberband_new(unsigned int sampleRate
,
76 unsigned int channels
,
77 RubberBandOptions options
,
78 double initialTimeRatio
,
79 double initialPitchScale
);
81 extern void rubberband_delete(RubberBandState
);
83 extern void rubberband_reset(RubberBandState
);
85 extern void rubberband_set_time_ratio(RubberBandState
, double ratio
);
86 extern void rubberband_set_pitch_scale(RubberBandState
, double scale
);
88 extern double rubberband_get_time_ratio(const RubberBandState
);
89 extern double rubberband_get_pitch_scale(const RubberBandState
);
91 extern unsigned int rubberband_get_latency(const RubberBandState
);
93 extern void rubberband_set_transients_option(RubberBandState
, RubberBandOptions options
);
94 extern void rubberband_set_phase_option(RubberBandState
, RubberBandOptions options
);
95 extern void rubberband_set_formant_option(RubberBandState
, RubberBandOptions options
);
96 extern void rubberband_set_pitch_option(RubberBandState
, RubberBandOptions options
);
98 extern void rubberband_set_expected_input_duration(RubberBandState
, unsigned int samples
);
100 extern unsigned int rubberband_get_samples_required(const RubberBandState
);
102 extern void rubberband_set_max_process_size(RubberBandState
, unsigned int samples
);
104 extern void rubberband_study(RubberBandState
, const float *const *input
, unsigned int samples
, int final
);
105 extern void rubberband_process(RubberBandState
, const float *const *input
, unsigned int samples
, int final
);
107 extern int rubberband_available(const RubberBandState
);
108 extern unsigned int rubberband_retrieve(const RubberBandState
, float *const *output
, unsigned int samples
);
110 extern unsigned int rubberband_get_channel_count(const RubberBandState
);
112 extern void rubberband_calculate_stretch(RubberBandState
);
114 extern void rubberband_set_debug_level(RubberBandState
, int level
);
115 extern void rubberband_set_default_debug_level(int level
);