Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with ohplayer and snd-aloop (for using brutefir convolution)
29-10-2016, 09:32 PM (This post was last modified: 30-10-2016 11:19 PM by droebbel.)
Post: #1
Problem with ohplayer and snd-aloop (for using brutefir convolution)
Hi!

Thank you first of all for your amazing work! I have been using ohplayer for a while now and am very happy with it.

I have now tried to incorporate some room correction using brutefir. This was done using the loopback alsa device. The setup has been proved working on a ubuntu pc.

Hovewer, on my rpi3 with raspbian jessie I get only severely distorted sound. It's crackling, it is significantly too slow, although with correct pitch. I assume there are some kind of permanent underruns.

I first suspected brutefir, so I ruled that out by replacing it with alsaloop. The problem remained the same. Load is quite low anyway.

I then ruled out the soundcard by using the USB-soundcard that was working on the ubuntu-pc instead of the hifiberry on the rpi3. Now change.

I also tried a different playback application. Playing with aplay works fine through the loopback device, both with alsaloop as "connector" to the real soundcard and with brutefir.

As ohplayer works perfectly wen playing directly to the "real" soundcard I assume there must be some kind of problem in the interaction between ohplayer and the loopback device, but I have now run out of ideas.

I would be immensely thankful if someone could try and reproduce this problem on a raspi.

Steps to reproduce:

Code:
sudo modprobe snd_aloop

edit /etc/asound.conf and change the default soundcard to
Code:
pcm.!default  {
type hw card 1
}
You may leave the ctl device alone.
Run
Code:
alsaloop -f S16_LE -c 44100 -U -C hw:Loopback,1 -P plughw:CARD=sndrpihifiberry,DEV=0
(you may have to replace soundcard and drop or change format and SR options - find the card with "aplay -L")
Restart ohplayer
turn down volume
play back audio

Thanks in advance for any ideas!
David
Find all posts by this user
29-10-2016, 11:25 PM (This post was last modified: 30-10-2016 12:12 AM by droebbel.)
Post: #2
RE: Problem with ohplayer and snd-aloop on raspberry
Now I have to partly correct myself:

It does not work on the ubuntu-pc either, as soon as I stop using Pulsaudio as an intermediate layer between ohplayer and the loopback device.

Starting to use pa on the rpi on the other hand "solved" the problem, but proved practically unusable: it suddenly switched to a horrible cracking sound several times.

And one more thing: on the pc, I did not notice any change in playback speed. On the pi, I measured 1'15 for a playback that should have been exactly 1 minute, but I think it varies slightly. As I said, the pitch is always correct.

And another update:

the problem remains, but I found a workaround using alsa dmix instead of pulseaudio. Seems to work so far, I'll do some more testing and provide a config in case anyone is interested.
Find all posts by this user
30-10-2016, 11:08 PM
Post: #3
RE: Problem with ohplayer and snd-aloop on raspberry
Hi again!

I think I found a temporary solution and have made some more observations on the way. I assume there is a bug somehere in the alsa part of ohplayer.

I found that by defining an intermediate layer that sets the samplerate in the alsa config (first try: dmix, then a simple generic slave plug) the playback was improved considerably.

However, there were still glitches when using dmix, which I could not get rid of. I tried the "rate" plugin briefly, with no success.

BTW, in some cases, I got no sound at all using ohplayer, and it ran through long files within a few seconds (visible in bubbleUpnp). I always doublechecked with aplay when a configuration did not work, and never got any problem like that or any glitches or distortions.

The final working configuration (I hope so at least after a few minutes of testing) is using a simple plug that does only one thing (as I understand it): setting a fixed samplerate without conversion. This may of course be unacceptable for many.

asound.conf:
Code:
pcm.Loopback {
type hw card 1
}

pcm.sndrpihifiberry {
type hw card 0
}

pcm.!default {
type plug
slave {
        pcm "Loopback"
        rate 44100
}
}

ctl.!default {
type hw
card 0
}
IO-part of brutefir config:
Code:
input "left_in", "right_in" {
   device: "alsa" { device: "hw:Loopback,1";};
   sample: "S16_LE";
   channels: 2/0,1;
   delay: 0,0;
   maxdelay: -1;
   subdelay: 0,0;
   mute: false,false;
};

output "left_out", "right_out" {
   device: "alsa" { device: "hw:sndrpihifiberry,0";};
   sample: "S32_LE";
   channels: 2/0,1;
   delay: 0,0;
   maxdelay: -1;
   subdelay: 0,0;
   mute: false,false;
   dither: true;
};

This would mean it is possible to use convolution with brutefir together with ohplayer.
The limitation to one working samplerate seems unnecessary though, and I would be glad to assist in finding the bug that causes the need for the above workaround.

David
Find all posts by this user
02-11-2016, 10:45 AM
Post: #4
RE: Problem with ohplayer and snd-aloop (for using brutefir convolution)
Hi David,

Glad to hear you like the OpenHome Player.

The loopback problem is an odd issue and is a little out of the scope for how we envisage the player being used.
The OpenHome linux alsa driver is also quite straightforward, querying the selected alsa device for supported sample rates, doing bitdepth conversion if required, and delivering packets to the nominated ALSA device.

I think your setup may be more complex - you have a variety of additional things going on between the openhome driver and the audio hardware - and it's unclear where these issues are coming from. I'm not sure it is a bug in the ALSA driver; we have tested with various soundcards without issues like this, but may be something specific to the loopback driver configuration. It seems that some of the configurations you mention may also require resampling, and I'm not sure whether you have the samplerate library installed on your pi.

I'll raise a ticket in our issue tracker, but we don't have a lot of resource to spare on investigating custom configs at the moment. However, if you are interested the source is on GitHub; it may be worthwhile building a debug version of the player and checking the console output on the Pi as it is running. The debug can be quite helpful in situations like this.

The source for the player (and build instructions) are at:
https://github.com/openhome/ohPlayer

Thanks,
Pete
Find all posts by this user
03-11-2016, 10:07 PM
Post: #5
RE: Problem with ohplayer and snd-aloop (for using brutefir convolution)
Hi Pedro,

thank you for your reply. I'll try with a debug build, I have built a headless version from git anyway (as the headless package still wants to pull in lots of gui-dependencies).

I am quite sure libsamplerate is there. I'll try to investigate further as good as I can, fully understanding this does not have high priority for you (but still: I think being able to do room correction with ohplayer is a cool feature, narrowing the gap between raspi and Linn hardware. "Killing" room modes does make a difference).

David
Find all posts by this user


Forum Jump: