[LINUX/MAC/WINDOWS] Never upsample/downsample all audio streams to 48kHz by default
#1
Question 
I am not that familiar with the audio system under linux, so I don't really know what is possible or not possible together with XBMC.

Basically, I would like to play my music in XBMC through s/pdif at 44.1Khz without an upsampling to 48Khz (as ususally happens?).

Comments, hints, ideas?

Cheers.
Reply
#2
Under linux you need to deal with alsa. XBMC doesn't resample it for you, so it passes the audio direct to alsa (i.e the XBMC side is "bit perfect" assuming no volume control is in use). Assuming alsa isn't doing any shenanigans you should be good to go. This, ofcourse, is the tricky bit! A good test is passing a DTS WAV (i.e. 44.1kHz .wav file with DTS audio encoded in it) through digital out to your receiver with DTS decoder. If that gets through you *should* have bit-perfect. Ofcourse, you have to make sure it gets through without XBMC seeing that it's DTS and decoding it for you. You can check this by playing it as audio and checking what PAPlayer thinks it is via the info on visualisation screen.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
Just a small update on this in case others are wondering about this as well.
If I used default as the audio output device in XBMC settings, my reciever always told me that the signal was a 48Khz signal. Clearly alsa was doing something with it.
However, when I changed this to the iec958 (same as passthrough setting) my Mp3s got passed through at 44.1Khz without any tampering by alsa whatsoever Smile
Reply
#4
Lightbulb 
Hello,
thanks for this great software that I'm using on my Xbox since long years...
I'm an audiophile lover and I use my computer to ear music with MediaPortal frontend with foobar2000 plugin .
I would like to use Xbmc but I notice a big difference in audio quality vs foobar2000.So I'd like to understand why is there this difference and if this quality can be increase in Xbmc. I use mp3 , ape and flac formats so how Xbmc decodes this formats ?
I notice also that the output signal is upsampled at 48 khz as the original is at 44.1khz.Is there a way to let it at 44.1khz.?
Thanks for your answers.
(I'm a french user so sorry for my poor english)
Reply
#5
Hi there, and welcome!

It's mainly a hangover from the xbox days, where we always upsample (as xbox only handles 48kHz output.) It can't currently be disabled. Feel free to post a feature request report on trac so that we may track this request.

Thanks,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#6
After looking a bit at the source I can clearly see that the resampler is initialized to 16Bit@48Khz in PAPlayer::CreateStream(). Here we can see the following:

Code:
// create our resampler
// upsample to 48000, only do this for sources with 1 or 2 channels
m_SampleRateOutput = channels>2?samplerate:48000;
m_BitsPerSampleOutput = 16;
m_resampler[num].InitConverter(samplerate, bitspersample, channels, m_SampleRateOutput, m_BitsPerSampleOutput, PACKET_SIZE);

This is a really bad idea since it will destroy all possibility of bit perfect playback. Maybe someone more familiar with the source can fix this?
If not I might me tempted to fix it myself.


Keep up the good work!
Reply
#7
jmarshall Wrote:Feel free to post a feature request report on trac so that we may track this request.
@Eicar, yes please submit a new ticket (as a feature request) on trac http://trac.xbmc.org

I suggest "Never upsample audio 48kHz by default, or no bit perfect playback" as title Nod

FYI; here bellow is the audio processing chain/path of XBMC for Xbox illustated (the code which for was copied without modification to XBMC for Linux/Mac/Windows when it was ported, and that is why we now have this issue in XBMC for Linux/Mac/Windows as a legacy from the Xbox version of XBMC):

Image
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#8
I've added a ticket to trac now.
Reply
#9
Thanks.

Note that one shouldn't simply disable the resampling - it is entirely dependent on the user's audio card, afterall. Many audio cards still just upsample to 48kHz internally using a rather bad resampling algorithm.

If anything, it should be a UI option.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#10
Yes you're right. Both the card (most soundblaster cards etc.) and the dreaded windows kmixer can resample the sound. However kmixer does not touch the sound if both the master and wave volume slider is set to 100%. It's also important that only ONE application is outputting sound or else kmixer will mix it together. Theme sounds must also be disabled as well to archive bit perfect playback. The best way to verify bit perfect playback is to playback a ac3 / dts encoded 44,1Khz wave file. If all is bit perfect you will hear the music. If it's not perfect then you will only get white noise...


-Eicar
Reply
#11
BTW: Let's not forget that XBMC resamples everything to 16 Bit 48KHz. This means that it would also DOWNSAMPLE as well, even if your card can playback 24Bit/192KHz. Maybe someone can change this thread's title to include the word downsample as well?


-Eicar
Reply
#12
For reference:
http://trac.xbmc.org/ticket/4731
Feature Request Trac Ticket #4731

Wink
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#13
Hello.
Does that resampling also affect outputing to SP/DIF? Maybe im hearing impaired as i cannot distinguish FLAC files played through XBMC, winamp or foobar. However i can distinguish blindly easily the same flac file encoded in mp3 @320kbps.
I think XBMC resamples output stream only in analog mode.
Using the latest atlantis ver 4.

Same as the user above i consider myself an audiophile afficionado too.

Kind regards.
Reply
#14
The resampling will also affect sp/dif Sad
Let's just pray that the resampling issue will get HIGH priority.
I'm still using MediaPortal just because of this...

-Eicar
Reply
#15
Eicar Wrote:The resampling will also affect sp/dif Sad
Let's just pray that the resampling issue will get HIGH priority.
I'm still using MediaPortal just because of this...

-Eicar

It should NOT affect AC3 pass-through, I think... the decoding is made after the transmission, in the destination, and only then will things like sample frequency be considered.
Reply

Logout Mark Read Team Forum Stats Members Help
[LINUX/MAC/WINDOWS] Never upsample/downsample all audio streams to 48kHz by default2