You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: androidresampler/src/main/cpp/resampler/README.md
+9-20Lines changed: 9 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,7 @@ To build it for use outside of Oboe:
14
14
15
15
1. Copy the "resampler" folder to a folder in your project that is in the include path.
16
16
2. Add all of the \*.cpp files in the resampler folder to your project IDE or Makefile.
17
-
3. In ResamplerDefinitions.h, define RESAMPLER_OUTER_NAMESPACE with your own project name.
18
-
Alternatively, use -DRESAMPLER_OUTER_NAMESPACE=mynamespace when compiling to avoid modifying the
19
-
resampler code.
17
+
3. In ResamplerDefinitions.h, define RESAMPLER_OUTER_NAMESPACE with your own project name. Alternatively, use -DRESAMPLER_OUTER_NAMESPACE=mynamespace when compiling to avoid modifying the resampler code.
20
18
21
19
## Creating a Resampler
22
20
@@ -25,8 +23,7 @@ Include the [main header](MultiChannelResampler.h) for the resampler.
25
23
#include "resampler/MultiChannelResampler.h"
26
24
27
25
Here is an example of creating a stereo resampler that will convert from 44100 to 48000 Hz.
28
-
Only do this once, when you open your stream. Then use the sample resampler to process multiple
29
-
buffers.
26
+
Only do this once, when you open your stream. Then use the sample resampler to process multiple buffers.
Possible values for quality include { Fastest, Low, Medium, High, Best }.
38
-
Higher quality levels will sound better but consume more CPU because they have more taps in the
39
-
filter.
35
+
Higher quality levels will sound better but consume more CPU because they have more taps in the filter.
40
36
41
37
## Fractional Frame Counts
42
38
43
39
Note that the number of output frames generated for a given number of input frames can vary.
44
40
45
-
For example, suppose you are converting from 44100 Hz to 48000 Hz and using an input buffer with 960
46
-
frames. If you calculate the number of output frames you get:
41
+
For example, suppose you are converting from 44100 Hz to 48000 Hz and using an input buffer with 960 frames. If you calculate the number of output frames you get:
47
42
48
43
960.0 * 48000 / 44100 = 1044.897959...
49
44
50
-
You cannot generate a fractional number of frames. So the resampler will sometimes generate 1044
51
-
frames and sometimes 1045 frames. On average it will generate 1044.897959 frames. The resampler
52
-
stores the fraction internally and keeps track of when to consume or generate a frame.
45
+
You cannot generate a fractional number of frames. So the resampler will sometimes generate 1044 frames and sometimes 1045 frames. On average it will generate 1044.897959 frames. The resampler stores the fraction internally and keeps track of when to consume or generate a frame.
53
46
54
-
You can either use a fixed number of input frames or a fixed number of output frames. The other
55
-
frame count will vary.
47
+
You can either use a fixed number of input frames or a fixed number of output frames. The other frame count will vary.
56
48
57
49
## Calling the Resampler with a fixed number of OUTPUT frames
58
50
59
-
In this example, suppose we have a fixed number of output frames and a variable number of input
60
-
frames.
51
+
In this example, suppose we have a fixed number of output frames and a variable number of input frames.
61
52
62
53
Assume you start with these variables and a method that returns the next input frame:
63
54
64
55
float *outputBuffer; // multi-channel buffer to be filled
65
56
int numOutputFrames; // number of frames of output
66
57
67
-
The resampler has a method isWriteNeeded() that tells you whether to write to or read from the
68
-
resampler.
58
+
The resampler has a method isWriteNeeded() that tells you whether to write to or read from the resampler.
69
59
70
60
int outputFramesLeft = numOutputFrames;
71
61
while (outputFramesLeft > 0) {
@@ -81,8 +71,7 @@ resampler.
81
71
82
72
## Calling the Resampler with a fixed number of INPUT frames
83
73
84
-
In this example, suppose we have a fixed number of input frames and a variable number of output
85
-
frames.
74
+
In this example, suppose we have a fixed number of input frames and a variable number of output frames.
0 commit comments