spa

Files: spa.h, spa.c

Stream a Soundpipe Audio File Similar to sp_diskin, sp_spa will stream a file in the internal soundpipe audio format. Such a format is useful for instances where you need to read audio files, but can't use libsndfile.

Functions

sp_spa_create(sp_spa **spa)
sp_spa_init(sp_data *sp, sp_spa *spa, const char *filename)
sp_spa_compute(sp_data *sp, sp_spa *spa, SPFLOAT *out)
sp_spa_destroy(sp_spa **spa)

Mandatory Parameters

filename: Filename of SPA file
(Recommended value: N/A)

Outputs

out: Output to spa.

Example Code

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "soundpipe.h"

typedef struct {
    sp_spa *spa;
} UserData;

void process(sp_data *sp, void *udata) {
    UserData *ud = udata;
    SPFLOAT spa = 0;
    sp_spa_compute(sp, ud->spa, NULL, &spa);
    sp->out[0] = spa;
}

int main() {
    UserData ud;
    sp_data *sp;
    sp_create(&sp);
    sp_srand(sp, 1234567);

    sp_spa_create(&ud.spa);

    sp_spa_init(sp, ud.spa, "oneart.spa");

    sp->len = 44100 * 10;
    sp_process(sp, &ud, process);

    sp_spa_destroy(&ud.spa);

    sp_destroy(&sp);
    return 0;
}