Skip to content
Snippets Groups Projects
Commit 6d426472 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

Merge branch 'master' into multichannel

Conflicts:
	daemon/src/audio/sound/audiofile.cpp
	daemon/src/sfl_types.h
parents 64ca6db1 c38a6c0e
Branches
Tags
No related merge requests found
......@@ -44,18 +44,18 @@
struct wavhdr {
char riff[4]; // "RIFF"
SINT32 file_size; // in bytes
int32_t file_size; // in bytes
char wave[4]; // "WAVE"
char fmt[4]; // "fmt "
SINT32 chunk_size; // in bytes (16 for PCM)
SINT16 format_tag; // 1=PCM, 2=ADPCM, 3=IEEE float, 6=A-Law, 7=Mu-Law
SINT16 num_chans; // 1=mono, 2=stereo
SINT32 sample_rate;
SINT32 bytes_per_sec;
SINT16 bytes_per_samp; // 2=16-bit mono, 4=16-bit stereo
SINT16 bits_per_samp;
int32_t chunk_size; // in bytes (16 for PCM)
int16_t format_tag; // 1=PCM, 2=ADPCM, 3=IEEE float, 6=A-Law, 7=Mu-Law
int16_t num_chans; // 1=mono, 2=stereo
int32_t sample_rate;
int32_t bytes_per_sec;
int16_t bytes_per_samp; // 2=16-bit mono, 4=16-bit stereo
int16_t bits_per_samp;
char data[4]; // "data"
SINT32 data_length; // in bytes
int32_t data_length; // in bytes
};
namespace {
......@@ -388,7 +388,7 @@ void AudioRecord::closeWavFile()
DEBUG("Close wave file");
SINT32 bytes = byteCounter_ * channels_;
int32_t bytes = byteCounter_ * channels_;
// jump to data length
if (fseek(fileHandle_, 40, SEEK_SET) != 0)
......@@ -397,7 +397,7 @@ void AudioRecord::closeWavFile()
if (ferror(fileHandle_))
WARN("Can't reach offset 40 while closing");
fwrite(&bytes, sizeof(SINT32), 1, fileHandle_);
fwrite(&bytes, sizeof(int32_t), 1, fileHandle_);
if (ferror(fileHandle_))
WARN("Can't write bytes for data length ");
......
......@@ -147,7 +147,7 @@ class AudioRecord {
/**
* Number of channels
*/
SINT16 channels_;
int16_t channels_;
/**
* Number of byte recorded
......
......@@ -149,7 +149,7 @@ WaveFile::WaveFile(const std::string &fileName, unsigned int sampleRate) : Audio
if (maxIteration == 0)
throw AudioFileException("Could not find \"fmt \" chunk");
SINT32 chunkSize; // fmt chunk size
int32_t chunkSize; // fmt chunk size
fileStream.read(reinterpret_cast<char *>(&chunkSize), sizeof chunkSize); // Read fmt chunk size.
unsigned short formatTag; // data compression tag
fileStream.read(reinterpret_cast<char *>(&formatTag), sizeof formatTag);
......@@ -158,24 +158,24 @@ WaveFile::WaveFile(const std::string &fileName, unsigned int sampleRate) : Audio
throw AudioFileException("File contains an unsupported data format type");
// Get number of channels from the header.
SINT16 chan;
int16_t chan;
fileStream.read(reinterpret_cast<char *>(&chan), sizeof chan);
if (chan > 2)
throw AudioFileException("WaveFile: unsupported number of channels");
// Get file sample rate from the header.
SINT32 fileRate;
int32_t fileRate;
fileStream.read(reinterpret_cast<char *>(&fileRate), sizeof fileRate);
SINT32 avgb;
int32_t avgb;
fileStream.read(reinterpret_cast<char *>(&avgb), sizeof avgb);
SINT16 blockal;
int16_t blockal;
fileStream.read(reinterpret_cast<char *>(&blockal), sizeof blockal);
// Determine the data type
SINT16 dt;
int16_t dt;
fileStream.read(reinterpret_cast<char *>(&dt), sizeof dt);
if (dt != 8 && dt != 16 && dt != 32)
......@@ -189,11 +189,11 @@ WaveFile::WaveFile(const std::string &fileName, unsigned int sampleRate) : Audio
fileStream.read(data, sizeof data / sizeof * data);
// Samplerate converter initialized with 88200 sample long
const int rate = static_cast<SINT32>(sampleRate);
const int rate = static_cast<int32_t>(sampleRate);
SamplerateConverter converter(std::max(fileRate, rate), chan);
// Get length of data from the header.
SINT32 bytes;
int32_t bytes;
fileStream.read(reinterpret_cast<char *>(&bytes), sizeof bytes);
// sample frames, should not be longer than a minute
......
......@@ -35,20 +35,8 @@
#include <stdint.h>
typedef int16_t SFLAudioSample;
typedef int16_t SINT16;
typedef int32_t SINT32;
#define SFL_DATA_FORMAT_MAX SHRT_MAX
/*
typedef struct {
int sample_rate;
size_t channels;
size_t sample_num; // number of multichannel samples
SFLAudioSample *samples; // buffer, must be able to hold at least channels*sample_num SFLAudioSamples
} SFLAudioBuffer;
*/
static const size_t SIZEBUF = 400000; /** About 12 sec of buffering at 8000 Hz*/
#endif // SFL_TYPES_H_
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment