Linux Audio the way to go!? - Page 10 - diyAudio
Go Back   Home > Forums > Source & Line > PC Based

PC Based Computer music servers, crossovers, and equalization

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 25th March 2007, 08:50 AM   #91
diyAudio Member
 
soundcheck's Avatar
 
Join Date: Mar 2005
Location: D
Default ecasound player script

Hi Werner and others who might want to try ecasound.

Below script is optimised for realtime playback.

As you can see I am running a 1 sample!! buffer size towards Alsa.

You can use the digital volume control. It comes with a linear scale!
I am listing as you can see below the linear and logarithmic scale to make life easier. ( I couldn't find a function in bash to prepare a formula doing that)

Note: I am not using an external volume control or pre-amp. Below gave me best results when doing it digital. I mainly never go below -14db attentuation. In
average I am running -12db (equals 2 bits). I am applying the to me best volume level to each album and save the particular volume in a volume-flag-file!
The limited dynamics I loose here are much less of a problem than the sound degradation I'd experienced with other equipment in the chain ( e.g. Stevens & Billington TX102 - transformer pot, which is IMO one of the best attentuators available )

I am also switching off a lot of stuff such as deamons, swap etc off before starting
the playback.

Actually, lately I am booting up in single user mode without even starting up the X environment. You won't get a faster system

Howto:

Copy below script into a file and save it under e.g. "eca".
Copy it to /usr/bin and chmod 770
Go to your music directory and just start eca. First time it'll ask you for the
best volume. Usually 20 is a good value.

You can stop the script by typing CTRL-C a couple of times.

I can post the stop script and the play-next song script later on if you like to have it.


Here we go.

Let me know if you run into problems.

Perhaps there are also some freaks around, who might tell me how to improve
below script.

I got one problem left with this setup. ecasound is not dithering when using the 32bit-DSP and then falling back to 16bit. They are working on it.
For that purpose I am thinking to use brutefir. I'd pipe ecasound 32bit into brutefir, which would do the dithering. I havn't really figured it out how to do it.


Cheers SC

------------------------------------------------------------------------------------------------------

#!/bin/bash
#
# The audio playback script using ecasound
# by soundcheck
#
# Rev.0.2 March-25-2007
#
# start script as root from the music file directory with $eca for full directory playback or with eca "searchstring" for playing a particular song. "searchsting" must be part of the filename
#
#
#

DEVICE="-o:alsahw,1,0"
PARAMS="-f:16,2,48000"
VOLUME="20"
VOLSRC=".volflg"
AUDIO_DIR=`pwd`
TEMP_DIR=/tmp # /tmp used as ramdisk. Enter string "tmpfs /tmp tmpfs defaults,size=1028m 0 0" to /etc/fstab for a 1 GB Ramdisk
ROOT_UID=0 # Only users with $UID 0 have root privileges.
LINES=50 # Default number of lines saved.
E_NOTROOT=67 # Non-root exit error.
E_WRONGARGS=65 # Non-numerical argument (bad arg format)


#-----------------------------------------------------------------------
# Run as root
#-----------------------------------------------------------------------

if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script."
exit $E_NOTROOT
fi

#-----------------------------------------------------------------------
# Prepare environment
#-----------------------------------------------------------------------

swapoff -a > /dev/null 2>&1
ps axco pid,command |grep xscreensaver | awk '{ print $1; }' | xargs kill -9 > /dev/null 2>&1
/etc/init.d/apmd stop > /dev/null 2>&1
/etc/init.d/networking stop > /dev/null 2>&1
/etc/init.d/cron stop > /dev/null 2>&1
/etc/init.d/klogd stop > /dev/null 2>&1
/etc/init.d/sysklogd stop > /dev/null 2>&1
/etc/init.d/acpid stop > /dev/null 2>&1


#--------------------------------------------------------------------------------------------------
# Prepare playlist. Example file name format: 01-Eric_Clapton-Unplugged-Tears_in_Heaven-48.wav
#--------------------------------------------------------------------------------------------------

if [ "$#" = 0 ]
then
fs=`find . -name "*.wav"`
else
if [ "$1" = "q" ]
then
shift
exit 0
fi
fs=`find . -name "*"$1"*.wav"`
fi


echo "Tracklist:"
for f in $fs
do
echo $f | mawk ' { gsub("_"," ") ; print } ' | mawk ' { gsub("48.wav","") ; print } ' | mawk ' { gsub("./","") ; print } '
done

#--------------------------------------------------------------------------------------------
# Check for default volume level stored in .volflg file
#--------------------------------------------------------------------------------------------------


if [ ! -f $VOLSRC ]
then
echo
echo "Could not locate <best-volume> flag. Default flag will be generated!"
touch $VOLSRC
chmod 666 $VOLSRC

echo "Linear/% 100 95 85 80 75 70 65 60 55 50 45 40 35 30 25 20 15 10 5"
echo "Log/-db 0.00 0.4 1.4 1.9 2.5 3.1 3.7 4.4 5.2 6.0 6.9 8.0 9.1 10.5 12.0 14.0 16.5 20.0 26.0"

echo "Please enter best-volume (linear scale in %):"
read VOL
echo $VOL > $VOLSRC
VOLUME=$VOL
else
if [ -z $VOLSRC ]
then
echo $VOLUME > $VOLSRC
else
VOLUME=`cat $VOLSRC`
fi
fi


#--------------------------------------------------------------------------------------------
# Enter volume for current playback
#--------------------------------------------------------------------------------------------

echo "Linear/% 100 95 85 80 75 70 65 60 55 50 45 40 35 30 25 20 15 10 5"
echo "Log/-db 0.00 0.4 1.4 1.9 2.5 3.1 3.7 4.4 5.2 6.0 6.9 8.0 9.1 10.5 12.0 14.0 16.5 20.0 26.0"

echo
echo "Volume (1-100) best( "$VOLUME" ) please enter new volume (linear scale in %) or type enter"
read VOL
case "$VOL" in
"" ) VOLUME=$VOLUME;;
* ) VOLUME=$VOL;;
esac
clear

