MCPcopy Create free account
hub / github.com/adamstark/AudioFile / AudioFile

Class AudioFile

AudioFile.h:84–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82//=============================================================
83template <class T>
84class AudioFile
85{
86public:
87
88 //=============================================================
89 typedef std::vector<std::vector<T> > AudioBuffer;
90
91 //=============================================================
92 /** Constructor */
93 AudioFile();
94
95 /** Constructor, using a given file path to load a file */
96 AudioFile (const std::string& filePath);
97
98 //=============================================================
99 /** Loads an audio file from a given file path.
100 * @Returns true if the file was successfully loaded
101 */
102 bool load (const std::string& filePath);
103
104 /** Saves an audio file to a given file path.
105 * @Returns true if the file was successfully saved
106 */
107 bool save (const std::string& filePath, AudioFileFormat format = AudioFileFormat::Wave);
108
109 //=============================================================
110 /** Loads an audio file from data in memory */
111 bool loadFromMemory (const std::vector<uint8_t>& fileData);
112
113 //=============================================================
114 /** Saves an audio file to data in memory */
115 bool saveToMemory (std::vector<uint8_t>& fileData, AudioFileFormat format = AudioFileFormat::Wave);
116
117 //=============================================================
118 /** @Returns the sample rate */
119 uint32_t getSampleRate() const;
120
121 /** @Returns the number of audio channels in the buffer */
122 int getNumChannels() const;
123
124 /** @Returns true if the audio file is mono */
125 bool isMono() const;
126
127 /** @Returns true if the audio file is stereo */
128 bool isStereo() const;
129
130 /** @Returns the bit depth of each sample */
131 int getBitDepth() const;
132
133 /** @Returns the number of samples per channel */
134 int getNumSamplesPerChannel() const;
135
136 /** @Returns the length in seconds of the audio file based on the number of samples and sample rate */
137 double getLengthInSeconds() const;
138
139 /** Prints a summary of the audio file to the console */
140 void printSummary() const;
141

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected