mpd instead of db for bit perfect 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

mpd instead of db for bit perfect playback

Postby ossuserr » Tue Feb 03, 2015 3:37 pm

The linux OS with alsa was configured to use Petrov's resampler. But i found that you can't use DB simultanously with jackd if they are configured to use the same device. It's because jackd locks the device specified in its settings for itself. If you try to playback via that device via DB or any other HONEST application which MAKES NO SECRET RESAMPLING when the same device is held by jackd you may get 1) No playback from the player 2) terrible playback which can burn your phones or speakers. With DB i got the burning thing. However i was lucky and my headphones survived but only smell burnt. But i decided to find a substitution for DB and mpd is that good program making no secret resampling. After installing it you need to create ~/.mpdconf file and copy the content of /etc/mpd.conf into it. Then edit it. Replace /var/lib/mpd/... paths to folders in your /home/user dir so that no root permissions would be required to run mpd. Create those dirs and files mentioned in ~/.mpdconf. Start mpd server by typing mpd in terminal. You can stop it by command: mpd --kill.
Your ~/.mpdconf file should look like that

music_directory "~/music"
playlist_directory "~/music/mpd/playlists"
db_file "~/music/mpd/db.file"
pid_file "~/music/mpd/pid.file"
state_file "~/music/mpd/state.file"
user "yourusername"
group "yourusername"
bind_to_address "127.0.0.1"
port "11111"
password "yourpass@read,add,control,admin"
default_permissions "read" #,add,control,admin"
save_absolute_paths_in_playlists "yes"
auto_update "yes"
auto_update_depth "5"
default_permissions "read,add,control,admin"
audio_output {
type "alsa"
name "anything"
auto_resample "no"
device "hw:0,0" # optional
#format "192000:32:*"
#mixer_type "hardware" # optional
#mixer_device "default" # optional
#mixer_control "PCM" # optional
#mixer_index "0" # optional
}

audio_buffer_size "4096"
buffer_before_play "10%"
connection_timeout "60"
max_connections "1"
max_playlist_length "16384"
max_command_list_size "2048"
max_output_buffer_size "8192"
filesystem_charset "UTF-8"
id3v1_encoding "ISO-8859-1"

Now install any gui for mpd, for example, ario. In ario settings go to connection tab and set address to 127.0.0.1 and port to 11111 and yourpass into passw field.
Issue mpd command in terminal and press Connect in ario and voila your gui will be filled with albums and songs from the specified music folder.

How did i found out that mpd makes no secret resampling? Well 1) it was compiled WIHOUT libsamplerate support, so external resampler would be required for files with samplerate not supported by the card before those files are fed into mpd 2) Internal low-quality mpd's resampler was not activated in .mpdconf
So i set up .mpdconf to hw:0,4 for audigy2zs and tried to supply 16-bit 48000 file and it was not played back because hw:0,4 BY DESIGN supports only 32-bit input. That proved that mpd make not secret resampling. At the same time i tried to play back the same file via gmusicbrowser configured to the same hw:0,4 device and to gstreamer and it was played back which proved THAT GSTREAMER MAKES SECRET RESAMPLING and you SHOULD not use gmusicbrowser for bit perfect audio playback.

So now you can use mpd for bit perfect playback. By bit-perfect i do not mean NO RESAMPLING. I mean NO SECRET LOW QUALITY RESAMPLING. You need to install Petrov's resampler for alsa. It will be configured for the default alsa device. Thus if you put the word default instead of hw:0,0 into .mpdconf the stream will be resampled by Petrov's high qulity resampler before fed to mpd. One more thing was left to be solved. How to use jackd and bit perfect playback simultanously since jack locks the device specified in it? You can solve this matter if you have two soundcards. You can just copy all lines of /etc/asound.conf created by Petrov's installer into the same file and n the pasted lines change names of pcm devices by adding the digit 1, for example. So pcm.!default becomes pcm.default1, pcm.xyz becomes pcm.xyz1, etc. Also in the Slave blocks of the pasted lines you must change PCM lines to point to the second soundcard. You your first card is hw:0,0, the second will be hw:1,0. You can use aplay -l command to see names of the soundcards. After that you get your second sound card configured to use Petrov's resampler too. So now you have two soundcards in the OS: default and default1. It's now easy to figure out that while using one with jackd or may now use the second for bit-perfect playback since it's not locked by jackd. So put default1 into .mpdconf instead of hw:0,0 to use the second soundcard for playback.
But what if one of the cards is of higher quality and when jackd is not running you want to use it for playback?
Then you need to modify .mpdconf again to put default instead of default1 into the appropriate line. But what if you are lazy to manually do this editing? Then you can create two scripts to switch between cards. Create two text files and paste into them the below codes.

