Main Page · Modules · All Classes · Class Hierarchy
MASoundData.hpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #pragma once
23 
24 #include "core/MACoreTypes.hpp"
25 
26 #include <string>
27 
28 class MCBinaryData;
29 
39 {
40 public:
50  static int GetFileDuration(const std::string& file_name);
51 
68  static bool LoadFromFile(const std::string& file_name, MC::DoubleList& left_channel,
69  MC::DoubleList& right_channel, int compression = 0, int bitrate = 0);
70 
80  static MC::DoubleList ConvertToDouble(const MCBinaryData& raw_data);
81 
92  static MCBinaryData* ConvertDoubleToRaw(MC::DoubleList& left_channel, MC::DoubleList& right_channel);
93 
102  static void RemoveLeadingTrailingSilence(MC::DoubleList& audio_data, unsigned int sample_rate);
103 
115  static MC::DoubleList Resample(const MC::DoubleList& audio_data, int original_frequency, int new_frequency);
116 
126  static unsigned int GetWindowSize(unsigned int frequency);
127 
141  static bool Join(const MCBinaryData& left_channel, const MCBinaryData& right_channel, MCBinaryData& stereo);
142 
152  static float CalculatePowerDb(const MC::DoubleList& audio_data);
153 
164  static float CalculateSnr(const float signal_power_db, const float noise_power_db);
165 
167  static const int SampleRateOnAIBO;
168 };
169 
static float CalculatePowerDb(const MC::DoubleList &audio_data)
Calculate the power level of the signal in dB.
static MCBinaryData * ConvertDoubleToRaw(MC::DoubleList &left_channel, MC::DoubleList &right_channel)
Convert double lists back to raw audio data.
static unsigned int GetWindowSize(unsigned int frequency)
Get window size for a given frequency.
static const int SampleRateOnAIBO
Sample rate for audio processing on AIBO.
Binary data class.
static void RemoveLeadingTrailingSilence(MC::DoubleList &audio_data, unsigned int sample_rate)
Remove leading and trailing silences from the audio data.
static int GetFileDuration(const std::string &file_name)
Get audio duration of a file.
Definition: MASoundData.cpp:37
static bool Join(const MCBinaryData &left_channel, const MCBinaryData &right_channel, MCBinaryData &stereo)
Join stereo track into two channels.
Handling sound data.
Definition: MASoundData.hpp:38
static float CalculateSnr(const float signal_power_db, const float noise_power_db)
Calculate signal-to-noise ratio (SNR)
static MC::DoubleList ConvertToDouble(const MCBinaryData &raw_data)
Convert audio data to a double list.
static MC::DoubleList Resample(const MC::DoubleList &audio_data, int original_frequency, int new_frequency)
Resample audio data.
static bool LoadFromFile(const std::string &file_name, MC::DoubleList &left_channel, MC::DoubleList &right_channel, int compression=0, int bitrate=0)
Load audio data from a wav file.
Definition: MASoundData.cpp:53