Begun creation of audio database class. Rethought AudioFile class design (removed mode switching approach)
This commit is contained in:
+4
-1
@@ -20,7 +20,7 @@ set(Boost_USE_STATIC_RUNTIME OFF)
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# Set build flags
|
# Set build flags
|
||||||
set(CMAKE_CXX_FLAGS "-g -Wall ")
|
set(CMAKE_CXX_FLAGS "-g -Wall")
|
||||||
# Set cmake to output executable to the bin directory
|
# Set cmake to output executable to the bin directory
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
@@ -56,7 +56,10 @@ add_subdirectory(external)
|
|||||||
|
|
||||||
add_executable(concatenator ${CONCATENATOR_SOURCE_FILES} ${CONCATENATOR_HEADER_FILES})
|
add_executable(concatenator ${CONCATENATOR_SOURCE_FILES} ${CONCATENATOR_HEADER_FILES})
|
||||||
|
|
||||||
|
# Link to external libraries
|
||||||
target_link_libraries(concatenator ${Boost_LIBRARIES})
|
target_link_libraries(concatenator ${Boost_LIBRARIES})
|
||||||
|
target_link_libraries(concatenator ${LIBSNDFILE_LIBRARIES})
|
||||||
|
|
||||||
# Test build options (this code adapted from: https://github.com/ComicSansMS/GhulbusBase/blob/master/CMakeLists.txt)
|
# Test build options (this code adapted from: https://github.com/ComicSansMS/GhulbusBase/blob/master/CMakeLists.txt)
|
||||||
option(BUILD_TESTS "Determines whether to build tests." ON)
|
option(BUILD_TESTS "Determines whether to build tests." ON)
|
||||||
if(BUILD_TESTS)
|
if(BUILD_TESTS)
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
class AudioDatabase {
|
||||||
|
public:
|
||||||
|
template<typename Iter>
|
||||||
|
AudioDatabase(std::string audio_dir, std::string database_dir, Iter it, Iter end);
|
||||||
|
private:
|
||||||
|
std::string database_dir = "";
|
||||||
|
std::string audio_dir = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename container>
|
||||||
|
bool in_array(const string &value, const container &array)
|
||||||
|
{
|
||||||
|
cout <<"Test: " << value << endl;
|
||||||
|
return std::find(array.begin(), array.end(), value) != array.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Iter>
|
||||||
|
bool check_analyses_valid(Iter iterator, Iter end)
|
||||||
|
{
|
||||||
|
static std::list<string> valid_analyses = {"f0", "RMS"};
|
||||||
|
|
||||||
|
while(iterator != end)
|
||||||
|
{
|
||||||
|
if(!in_array(*iterator, valid_analyses)) {
|
||||||
|
cout << "Nope!" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
++iterator;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Iter>
|
||||||
|
AudioDatabase::AudioDatabase(string audio_dir, string database_dir, Iter it, Iter end) {
|
||||||
|
cout << "HELLO?!?" << endl;
|
||||||
|
check_analyses_valid(it, end);
|
||||||
|
}
|
||||||
|
|||||||
+7
-9
@@ -3,19 +3,17 @@
|
|||||||
|
|
||||||
class AudioFile {
|
class AudioFile {
|
||||||
public:
|
public:
|
||||||
AudioFile(const char * fname, bool open=true);
|
AudioFile(const char * &name, const int &mode=SFM_RDWR, const int &format=0, const int &channels=0, const int &samplerate=0);
|
||||||
AudioFile(const char * fname, int format, int channels, int samplerate);
|
int open(const int &mode=SFM_READ, const int &format=0, const int &channels=0, const int &samplerate=0);
|
||||||
~AudioFile();
|
protected:
|
||||||
void swap_mode(std::string m);
|
|
||||||
bool is_open() { return open; };
|
|
||||||
private:
|
|
||||||
std::string mode;
|
|
||||||
std::string name;
|
|
||||||
bool open;
|
|
||||||
SndfileHandle file;
|
SndfileHandle file;
|
||||||
|
SF_INFO* file_info;
|
||||||
|
private:
|
||||||
|
std::string name;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AnalysedAudioFile : public AudioFile {
|
class AnalysedAudioFile : public AudioFile {
|
||||||
public:
|
public:
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
|
|||||||
+15
-14
@@ -1,22 +1,23 @@
|
|||||||
#include "AudioFile.h"
|
#include "AudioFile.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
AudioFile::AudioFile(const char * fname, bool open)
|
AudioFile::AudioFile(const char * &name, const int &mode, const int &format, const int &channels, const int &samplerate)
|
||||||
{
|
{
|
||||||
if(open) {
|
this->name = name;
|
||||||
file = SndfileHandle(fname);
|
open(mode, format, channels, samplerate);
|
||||||
|
}
|
||||||
|
|
||||||
|
int AudioFile::open(const int &mode, const int &format, const int &channels, const int &samplerate)
|
||||||
|
{
|
||||||
|
switch(mode){
|
||||||
|
case SFM_READ: file = SndfileHandle(name);
|
||||||
|
case SFM_WRITE: file = SndfileHandle(name, SFM_WRITE, format, channels, samplerate);
|
||||||
|
case SFM_RDWR: file = SndfileHandle(name, SFM_RDWR, format, channels, samplerate);
|
||||||
}
|
}
|
||||||
name = fname;
|
|
||||||
}
|
return 0;
|
||||||
|
|
||||||
AudioFile::AudioFile(const char * fname, const int format, const int channels, const int samplerate)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioFile::swap_mode(string m)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Logger.h"
|
#include "logger.h"
|
||||||
#include "ArgumentParser.h"
|
#include "ArgumentParser.h"
|
||||||
#include "AudioDatabase.h"
|
#include "AudioDatabase.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
Logger log = Logger();
|
Logger log = Logger();
|
||||||
|
|
||||||
ArgumentParser argparse = ArgumentParser();
|
ArgumentParser argparse = ArgumentParser();
|
||||||
//argparse.parseargs(argc, argv);
|
//argparse.parseargs(argc, argv);
|
||||||
log.error("My pretty little error!");
|
log.error("My pretty little error!");
|
||||||
|
|
||||||
|
vector<string> analyses = {"BLARGH"};
|
||||||
|
AudioDatabase db = AudioDatabase("./", "./", analyses.begin(), analyses.end());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user