2
Aubioライブラリに格納されているC値にアクセスしようとしていて、構造体値にアクセスしていると思います。swift 4アクセスライブラリのC構造体値
ライブラリは、C構造体とfvec_get_data機能を持っています
戻る迅速に提案されているよう私は、データを読み込むtypedef struct {
uint_t length; /**< length of buffer */
smpl_t *data; /**< data vector of length ::fvec_t.length */
} fvec_t;
//in fvec.c
smpl_t * fvec_get_data(const fvec_t *s) {
return s->data;
}
:
let oout = new_fvec(n_coefs)
let c = new_aubio_mfcc(win_s, n_filters, n_coefs, samplerate);
var read: uint_t = 0
var dataStore = [smpl_t]()
while (true) {
aubio_source_do(b, a, &read)
aubio_mfcc_do(c, iin, oout)
dataStore.append(fvec_get_data(oout).pointee)
total_frames += read
if (read < hop_size) { break }
}
をしかし、これはすべてのデータを取得しないで、配列は最初の値だけです。 whileループでの比較では、呼び出すことができます。
この行い c codeを見てみるとfvec_print(oout) // this prints out ALL values not just the first
...
:スウィフトにすべての値を取得する方法について
void fvec_print(const fvec_t *s) {
uint_t j;
for (j=0; j< s->length; j++) {
AUBIO_MSG(AUBIO_SMPL_FMT " ", s->data[j]);
}
AUBIO_MSG("\n");
}
任意の提案を大いに感謝します。
おかげで、タイプ 'UnsafeMutablePointer?'の値を取得します。メンバ 'length'はありません。 2番目のオプションでは、値 'UnsafeMutablePointer ?'を取得します。メンバーのデータがありません –
mlrob
@mlrob:更新された回答を参照してください。 –
ありがとうございます - どちらも素晴らしいです。 – mlrob