Running portaudio?

Hello :slight_smile:
I wanted to see if someone could help me understand pisound a little bit better. Currently I am trying to run the examples from the portaudio repo, but the output is coming from the rpi jack. I tried writing a .asoundrc like this:

pcm.!default {
    type hw
    card 1
}

pcm.!default {
    type hw
    card 1
}

But with no change. aplay -l returns this:

**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 7/7
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: ALSA [bcm2835 ALSA], device 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: pisound [pisound], device 0: PS-3S8GG17 snd-soc-dummy-dai-0 []
  Subdevices: 0/1
  Subdevice #0: subdevice #0

I have not been successful in getting sound from the output from the pisound yet. I know portaudio can probably find it because running ./pa_devs from /portaudio/bin/ gives me this:

--------------------------------------- device #2
Name                        = pisound: - (hw:1,0)
Host API                    = ALSA
Max inputs = 2, Max outputs = 2
Default low input latency   =   0.0080
Default low output latency  =   0.0080
Default high input latency  =   0.0320
Default high output latency =   0.0320
Default sample rate         = 48000.00
Supported standard sample rates
 for half-duplex 16 bit 2 channel input = 
	48000.00, 96000.00, 192000.00
Supported standard sample rates
 for half-duplex 16 bit 2 channel output = 
	48000.00, 96000.00, 192000.00
Supported standard sample rates
 for full-duplex 16 bit 2 channel input, 2 channel output = 
	48000.00, 96000.00, 192000.00

So I guess I am taking this opportunity to maybe learn something if someone is kind enough. Why when I run alsamixer it shows PulseAudio as the default card? I am curious about what is going on behind the scenes, because thanks to the forum I learned the speaker-test command but it only outputs from the pisound when I turn off jack. I also learned that aplay sample.wav outputs to the rpi jack, while to output from the pisound I have to do aplay sample.wav -D sysdefault:CARD=1.

I am running patchbox. I am new to the forum so if there is anything I should have put here let me know. :slight_smile: :slightly_smiling_face:

Hey, in Linux, there’s a couple of audio backends to choose from. There’s ALSA which usually works exclusively with a single piece of software, and doesn’t give access to other software at the same time. Then there’s Jack which itself uses ALSA to work with the audio card, but it itself lets multiple software to pipe audio between each other and finally to the hardware outputs. The Jack backend is usually preferred, if the software you’re using allows for it.

Port Audio is an abstraction library for working with audio - it hides OS specific details to let developer write just a single version of code to work on all OSes supported by Port Audio. Port Audio itself is supposed to have ALSA and Jack output capabilities, which you should be able to configure, try browsing its API documentation & examples. I’d recommend trying to explicitly specify the audio destination to use (preferably the already running Jack server) rather than rely on .asoundrc. In my experience, setting the default card via .asoundrc may actually make it more difficult to do what you want, as some background software may end up blocking the card you intend to use. :slight_smile:

Also, keep in mind that you have to use 48kHz, 96kHz or 192kHz sampling rates with Pisound. Otherwise, you have to set up some software resampling if you must use 44100kHz or other sampling rates.

1 Like