Csound and CsoundAC API
5.17
|
Simple, basic read/write access, in sample frames, to PCM soundfiles. More...
#include <Soundfile.hpp>
Public Member Functions | |
virtual void | blank (double duration) |
Make the soundfile be so many seconds of silence. | |
virtual void | blank (double duration) |
Make the soundfile be so many seconds of silence. | |
virtual int | close () |
Close the soundfile. | |
virtual int | close () |
Close the soundfile. | |
virtual void | cosineGrain (double centerTimeSeconds, double durationSeconds, double frequencyHz, double amplitude, double phaseOffsetRadians, double pan, bool synchronousPhase=true, bool buffer=false) |
Mix a cosine grain into the soundfile. | |
virtual int | create (std::string filename, int framesPerSecond=44100, int channelsPerFrame=2, int format=SF_FORMAT_WAV|SF_FORMAT_FLOAT) |
Create a new soundfile for writing and/or reading. | |
virtual int | create (std::string filename, int framesPerSecond=44100, int channelsPerFrame=2, int format=SF_FORMAT_WAV|SF_FORMAT_FLOAT) |
Create a new soundfile for writing and/or reading. | |
virtual void | error () const |
Print to stderr any current error status message. | |
virtual void | error () const |
Print to stderr any current error status message. | |
virtual int | getChannelsPerFrame () const |
virtual int | getChannelsPerFrame () const |
virtual int | getFormat () const |
See sndfile.h for a descriptive list of format numbers. | |
virtual int | getFormat () const |
See sndfile.h for a descriptive list of format numbers. | |
virtual int | getFrames () const |
Return the number of sample frames in a just opened file, or just after calling updateHeader. | |
virtual int | getFrames () const |
Return the number of sample frames in a just opened file, or just after calling updateHeader. | |
virtual int | getFramesPerSecond () const |
virtual int | getFramesPerSecond () const |
virtual void | jonesParksGrain (double centerTimeSeconds, double durationSeconds, double beginningFrequencyHz, double centerFrequencyHz, double centerAmplitude, double centerPhaseOffsetRadians, double pan, bool synchronousPhase=true, bool buffer=false) |
Mix a Gaussian chirp into the soundfile. | |
virtual int | mixFrames (double *inputFrames, int samples, double *mixedFrames) |
Mix one or more samples, from a double array (in C++) or a binary string (in Python), into the existing signal in the soundfile. | |
virtual int | mixFrames (double *inputFrames, int samples, double *mixedFrames) |
Mix one or more samples, from a double array (in C++) or a binary string (in Python), into the existing signal in the soundfile. | |
virtual void | mixGrain () |
Mix a grain that has already been computed into the soundfile. | |
virtual int | open (std::string filename) |
Open an existing soundfile for reading and/or writing. | |
virtual int | open (std::string filename) |
Open an existing soundfile for reading and/or writing. | |
virtual int | readFrame (double *outputFrame) |
Read one sample frame, and return it in a double array (in C++) or a sequence (in Python). | |
virtual int | readFrame (double *outputFrame) |
Read one sample frame, and return it in a double array (in C++) or a sequence (in Python). | |
virtual int | readFrames (double *outputFrames, int samples) |
Read one or more samples, and return them in a double array (in C++) or a binary string (in Python). | |
virtual int | readFrames (double *outputFrames, int samples) |
Read one or more samples, and return them in a double array (in C++) or a binary string (in Python). | |
virtual int | seek (int frames, int whence=0) |
Position the soundfile read/write pointer at the indicated sample frame. | |
virtual int | seek (int frames, int whence=0) |
Position the soundfile read/write pointer at the indicated sample frame. | |
virtual double | seekSeconds (double seconds, int whence=0) |
virtual double | seekSeconds (double seconds, int whence=0) |
virtual void | setChannelsPerFrame (int channelsPerFrame) |
virtual void | setChannelsPerFrame (int channelsPerFrame) |
virtual void | setFormat (int format) |
See sndfile.h for a descriptive list of format numbers. | |
virtual void | setFormat (int format) |
See sndfile.h for a descriptive list of format numbers. | |
virtual void | setFramesPerSecond (int framesPerSecond) |
virtual void | setFramesPerSecond (int framesPerSecond) |
Soundfile () | |
Soundfile () | |
virtual void | updateHeader () |
Update the soundfile header with the current file size, RIFF chunks, and so on. | |
virtual void | updateHeader () |
Update the soundfile header with the current file size, RIFF chunks, and so on. | |
virtual int | writeFrame (double *inputFrame) |
Write one sample frame, from a double array (in C++) or a sequence (in Python). | |
virtual int | writeFrame (double *inputFrame) |
Write one sample frame, from a double array (in C++) or a sequence (in Python). | |
virtual int | writeFrames (double *inputFrames, int samples) |
Write one or more samples, from a double array (in C++) or a binary string (in Python). | |
virtual int | writeFrames (double *inputFrames, int samples) |
Write one or more samples, from a double array (in C++) or a binary string (in Python). | |
virtual | ~Soundfile () |
virtual | ~Soundfile () |
Protected Member Functions | |
virtual void | initialize () |
virtual void | initialize () |
Private Attributes | |
Eigen::MatrixXd | grainBuffer |
Eigen::MatrixXd | grainOutput |
size_t | sampleCount |
SF_INFO | sf_info |
SNDFILE * | sndfile |
double | startTimeSeconds |
Simple, basic read/write access, in sample frames, to PCM soundfiles.
Reads and writes any format, but write defaults to WAV float format. This class is designed for Python wrapping with SWIG. See http://www.mega-nerd.com/libsndfile for more information on the underlying libsndfile library.
csound::Soundfile::Soundfile | ( | ) |
|
virtual |
csound::Soundfile::Soundfile | ( | ) |
|
virtual |
|
virtual |
Make the soundfile be so many seconds of silence.
|
virtual |
Make the soundfile be so many seconds of silence.
|
virtual |
Close the soundfile.
Should be called once for every opened or created soundfile, although the class destructor will automatically close an open soundfile.
|
virtual |
Close the soundfile.
Should be called once for every opened or created soundfile, although the class destructor will automatically close an open soundfile.
|
virtual |
Mix a cosine grain into the soundfile.
If the soundfile is stereo, the grain will be panned. If the synchronousPhase argument is true (the default value), then all grains of the same frequency will have synchronous phases, which can be useful in avoiding certain artifacts. For example, if cosine grains of the same frequency have synchronous phases, they can be overlapped by 1/2 their duration without artifacts to produce a continuous cosine tone.
If the buffer argument is true (the default is false), the grain is mixed into a buffer; this can be used to speed up writing grains that are arrangement in columns. To actually write the grain, call writeGrain().
The algorithm uses an efficient difference equation.
|
virtual |
Create a new soundfile for writing and/or reading.
The default soundfile format is WAV PCM float samples at 44100 frames per second, stereo.
|
virtual |
Create a new soundfile for writing and/or reading.
The default soundfile format is WAV PCM float samples at 44100 frames per second, stereo.
|
virtual |
Print to stderr any current error status message.
|
virtual |
Print to stderr any current error status message.
|
virtual |
|
virtual |
|
virtual |
See sndfile.h for a descriptive list of format numbers.
|
virtual |
See sndfile.h for a descriptive list of format numbers.
|
virtual |
Return the number of sample frames in a just opened file, or just after calling updateHeader.
|
virtual |
Return the number of sample frames in a just opened file, or just after calling updateHeader.
|
virtual |
|
virtual |
|
protectedvirtual |
|
protectedvirtual |
|
virtual |
Mix a Gaussian chirp into the soundfile.
If the soundfile is stereo, the grain will be panned. If the synchronousPhase argument is true (the default value), then all grains of the same frequency will have synchronous phases, which can be useful in avoiding certain artifacts.
If the buffer argument is true (the default is false), the grain is mixed into a buffer; this can be used to speed up writing grains that are arrangement in columns. To actually write the grain, call writeGrain().
The algorithm uses an efficient difference equation.
|
virtual |
Mix one or more samples, from a double array (in C++) or a binary string (in Python), into the existing signal in the soundfile.
The arrays or the strings must contain as many elements as there are samples (channels times frames) Channels are interleaved within frames. For efficiency, there is no checking of bounds or type in Python; the string must contain binary Float64.
|
virtual |
Mix one or more samples, from a double array (in C++) or a binary string (in Python), into the existing signal in the soundfile.
The arrays or the strings must contain as many elements as there are samples (channels times frames) Channels are interleaved within frames. For efficiency, there is no checking of bounds or type in Python; the string must contain binary Float64.
|
virtual |
Mix a grain that has already been computed into the soundfile.
|
virtual |
Open an existing soundfile for reading and/or writing.
|
virtual |
Open an existing soundfile for reading and/or writing.
|
virtual |
Read one sample frame, and return it in a double array (in C++) or a sequence (in Python).
The array or the sequence must already contain as many elements as there are channels. For efficiency, there is no bounds checking.
|
virtual |
Read one sample frame, and return it in a double array (in C++) or a sequence (in Python).
The array or the sequence must already contain as many elements as there are channels. For efficiency, there is no bounds checking.
|
virtual |
Read one or more samples, and return them in a double array (in C++) or a binary string (in Python).
The array or the string must already contain as many elements as there are samples (channels times frames). Channels are interleaved within frames. For efficiency, there is no bounds checking; on return the string will contain binary Float64. In Python this function is not thread-safe, as a static buffer is used internally.
|
virtual |
Read one or more samples, and return them in a double array (in C++) or a binary string (in Python).
The array or the string must already contain as many elements as there are samples (channels times frames). Channels are interleaved within frames. For efficiency, there is no bounds checking; on return the string will contain binary Float64. In Python this function is not thread-safe, as a static buffer is used internally.
|
virtual |
Position the soundfile read/write pointer at the indicated sample frame.
Set whence to 0 for SEEK_SET, 1 for SEEK_CUR, 2 for SEEK_END. Calling with whence = SEEK_CUR and frames = 0 returns the current read/write pointer.
|
virtual |
Position the soundfile read/write pointer at the indicated sample frame.
Set whence to 0 for SEEK_SET, 1 for SEEK_CUR, 2 for SEEK_END. Calling with whence = SEEK_CUR and frames = 0 returns the current read/write pointer.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
See sndfile.h for a descriptive list of format numbers.
|
virtual |
See sndfile.h for a descriptive list of format numbers.
|
virtual |
|
virtual |
|
virtual |
Update the soundfile header with the current file size, RIFF chunks, and so on.
|
virtual |
Update the soundfile header with the current file size, RIFF chunks, and so on.
|
virtual |
Write one sample frame, from a double array (in C++) or a sequence (in Python).
The array or the sequence must contain as many elements as there are channels. For efficiency, there is no checking of bounds or type in Python; the string must contain Floats. In Python this function is not thread-safe, as a static buffer is used internally.
|
virtual |
Write one sample frame, from a double array (in C++) or a sequence (in Python).
The array or the sequence must contain as many elements as there are channels. For efficiency, there is no checking of bounds or type in Python; the string must contain Floats. In Python this function is not thread-safe, as a static buffer is used internally.
|
virtual |
Write one or more samples, from a double array (in C++) or a binary string (in Python).
The array or the string must contain as many elements as there are samples (channels times frames) Channels are interleaved within frames. For efficiency, there is no checking of bounds or type in Python; the string must contain binary Float64.
|
virtual |
Write one or more samples, from a double array (in C++) or a binary string (in Python).
The array or the string must contain as many elements as there are samples (channels times frames) Channels are interleaved within frames. For efficiency, there is no checking of bounds or type in Python; the string must contain binary Float64.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |