summaryrefslogtreecommitdiffstats
path: root/src/wavfile.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-07-24 14:43:24 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-07-24 14:43:24 +0200
commit62409ce26f1fd41d915c4022088fcb8b133ae6c6 (patch)
tree9ce0442470430445daf09ad6deb5f52026078c4b /src/wavfile.cpp
parent864cebd1d753a603de9a24d26a830bad87e2a42f (diff)
downloadODR-AudioEnc-62409ce26f1fd41d915c4022088fcb8b133ae6c6.tar.gz
ODR-AudioEnc-62409ce26f1fd41d915c4022088fcb8b133ae6c6.tar.bz2
ODR-AudioEnc-62409ce26f1fd41d915c4022088fcb8b133ae6c6.zip
Add a --decoder option for loopback testing
Diffstat (limited to 'src/wavfile.cpp')
-rw-r--r--src/wavfile.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/wavfile.cpp b/src/wavfile.cpp
index dbc1e13..7de4ffc 100644
--- a/src/wavfile.cpp
+++ b/src/wavfile.cpp
@@ -211,7 +211,15 @@ struct wavfile_header {
int data_length;
};
-WavWriter::WavWriter(const char *filename, int rate)
+WavWriter::WavWriter(const char *filename)
+{
+ m_fd = fopen(filename, "w+");
+ if (not m_fd) {
+ throw std::runtime_error("Could not open wav file");
+ }
+}
+
+void WavWriter::initialise_header(int rate)
{
struct wavfile_header header;
@@ -233,11 +241,6 @@ WavWriter::WavWriter(const char *filename, int rate)
header.bits_per_sample = bits_per_sample;
header.data_length = 0;
- m_fd = fopen(filename, "w+");
- if (not m_fd) {
- throw std::runtime_error("Could not open wav file");
- }
-
fwrite(&header,sizeof(header),1,m_fd);
fflush(m_fd);
@@ -261,8 +264,8 @@ WavWriter::~WavWriter()
fclose(m_fd);
}
-void WavWriter::write_data(short data[], int length)
+void WavWriter::write_data(const uint8_t *data, int length)
{
- fwrite(data,sizeof(short),length,m_fd);
+ fwrite(data,sizeof(uint8_t),length,m_fd);
}