waveset

Files: waveset.h, waveset.c

Simple Time-stretching from repeating wavecyles This module looks for zero-crossings and repeats them by a integer factor. While a crude means for time stretching, it is a very aesthetically pleasing effect to use on sounds and often produces at "wet" sound.
The waveset algorithm was originally created by Trevor Wishart for the Composer Desktop Project (CDP), and was then ported to Csound.

Functions

sp_waveset_create(sp_waveset **waveset)
sp_waveset_init(sp_data *sp, sp_waveset *waveset, SPFLOAT ilen)
sp_waveset_compute(sp_data *sp, sp_waveset *waveset, SPFLOAT *input, SPFLOAT *out)
sp_waveset_destroy(sp_waveset **waveset)

Mandatory Parameters

ilen: Length of buffer (in seconds).
(Recommended value: 1.0)

Optional Parameters

rep: Number of repeats.
(Default value: 1.5)

Inputs

input: Signal input.

Outputs

out: signal output.

Example Code

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

typedef struct {
    sp_waveset *waveset;
    sp_diskin *diskin;
} UserData;

void process(sp_data *sp, void *udata) {
    UserData *ud = udata;
    SPFLOAT wav = 0, waveset = 0;
    sp_diskin_compute(sp, ud->diskin, NULL, &wav);
    sp_waveset_compute(sp, ud->waveset, &wav, &waveset);
    sp_out(sp, 0, waveset);
}

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

    sp_waveset_create(&ud.waveset);
    sp_diskin_create(&ud.diskin);

    sp_waveset_init(sp, ud.waveset, 1.0);
    ud.waveset->rep = 3.0;
    sp_diskin_init(sp, ud.diskin, "oneart.wav");

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

    sp_waveset_destroy(&ud.waveset);
    sp_diskin_destroy(&ud.diskin);

    sp_destroy(&sp);
    return 0;
}