3. sqlar_loadraw

Like sqlar_loadwav, only for RAW data.

<<funcdefs>>=
int sqlar_loadraw_db(sqlite3 *db,
                     const char *filename,
                     sp_ftbl **ft);
<<functions>>=
int sqlar_loadraw_db(sqlite3 *db,
                     const char *filename,
                     sp_ftbl **ft)
{
    char *bytes;
    int sz;
    size_t size;
    SPFLOAT *tbl;
    sp_ftbl *ftp;
    int rc;
    SPFLOAT *buf;
    int i;

    sz = 0;
    bytes = NULL;
    rc = sqlar_extract_to_buffer_db(db, filename, &bytes, &sz);

    buf = (SPFLOAT *)bytes;

    if (rc != SQLITE_OK) {
        if (buf != NULL) free(buf);
        fprintf(stderr, "SQLite problems\n");
        return SP_NOT_OK;
    }

    size = sz / sizeof(SPFLOAT);
    sp_ftbl_create(NULL, ft, size);
    ftp = *ft;
    tbl = ftp->tbl;

    for (i = 0; i < size; i++) tbl[i] = buf[i];

    free(bytes);
    return SP_OK;
}



prev | home | next