Version 4.2.0

This commit is contained in:
Gary Scavone
2009-03-24 23:02:14 -04:00
committed by Stephen Sinclair
parent cf06b7598b
commit a6381b9d38
281 changed files with 17152 additions and 12000 deletions

View File

@@ -14,32 +14,31 @@
tickFrame() method, which takes a pointer
to multi-channel sample frame data.
WvOut currently supports WAV, AIFF, AIFC, SND
(AU), MAT-file (Matlab), and STK RAW file
formats. Signed integer (8-, 16-, and 32-bit)
and floating- point (32- and 64-bit) data types
are supported. STK RAW files use 16-bit
integers by definition. MAT-files will always
be written as 64-bit floats. If a data type
specification does not match the specified file
type, the data type will automatically be
modified. Uncompressed data types are not
supported.
WvOut currently supports uncompressed WAV,
AIFF, AIFC, SND (AU), MAT-file (Matlab), and
STK RAW file formats. Signed integer (8-,
16-, and 32-bit) and floating- point (32- and
64-bit) data types are supported. STK RAW
files use 16-bit integers by definition.
MAT-files will always be written as 64-bit
floats. If a data type specification does not
match the specified file type, the data type
will automatically be modified. Compressed
data types are not supported.
Currently, WvOut is non-interpolating and the
output rate is always Stk::sampleRate().
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
by Perry R. Cook and Gary P. Scavone, 1995 - 2004.
*/
/***************************************************/
#if !defined(__WVOUT_H)
#define __WVOUT_H
#ifndef STK_WVOUT_H
#define STK_WVOUT_H
#include "Stk.h"
#include <stdio.h>
#define BUFFER_SIZE 1024 // sample frames
const unsigned long BUFFER_SIZE = 1024; // sample frames
class WvOut : public Stk
{
@@ -60,7 +59,7 @@ class WvOut : public Stk
/*!
An StkError is thrown for invalid argument values or if an error occurs when initializing the output file.
*/
WvOut( const char *fileName, unsigned int nChannels = 1, FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT format = STK_SINT16 );
WvOut( const char *fileName, unsigned int nChannels = 1, FILE_TYPE type = WVOUT_WAV, Stk::StkFormat format = STK_SINT16 );
//! Class destructor.
virtual ~WvOut();
@@ -70,7 +69,7 @@ class WvOut : public Stk
An StkError is thrown for invalid argument values or if an error occurs when initializing the output file.
*/
void openFile( const char *fileName, unsigned int nChannels = 1,
WvOut::FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT format = STK_SINT16 );
WvOut::FILE_TYPE type = WVOUT_WAV, Stk::StkFormat format = STK_SINT16 );
//! If a file is open, write out samples in the queue and then close it.
void closeFile( void );
@@ -79,25 +78,48 @@ class WvOut : public Stk
unsigned long getFrames( void ) const;
//! Return the number of seconds of data output.
MY_FLOAT getTime( void ) const;
StkFloat getTime( void ) const;
//! Returns \c true if clipping has been detected during output since instantiation or the last reset.
bool getClipStatus( void ) { return clipping_; };
//! Reset the clipping status to \c false.
void resetClipStatus( void ) { clipping_ = false; };
//! Output a single sample to all channels in a sample frame.
/*!
An StkError is thrown if a file write error occurs.
*/
virtual void tick(const MY_FLOAT sample);
virtual void tick(const StkFloat sample);
//! Output each sample in \e vector to all channels in \e vectorSize sample frames.
/*!
An StkError is thrown if a file write error occurs.
*/
virtual void tick(const MY_FLOAT *vector, unsigned int vectorSize);
virtual void tick( const StkFloat *vector, unsigned int vectorSize );
//! Output a channel of the StkFrames object to all channels of the WvOut object.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if a file
write error occurs or the \c channel argument is zero or it is
greater than the number of channels in the StkFrames object.
*/
virtual void tick( const StkFrames& frames, unsigned int channel = 1 );
//! Output the \e frameVector of sample frames of the given length.
/*!
An StkError is thrown if a file write error occurs.
*/
virtual void tickFrame(const MY_FLOAT *frameVector, unsigned int frames = 1);
virtual void tickFrame( const StkFloat *frameVector, unsigned int frames = 1);
//! Output the StkFrames data to the WvOut object.
/*!
An StkError will be thrown if a file write error occurs or if
there is an incompatability between the number of channels in the
WvOut object and that in the StkFrames object.
*/
virtual void tickFrame( const StkFrames& frames );
protected:
@@ -107,6 +129,9 @@ class WvOut : public Stk
// Write data to output file;
virtual void writeData( unsigned long frames );
// Check for sample clipping and clamp.
void clipTest( StkFloat& sample );
// Write STK RAW file header.
bool setRawFile( const char *fileName );
@@ -134,16 +159,16 @@ class WvOut : public Stk
// Close MAT-file, updating the header.
void closeMatFile( void );
char msg[256];
FILE *fd;
MY_FLOAT *data;
FILE_TYPE fileType;
STK_FORMAT dataType;
bool byteswap;
unsigned int channels;
unsigned long counter;
unsigned long totalCount;
FILE *fd_;
std::valarray<StkFloat> data_;
FILE_TYPE fileType_;
StkFormat dataType_;
unsigned int channels_;
unsigned long counter_;
unsigned long totalCount_;
bool byteswap_;
bool clipping_;
};
#endif // defined(__WVOUT_H)
#endif