Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

FileRead.h
1#ifndef STK_FILEREAD_H
2#define STK_FILEREAD_H
3
4#include "Stk.h"
5
6 namespace stk {
7
8/***************************************************/
39/***************************************************/
40
41 class FileRead : public Stk
42{
43 public:
45 FileRead( void );
46
48
54 FileRead( std::string fileName, bool typeRaw = false, unsigned int nChannels = 1,
55 StkFormat format = STK_SINT16, StkFloat rate = 22050.0 );
56
58 ~FileRead( void );
59
61
67 void open( std::string fileName, bool typeRaw = false, unsigned int nChannels = 1,
68 StkFormat format = STK_SINT16, StkFloat rate = 22050.0 );
69
71 void close( void );
72
74 bool isOpen( void );
75
77 unsigned long fileSize( void ) const { return fileSize_; };
78
80 unsigned int channels( void ) const { return channels_; };
81
83 StkFormat format( void ) const { return dataType_; };
84
86
91 StkFloat fileRate( void ) const { return fileRate_; };
92
94
106 void read( StkFrames& buffer, unsigned long startFrame = 0, bool doNormalize = true );
107
108 protected:
109
110 // Get STK RAW file information.
111 bool getRawInfo( const char *fileName, unsigned int nChannels,
112 StkFormat format, StkFloat rate );
113
114 // Get WAV file header information.
115 bool getWavInfo( const char *fileName );
116
117 // Get SND (AU) file header information.
118 bool getSndInfo( const char *fileName );
119
120 // Get AIFF file header information.
121 bool getAifInfo( const char *fileName );
122
123 // Get MAT-file header information.
124 bool getMatInfo( const char *fileName );
125
126 // Helper function for MAT-file parsing.
127 bool findNextMatArray( SINT32 *chunkSize, SINT32 *rows, SINT32 *columns, SINT32 *nametype );
128
129 FILE *fd_;
130 bool byteswap_;
131 bool wavFile_;
132 unsigned long fileSize_;
133 unsigned long dataOffset_;
134 unsigned int channels_;
135 StkFormat dataType_;
136 StkFloat fileRate_;
137};
138
139} // stk namespace
140
141#endif
stk::FileRead::channels
unsigned int channels(void) const
Return the number of audio channels in the file.
Definition FileRead.h:80
stk::FileRead::~FileRead
~FileRead(void)
Class destructor.
stk::FileRead::fileSize
unsigned long fileSize(void) const
Return the file size in sample frames.
Definition FileRead.h:77
stk::FileRead::isOpen
bool isOpen(void)
Returns true if a file is currently open.
stk::FileRead::close
void close(void)
If a file is open, close it.
stk::FileRead::read
void read(StkFrames &buffer, unsigned long startFrame=0, bool doNormalize=true)
Read sample frames from the file into an StkFrames object.
stk::FileRead::FileRead
FileRead(void)
Default constructor.
stk::FileRead::fileRate
StkFloat fileRate(void) const
Return the file sample rate in Hz.
Definition FileRead.h:91
stk::FileRead::format
StkFormat format(void) const
Return the data format of the file.
Definition FileRead.h:83
stk::FileRead::open
void open(std::string fileName, bool typeRaw=false, unsigned int nChannels=1, StkFormat format=STK_SINT16, StkFloat rate=22050.0)
Open the specified file and determine its formatting.
stk::FileRead::FileRead
FileRead(std::string fileName, bool typeRaw=false, unsigned int nChannels=1, StkFormat format=STK_SINT16, StkFloat rate=22050.0)
Overloaded constructor that opens a file during instantiation.
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.