diff --git a/atom b/atom index 4108d8c..999596a 100755 --- a/atom +++ b/atom @@ -23,6 +23,7 @@ declare -A \ destinationpath \ destinationquality \ destinationrename \ + destinationnoresample \ destinationrenamepath \ destinationskipmime \ || { @@ -218,6 +219,21 @@ getConfigDestination() { unset expr destinationfrequency["$destination"]=$value ;; + 'noresample') + case $value in + 'true'|'on'|'yes') + destinationnoresample["$destination"]=1 + ;; + 'false'|'off'|'no') + destinationnoresample["$destination"]=0 + ;; + *) + echo "noresample takes values:" \ + "'yes' ,'true' ,'on', 'no', 'false',"\ + "'off'" + ;; + esac + ;; 'rename') case "$value" in */*) @@ -1076,6 +1092,38 @@ encodeFile::mp3() { [ -n "$title" ] && lameopts+=" --tt \"$title\"" [ -n "$track" ] && lameopts+=" --tn \"$track\"" [ -n "$year" ] && lameopts+=" --ty \"$year\"" + if (( ${destinationnoresample[$destination]:-0} == 1 )) + then + # If 'rate' is not one of these value, it cannot be encoded to + # MP3, in which case we'd be better of letting lame decide which + # rate to use. + if [ -n "${destinationfrequency["$destination"]}" ] + then + case ${destinationfrequency["$destination"]} in + 48000) lameopts+=" --resample 48" ;; + 44100) lameopts+=" --resample 44.1" ;; + 32000) lameopts+=" --resample 32" ;; + 24000) lameopts+=" --resample 24" ;; + 22050) lameopts+=" --resample 22.05" ;; + 16000) lameopts+=" --resample 16" ;; + 12000) lameopts+=" --resample 12" ;; + 11025) lameopts+=" --resample 11.025" ;; + 8000) lameopts+=" --resample 8" ;; + esac + else + case $rate in + 48000) lameopts+=" --resample 48" ;; + 44100) lameopts+=" --resample 44.1" ;; + 32000) lameopts+=" --resample 32" ;; + 24000) lameopts+=" --resample 24" ;; + 22050) lameopts+=" --resample 22.05" ;; + 16000) lameopts+=" --resample 16" ;; + 12000) lameopts+=" --resample 12" ;; + 11025) lameopts+=" --resample 11.025" ;; + 8000) lameopts+=" --resample 8" ;; + esac + fi + fi encodetaskid=$( Insert tasks <<-EOInsert key ${fileid}lame$destination diff --git a/doc/config b/doc/config index 13bd1a2..cb8d839 100644 --- a/doc/config +++ b/doc/config @@ -92,3 +92,7 @@ Sections: MP3 parameters: * bitrate : Set ABR to . Again, if you want CBR or any other mode supported by lame, please fork and file a pull request. + * noresample /: LAME may decide to encode your file to a lower + sampling-rate if you use a low bitrate. Setting this to yes will + append --resample , preventing any resampling from + happening. diff --git a/doc/example.cfg b/doc/example.cfg index c71066d..de2720e 100644 --- a/doc/example.cfg +++ b/doc/example.cfg @@ -25,14 +25,15 @@ copy_mime-type image/* copy_mime-type text/* [MP3] -path /mnt/Musique-mp3.test -format mp3 -bitrate 96 +path /mnt/Musique-mp3.test +format mp3 +bitrate 96 +noresample yes normalize yes higher-than 128 # rename file, path unchanged -rename %{track}--%{artist}-%{title} +rename %{track}--%{artist}-%{title} # change the whole filepath #rename %{genre}/%{albumartist}/%{year}-%{album}/%{track}--%{artist}-%{title} skip_mime-type image/*