-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwavfilehandler.h
51 lines (44 loc) · 1.53 KB
/
wavfilehandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef FILEHANDLER_H
#define FILEHANDLER_H
#include <QtGlobal>
#ifdef _WIN32
#include <cstdint>
#elif __APPLE__
#include <stdint.h>
#endif
#include <string>
#include <cstdio>
/// Structure to contain WAVE file data.
struct wave_t
{
uint32_t size; ///< Size of the WAVE file.
uint32_t chunkSize; ///< Size of the fmt chunk.
uint32_t sampleRate; ///< Sample rate of the audio.
uint32_t avgBytesPerSec; ///< Average byte rate.
uint32_t dataSize; ///< Size of the data chunk.
short formatType; ///< Audio format.
short channels; ///< Number of audio channels.
short bytesPerSample; ///< Number of bytes per sample.
short bitsPerSample; ///< Number of bits per sample.
unsigned char* buffer; ///< Buffer to hold audio data.
wave_t() : buffer(NULL) {} ///< Structure Constructor. Initialises data buffer to NULL.
};
/// Class to handle loading of Microsoft signed 16-bit PCM WAVE audio files.
class WavFileHandler
{
public:
/// Loads a given wave file, fills wave_t structure with wave data.
/**
\param File path relative to execution directory.
\param Pointer to a wave_t structure to contain the wave data.
**/
static bool loadWave(std::string fileName, wave_t* wavePtr);
private:
/// Error handling function.
/**
Always returns false, outputs argumen string to the command line.
\param Error message to output.
**/
static bool endOnError(std::string errmsg);
};
#endif