Files: lpc.h, lpc.c

A linear predictive coding filter. This module is a wrapper for the open source library openlpc, which implements the LPC10 audio codec optimized for speech signals. This module takes in an input signal, downsamples it, and produces a decoded LPC10 audio signal, which has a similar sound to that of a speak and spell. In this context, the LPC signal is meant to be more of a audio effect rather than a utility for communication.
Because the LPC10 encoder relies on frames for encoding, the output signal has a few milliseconds of delay. The delay can be calculated in seconds as (framesize * 4) / samplerate.
In addition to using the LPC as a decoder/encoder, this module can also be set to synth mode. Instead of reading from an input signal, the LPC can instead read from parameters set directly in a scaled ftable.


sp_lpc_create(sp_lpc **lpc)
sp_lpc_init(sp_data *sp, sp_lpc *lpc, int framesize)
sp_lpc_compute(sp_data *sp, sp_lpc *lpc, SPFLOAT *input, SPFLOAT *output)
sp_lpc_destroy(sp_lpc **lpc)

Mandatory Parameters

framesize: Sets the frame size for the encoder.
(Recommended value: 512)

Optional Parameters


input: Input signal to be processed with LPC.


output: LPC encoded signal.

Other Functions:

sp_lpc_synth(sp_data *sp, sp_lpc *lpc, sp_ftbl * ft)
Toggle synth mode. Instead of reading an input, manipulate the parameters in a scaled ftable.
ft: ftable of size 7
(Suggested default: N/A)

Example Code

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

typedef struct {
    sp_diskin *wav;
    sp_lpc *lpc;
} user_data;

static void process(sp_data *sp, void *ud)
    user_data *dt;
    SPFLOAT diskin;
    SPFLOAT out;
    dt = ud;

    sp_diskin_compute(sp, dt->wav, NULL, &diskin);
    sp_lpc_compute(sp, dt->lpc, &diskin, &out);

    sp_out(sp, 0, out);

int main(int argc, char **argv)
    user_data dt;
    sp_data *sp;

    sp->sr = 44100;
    sp->len = sp->sr * 8;

    sp_lpc_init(sp, dt.lpc, 512);

    sp_diskin_init(sp, dt.wav, "oneart.wav");

    sp_process(sp, &dt, process);
    return 0;