feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5sampler
Last change
on this file since b799241 was
24a7764,
checked in by Paul Brossier <piem@piem.org>, 8 years ago
|
doc/xcode_frameworks.rst: add simple swift example
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Rev | Line | |
---|
[40dd715] | 1 | .. _xcode-frameworks-label: |
---|
| 2 | |
---|
| 3 | Using aubio frameworks in Xcode |
---|
| 4 | ------------------------------- |
---|
| 5 | |
---|
| 6 | `Binary frameworks`_ are available and ready to use in your XCode project, for |
---|
| 7 | `iOS`_ and `macOS`_. |
---|
| 8 | |
---|
[3438b42] | 9 | #. Download and extract the corresponding ``framework.zip`` file from the `Download`_ page |
---|
[40dd715] | 10 | |
---|
[3438b42] | 11 | #. Select **Build Phases** in your project setting and unfold **Link Binary with Libraries** |
---|
[40dd715] | 12 | |
---|
[3438b42] | 13 | #. Add *AudioToolbox* and *Accelerate* system frameworks (or make sure they are listed) |
---|
[40dd715] | 14 | |
---|
[3438b42] | 15 | #. Add ``aubio.framework`` from the unzipped ``framework.zip`` |
---|
[40dd715] | 16 | |
---|
| 17 | #. Include the aubio header in your code: |
---|
| 18 | |
---|
| 19 | * in C/C++: |
---|
| 20 | |
---|
| 21 | .. code-block:: c |
---|
| 22 | |
---|
| 23 | #include <aubio/aubio.h> |
---|
| 24 | |
---|
| 25 | * in Obj-C: |
---|
| 26 | |
---|
| 27 | .. code-block:: obj-c |
---|
| 28 | |
---|
| 29 | #import <aubio/aubio.h> |
---|
| 30 | |
---|
| 31 | * in Swift: |
---|
| 32 | |
---|
| 33 | .. code-block:: swift |
---|
| 34 | |
---|
| 35 | import aubio |
---|
| 36 | |
---|
[24a7764] | 37 | Using aubio from swift |
---|
| 38 | ...................... |
---|
| 39 | |
---|
| 40 | Here is a short example showing how to read a sound file in swift: |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | .. code-block:: swift |
---|
| 44 | |
---|
| 45 | import aubio |
---|
| 46 | |
---|
| 47 | let path = Bundle.main.path(forResource: "example", ofType: "mp4") |
---|
| 48 | if (path != nil) { |
---|
| 49 | let hop_size : uint_t = 512 |
---|
| 50 | let a = new_fvec(hop_size) |
---|
| 51 | let b = new_aubio_source(path, 0, hop_size) |
---|
| 52 | var read: uint_t = 0 |
---|
| 53 | var total_frames : uint_t = 0 |
---|
| 54 | while (true) { |
---|
| 55 | aubio_source_do(b, a, &read) |
---|
| 56 | total_frames += read |
---|
| 57 | if (read < hop_size) { break } |
---|
| 58 | } |
---|
| 59 | print("read", total_frames, "frames at", aubio_source_get_samplerate(b), "Hz") |
---|
| 60 | del_aubio_source(b) |
---|
| 61 | del_fvec(a) |
---|
| 62 | } else { |
---|
| 63 | print("could not find file") |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | |
---|
[40dd715] | 67 | .. _Binary frameworks: https://aubio.org/download |
---|
| 68 | .. _iOS: https://aubio.org/download#ios |
---|
| 69 | .. _macOS: https://aubio.org/download#osx |
---|
| 70 | .. _Download: https://aubio.org/download |
---|
Note: See
TracBrowser
for help on using the repository browser.