Moode Forum

Full Version: Official moOde 6.5.2 support thread
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
(05-26-2020, 11:18 PM)Tim Curtis Wrote: [ -> ]Source repo for Crossfeed
https://sourceforge.net/projects/bs2b/

Here's the C header file for the Crossfeed software that defines what sample rates and bit depths are supported.
Code:
/*-
* Copyright (c) 2005 Boris Mikhaylov
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef BS2B_H
#define BS2B_H

#include "bs2bversion.h"
#include "bs2btypes.h"

/* Minimum/maximum sample rate (Hz) */
#define BS2B_MINSRATE 2000
#define BS2B_MAXSRATE 384000

/* Minimum/maximum cut frequency (Hz) */
/* bs2b_set_level_fcut() */
#define BS2B_MINFCUT 300
#define BS2B_MAXFCUT 2000

/* Minimum/maximum feed level (dB * 10 @ low frequencies) */
/* bs2b_set_level_feed() */
#define BS2B_MINFEED 10   /* 1 dB */
#define BS2B_MAXFEED 150  /* 15 dB */

/* Normal crossfeed levels (Obsolete) */
#define BS2B_HIGH_CLEVEL     ( ( uint32_t )700 | ( ( uint32_t )30 << 16 ) )
#define BS2B_MIDDLE_CLEVEL   ( ( uint32_t )500 | ( ( uint32_t )45 << 16 ) )
#define BS2B_LOW_CLEVEL      ( ( uint32_t )360 | ( ( uint32_t )60 << 16 ) )

/* Easy crossfeed levels (Obsolete) */
#define BS2B_HIGH_ECLEVEL    ( ( uint32_t )700 | ( ( uint32_t )60 << 16 ) )
#define BS2B_MIDDLE_ECLEVEL  ( ( uint32_t )500 | ( ( uint32_t )72 << 16 ) )
#define BS2B_LOW_ECLEVEL     ( ( uint32_t )360 | ( ( uint32_t )84 << 16 ) )

/* Default crossfeed levels */
/* bs2b_set_level() */
#define BS2B_DEFAULT_CLEVEL  ( ( uint32_t )700 | ( ( uint32_t )45 << 16 ) )
#define BS2B_CMOY_CLEVEL     ( ( uint32_t )700 | ( ( uint32_t )60 << 16 ) )
#define BS2B_JMEIER_CLEVEL   ( ( uint32_t )650 | ( ( uint32_t )95 << 16 ) )

/* Default sample rate (Hz) */
#define BS2B_DEFAULT_SRATE   44100

/* A delay at low frequency by microseconds according to cut frequency */
#define bs2b_level_delay( fcut ) ( ( 18700 / fcut ) * 10 )

typedef struct
{
    uint32_t level;              /* Crossfeed level */
    uint32_t srate;              /* Sample rate (Hz) */
    double a0_lo, b1_lo;         /* Lowpass IIR filter coefficients */
    double a0_hi, a1_hi, b1_hi;  /* Highboost IIR filter coefficients */
    double gain;                 /* Global gain against overloading */
    /* Buffer of last filtered sample: [0] 1-st channel, [1] 2-d channel */
    struct { double asis[ 2 ], lo[ 2 ], hi[ 2 ]; } lfs;
} t_bs2bd;

typedef t_bs2bd *t_bs2bdp;

#ifdef __cplusplus
extern "C"
{
#endif    /* __cplusplus */

/* Allocates and sets a data to defaults.
* Return NULL on error.
*/
t_bs2bdp bs2b_open( void );

/* Close */
void bs2b_close( t_bs2bdp bs2bdp );

/* Sets a new coefficients by new crossfeed value.
* level = ( ( uint32_t )fcut | ( ( uint32_t )feed << 16 ) )
* where 'feed' is crossfeeding level at low frequencies (dB * 10)
* and 'fcut' is cut frecuency (Hz)
*/
void bs2b_set_level( t_bs2bdp bs2bdp, uint32_t level );

/* Return a current crossfeed level value. */
uint32_t bs2b_get_level( t_bs2bdp bs2bdp );

/* Sets a new coefficients by new cut frecuency value (Hz). */
void bs2b_set_level_fcut( t_bs2bdp bs2bdp, int fcut );

/* Return a current cut frecuency value (Hz). */
int bs2b_get_level_fcut( t_bs2bdp bs2bdp );

/* Sets a new coefficients by new crossfeeding level value (dB * 10). */
void bs2b_set_level_feed( t_bs2bdp bs2bdp, int feed );

/* Return a current crossfeeding level value (dB * 10). */
int bs2b_get_level_feed( t_bs2bdp bs2bdp );

/* Return a current delay value at low frequencies (micro seconds). */
int bs2b_get_level_delay( t_bs2bdp bs2bdp );

/* Clear buffers and sets a new coefficients with new sample rate value.
* srate - sample rate by Hz.
*/
void bs2b_set_srate( t_bs2bdp bs2bdp, uint32_t srate );

/* Return current sample rate value */
uint32_t bs2b_get_srate( t_bs2bdp bs2bdp );

/* Clear buffer */
void bs2b_clear( t_bs2bdp bs2bdp );

/* Return 1 if buffer is clear */
int bs2b_is_clear( t_bs2bdp bs2bdp );

/* Return bs2b version string */
char const *bs2b_runtime_version( void );

/* Return bs2b version integer */
uint32_t bs2b_runtime_version_int( void );

/* 'bs2b_cross_feed_*' crossfeeds buffer of 'n' stereo samples
* pointed by 'sample'.
* sample[i]   - first channel,
* sample[i+1] - second channel.
* Where 'i' is ( i = 0; i < n * 2; i += 2 )
*/

/* sample poits to double floats native endians */
void bs2b_cross_feed_d( t_bs2bdp bs2bdp, double *sample, int n );

/* sample poits to double floats big endians */
void bs2b_cross_feed_dbe( t_bs2bdp bs2bdp, double *sample, int n );

/* sample poits to double floats little endians */
void bs2b_cross_feed_dle( t_bs2bdp bs2bdp, double *sample, int n );

/* sample poits to floats native endians */
void bs2b_cross_feed_f( t_bs2bdp bs2bdp, float *sample, int n );

/* sample poits to floats big endians */
void bs2b_cross_feed_fbe( t_bs2bdp bs2bdp, float *sample, int n );

/* sample poits to floats little endians */
void bs2b_cross_feed_fle( t_bs2bdp bs2bdp, float *sample, int n );

/* sample poits to 32bit signed integers native endians */
void bs2b_cross_feed_s32( t_bs2bdp bs2bdp, int32_t *sample, int n );

/* sample poits to 32bit unsigned integers native endians */
void bs2b_cross_feed_u32( t_bs2bdp bs2bdp, uint32_t *sample, int n );

/* sample poits to 32bit signed integers big endians */
void bs2b_cross_feed_s32be( t_bs2bdp bs2bdp, int32_t *sample, int n );

/* sample poits to 32bit unsigned integers big endians */
void bs2b_cross_feed_u32be( t_bs2bdp bs2bdp, uint32_t *sample, int n );

/* sample poits to 32bit signed integers little endians */
void bs2b_cross_feed_s32le( t_bs2bdp bs2bdp, int32_t *sample, int n );

/* sample poits to 32bit unsigned integers little endians */
void bs2b_cross_feed_u32le( t_bs2bdp bs2bdp, uint32_t *sample, int n );

/* sample poits to 16bit signed integers native endians */
void bs2b_cross_feed_s16( t_bs2bdp bs2bdp, int16_t *sample, int n );

/* sample poits to 16bit unsigned integers native endians */
void bs2b_cross_feed_u16( t_bs2bdp bs2bdp, uint16_t *sample, int n );

/* sample poits to 16bit signed integers big endians */
void bs2b_cross_feed_s16be( t_bs2bdp bs2bdp, int16_t *sample, int n );

/* sample poits to 16bit unsigned integers big endians */
void bs2b_cross_feed_u16be( t_bs2bdp bs2bdp, uint16_t *sample, int n );

/* sample poits to 16bit signed integers little endians */
void bs2b_cross_feed_s16le( t_bs2bdp bs2bdp, int16_t *sample, int n );

/* sample poits to 16bit unsigned integers little endians */
void bs2b_cross_feed_u16le( t_bs2bdp bs2bdp, uint16_t *sample, int n );

/* sample poits to 8bit signed integers */
void bs2b_cross_feed_s8( t_bs2bdp bs2bdp, int8_t *sample, int n );

/* sample poits to 8bit unsigned integers */
void bs2b_cross_feed_u8( t_bs2bdp bs2bdp, uint8_t *sample, int n );

/* sample poits to 24bit signed integers native endians */
void bs2b_cross_feed_s24( t_bs2bdp bs2bdp, bs2b_int24_t *sample, int n );

/* sample poits to 24bit unsigned integers native endians */
void bs2b_cross_feed_u24( t_bs2bdp bs2bdp, bs2b_uint24_t *sample, int n );

/* sample poits to 24bit signed integers be endians */
void bs2b_cross_feed_s24be( t_bs2bdp bs2bdp, bs2b_int24_t *sample, int n );

/* sample poits to 24bit unsigned integers be endians */
void bs2b_cross_feed_u24be( t_bs2bdp bs2bdp, bs2b_uint24_t *sample, int n );

/* sample poits to 24bit signed integers little endians */
void bs2b_cross_feed_s24le( t_bs2bdp bs2bdp, bs2b_int24_t *sample, int n );

/* sample poits to 24bit unsigned integers little endians */
void bs2b_cross_feed_u24le( t_bs2bdp bs2bdp, bs2b_uint24_t *sample, int n );

#ifdef __cplusplus
}    /* extern "C" */
#endif /* __cplusplus */

