IT++ Logo
Public Member Functions | List of all members
itpp::SND_Out_File Class Reference

A class to write SND-files (the .au format) More...

#include <itpp/srccode/audiofile.h>

Public Member Functions

 SND_Out_File ()
 Default constructor - creates uninitialized stream.
 
 SND_Out_File (const char *fname, const Audio_Stream_Description &d)
 Constructor from file name fname and stream description d.
 
 ~SND_Out_File ()
 Stream destructor.
 
bool open (const char *fname, const Audio_Stream_Description &d)
 Open the file fname with stream description d.
 
void close ()
 Close the file.
 
Audio_Stream_Description get_description () const
 Get stream description.
 
bool seek_write (std::streamoff pos)
 Set current position to write to pos (samples).
 
std::streamoff tell_write ()
 Get current position in samples.
 
std::streamoff num_samples () const
 Get number of samples in stream.
 
bool write_sample (const double &s, int ch=0)
 Write single sample s at current position to channel ch.
 
bool write_channel (const vec &v, int ch=0)
 Write the vector v to channel ch starting at current position.
 
bool write (const mat &m)
 Write audio channels from columns of the matrix m starting at current position.
 

Detailed Description

A class to write SND-files (the .au format)

Output stream uses underlying binary stream to write audio data to the audio file in au format. Audio can be written sample-by sample, channel-wise or taken column-wise from the input matrix

Following example illustrates write operations with SND_Out_File:

using namespace itpp;
int main() {
//create stream description to store 8kHz 16-bit PCM stereo audio data
d = Audio_Stream_Description(enc_linear16, 8000,2);
//create audio stream
SND_Out_File f_out("inptut.au",d);
//fill input with 10004 Hz test tone
mat in(100,2);
for(int i = 0; i < 100; ++i){
in(i,0) = sin(2*pi*i*1004/8000);
in(i,1) = cos(2*pi*i*1004/8000);
}
//write audio samples
f_out.write(in);
//zero sample 5 in channel 0
f_out.seek_write(5); f_out.write_sample(0,0);
//zero samples 5..7 in channel 1
vec z(3); z(0) = 0.0; z(1) = 0.0; z(2) = 0.0;
f_out.seek_write(5); f_out.write_channel(z,1);
return 0;
}

Definition at line 282 of file audiofile.h.


The documentation for this class was generated from the following file:
SourceForge Logo

Generated on Sat Jul 6 2013 10:54:35 for IT++ by Doxygen 1.8.2