Utility function for reading WAV audio files.
More...
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "wave_file_reader.h"
Utility function for reading WAV audio files.
- Author
- Edward A. Lee
- Copyright
- (c) 2020-2023, The University of California at Berkeley License in BSD 2-clause
See wave_file_reader.h for instructions.
◆ FILE_PATH_SEPARATOR
#define FILE_PATH_SEPARATOR '/'; |
◆ read_wave_file()
Open a wave file, check that the format is supported, allocate memory for the sample data, and fill the memory with the sample data. It is up to the caller to free the memory when done with it. That code should first free the waveform element of the returned struct, then the struct itself. This implementation supports only 16-bit linear PCM files. On a Mac, you can convert audio files into this format using the afconvert utility.
- Parameters
-
path | The path to the file. |
- Returns
- An array of sample data or NULL if the file can't be opened or has an usupported format.