Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

FileWrite.h
1#ifndef STK_FILEWRITE_H
2#define STK_FILEWRITE_H
3
4#include "Stk.h"
5
6 namespace stk {
7
8/***************************************************/
29/***************************************************/
30
31 class FileWrite : public Stk
32{
33 public:
34
35 typedef unsigned long FILE_TYPE;
36
37 static const FILE_TYPE FILE_RAW;
38 static const FILE_TYPE FILE_WAV;
39 static const FILE_TYPE FILE_SND;
40 static const FILE_TYPE FILE_AIF;
41 static const FILE_TYPE FILE_MAT;
42
44 FileWrite( void );
45
47
50 FileWrite( std::string fileName, unsigned int nChannels = 1, FILE_TYPE type = FILE_WAV, Stk::StkFormat format = STK_SINT16 );
51
53 virtual ~FileWrite();
54
56
59 void open( std::string fileName, unsigned int nChannels = 1,
60 FileWrite::FILE_TYPE type = FILE_WAV, Stk::StkFormat format = STK_SINT16 );
61
63 void close( void );
64
66 bool isOpen( void );
67
69
74 void write( StkFrames& buffer );
75
76 protected:
77
78 // Write STK RAW file header.
79 bool setRawFile( std::string fileName );
80
81 // Write WAV file header.
82 bool setWavFile( std::string fileName );
83
84 // Close WAV file, updating the header.
85 void closeWavFile( void );
86
87 // Write SND (AU) file header.
88 bool setSndFile( std::string fileName );
89
90 // Close SND file, updating the header.
91 void closeSndFile( void );
92
93 // Write AIFF file header.
94 bool setAifFile( std::string fileName );
95
96 // Close AIFF file, updating the header.
97 void closeAifFile( void );
98
99 // Write MAT-file header.
100 bool setMatFile( std::string fileName );
101
102 // Close MAT-file, updating the header.
103 void closeMatFile( void );
104
105 FILE *fd_;
106 FILE_TYPE fileType_;
107 StkFormat dataType_;
108 unsigned int channels_;
109 unsigned long frameCounter_;
110 bool byteswap_;
111
112};
113
114} // stk namespace
115
116#endif
stk::FileWrite::FILE_SND
static const FILE_TYPE FILE_SND
Definition FileWrite.h:39
stk::FileWrite::FileWrite
FileWrite(std::string fileName, unsigned int nChannels=1, FILE_TYPE type=FILE_WAV, Stk::StkFormat format=STK_SINT16)
Overloaded constructor used to specify a file name, type, and data format with this object.
stk::FileWrite::isOpen
bool isOpen(void)
Returns true if a file is currently open.
stk::FileWrite::FILE_AIF
static const FILE_TYPE FILE_AIF
Definition FileWrite.h:40
stk::FileWrite::open
void open(std::string fileName, unsigned int nChannels=1, FileWrite::FILE_TYPE type=FILE_WAV, Stk::StkFormat format=STK_SINT16)
Create a file of the specified type and name and output samples to it in the given data format.
stk::FileWrite::FILE_WAV
static const FILE_TYPE FILE_WAV
Definition FileWrite.h:38
stk::FileWrite::close
void close(void)
If a file is open, write out samples in the queue and then close it.
stk::FileWrite::FileWrite
FileWrite(void)
Default constructor.
stk::FileWrite::~FileWrite
virtual ~FileWrite()
Class destructor.
stk::FileWrite::FILE_RAW
static const FILE_TYPE FILE_RAW
Definition FileWrite.h:37
stk::FileWrite::FILE_MAT
static const FILE_TYPE FILE_MAT
Definition FileWrite.h:41
stk::FileWrite::write
void write(StkFrames &buffer)
Write sample frames from the StkFrames object to the file.
stk::StkFrames
An STK class to handle vectorized audio data.
Definition Stk.h:279
stk::Stk::STK_SINT16
static const StkFormat STK_SINT16
Definition Stk.h:141
stk::Stk::Stk
Stk(void)
Default constructor.
stk
The STK namespace.
Definition ADSR.h:6

The Synthesis ToolKit in C++ (STK)
©1995--2023 Perry R. Cook and Gary P. Scavone. All Rights Reserved.