Hi!
When playing files like 24/96, 16/48, somtheng another than 16/44,1 sound bitstreaming in soundcard, but operating system doesn't chachge internal clock of it quartz, so 0404usb decoding at 44100 samples all files and break quality.
by Sergey » 11 Jan 2015, 16:30
by Sergey » 11 Jan 2015, 18:01
by Sergey » 16 Jan 2015, 17:44
by ACX » 16 Jan 2015, 20:24
by Sergey » 17 Jan 2015, 17:06
by ACX » 17 Jan 2015, 18:33
by Sergey » 18 Jan 2015, 06:58
#!/bin/bash
# if this is the first run, EMU-rate does not exist,create it
if [ ! -f /dev/shm/EMU-rate ]; then # file does not exist
echo "00" > /dev/shm/EMU-rate
fi
while : ; do
mpc idle
# stuff below executes when mpc is not idle
sleep 0.4 # wait for actual track to start playing (fist 0,4 sec., to determine the sample rate)
old_rate=$(cat /dev/shm/EMU-rate)
# echo "old rate:$old_rate"
sRateStr=$(cat /proc/asound/card1/stream0 | grep Momentary)
# echo "full line: " $sRateStr
cur_rate=${sRateStr:21:2} # here we get just the first two digits (44, 48, 96, etc.)
# echo "cur rate:$cur_rate"
# if $cur_rate is empty, next iteration ("continue")
if [ -z "$cur_rate" ] # string is empty
then
# echo "No song playing"
continue # $cur_rate is null/empty, nothing to do, wait for next iteration
fi
# echo "Track sample rate: $cur_rate"
if [ "$old_rate" = "$cur_rate" ]
then
# echo "The rates are the same"
continue # rates are the same, nothing to do, wait for next iteration
fi
# here we actually compare rates and take appropriate action (change EMU clock rate using "amixer")
# E-MU 0404 is visible as "card 1" on my system, i.e. it needs switch "-c1" for manipulation
case $cur_rate in
44)
amixer -c1 set 'Clock rate Selector' 0
echo "$cur_rate" > /dev/shm/EMU-rate
continue
;;
48)
amixer -c1 set 'Clock rate Selector' 1
echo "$cur_rate" > /dev/shm/EMU-rate
continue
;;
88)
amixer -c1 set 'Clock rate Selector' 2
echo "$cur_rate" > /dev/shm/EMU-rate
continue
;;
96)
amixer -c1 set 'Clock rate Selector' 3
echo "$cur_rate" > /dev/shm/EMU-rate
continue
;;
17)
amixer -c1 set 'Clock rate Selector' 4
echo "$cur_rate" > /dev/shm/EMU-rate
continue
;;
19)
amixer -c1 set 'Clock rate Selector' 5
echo "$cur_rate" > /dev/shm/EMU-rate
continue
;;
esac
echo "$cur_rate" > /dev/shm/EMU-rate
done
Then i create systemd service "clock.service", put it int "/etc/systemd/system":
[Unit]
Description=Samplerate EMU Fix
[Install]
WantedBy=multi-user.target
[Service]
Type=idle
RemainAfterExit=yes
ExecStart=/home/clock.sh
by ACX » 18 Jan 2015, 17:48
by den_hr » 17 Feb 2015, 14:16
support RuneAudio