SPKitWriter


User's Guide

SPKitWriter is an signal output class. It requests samples from its input in a loop and writes them into a soundfile.

SPKitWriter is connected to its input object and output soundfile with the setInputOutput(SPKitProcessor* ip, char* sf) function, where ip is a pointer to the input object and sf is the name of the output soundfile. setInputOutput() opens the soundfile for writing. It overwrites an existing file by the same name as in sf.

SPKitWriter writes the audio samples with either the run() or runFor(int nSamples) function. run() writes all samples in one loop, while runFor() writes in batches on nSamples per call. runFor return the number of samples written.

Here is an example.

The current implementation of SPKitWriter supports only 16 bit linear NeXT/SUN audio files.


Programmer's Reference

Defined in <spkit/writer.h>
Inherits from SPKitProcessor

SPKitWriter defines run() and runFor() functions for writing audio samples into a soundfile. SPKitWriter also defines a setInputOutput() function for connecting the object to its input object and output soundfile.

The setInput() and getSample() functions defined in SPKitProcessor should not be used with SPKitWriter.

Public Members

SPKitError setInputOutput(SPKitProcessor* ip, char* sf)
connect an input (ip) to the object, open a soundfile (sf) for writing.

Sets input to ip.

Calls SPKitProcessor::setInput().

void run()
request samples from input in a loop and and write them into the output soundfile.
void runFor(int nSamples)
request samples from input in a loop, nSamples per call, and and write them into the output soundfile. Returns the number of samples written on the call.
int32 getSamplesWritten()
return samplesWritten

Protected Members

These members are specific to the "generic" version of SPKit, which supports the NeXT/Sun soundfile format. The SGI version is not documented yet. The public members are the same in both versions.
FILE* filePtr
pointer to the output soundfile
SndHeader* fileHeader
pointer to the output soundfile header
int32 samplesWritten
number of samples written into the output soundfile

Return to SPKit home

Kai Lassfolk / University of Helsinki / kpl@elisir.helsinki.fi