cannam@95
|
1 /* Copyright Chris Cannam - All Rights Reserved */
|
cannam@95
|
2
|
cannam@95
|
3 package com.breakfastquay.rubberband;
|
cannam@95
|
4
|
cannam@95
|
5 public class RubberBandStretcher
|
cannam@95
|
6 {
|
cannam@95
|
7 public RubberBandStretcher(int sampleRate, int channels,
|
cannam@95
|
8 int options,
|
cannam@95
|
9 double initialTimeRatio,
|
cannam@95
|
10 double initialPitchScale) {
|
cannam@95
|
11 handle = 0;
|
cannam@95
|
12 initialise(sampleRate, channels, options,
|
cannam@95
|
13 initialTimeRatio, initialPitchScale);
|
cannam@95
|
14 }
|
cannam@95
|
15
|
cannam@95
|
16 public native void dispose();
|
cannam@95
|
17
|
cannam@95
|
18 public native void reset();
|
cannam@95
|
19
|
cannam@95
|
20 public native void setTimeRatio(double ratio);
|
cannam@95
|
21 public native void setPitchScale(double scale);
|
cannam@95
|
22
|
cannam@95
|
23 public native int getChannelCount();
|
cannam@95
|
24 public native double getTimeRatio();
|
cannam@95
|
25 public native double getPitchScale();
|
cannam@95
|
26
|
cannam@95
|
27 public native int getLatency();
|
cannam@95
|
28
|
cannam@95
|
29 public native void setTransientsOption(int options);
|
cannam@95
|
30 public native void setDetectorOption(int options);
|
cannam@95
|
31 public native void setPhaseOption(int options);
|
cannam@95
|
32 public native void setFormantOption(int options);
|
cannam@95
|
33 public native void setPitchOption(int options);
|
cannam@95
|
34
|
cannam@95
|
35 public native void setExpectedInputDuration(long samples);
|
cannam@95
|
36 public native void setMaxProcessSize(int samples);
|
cannam@95
|
37
|
cannam@95
|
38 public native int getSamplesRequired();
|
cannam@95
|
39
|
cannam@95
|
40 //!!! todo: setKeyFrameMap
|
cannam@95
|
41
|
cannam@95
|
42 public native void study(float[][] input, int offset, int n, boolean finalBlock);
|
cannam@95
|
43 public void study(float[][] input, boolean finalBlock) {
|
cannam@95
|
44 study(input, 0, input[0].length, finalBlock);
|
cannam@95
|
45 }
|
cannam@95
|
46
|
cannam@95
|
47 public native void process(float[][] input, int offset, int n, boolean finalBlock);
|
cannam@95
|
48 public void process(float[][] input, boolean finalBlock) {
|
cannam@95
|
49 process(input, 0, input[0].length, finalBlock);
|
cannam@95
|
50 }
|
cannam@95
|
51
|
cannam@95
|
52 public native int available();
|
cannam@95
|
53
|
cannam@95
|
54 public native int retrieve(float[][] output, int offset, int n);
|
cannam@95
|
55 public int retrieve(float[][] output) {
|
cannam@95
|
56 return retrieve(output, 0, output[0].length);
|
cannam@95
|
57 }
|
cannam@95
|
58
|
cannam@95
|
59 private native void initialise(int sampleRate, int channels, int options,
|
cannam@95
|
60 double initialTimeRatio,
|
cannam@95
|
61 double initialPitchScale);
|
cannam@95
|
62 private long handle;
|
cannam@95
|
63
|
cannam@95
|
64 public static final int OptionProcessOffline = 0x00000000;
|
cannam@95
|
65 public static final int OptionProcessRealTime = 0x00000001;
|
cannam@95
|
66
|
cannam@95
|
67 public static final int OptionStretchElastic = 0x00000000;
|
cannam@95
|
68 public static final int OptionStretchPrecise = 0x00000010;
|
cannam@95
|
69
|
cannam@95
|
70 public static final int OptionTransientsCrisp = 0x00000000;
|
cannam@95
|
71 public static final int OptionTransientsMixed = 0x00000100;
|
cannam@95
|
72 public static final int OptionTransientsSmooth = 0x00000200;
|
cannam@95
|
73
|
cannam@95
|
74 public static final int OptionDetectorCompound = 0x00000000;
|
cannam@95
|
75 public static final int OptionDetectorPercussive = 0x00000400;
|
cannam@95
|
76 public static final int OptionDetectorSoft = 0x00000800;
|
cannam@95
|
77
|
cannam@95
|
78 public static final int OptionPhaseLaminar = 0x00000000;
|
cannam@95
|
79 public static final int OptionPhaseIndependent = 0x00002000;
|
cannam@95
|
80
|
cannam@95
|
81 public static final int OptionThreadingAuto = 0x00000000;
|
cannam@95
|
82 public static final int OptionThreadingNever = 0x00010000;
|
cannam@95
|
83 public static final int OptionThreadingAlways = 0x00020000;
|
cannam@95
|
84
|
cannam@95
|
85 public static final int OptionWindowStandard = 0x00000000;
|
cannam@95
|
86 public static final int OptionWindowShort = 0x00100000;
|
cannam@95
|
87 public static final int OptionWindowLong = 0x00200000;
|
cannam@95
|
88
|
cannam@95
|
89 public static final int OptionSmoothingOff = 0x00000000;
|
cannam@95
|
90 public static final int OptionSmoothingOn = 0x00800000;
|
cannam@95
|
91
|
cannam@95
|
92 public static final int OptionFormantShifted = 0x00000000;
|
cannam@95
|
93 public static final int OptionFormantPreserved = 0x01000000;
|
cannam@95
|
94
|
cannam@95
|
95 public static final int OptionPitchHighSpeed = 0x00000000;
|
cannam@95
|
96 public static final int OptionPitchHighQuality = 0x02000000;
|
cannam@95
|
97 public static final int OptionPitchHighConsistency = 0x04000000;
|
cannam@95
|
98
|
cannam@95
|
99 public static final int OptionChannelsApart = 0x00000000;
|
cannam@95
|
100 public static final int OptionChannelsTogether = 0x10000000;
|
cannam@95
|
101
|
cannam@95
|
102 public static final int DefaultOptions = 0x00000000;
|
cannam@95
|
103 public static final int PercussiveOptions = 0x00102000;
|
cannam@95
|
104
|
cannam@95
|
105 static {
|
cannam@95
|
106 System.loadLibrary("rubberband");
|
cannam@95
|
107 }
|
cannam@95
|
108 };
|
cannam@95
|
109
|