diff --git a/plugins/NeuralRecord/Makefile b/plugins/NeuralRecord/Makefile index 071d3a0..34c7b3c 100644 --- a/plugins/NeuralRecord/Makefile +++ b/plugins/NeuralRecord/Makefile @@ -165,7 +165,7 @@ ifeq ($(BUILD_LV2),true) @mkdir -p -m755 $(USER_LV2_DIR)/$(NAME).lv2 && \ install -m755 $(TARGET_DIR)/$(NAME).lv2/*$(LIB_EXT) $(USER_LV2_DIR)/$(NAME).lv2 && \ install -m644 $(TARGET_DIR)/$(NAME).lv2/*.ttl $(USER_LV2_DIR)/$(NAME).lv2 && \ - cp -r $(TARGET_DIR)/$(NAME).lv2/resources $(DESTDIR)$(LV2_DIR)/$(NAME).lv2 + cp -r $(TARGET_DIR)/$(NAME).lv2/resources $(USER_LV2_DIR)/$(NAME).lv2 endif ifeq ($(BUILD_JACK),true) ifeq ($(HAVE_JACK),true) diff --git a/plugins/NeuralRecord/profiler.cc b/plugins/NeuralRecord/profiler.cc index 294b69e..7f6c302 100644 --- a/plugins/NeuralRecord/profiler.cc +++ b/plugins/NeuralRecord/profiler.cc @@ -283,17 +283,32 @@ inline std::string Profil::get_ifilename() { struct stat sb; char * path = strdup(get_profile_library_path().data()); std::string iname = dirname(path); - iname += PATH_SEPARATOR "resources" PATH_SEPARATOR "input.wav"; + iname += PATH_SEPARATOR "resources" PATH_SEPARATOR "input.flac"; std::string oname = get_path() + "input.wav"; if (stat (oname.c_str(), &sb) != 0 && stat (iname.c_str(), &sb) == 0) { - std::ifstream src(iname.c_str(), std::ios::binary); - std::ofstream dest(oname.c_str(), std::ios::binary); - dest << src.rdbuf(); + convert_to_wave(iname, oname); } free(path); return oname; } +inline void Profil::convert_to_wave(std::string fname, std::string oname) { + if (tape1) { delete[] tape1; tape1 = 0; } + int lsize = load_from_wave(fname); // load flac file + SF_INFO sfinfo ; + sfinfo.channels = channel; + sfinfo.samplerate = fSamplingFreq; + sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_24; + + SNDFILE * sf = sf_open(oname.c_str(), SFM_WRITE, &sfinfo); + if (sf) { + save_to_wave(sf, tape1, lsize); + sf_close(sf); + } + if (tape1) { delete[] tape1; tape1 = 0; } +} + + // load wav file into buffer inline int Profil::load_from_wave(std::string fname) { SF_INFO sfinfo; diff --git a/plugins/NeuralRecord/profiler.h b/plugins/NeuralRecord/profiler.h index 4922aa6..461df56 100644 --- a/plugins/NeuralRecord/profiler.h +++ b/plugins/NeuralRecord/profiler.h @@ -143,6 +143,7 @@ class Profil { void normalize(); static void *run_thread(void* p); inline int load_from_wave(std::string fname); + inline void convert_to_wave(std::string fname, std::string oname); inline std::string get_path(); inline std::string get_ffilename(); inline std::string get_ifilename(); diff --git a/plugins/NeuralRecord/resources/input.flac b/plugins/NeuralRecord/resources/input.flac new file mode 100644 index 0000000..2b7402a Binary files /dev/null and b/plugins/NeuralRecord/resources/input.flac differ diff --git a/plugins/NeuralRecord/resources/input.wav b/plugins/NeuralRecord/resources/input.wav deleted file mode 100644 index 4daec19..0000000 Binary files a/plugins/NeuralRecord/resources/input.wav and /dev/null differ