source: doc/develop.rst @ 88b301a

feature/autosinkfeature/cnnfeature/crepefix/ffmpeg5
Last change on this file since 88b301a was a10cd45, checked in by Paul Brossier <piem@piem.org>, 7 years ago

doc/develop.rst: fix title markup

  • Property mode set to 100644
File size: 3.9 KB
RevLine 
[e65fbec]1.. _develop:
2
[43ce34c]3Developing with aubio
[a10cd45]4=====================
[7a8a07e]5
[f80519b]6Here is a brief overview of the C library.
[7a8a07e]7
[4da6f20]8For a more detailed list of available functions, see the `API documentation
9<https://aubio.org/doc/latest/>`_.
[7a8a07e]10
[f80519b]11To report issues, ask questions, and request new features, use `Github Issues
12<https://github.com/aubio/aubio/issues>`_
[7a8a07e]13
[5399f17]14Design Basics
[f80519b]15-------------
[5399f17]16
17The library is written in C and is optimised for speed and portability.
18
[67e0eeb]19All memory allocations take place in the `new_` methods. Each successful call
20to `new_` should have a matching call to `del_` to deallocate the object.
[5399f17]21
22.. code-block:: C
23
24   // new_ to create an object foobar
25   aubio_foobar_t * new_aubio_foobar(void * args);
26   // del_ to delete foobar
[67e0eeb]27   void del_aubio_foobar (aubio_foobar_t * foobar);
[5399f17]28
[67e0eeb]29The main computations are done in the `_do` methods.
[5399f17]30
[67e0eeb]31.. code-block:: C
[5399f17]32
[67e0eeb]33   // _do to process output = foobar(input)
34   audio_foobar_do (aubio_foobar_t * foobar, fvec_t * input, cvec_t * output);
[7a8a07e]35
[67e0eeb]36Most parameters can be read and written at any time:
[7a8a07e]37
[67e0eeb]38.. code-block:: C
[7a8a07e]39
[67e0eeb]40   // _get_param to get foobar.param
41   smpl_t aubio_foobar_get_a_parameter (aubio_foobar_t * foobar);
42   // _set_param to set foobar.param
43   uint_t aubio_foobar_set_a_parameter (aubio_foobar_t * foobar, smpl_t a_parameter);
44
45In some case, more functions are available:
[7a8a07e]46
47.. code-block:: C
48
[67e0eeb]49   // non-real time functions
50   uint_t aubio_foobar_reset(aubio_foobar_t * t);
[7a8a07e]51
[67e0eeb]52Basic Types
53-----------
54
55.. code-block:: C
56
57    // integers
58    uint_t n = 10;                 // unsigned
59    sint_t delay = -90;            // signed
60
61    // float
62    smpl_t a = -90.;               // simple precision
63    lsmp_t f = 0.024;              // double precision
64
65    // vector of floats (simple precision)
66    fvec_t * vec = new_fvec(n);
67    vec->data[0] = 1;
68    vec->data[vec->length-1] = 1.; // vec->data has n elements
69    fvec_print(vec);
70    del_fvec(vec);
71
72    // complex data
73    cvec_t * fftgrain = new_cvec(n);
74    vec->norm[0] = 1.;             // vec->norm has n/2+1 elements
75    vec->phas[n/2] = 3.1415;       // vec->phas as well
76    del_cvec(fftgrain);
77
78    // matrix
79    fmat_t * mat = new_fmat (height, length);
80    mat->data[height-1][0] = 1;    // mat->data has height rows
81    mat->data[0][length-1] = 10;   // mat->data[0] has length columns
82    del_fmat(mat);
[7a8a07e]83
84
85Reading a sound file
[f80519b]86--------------------
87
[5782f99]88In this example, `aubio_source <https://aubio.org/doc/latest/source_8h.html>`_
[a7eca0d]89is used to read a media file.
[7a8a07e]90
[5782f99]91First, define a few variables and allocate some memory.
[7a8a07e]92
93.. literalinclude:: ../tests/src/io/test-source.c
94   :language: C
95   :lines: 22-24, 30-32, 34
96
97.. note::
98   With ``samplerate = 0``, ``aubio_source`` will be created with the file's
99   original samplerate.
100
101Now for the processing loop:
102
103.. literalinclude:: ../tests/src/io/test-source.c
104   :language: C
105   :lines: 40-44
106
[5782f99]107At the end of the processing loop, memory is deallocated:
[7a8a07e]108
109.. literalinclude:: ../tests/src/io/test-source.c
110   :language: C
[5782f99]111   :lines: 55-56
[7a8a07e]112
113See the complete example: :download:`test-source.c
114<../tests/src/io/test-source.c>`.
115
[f80519b]116Computing a spectrum
117--------------------
[7a8a07e]118
119Now let's create a phase vocoder:
120
121.. literalinclude:: ../tests/src/spectral/test-phasevoc.c
122   :language: C
123   :lines: 6-11
124
[2d00e5c]125The processing loop could now look like:
[7a8a07e]126
127.. literalinclude:: ../tests/src/spectral/test-phasevoc.c
128   :language: C
[5782f99]129   :lines: 20-37
130
131Time to clean up the previously allocated memory:
132
133.. literalinclude:: ../tests/src/spectral/test-phasevoc.c
134   :language: C
135   :lines: 39-44
[7a8a07e]136
137See the complete example: :download:`test-phasevoc.c
138<../tests/src/spectral/test-phasevoc.c>`.
139
140.. _doxygen-documentation:
141
142Doxygen documentation
143---------------------
144
[f80519b]145The latest version of the API documentation is built using `Doxygen
146<http://www.doxygen.org/>`_ and is available at:
[7a8a07e]147
[4da6f20]148    https://aubio.org/doc/latest/
[7a8a07e]149
150Contribute
151----------
152
153Please report any issue and feature request at the `Github issue tracker
154<https://github.com/aubio/aubio/issues>`_. Patches and pull-requests welcome!
Note: See TracBrowser for help on using the repository browser.