echo "eca audio player - playing at volume: $VOLUME"
echo "_________________________________________________ _______"
echo

sleep 2

#--------------------------------------------------------------------------------------------
# Main
#--------------------------------------------------------------------------------------------


xset dpms force off > /dev/null 2>&1 # switch off screen

for f in $fs ;
do
echo $f | mawk ' { gsub("_"," ") ; print } ' | mawk ' { gsub("48.wav","") ; print } ' | mawk ' { gsub("./","") ; print } '
xset dpms force off > /dev/null 2>&1
cp $f $TEMP_DIR
cd $TEMP_DIR
ecasound -r:98 -B:rtlowlatency -b:1 $PARAMS -i:$f -ea:"$VOLUME" $DEVICE > /dev/null 2>&1
cd $AUDIO_DIR
rm -rf $TEMP_DIR/*.wav > /dev/null 2>&1
done


#-----------------------------------------------------------------------
# Establish environment
#-----------------------------------------------------------------------

xset dpms force on > /dev/null 2>&1
# swapon -a > /dev/null 2>&1
# /etc/init.d/networking start > /dev/null 2>&1
# /etc/init.d/cron start > /dev/null 2>&1


echo "eca audio player - Hope you enjoyed it! - done"

exit 0
----------------------------------------------------------------------------------------------------------------------------------
  Reply With Quote
Old 25th March 2007, 02:03 PM   #92
diyAudio Member
 
soundcheck's Avatar
 
Join Date: Mar 2005
Location: D
Hi there.

Just a hint regarding my earlier post.

You should be careful with switching off the apcid deamon as stated in the last line of
the environment setup.
Just put a # in front of it or just delete it. AFAIK it is only for logging purposes. It works fine with my PC.
But you never know. ACPI issues might cause severe damage to the PC.
Don't blame me if something gets smoked

BTW - I am running the script on Ubuntu 6.10, a 2.6.20 Kernel and a Lenovo T60p.

Cheers
  Reply With Quote
Old 26th March 2007, 08:11 AM   #93
diyAudio Member
 
soundcheck's Avatar
 
Join Date: Mar 2005
Location: D
Hi folks.

I made great progress yesterday.

Now my script checks available space on the RAMDISC.
It then copies the whole CD (directory) to the RAMDISC for gapless playback.
If there is not sufficiant space on the RAMDISC, in case the directory content is larger than the RAMDISC, it'll copy track by track.

I also managed to put /var and /dev on the RAMDISC. This was needed to prevent the disk from spinning up every other minute.

My hardisk can be spinned down now with hdparm -y /dev/sda while playing back music. (What's strange though - sdparm is not working even though I got a SATA drive installed!)

I am doing the spindown only if I store the whole directory on the RAMDISC .
Spinning down the disc every other song might cause damage to the harddisc on the long run.

During the coming days I'll do some listening tests to see if it makes an audible difference.
However, gapless playback and spindown of the disc due to power consumption savings on my notebook are reasons enough to leave it as it is right now.


I also got very close to get brutefir up'n running.
To be continued!



Cheers SC
  Reply With Quote
Old 26th March 2007, 11:38 PM   #94
peufeu is offline peufeu  France
diyAudio Member
 
Join Date: Mar 2001
Location: Lyon, France
Yes repeated spin ups/down are supposed to wear harddisks.

You can use noflush (so that the OS doesn't spin up the HDD, check out laptop-mode) and store the stuff on the network, too. This way the HDD is used for boot mostly.
  Reply With Quote
Old 27th March 2007, 09:10 PM   #95
diyAudio Member
 
Werner Rem's Avatar
 
Join Date: Sep 2004
Location: Amsterdam
Hi Soundcheck

Thanks for sharing the ecosound playback script.
After I got it working it sounded like crap. But ofcoarse I have no lowlatency running, so the 1 sample does not work. (it sounded like half speed with a lot of distortion). After putting -b: to 256 in stead of 1 things started to work.

I tried to get the ubuntu 2.6.20 lowlatency kernel to work but too much things do not compare to the HOWTO's I find on the net. (no lilo.config, no grub.config, no bzImage found etc)
While doing the old.config I found out that there is about 95% in a kernel that you do not need to play music. I realy would like a small fast kernel without all the **** I don' need, but I'll first have to be a linux pro to arrange that I guess

Thank again Soundcheck
regards
Werner
  Reply With Quote
Old 27th March 2007, 10:44 PM   #96
diyAudio Member
 
soundcheck's Avatar
 
Join Date: Mar 2005
Location: D
Quote:
Originally posted by peufeu
Yes repeated spin ups/down are supposed to wear harddisks.

You can use noflush (so that the OS doesn't spin up the HDD, check out laptop-mode) and store the stuff on the network, too. This way the HDD is used for boot mostly.

The network playback I tried before. I doesn't work well when copying the tracks to
the ramdisk, as I do it. 100Mbit is just too slow, with 1GB ethernet it would be acceptable. If you do it track by track you'll get a gap in the range of 10s
between the tracks and for a full CD it takes more than a minute to download the
whole stuff..

Cheers
  Reply With Quote
Old 27th March 2007, 10:57 PM   #97
peufeu is offline peufeu  France
diyAudio Member
 
Join Date: Mar 2001
Location: Lyon, France
But if the computer plays the file directly from the network, the HDD is not used, hence you don't need RAMDISK maybe...
  Reply With Quote
Old 27th March 2007, 11:12 PM   #98
diyAudio Member
 
soundcheck's Avatar
 
Join Date: Mar 2005
Location: D
Quote:
Originally posted by Werner Rem
Hi Soundcheck

Thanks for sharing the ecosound playback script.
After I got it working it sounded like crap. But ofcoarse I have no lowlatency running, so the 1 sample does not work. (it sounded like half speed with a lot of distortion). After putting -b: to 256 in stead of 1 things started to work.

I tried to get the ubuntu 2.6.20 lowlatency kernel to work but too much things do not compare to the HOWTO's I find on the net. (no lilo.config, no grub.config, no bzImage found etc)
While doing the old.config I found out that there is about 95% in a kernel that you do not need to play music. I realy would like a small fast kernel without all the **** I don' need, but I'll first have to be a linux pro to arrange that I guess

Thank again Soundcheck
regards
Werner
Hi Werner.

Good to see that the script works. The kernel work is a bit tricky I can understand that. It took me also a while to get on top of it. You'll learn a lot while digging into it.

Tom, another guy trying my setup on a DDDAC, reported also great results with
the player script. He managed to get the rt-kernel working and is running
1 sample buffer size now.


I am still working on a HD spindown issue, I realized today. Since I am starting ecasound every time I play back a song I'll cause spin-ups by doing it this way,
I need to copy all programmes and tools to the RAMDISK to avoid disk-reads. That issue I solved in the new version.

The main problem I still have. ecasound reads every time it starts an /etc/ecasoundrc config-file and ~/.ecasound file, which are causing disk access.
I'll check tommorow with the ecasound folks, if i can get around it.
I guess that'll only work if I could start ecasound with an option, where I could specify the configfiles to be used.

If I manage to solve that issue, I'll sent you the new version of the script.

Perhaps I'll also look for a memory-stick/usb-stick installation of ubuntu, that would
resolve some issues.


Cheers
  Reply With Quote
Old 27th March 2007, 11:25 PM   #99
diyAudio Member
 
soundcheck's Avatar
 
Join Date: Mar 2005
Location: D
Quote:
Originally posted by peufeu
But if the computer plays the file directly from the network, the HDD is not used, hence you don't need RAMDISK maybe...
Perhaps the networkstreaming is worth a try.
Still, from RAM to the processor is a much shorter way, I'd expect less latencies in the chain.

Beside that I have my audio rig completely isolated from mains.
I'd need to deploy an optical ethernet connection first to get my network drive
hooked on to the PC. (That'll cost me another 200)

Cheers
  Reply With Quote
Old 28th March 2007, 01:19 AM   #100
peufeu is offline peufeu  France
diyAudio Member
 
Join Date: Mar 2001
Location: Lyon, France
I repeat : Ethernet is transformer isolated at both ends. All you need is a $2 UTP cable (not STP).

It would NEVER work up to 100 meters without transformers...

For ecasound, you can chroot it into your ramdisk.
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



New To Site? Need Help?

All times are GMT. The time now is 07:28 PM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2