identify sample-rate/channels

This commit is contained in:
Vincent Riquer 2013-03-06 22:57:26 +01:00
parent b148bf331f
commit a66528ac89
2 changed files with 54 additions and 5 deletions

57
atom
View File

@ -628,6 +628,27 @@ removeObsoleteFiles() {
EOWhere EOWhere
} }
getRateChannelSoxi() {
rate=$(soxi -r "$sourcepath/$filename" 2>/dev/null)
channels=$(soxi -c "$sourcepath/$filename" 2>/dev/null)
}
getRateChannelMPC() {
while read key value garbage
do
case $key in
'samplerate:')
rate=$value
;;
'channels:')
channels=$value
;;
esac
done < <(
mpcdec "$sourcepath/$filename"
)
}
gettag() { gettag() {
tagval=$( tagval=$(
echo -e "$infos" \ echo -e "$infos" \
@ -639,7 +660,7 @@ gettag() {
getInfos::MP3() { getInfos::MP3() {
infos=$( infos=$(
soxi -a "$sourcepath/$filename" soxi -a "$sourcepath/$filename" 2>/dev/null
) )
album=$(gettag album) album=$(gettag album)
artist=$(gettag artist) artist=$(gettag artist)
@ -647,6 +668,7 @@ getInfos::MP3() {
title=$(gettag title) title=$(gettag title)
tracknum=$(gettag tracknumber) tracknum=$(gettag tracknumber)
year=$(gettag year) year=$(gettag year)
getRateChannelSoxi
[ -n "$album" \ [ -n "$album" \
-o -n "$artist" \ -o -n "$artist" \
-o -n "$genre" \ -o -n "$genre" \
@ -676,6 +698,9 @@ getInfos::Ogg() {
tracknum="$tracknum/$tracktotal" tracknum="$tracknum/$tracktotal"
fi fi
year=$(gettag date) year=$(gettag date)
infos="${infos//: /=}"
rate=$(gettag rate)
channels=$(gettag channels)
[ -n "$album" \ [ -n "$album" \
-o -n "$albumartist" \ -o -n "$albumartist" \
-o -n "$artist" \ -o -n "$artist" \
@ -715,6 +740,15 @@ getInfos::FLAC() {
title=$(gettag title) title=$(gettag title)
tracknum="$(gettag tracknumber)/$(gettag tracktotal)" tracknum="$(gettag tracknumber)/$(gettag tracktotal)"
year=$(gettag date) year=$(gettag date)
{
read rate
read channels
} < <(
metaflac \
--show-sample-rate \
--show-channels \
"$sourcepath/$filename"
)
[ -n "$album" \ [ -n "$album" \
-o -n "$albumartist" \ -o -n "$albumartist" \
-o -n "$artist" \ -o -n "$artist" \
@ -791,6 +825,12 @@ getInfos::APE() {
|| return 1 || return 1
} }
tryAPE() {
grep -q 'APETAGEX' \
"$sourcepath/$filename" \
&& type=APE
}
getTags() { getTags() {
unset type unset type
case "$mimetype" in case "$mimetype" in
@ -809,10 +849,13 @@ getTags() {
*' ID3 '*) *' ID3 '*)
type=MP3 type=MP3
;; ;;
*' Musepack '*)
getRateChannelMPC
tryAPE
;;
*) *)
grep -q 'APETAGEX' \ getRateChannelSoxi
"$sourcepath/$filename" \ tryAPE
&& type=APE
;; ;;
esac esac
;; ;;
@ -1004,6 +1047,8 @@ do
track "$tracknum" \ track "$tracknum" \
year "$year" \ year "$year" \
last_change "$lastchange" \ last_change "$lastchange" \
rate "$rate" \
channels "$channels" \
>/dev/null <<<"source_file = $sourcefileid" >/dev/null <<<"source_file = $sourcefileid"
unset genre \ unset genre \
albumartist \ albumartist \
@ -1014,7 +1059,9 @@ do
tracknum \ tracknum \
title \ title \
composer \ composer \
performer performer \
rate \
channels
fi fi
done done
echo 'COMMIT;' >&3 echo 'COMMIT;' >&3

View File

@ -50,6 +50,8 @@ CREATE TABLE tags (
title TEXT, title TEXT,
composer TEXT, composer TEXT,
performer TEXT, performer TEXT,
rate INTEGER,
channels INTEGER,
last_change INTEGER, last_change INTEGER,
FOREIGN KEY (source_file) REFERENCES source_files(id) FOREIGN KEY (source_file) REFERENCES source_files(id)
ON DELETE CASCADE ON DELETE CASCADE