#endif    /* BS2B_H */

Thanks...  Now if only I wasn't more rust than language skills in regards to C... 

So, I have two Moode setups in front of me, one with an Allo Boss,  and one with a Schiit Modi 3.

So, what I see happening,  is on both my DACS, when you are not doing any resampling,  and you turn on the crossfeed (or one of the two EQ's) what you see in the audio info is that the output is 32bit and whatever the input sample rate is.  Like a 32/* resample has been applied.  No problem, music plays on both.  

If you do resampling, and select a particular bitrate,  as expected you get a different bitrate,  but up to a point on my Schiit.  I select 32/384 and the resampler says it did 384, but the output says 32/192.  Still plays OK.  

Now, if I turn on the crossfeed/EQ,  I get the ALSA device warning, and no sound.  Seems any resampling choice above 32/192 will be broken in this case.

On the other system, with the Allo Boss,  I do not see a different output bitrate above 32/192,  I see the ouput matching what the resampler is set to, all the way to 32/384.  And, it plays, even with the crossfeeed on.

So,  it seems odd, but possibly expected behavior for the crossfeed/EQ blocks to "resample" or convert the bitsream to 32b.  I'm researching now, since I was under the impression that a Schiit Modi 3 was a 32/384 DAC.   Now, on their site, I see "up to 24/192"   Huh

Edit: OK, have done some datasheet trolling... The Schiit has a AKM4490, a decent chip that can go to 768kbit and 11.2mHz DSD, IF the rest is up to it. And, it looks like the USB interface cant quite fully follow. Chip in question there, is a CM6631A and it tops out at 32/192. So I would think, that the Modi 3 is self limited by it's USB interface. I do see some error codes in response to it in the boot up log with dmesg, that I want to ask about later, and there are a few differences in the formats, so maybe the Modi isn't being set up as perfectly as possible, but it looks like we're overreaching the DAC.

Interesting question on how, without the crossfeed on, somehow Mood seems to "know" and provide it with 32/192, but the crossfeed prevents that. Maybe that can be preserved with crossfeed/EQ on.
The audio interfaces are different for your two DAC's and so results can be different.

The USB DAC will be using the universal Linux USB audio driver and its "Quirks" file that contains definitions of USB DAC's and their custom requirements. Your DAC is prolly in the Quirks file and its correctly reporting its max sample rate of 192K.

The I2S DAC has its own custom driver and so more likely to not cause issues.

Also, ALSA will always try to provide the bit depth that the audio device accepts. it zero-pad's it so no loss of bit-perfect-ness. This all happens behind the scenes.

What exactly are you trying to achieve with regard to resampling and your two DAC's?
@JonPike 

I'm not sure I followed your dissection of the Schiit Modi 3, but moOde can only work with the capabilities of DACs as reported through ALSA.

Tim has included in moOde the command-line utility alsacap which can tell you what ALSA believes to be true about yours.


Here's its output for the USB Khadas Tone Board on my living room system:


Code:
pi@moodelr:~ $ alsacap -C 1
*** Scanning for playback devices on card 1 ***
Card 1, ID `Control', name `Khadas Tone Control'
  Device 0, ID `USB Audio', name `USB Audio', 1 subdevices (1 available)
    2 channels, sampling rate 44100..768000 Hz
    Sample formats: S16_LE, S32_LE, SPECIAL, DSD_U32_BE
    Buffer size range from 16 to 262144
    Period size range from 8 to 131072

      Subdevice 0, name `subdevice #0'


while here's its output for the USB-BT adapter on a test system:


Code:
pi@moode3b:~ $ alsacap -C 1
*** Scanning for playback devices on card 1 ***
Card 1, ID `W2', name `Creative Bluetooth Audio W2'
 Device 0, ID `USB Audio', name `USB Audio', 1 subdevices (1 available)
   2 channels, sampling rate 48000..48000 Hz
   Sample formats: S16_LE
   Buffer size range from 96 to 262144
   Period size range from 48 to 131072

     Subdevice 0, name `subdevice #0'


In both cases, I restricted the search to card 1 because I knew that was how the DAC of interest was enumerated. Try the --help command to see other alsacap options.

Here's the man page and here's a more extensive article by Volker Schatz who wrote the utility: A close look at ALSA.

Regards,
Kent
(05-27-2020, 01:42 AM)Tim Curtis Wrote: [ -> ]The audio interfaces are different for your two DAC's and so results can be different.

The USB DAC will be using the universal Linux USB audio driver and its "Quirks" file that contains definitions of USB DAC's and their custom requirements. Your DAC is prolly in the Quirks file and its correctly reporting its max sample rate of 192K.

The I2S DAC has its own custom driver and so more likely to not cause issues.

Also, ALSA will always try to provide the bit depth that the audio device accepts. it zero-pad's it so no loss of bit-perfect-ness. This all happens behind the scenes.

What exactly are you trying to achieve with regard to resampling and your two DAC's?

Yep...  Due to my Schiit being a USB device, the data has to flow thru a USB interface,  and of course whatever is the slowest link will define the limits.

I'm curious as to what's in the Quirks file for the Schiit...  where is that located? And yes, sounds like it's correct, in that it seems 192khz is the right "top speed", for the USB interface, but I'm interested anyway.

A good question would be,  since it can change or limit to 192 when I resample to something higher and play successfully, why does it NOT do that when the crossfeed/EQ is engaged? 

Overall, was succumbing to a bit of audiophilia..  just thought I'd play with higher bitrate resampling and see if it made any difference.  On the Allo Boss, I think you get the filtering turned off, so that might actually be audible. The Schiit, using a different chip, probably not. The Modi 3, I thought was good to 32/384, especially since it played when I set it there...  Confused   but as we see,  appearances aren't always what they seem.  

Also was trying to crosscheck the earlier poster reporting a sudden similar problem since I had 6.4.2 and a 6.5.2 players handy.   I saw the problem on both, so I'm wondering if he also did the same thing I did,  inadvertently change sample rates.  Would be good to hear back from him to see if his issue is actually the same kind of thing.
I don't track these files and so I'm just posting for reference purposes but for USB audio devices here are some links to the quirks file.

Upstream sound/usb quirks file
https://github.com/torvalds/linux/blob/m...b/quirks.c

Raspberry Pi Linux downstream file for the 5.4.y kernel
https://github.com/raspberrypi/linux/blo...b/quirks.c
(05-27-2020, 03:46 PM)TheOldPresbyope Wrote: [ -> ]@JonPike 

I'm not sure I followed your dissection of the Schiit Modi 3, but moOde can only work with the capabilities of DACs as reported through ALSA.

Tim has included in moOde the command-line utility alsacap which can tell you what ALSA believes to be true about yours.

Ah, thanks for that.  The article especially, that will help a lot with me understanding ALSA better.

I was using the Modi 3 on my 6.5.2 player.   Here's what I see in the Audio Info:

Audio Device
Device:      USB audio device
Chip:      
Interface:      USB
Formats:      S16_LE, S32_LE, S24_3LE
Platform:      Pi-3B 1GB v1.2


And what I see with alsacap:  (not showing the Pi's audio jack and two HDMI devices)

Card 1, ID `S3', name `Schiit Modi 3'
  Device 0, ID `USB Audio', name `USB Audio', 1 subdevices (1 available)
    2 channels, sampling rate 44100..192000 Hz
    Sample formats: S16_LE, S32_LE, S24_3LE
    Buffer size range from 16 to 262144
    Period size range from 8 to 131072

So, it seems that the Modi 3 is recognized as handling 32b data,  and rates up to 192k.  This follows with what the Cmedia USB interface chip can do, (and not what the Schiit website says, which is 24b).  And, probably everything setup wise is OK in that regard.

The weird thing, is when you resample higher than that.  So, if I sample to a higher rate than 192k,  I'd expect no sound and a error message.  What happens is this, from the Audio Info window:

Resampling to 32/384, no cross

Input / Output
Source:      http://stream-tx3.radioparadise.com/aac-320
Encoded at:      VBR compression
Decoded to:      16 bit, 44.1 kHz, Stereo, 320 kbps
Destination:      Local
Output rate:      32 bit, 192 kHz, Stereo, 12.288 Mbps
DSP operations
Volume ctl:      Software (MPD 32-bit float with dither)
Resampling:      32 bit, 384 kHz, Stereo (SoX very high quality)
Polarity inv:      off
Crossfade:      off
Crossfeed:      off

Notice that I've set it to resample to 32/384,  but the output ends up 32/192.   And it plays, since the Modi can handle that.  Not sure what's exactly happening here, but it looks like some resampling or altering of the commanded setting to a different (the max valid?) rate. 

Now, if I turn on the Crossfeed, or select an EQ, this breaks,  and I get no decode or output, looking like this, along with the ALSA no device msg like Morias saw:

Input / Output
Source:      http://stream-tx3.radioparadise.com/aac-320
Encoded at:      VBR compression
Decoded to:      0 bps
Destination:      Local
Output rate:      0 bps
DSP operations
Volume ctl:      Software (MPD 32-bit float with dither)
Resampling:      32 bit, 384 kHz, Stereo (SoX very high quality)
Polarity inv:      off
Crossfade:      off
Crossfeed:      700 Hz 4.5 dB

If I lower the resampling rate to 32/192,  it works with the crossfeed on.

So, it looks like the system will "protect" you from setting beyond the rate of your DAC,  but if you enable a feature it will not.  Maybe that's not what's happening, but that's the result.  It's perhaps a low level bug,  but if it would be possible to maintain the "protecting" behavior with the crossfeed/EQ on, it would keep people from stumbling into a confusing non playing situation.  I have no idea if the stuff doing this is near the surface in Moode land,  or deep under the hood of ALSA....

A possible clue is that if you don't do any resampling, and you turn on the crossfeed/EQ you get the same data rate as you had on the input, but the reported depth on output changes to 32b.  As Tim explained, that's something ALSA will do, but in this case only when those features are on.
@JonPike 

As your alsacap output shows, your Schiit is reporting it can handle 32-bit material so moOde/MPD/ALSA will send it, but in a quick search of the InterWEB™, I see others saying it converts 32-bit material back down to 24-bit internally.

Why don't you ask Schiit?

Regards,
Kent
MPD and ALSA will try to play a bit depth and sample rate that your DAC will accept but the DSP plugins most of which are not maintained anymore have their own limits and methods of failing that neither MPD not ALSA have control over.

Also when you set MPD to resample at bit depths and rates that are incompatible with either the DSP plugin and/or the audio device there can be unexpected results.
What happens inside a DAC is interesting to say the least.
(05-29-2020, 12:38 AM)TheOldPresbyope Wrote: [ -> ]@JonPike 

As your alsacap output shows, your Schiit is reporting it can handle 32-bit material so moOde/MPD/ALSA will send it, but in a quick search of the InterWEB™, I see others saying it converts 32-bit material back down to 24-bit internally.

Why don't you ask Schiit?

Regards,
Kent

I may..  but that probably isn't part of the issue here.  From data sheets,  we  know that the core DAC can handle up to 32/768,  if set up for it,  but the USB interface can handle a max of 32/192.  The SPDIF input is limited to 24/192. 

The issue seems to be in the software, someplace... in the parts that feed the audio devices,  resample, bit pad, and apply filtering.  I had thought it might be some config issue with the Schiit, but I dont think so now. The name dosen't appear in the quirks, it gets reported as it should, etc.

As Tim says,  you have to figure what the different pieces along the way have as limitations.  I found a mention in the history of the crossfeed, that it has a 192k limit, but in the above code there's a line saying max rate is 384? Looks like the guy who wrote it has been gone 5+ years and isn't available to ask. 

What do you think, Tim?  Maybe there's some kind of error handling in the main line audio stuff,  for when you attempt to resample to something over what the stated device limit is, and the EQ blocks don't support and break it?  The error msg sounds like its reporting not finding a (faster than exists) device.

Anyway, don't want to beat a dead horse,  or even one that's just feeling poorly...  Was hoping it might be an easy thing to find.

Overall conclusion, if you're using a Schiit Modi 3 (or any other dac that has limits?) and you want to resample and do some DSP, best keep it below the limit it should perform at.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16