History

Update site documentation

* Use GitHub's Jekyll static site generator. * Move all documentation to docs/ directory. * Convert HTML to Markdown.

evpobr committed 6 years ago

Commit 260c3f61 parent 01284e738 files · +1057 −2227Browse files

Showing the changes to docs/api_simple.md (1 of 38 files). Show all

Unified · Split

docs/api_simple.md+71−0
@@ -0,0 +1,71 @@
1---
2layout: default
3---
4
5# Simple API
6
7**Important Note:** The simple API is not designed to work on small chunks of a
8larger piece of audio. If you attempt to use it this way you are doing it wrong
9and will not get the results you want. For processing audio data in chunks you
10**must** use the [full api](api_full.md) or the [callback based api](api_callback.md).
11
12The simple API consists of a single function:
13
14```c
15int src_simple (SRC_DATA *data, int converter_type, int channels) ;
16```
17
18The use of this function rather than the more fully featured API requires the
19caller to know the total length of the input data before hand and that all input
20and output data can be held in the system's memory at once. It also assumes that
21there is a single constant ratio between input and output sample rates.
22
23Dealing with the easy stuff first, the **converter_type** parameter should be
24one of the values defined in **samplerate.h** and documented [here](api_misc.md#converters)
25while the **channels** parameter specifies the number of interleaved channels
26that the sample rate converter is being asked to process (number of input
27channels and output channels is always equal). There is no hard upper limit on
28the number of channels; it is limited purely by the amount of memory available.
29
30The first parameter to **src_simple** is a pointer to an **SRC_DATA** struct
31(more info [here](api_misc.md#src_data)) defined as follows:
32
33```c
34typedef struct
35{ const float *data_in;
36 float *data_out ;
37
38 long input_frames, output_frames ;
39 long input_frames_used, output_frames_gen ;
40
41 int end_of_input ;
42
43 double src_ratio ;
44} SRC_DATA ;
45```
46
47The fields of this struct which must be filled in by the caller are:
48
49data_in
50: A pointer to the input data samples.
51
52input_frames
53: The number of frames of data pointed to by data_in.
54
55data_out
56: A pointer to the output data samples.
57
58output_frames
59: Maximum number of frames pointer to by data_out.
60
61src_ratio
62: Equal to output_sample_rate / input_sample_rate.
63
64When the **src_simple** function returns **output_frames_gen** will be set to
65the number of output frames generated and **input_frames_used** will be set to
66the number of input frames used to generate the provided number of output
67frames.
68
69The **src_simple** function returns a non-zero value when an error occurs. See
70[here](api_misc.md#error-reporting) for how to convert the error value into a
71text string.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t