Ecasound engine for potentially high-quality playback

OSS specific Linux discussion (x86/amd64)

Moderators: hannu, dev, cesium

ossuserr
Known Member
Posts: 272
Joined: Thu Jan 08, 2015 12:01 am
Sound Card: audigy 2 zs platinum, esi juli
OS: gentu riced to bo0st
Location: Earth

Ecasound engine for potentially high-quality playback

Postby ossuserr » Tue Sep 15, 2015 9:33 pm

I have come across the post praising ecasound:
Outline of my solution:
1. You need an rt-kernel
2. You need to shutdown as many processes as possible - best to boot into recovery mode - preferably on a headless client.
3. Copy your audio data to /dev/shm (ramdisk) before playback
4. Use ecasound as playback engine
5. You can use all HW and Bios optimizations as proposed by Cics
When using Sox under Linux make sure that it is not doing automatic dithering. Offline processing is prefable over realtime processing.

After installing ecasound you may try my script for playing files via it. Beware, ecasound uses own low-quality resampler or libsamplerate. So supply files already converted to 44100 by Petrov's or sox resampler. If they are 44100 already, no convertion is needed.
Also check that your soundcard resampling rate is set to 44100.

Code: Select all

#!/bin/bash
SONGNAME=$1
if [ -z "$SONGNAME" ]; then echo "usage: $0 <song name>" ; exit 1 ; fi
NUMBER=$(find /path/to/musicfolder -regex '.*\.\(mp3\|flac\|ape\|wav\|ogg\)' -type f -name \*"$SONGNAME"\* | wc -l)
if [ $NUMBER -eq 1 ]; then
find /path/to/musicfolder -regex '.*\.\(mp3\|flac\|ape\|wav\|ogg\)' -type f -name \*"$SONGNAME"\* -exec ecasound -i {} -o alsahw,1,0 \;
else
echo "Several files with this name were found. Press the digit correposing to the needed song"
find /path/to/musicfolder -regex '.*\.\(mp3\|flac\|ape\|wav \|ogg\)' -type f -name \*"$SONGNAME"\* > ~/listoffound
cat -n ~/listoffound > ~/list2
sed 's/^.*\///' ~/list2 > ~/lists5 && cat -n ~/lists5
read CCC
awk NR==$CCC ~/list2  > ~/lists3
sed -e 's#[^/]*/#/#' ~/lists3 | xargs -I '{}' ecasound -i '{}' -o alsahw,1,0
fi
rm -f ~/lists3 ~/lists5 ~/list2 ~/listoffound
exit 0


Change /path/to/musicfolder by your path with your music files. Also change alsahw,1,0 by your corresponding alsa device or by /dev/dsp if you are using OSS.

What script does? It allows to easily play a song from your music folder via ecasound.
To play a song issue the command:
ec part-of-the-name-of-the-song

For example, instead of inputing rachmaninoff-concerto-2.flac you may enter just 'ra'
THe script will find the file and start its playback. If you have some other files in your music folder which contain the combination of letters 'ra', the script will list all such files and will ask you to select the right one by giving the corresponding number.

How to install the script.

Create a text file named 'ec' in any folder in your /home/user directory, for example in ~/Music. Modify the script as prescribed above. Then make it executable:

Code: Select all

chmod ug+x ~/Music/ec


Then as a root issue:

Code: Select all

ln -s /home/your-user-name/Music/ec /usr/local/bin/ec


Now you can play a file by ec part-of-file-name
Last edited by nuc on Tue Mar 29, 2016 6:33 pm, edited 1 time in total.
Reason: please use [code] tags...

ossuserr
Known Member
Posts: 272
Joined: Thu Jan 08, 2015 12:01 am
Sound Card: audigy 2 zs platinum, esi juli
OS: gentu riced to bo0st
Location: Earth

Re: Ecasound engine for potentially high-quality playback

Postby ossuserr » Wed Sep 16, 2015 11:01 am

The following script v2 is modification of the initial script. In addition to the functions implemented in the previous script this one before playback resamples stream to 44.1\16 which is the format of ecasound. You can name the script as 'ecr' and issue as root: ln -s /place/of/script/ecr /usr/local/bin/ecr
Then you can play songs as usual by issuing: ecr songname
Remember that your soundcard must be set to 44.1k while using ecasound.
USE script v1 for playback of files of 44.1k rate (cds, mp3, etc having this rate) TO AVOID ANY ADDITIONAL RESAMPLING.
USE script v2 for playback of files with samplerates other than 44.1k i.e. for 48k, 96k, 192k.

Ecasound seems to be able to playback 48000 but who knows if it does inner resamling to 44.1 or not... If it playsback 48000 and other formats other than 44.1 without resampling then script v2 is not needed. But don't forget to set the correct sampling rate corresponding to that of the song for the card if its available in driver.

Code: Select all

