Skip to content

Commit

Permalink
Add Easy Mode preset option to skip MP4 detection
Browse files Browse the repository at this point in the history
  • Loading branch information
complexlogic committed Sep 9, 2023
1 parent cd3694b commit 7d31d5a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 17 deletions.
1 change: 1 addition & 0 deletions config/presets/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ OpusMode=d
#MaxPeakLevel=0.0
#TruePeak=false
#Lowercase=false
#SkipMP4=false

[WMA]
#TagMode=i
Expand Down
1 change: 1 addition & 0 deletions config/presets/ebur128.ini
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ OpusMode=d
#MaxPeakLevel=-1.0
#TruePeak=true
#Lowercase=false
#SkipMP4=false

[WMA]
#TagMode=i
Expand Down
1 change: 1 addition & 0 deletions config/presets/loudgain.ini
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ TargetLoudness=-23
#MaxPeakLevel=-1.0
#TruePeak=true
#Lowercase=true
#SkipMP4=false

[WMA]
#TagMode=i
Expand Down
1 change: 1 addition & 0 deletions config/presets/no_album.ini
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ OpusMode=d
#MaxPeakLevel=0.0
#TruePeak=false
#Lowercase=false
#SkipMP4=false

[WMA]
#TagMode=i
Expand Down
44 changes: 30 additions & 14 deletions src/easymode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// MP2 config
Expand All @@ -72,7 +73,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// MP3 config
Expand All @@ -89,7 +91,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// FLAC config
Expand All @@ -106,7 +109,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// OGG config
Expand All @@ -123,7 +127,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// OPUS config
Expand All @@ -140,7 +145,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// M4A config
Expand All @@ -157,7 +163,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// WMA config
Expand All @@ -174,7 +181,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// WAV config
Expand All @@ -191,7 +199,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// AIFF config
Expand All @@ -208,7 +217,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// Wavpack config
Expand All @@ -225,7 +235,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// APE config
Expand All @@ -242,7 +253,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// TAK config
Expand All @@ -259,7 +271,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
},

// Musepack config
Expand All @@ -276,7 +289,8 @@ static Config configs[] = {
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
}
};

Expand Down Expand Up @@ -528,6 +542,8 @@ int format_handler([[maybe_unused]] void *user, const char *section, const char
convert_bool(value, configs[static_cast<int>(file_type)].true_peak);
else if (MATCH(name, "OpusMode"))
parse_opus_mode(value, configs[static_cast<int>(file_type)].opus_mode);
else if (file_type == FileType::M4A && MATCH(name, "SkipMP4"))
convert_bool(value, configs[static_cast<int>(file_type)].skip_mp4);
return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion src/rsgain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ static void custom_mode(int argc, char *argv[])
.sort_alphanum = false,
.lowercase = false,
.id3v2version = 3,
.opus_mode = 'd'
.opus_mode = 'd',
.skip_mp4 = false
};

while ((rc = getopt_long(argc, argv, short_opts, long_opts, &i)) != -1) {
Expand Down
1 change: 1 addition & 0 deletions src/rsgain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct Config {
bool lowercase;
unsigned int id3v2version;
char opus_mode;
bool skip_mp4;
};


Expand Down
5 changes: 3 additions & 2 deletions src/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ ScanJob* ScanJob::factory(const std::filesystem::path &path)
std::vector<Track> tracks;

for (const std::filesystem::directory_entry &entry : std::filesystem::directory_iterator(path)) {
if (entry.is_regular_file() && entry.path().has_extension() &&
(file_type = determine_filetype(entry.path().extension().string())) != FileType::INVALID) {
if (entry.is_regular_file() && entry.path().has_extension()
&& ((file_type = determine_filetype(entry.path().extension().string())) != FileType::INVALID)
&& !(file_type == FileType::M4A && get_config(file_type).skip_mp4 && entry.path().extension().string() == ".mp4")) {
tracks.emplace_back(entry.path().string(), file_type);
extensions.insert(file_type);
}
Expand Down

0 comments on commit 7d31d5a

Please sign in to comment.