paulstretch

Files: paulstretch.h, paulstretch.c

An extreme time-stretching algorithm by Paul Nasca Octavian This is an implementation of the popular paulstretch algorithm used for time stretching an audio signal to create ambient textures. Ideally, this algorithm is best used for stretching signals by very very long amounts.
This version of paulstretch will take an ftable and loop through it, make it an ideal means for creating sustained pads.

Functions

sp_paulstretch_create(sp_paulstretch **paulstretch)
sp_paulstretch_init(sp_data *sp, sp_paulstretch *paulstretch, sp_ftbl *ft, SPFLOAT windowsize, SPFLOAT stretch)
sp_paulstretch_compute(sp_data *sp, sp_paulstretch *paulstretch, SPFLOAT *out)
sp_paulstretch_destroy(sp_paulstretch **paulstretch)

Mandatory Parameters

ft: ftable containing audio data
(Recommended value: N/A)
windowsize: Window size, in seconds.
(Recommended value: 10)
stretch: Stretch factor, 1.0 is no stretch.
(Recommended value: 10)

Optional Parameters


Outputs

out: Signal output.

Example Code

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

typedef struct {
    sp_paulstretch *paulstretch;
    sp_ftbl *ft; 
} UserData;

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

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

    sp_paulstretch_create(&ud.paulstretch);
    sp_ftbl_loadfile(sp, &ud.ft, "oneart.wav");

    sp_paulstretch_init(sp, ud.paulstretch, ud.ft, 1.0, 10);

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

    sp_paulstretch_destroy(&ud.paulstretch);
    sp_ftbl_destroy(&ud.ft);

    sp_destroy(&sp);
    return 0;
}