#!/bin/bash
SONGNAME=$1
if [ -z "$SONGNAME" ]; then echo "usage: $0 <song name>" ; exit 1 ; fi
NUMBER=$(find /path/to/musicfolder -regex '.*\.\(mp3\|flac\|ape\|wav\|ogg\)' -type f -name \*"$SONGNAME"\* | wc -l)
if [ $NUMBER -eq 1 ]; then
find /path/to/musicfolder -regex '.*\.\(mp3\|flac\|ape\|wav\|ogg\)' -type f -name \*"$SONGNAME"\* | xargs -I '{}' flac -f -d {} -o ~/tmp.wav
sox ~/tmp.wav -b 16 ~/tmp1.wav rate -v -L 44100
ecasound -i ~/tmp1.wav -o alsahw,1,0
else
echo "Several files with this name were found. Press the digit correposing to the needed song"
find /path/to/musicfolder -regex '.*\.\(mp3\|flac\|ape\|wav \|ogg\)' -type f -name \*"$SONGNAME"\* > ~/listoffound
cat -n ~/listoffound > ~/list2
sed 's/^.*\///' ~/list2 > ~/lists5 && cat -n ~/lists5
read CCC
awk NR==$CCC ~/list2  > ~/lists3
sed -e 's#[^/]*/#/#' ~/lists3 |xargs -I '{}' flac -f -d {} -o ~/tmp.wav
sox ~/tmp.wav -b 16 ~/tmp1.wav rate -v -L 44100
ecasound -i ~/tmp1.wav -o alsahw,1,0
fi
rm -f ~/lists3 ~/lists5 ~/list2 ~/listoffound ~/tmp1.wav ~/tmp.wav
exit 0


Don't forget to modify the script, i.e. change /path/to/musicfolder by the appropriate path, and alsahw,1,0 by your device and make the script executable by chmod ug+x /path/to/script/ecr
Last edited by nuc on Tue Mar 29, 2016 6:33 pm, edited 1 time in total.
Reason: please use [code] tags...

ossuserr
Known Member
Posts: 272
Joined: Thu Jan 08, 2015 12:01 am
Sound Card: audigy 2 zs platinum, esi juli
OS: gentu riced to bo0st
Location: Earth

Re: Ecasound engine for potentially high-quality playback

Postby ossuserr » Wed Sep 16, 2015 1:34 pm

Here is a modified version of script v1 to playback files via sox instead of ecasound. No resampling is made with sox but look that your card's rate correspond to that of a song.

Code: Select all

#!/bin/bash
SONGNAME=$1
if [ -z "$SONGNAME" ]; then echo "usage: $0 <song name>" ; exit 1 ; fi
NUMBER=$(find /path/tomusic/folder -regex '.*\.\(mp3\|flac\|ape\|wav\|ogg\)' -type f -name \*"$SONGNAME"\* | wc -l)
if [ $NUMBER -eq 1 ]; then
find /path/tomusic/folder -regex '.*\.\(mp3\|flac\|ape\|wav\|ogg\)' -type f -name \*"$SONGNAME"\* -exec sox {} -t alsa hw:1,0 \;
else
echo "Several files with this name were found. Press the digit correposing to the needed song"
find /path/tomusic/folder -regex '.*\.\(mp3\|flac\|ape\|wav \|ogg\)' -type f -name \*"$SONGNAME"\* > ~/listoffound
cat -n ~/listoffound > ~/list2
sed 's/^.*\///' ~/list2 > ~/lists5 && cat -n ~/lists5
read CCC
awk NR==$CCC ~/list2  > ~/lists3
sed -e 's#[^/]*/#/#' ~/lists3 | xargs -I '{}' sox {} -t alsa hw:1,0
fi
rm -f ~/lists3 ~/lists5 ~/list2 ~/listoffound
exit 0


In my opinion there is no much difference in sound between resampled in ecasound and non-resampled in sox.
Last edited by nuc on Tue Mar 29, 2016 6:31 pm, edited 1 time in total.
Reason: improved formatting

ossuserr
Known Member
Posts: 272
Joined: Thu Jan 08, 2015 12:01 am
Sound Card: audigy 2 zs platinum, esi juli
OS: gentu riced to bo0st
Location: Earth

Re: Ecasound engine for potentially high-quality playback

Postby ossuserr » Mon Jan 04, 2016 1:46 pm

Ecasound plays clearer than audacious and mpd (mpd's crap).

A script to output via oss for ecasound will be like those above but you should replace -o alsahw,1,0 by -o /dev/dsp

ossuserr
Known Member
Posts: 272
Joined: Thu Jan 08, 2015 12:01 am
Sound Card: audigy 2 zs platinum, esi juli
OS: gentu riced to bo0st
Location: Earth

Re: Ecasound engine for potentially high-quality playback

Postby ossuserr » Mon Jan 04, 2016 3:06 pm

Interesting! I have compiled deadbeef /DB/ from source code:

Code: Select all

git clone https://github.com/Alexey-Yakovenko/deadbeef.git
CXXFLAGS="-O2 -pipe -frename-registers" CFLAGS="${CXXFLAGS}" ./autogen.sh
CXXFLAGS="-O2 -pipe -frename-registers" CFLAGS="${CXXFLAGS}" ./configure --enable-static=yes --disable-nls --disable-alsa --disable-nullout --disable-pulse --disable-coreaudio --disable-vfs-curl --disable-lfm  --disable-artwork --disable-artwork-network --disable-supereq --disable-sid --disable-vtx --disable-mms --enable-src=no --enable-artwork-imlib2=no
CXXFLAGS="-O2 -pipe -frename-registers" CFLAGS="${CXXFLAGS}" make -j5
su -c 'make install'


As u can see alsa and libsamplerate are disabled. No other plugins or effects are loaded. Now i have compared DB vs ecasound. Vmix is ON with production quality. There is difference. With DB highs sound louder, with ecasound mids and bass are more pronounced. Ecasound also gives louder output. Both DB and ecasound can be used with OSS. Deadbeef looks like more glamor and much more convenient than commandline ecasound.
Last edited by nuc on Tue Mar 29, 2016 6:32 pm, edited 1 time in total.
Reason: please use [code] tags...


Return to “Linux”

Who is online

Users browsing this forum: No registered users and 2 guests