From a66528ac893e71f15c5ac44cc1242babc74393cb Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Wed, 6 Mar 2013 22:57:26 +0100 Subject: [PATCH] identify sample-rate/channels --- atom | 57 +++++++++++++++++++++++++++++++++++++++++++----- share/schema.sql | 2 ++ 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/atom b/atom index 357c6fd..bcdeb0a 100755 --- a/atom +++ b/atom @@ -628,6 +628,27 @@ removeObsoleteFiles() { 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() { tagval=$( echo -e "$infos" \ @@ -639,7 +660,7 @@ gettag() { getInfos::MP3() { infos=$( - soxi -a "$sourcepath/$filename" + soxi -a "$sourcepath/$filename" 2>/dev/null ) album=$(gettag album) artist=$(gettag artist) @@ -647,6 +668,7 @@ getInfos::MP3() { title=$(gettag title) tracknum=$(gettag tracknumber) year=$(gettag year) + getRateChannelSoxi [ -n "$album" \ -o -n "$artist" \ -o -n "$genre" \ @@ -676,6 +698,9 @@ getInfos::Ogg() { tracknum="$tracknum/$tracktotal" fi year=$(gettag date) + infos="${infos//: /=}" + rate=$(gettag rate) + channels=$(gettag channels) [ -n "$album" \ -o -n "$albumartist" \ -o -n "$artist" \ @@ -715,6 +740,15 @@ getInfos::FLAC() { title=$(gettag title) tracknum="$(gettag tracknumber)/$(gettag tracktotal)" year=$(gettag date) + { + read rate + read channels + } < <( + metaflac \ + --show-sample-rate \ + --show-channels \ + "$sourcepath/$filename" + ) [ -n "$album" \ -o -n "$albumartist" \ -o -n "$artist" \ @@ -791,6 +825,12 @@ getInfos::APE() { || return 1 } +tryAPE() { + grep -q 'APETAGEX' \ + "$sourcepath/$filename" \ + && type=APE +} + getTags() { unset type case "$mimetype" in @@ -809,10 +849,13 @@ getTags() { *' ID3 '*) type=MP3 ;; + *' Musepack '*) + getRateChannelMPC + tryAPE + ;; *) - grep -q 'APETAGEX' \ - "$sourcepath/$filename" \ - && type=APE + getRateChannelSoxi + tryAPE ;; esac ;; @@ -1004,6 +1047,8 @@ do track "$tracknum" \ year "$year" \ last_change "$lastchange" \ + rate "$rate" \ + channels "$channels" \ >/dev/null <<<"source_file = $sourcefileid" unset genre \ albumartist \ @@ -1014,7 +1059,9 @@ do tracknum \ title \ composer \ - performer + performer \ + rate \ + channels fi done echo 'COMMIT;' >&3 diff --git a/share/schema.sql b/share/schema.sql index c620776..9a81919 100644 --- a/share/schema.sql +++ b/share/schema.sql @@ -50,6 +50,8 @@ CREATE TABLE tags ( title TEXT, composer TEXT, performer TEXT, + rate INTEGER, + channels INTEGER, last_change INTEGER, FOREIGN KEY (source_file) REFERENCES source_files(id) ON DELETE CASCADE