Script 1

#!/bin/bash
mpd --kill && sed -i '214s/default1/default/' ~/.mpdconf && mpd
exit0

Script 2

#!/bin/bash
mpd --kill && sed -i '214s/default/default1/' ~/.mpdconf && mpd
exit0

Make each script executable by chmod u+x /path/to/your-newly-created-script
Digit 214 is the line number in the .mpdconf file where the device (card) is to be specified, namely where you put hw:0,0 or default or default1 ... Check what's your line number.
Now you can add launchers to your desktop specifying pathes to the scripts. Then on clicking laucnehers you will be able to switch between the devices (soundcards) to be employed by mpd.
Now you can get rid of that deadly evil DB and its ability to burn hardware while struggling against jackd for capturing the device.
Last edited by ossuserr on Tue Feb 03, 2015 4:42 pm, edited 1 time in total.

igorzwx
Known Member
Posts: 1258
Joined: Sun Jun 28, 2009 9:31 pm

Re: mpd instead of db for bit perfect playback

Postby igorzwx » Tue Feb 03, 2015 4:27 pm

I tend to believe that "bit perfect playback" with OSS4's "exclusive mode" ("ossplay -R", or "pcm_play -e") is more perfect and exact than any ALSA hack.

Notice, that both COOKEDMODE and VMIX can be disabled in /usr/lib/oss/conf/osscore.conf (then soundoff/soundon ).
Such "exclusive mode" seems to be default settings for professional soundcards with OSS4.

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: mpd instead of db for bit perfect playback

Postby ossuserr » Tue Feb 03, 2015 4:50 pm

If you are using jackd disabling vmix and cooked_mode can be dangerous I guess. Jackd can refuse to work, you may get cracking or terrible noise if you use samples of rates not supported by the soundcard. For composing purposes I would not switch off those things because resampling will be necessary since samples may have different rates.

Also i can confirm that even with cooked mode and vmix on OSS sounds better than alsa with Petrov's plugin. Why? May be they somehow wrote drivers with taking into account the specs for wavetables of soundcards and fix the non-linear noise things by the driver. So the matter is not just resampling but some things in the driver itself. That's why OSS sounds in way like kxdriver for creative products.

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: mpd instead of db for bit perfect playback

Postby ossuserr » Fri Aug 21, 2015 12:19 am

Now i am listening via mpd and oss, vmix on production quality. The difference to alsa - more pronounced and voluptious highs, more dynamics. Crashes and highhats sound like better separated from middles while in alsa all sounded like a single mix. With oss i also better feel position and size of drum instruments. Interestingly, i am listening to my recordings produced with alsa and jackd and still they sound better though probably they were not high quality from the begginning. oss4 is a pro driver while alsa is an amateur one definitely.
To activate oss with mpd you must edit oss output section of ~/.mpdconf Just uncomment all strings of that section, ie remove # signs there including before }. Put # before all strings of alsa output section.

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: mpd instead of db for bit perfect playback

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

mpd + oss = crap I get metalliclike distortions....
You may try yourself

.mpdconf for audio output for oss will be like that:
audio_output {
type "oss"
name "My OSS Device"
device "/dev/dsp" # optional
mixer_type "hardware" # optional
mixer_device "/dev/mixer" # optional
mixer_control "PCM" # optional
}

You must also remove or comment out by # all lines referring to alsa.

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: mpd instead of db for bit perfect playback

Postby ossuserr » Sun Jan 10, 2016 1:01 pm

That mpd seems to be crap. I disabled vmix since my card supports hw resampling and turned on hw resampling by checking src box. Then i start mpd && ario and try to play a song. But slider does not move and there is no sound.
I would recommend against mpd for oss and alsa users. That server-like vlc-like crap uses http ip streaming technologies and can't work directly with the hardware.


Return to “Linux”

Who is online

Users browsing this forum: No registered users and 3 guests