Ignore:
Timestamp:
Feb 27, 2017, 1:20:41 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, sampler
Children:
410a157
Parents:
4f89154
Message:

doc/xcode_frameworks.rst: add simple swift example

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/xcode_frameworks.rst

    r4f89154 r24a7764  
    3535    import aubio
    3636
     37Using aubio from swift
     38......................
     39
     40Here 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
    3767.. _Binary frameworks: https://aubio.org/download
    3868.. _iOS: https://aubio.org/download#ios
Note: See TracChangeset for help on using the changeset viewer.