Skip to content

Commit

Permalink
Use polymorphism
Browse files Browse the repository at this point in the history
Former-commit-id: ba8b1af
  • Loading branch information
YuzukiTsuru committed Jun 5, 2022
1 parent 8dc9e28 commit ac75159
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/FileIO/GenerateAudioModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ GenerateAudioModel::GenerateAudioModel(std::filesystem::path path, lessConfigure
GenerateModelFromFile();
}

GenerateAudioModel::GenerateAudioModel(char *path, lessConfigure configure) : configure(std::move(configure)) {
auto file_path = std::string(path);
WavFileModel(file_path);
}

void GenerateAudioModel::PrintWavFiles() {
for (const auto &file: wav_files) {
YALL_DEBUG_ << file.string();
Expand Down Expand Up @@ -117,3 +122,4 @@ template<class I, class F>
void GenerateAudioModel::for_each(I begin, I end, F f) {
for_each(std::thread::hardware_concurrency(), begin, end, f);
}

1 change: 1 addition & 0 deletions src/FileIO/GenerateAudioModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
class GenerateAudioModel {
public:
GenerateAudioModel(std::filesystem::path path, lessConfigure configure);
GenerateAudioModel(char *path, lessConfigure configure);

void PrintWavFiles();

Expand Down
6 changes: 3 additions & 3 deletions src/lessampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ void lessampler::run() {

// In some projects, the creator will use x.wav, z.wav or other non-existing audio to force truncation of audio
// here is a basic handle。
if (!std::filesystem::exists(in_file_path)){
if (!std::filesystem::exists(in_file_path)) {
return;
}

// Check if an audio model exists。 If it does not exist, turn on multithreaded generation
if (!audio_model_io.CheckAudioModel()) {
YALL_INFO_ << "Audio model: " + in_file_path.string() + " not found, generating...";
GenerateAudioModel genmodule(std::filesystem::weakly_canonical(std::filesystem::path(argv[1])).parent_path(), configure);
GenerateAudioModel genmodule(argv[1], configure);
}

// Read audio model
Expand Down Expand Up @@ -107,7 +107,7 @@ bool lessampler::ParseArgs() {
show_logo();
Dialogs::notify("lessampler", "Start modeling against the audio files");
YALL_INFO_ << "Start modeling against the audio files in the provided destination folder...";
GenerateAudioModel genmodule(argv[1], configure);
GenerateAudioModel genmodule(std::filesystem::path(argv[1]), configure);
return false;
}

Expand Down

0 comments on commit ac75159

Please sign in to comment.