alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* Fwd: Odd issue with ALSA connecting directly to HDMI audio output
       [not found] <CAJrgGbZfPYHhf+p1TJO_LQe=pxkxDtAMPsY6sXOh1xVxq0b69w@mail.gmail.com>
@ 2023-07-18 16:22 ` Ico Bukvic
  2023-07-18 17:12   ` Geraldo Nascimento
  0 siblings, 1 reply; 8+ messages in thread
From: Ico Bukvic @ 2023-07-18 16:22 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 1557 bytes --]

Hi all,

I have a consumer-level setup audio question. My research project uses a
Raspberry Pi in conjunction with a small portable monitor that has built-in
loudspeakers that are to be used via HDMI connection. The goal here is
portability and minimal cost.

Curiously, when trying to connect to monitor's loudspeakers (via HDMI)
using ALSA, no matter what settings I pick, at worst I cannot get
audio out, and at best, get a buzzy sound whose waveform is in the attached
image. The sound is clearly periodic and impulse-like. It happens every 59
samples. Changing sample rate increases pitch, suggesting 59 samples remain
constant regardless of the sampling rate. When playing the actual audio,
you can hear it in the background, but this buzz is easily overpowering it.

Changing sample rate or bit depth, or buffering, makes no difference.
Selecting 8 channels for output (one of HDMI's standards, as far as I can
tell), sometimes manages to output a tiny chunk of a good audio sample, and
then goes silent.

Now, even more curiously, when using the portaudio backend and connecting
to the default pulseaudio sink, works just fine. What could be causing this
discrepancy?

Best,

Ico

-- 
Ivica Ico Bukvic, D.M.A.
Director, Creativity + Innovation
Director, Human-Centered Design iPhD
Institute for Creativity, Arts, and Technology

Virginia Tech
Creative Technologies in Music
School of Performing Arts – 0141
Blacksburg, VA 24061
(540) 231-6139
ico@vt.edu

ci.icat.vt.edu
l2ork.icat.vt.edu
ico.bukvic.net

[-- Attachment #2: Screenshot 2023-07-13 124559.png --]
[-- Type: image/png, Size: 77677 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Fwd: Odd issue with ALSA connecting directly to HDMI audio output
  2023-07-18 16:22 ` Fwd: Odd issue with ALSA connecting directly to HDMI audio output Ico Bukvic
@ 2023-07-18 17:12   ` Geraldo Nascimento
  2023-07-19  3:51     ` Geraldo Nascimento
  0 siblings, 1 reply; 8+ messages in thread
From: Geraldo Nascimento @ 2023-07-18 17:12 UTC (permalink / raw)
  To: Ico Bukvic; +Cc: alsa-devel

On Tue, Jul 18, 2023 at 12:22:35PM -0400, Ico Bukvic wrote:
> Hi all,

Hi Ico and friends,

> 
> I have a consumer-level setup audio question. My research project uses a
> Raspberry Pi in conjunction with a small portable monitor that has built-in
> loudspeakers that are to be used via HDMI connection. The goal here is
> portability and minimal cost.
> 
> Curiously, when trying to connect to monitor's loudspeakers (via HDMI)
> using ALSA, no matter what settings I pick, at worst I cannot get
> audio out, and at best, get a buzzy sound whose waveform is in the attached
> image. The sound is clearly periodic and impulse-like. It happens every 59
> samples. Changing sample rate increases pitch, suggesting 59 samples remain
> constant regardless of the sampling rate. When playing the actual audio,
> you can hear it in the background, but this buzz is easily overpowering it.
> 

Ico, just a wild guess but are you sure you are not capturing the raw SPDIF
signal going through HDMI instead of Linear PCM audio signal?

> Changing sample rate or bit depth, or buffering, makes no difference.
> Selecting 8 channels for output (one of HDMI's standards, as far as I can
> tell), sometimes manages to output a tiny chunk of a good audio sample, and
> then goes silent.
> 
> Now, even more curiously, when using the portaudio backend and connecting
> to the default pulseaudio sink, works just fine. What could be causing this
> discrepancy?

Perhaps PortAudio is forcing the Linear PCM bits on the underlying ALSA
backend somehow, see for example:
https://fossies.org/linux/alsa-lib/src/conf/pcm/iec958.conf
But this is just wild speculation, it may or may not be the case with
your report. It's best if you ask Takashi Iwai and Jaroslav Kysela
directly through the list with Cc: in case nobody else has any more
ideas of what could be the root cause of your report.

Good luck,
Geraldo Nascimento

> 
> Best,
> 
> Ico
> 
> -- 
> Ivica Ico Bukvic, D.M.A.
> Director, Creativity + Innovation
> Director, Human-Centered Design iPhD
> Institute for Creativity, Arts, and Technology
> 
> Virginia Tech
> Creative Technologies in Music
> School of Performing Arts – 0141
> Blacksburg, VA 24061
> (540) 231-6139
> ico@vt.edu
> 
> ci.icat.vt.edu
> l2ork.icat.vt.edu
> ico.bukvic.net



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Fwd: Odd issue with ALSA connecting directly to HDMI audio output
  2023-07-18 17:12   ` Geraldo Nascimento
@ 2023-07-19  3:51     ` Geraldo Nascimento
  2023-07-19  5:58       ` Ico Bukvic
  0 siblings, 1 reply; 8+ messages in thread
From: Geraldo Nascimento @ 2023-07-19  3:51 UTC (permalink / raw)
  To: Ico Bukvic; +Cc: alsa-devel

On Tue, Jul 18, 2023 at 02:12:31PM -0300, Geraldo Nascimento wrote:
> On Tue, Jul 18, 2023 at 12:22:35PM -0400, Ico Bukvic wrote:
> > Hi all,
> 
> Hi Ico and friends,
> 
> > 
> > I have a consumer-level setup audio question. My research project uses a
> > Raspberry Pi in conjunction with a small portable monitor that has built-in
> > loudspeakers that are to be used via HDMI connection. The goal here is
> > portability and minimal cost.
> > 
> > Curiously, when trying to connect to monitor's loudspeakers (via HDMI)
> > using ALSA, no matter what settings I pick, at worst I cannot get
> > audio out, and at best, get a buzzy sound whose waveform is in the attached
> > image. The sound is clearly periodic and impulse-like. It happens every 59
> > samples. Changing sample rate increases pitch, suggesting 59 samples remain
> > constant regardless of the sampling rate. When playing the actual audio,
> > you can hear it in the background, but this buzz is easily overpowering it.
> > 
> 
> Ico, just a wild guess but are you sure you are not capturing the raw SPDIF
> signal going through HDMI instead of Linear PCM audio signal?

Here's a comment from the VC4 HDMI driver:

 * HDMI audio is implemented entirely within the HDMI IP block.  A
 * register in the HDMI encoder takes SPDIF frames from the DMA engine
 * and transfers them over an internal MAI (multi-channel audio
 * interconnect) bus to the encoder side for insertion into the video
 * blank regions.

And there's this perhaps closely related old issue with the vendor
kernel and Android:
https://github.com/raspberrypi/linux/issues/4654

> 
> > Changing sample rate or bit depth, or buffering, makes no difference.
> > Selecting 8 channels for output (one of HDMI's standards, as far as I can
> > tell), sometimes manages to output a tiny chunk of a good audio sample, and
> > then goes silent.
> > 
> > Now, even more curiously, when using the portaudio backend and connecting
> > to the default pulseaudio sink, works just fine. What could be causing this
> > discrepancy?
> 
> Perhaps PortAudio is forcing the Linear PCM bits on the underlying ALSA
> backend somehow, see for example:
> https://fossies.org/linux/alsa-lib/src/conf/pcm/iec958.conf
> But this is just wild speculation, it may or may not be the case with
> your report. It's best if you ask Takashi Iwai and Jaroslav Kysela
> directly through the list with Cc: in case nobody else has any more
> ideas of what could be the root cause of your report.

You're probably sending PCM data to HDMI, which expects SPDIF frames
instead, and PortAudio + PulseAudio seems to be aware of this. That's my
theory at least. Setting the necessary bits and necessary IEC958 format
on your ALSA playback may resolve your issue.

> 
> Good luck,
> Geraldo Nascimento
> 
> > 
> > Best,
> > 
> > Ico
> > 
> > -- 
> > Ivica Ico Bukvic, D.M.A.
> > Director, Creativity + Innovation
> > Director, Human-Centered Design iPhD
> > Institute for Creativity, Arts, and Technology
> > 
> > Virginia Tech
> > Creative Technologies in Music
> > School of Performing Arts – 0141
> > Blacksburg, VA 24061
> > (540) 231-6139
> > ico@vt.edu
> > 
> > ci.icat.vt.edu
> > l2ork.icat.vt.edu
> > ico.bukvic.net
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Fwd: Odd issue with ALSA connecting directly to HDMI audio output
  2023-07-19  3:51     ` Geraldo Nascimento
@ 2023-07-19  5:58       ` Ico Bukvic
  2023-07-19  8:08         ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Ico Bukvic @ 2023-07-19  5:58 UTC (permalink / raw)
  To: Geraldo Nascimento; +Cc: alsa-devel

Thank you for a follow-up. How would one set such a flag in alsa? Using
alsactl or by editing a config file? The app in question seeks to open the
audio hardware directly to minimize latency. Any examples are appreciated.

Best,

Ico

-- 
Ivica Ico Bukvic, D.M.A.
Director, Creativity + Innovation
Director, Human-Centered Design iPhD
Institute for Creativity, Arts, and Technology

Virginia Tech
Creative Technologies in Music
School of Performing Arts – 0141
Blacksburg, VA 24061
(540) 231-6139
ico@vt.edu

ci.icat.vt.edu
l2ork.icat.vt.edu
ico.bukvic.net



On Tue, Jul 18, 2023 at 11:51 PM Geraldo Nascimento <
geraldogabriel@gmail.com> wrote:

> On Tue, Jul 18, 2023 at 02:12:31PM -0300, Geraldo Nascimento wrote:
> > On Tue, Jul 18, 2023 at 12:22:35PM -0400, Ico Bukvic wrote:
> > > Hi all,
> >
> > Hi Ico and friends,
> >
> > >
> > > I have a consumer-level setup audio question. My research project uses
> a
> > > Raspberry Pi in conjunction with a small portable monitor that has
> built-in
> > > loudspeakers that are to be used via HDMI connection. The goal here is
> > > portability and minimal cost.
> > >
> > > Curiously, when trying to connect to monitor's loudspeakers (via HDMI)
> > > using ALSA, no matter what settings I pick, at worst I cannot get
> > > audio out, and at best, get a buzzy sound whose waveform is in the
> attached
> > > image. The sound is clearly periodic and impulse-like. It happens
> every 59
> > > samples. Changing sample rate increases pitch, suggesting 59 samples
> remain
> > > constant regardless of the sampling rate. When playing the actual
> audio,
> > > you can hear it in the background, but this buzz is easily
> overpowering it.
> > >
> >
> > Ico, just a wild guess but are you sure you are not capturing the raw
> SPDIF
> > signal going through HDMI instead of Linear PCM audio signal?
>
> Here's a comment from the VC4 HDMI driver:
>
>  * HDMI audio is implemented entirely within the HDMI IP block.  A
>  * register in the HDMI encoder takes SPDIF frames from the DMA engine
>  * and transfers them over an internal MAI (multi-channel audio
>  * interconnect) bus to the encoder side for insertion into the video
>  * blank regions.
>
> And there's this perhaps closely related old issue with the vendor
> kernel and Android:
> https://github.com/raspberrypi/linux/issues/4654
>
> >
> > > Changing sample rate or bit depth, or buffering, makes no difference.
> > > Selecting 8 channels for output (one of HDMI's standards, as far as I
> can
> > > tell), sometimes manages to output a tiny chunk of a good audio
> sample, and
> > > then goes silent.
> > >
> > > Now, even more curiously, when using the portaudio backend and
> connecting
> > > to the default pulseaudio sink, works just fine. What could be causing
> this
> > > discrepancy?
> >
> > Perhaps PortAudio is forcing the Linear PCM bits on the underlying ALSA
> > backend somehow, see for example:
> > https://fossies.org/linux/alsa-lib/src/conf/pcm/iec958.conf
> > But this is just wild speculation, it may or may not be the case with
> > your report. It's best if you ask Takashi Iwai and Jaroslav Kysela
> > directly through the list with Cc: in case nobody else has any more
> > ideas of what could be the root cause of your report.
>
> You're probably sending PCM data to HDMI, which expects SPDIF frames
> instead, and PortAudio + PulseAudio seems to be aware of this. That's my
> theory at least. Setting the necessary bits and necessary IEC958 format
> on your ALSA playback may resolve your issue.
>
> >
> > Good luck,
> > Geraldo Nascimento
> >
> > >
> > > Best,
> > >
> > > Ico
> > >
> > > --
> > > Ivica Ico Bukvic, D.M.A.
> > > Director, Creativity + Innovation
> > > Director, Human-Centered Design iPhD
> > > Institute for Creativity, Arts, and Technology
> > >
> > > Virginia Tech
> > > Creative Technologies in Music
> > > School of Performing Arts – 0141
> > > Blacksburg, VA 24061
> > > (540) 231-6139
> > > ico@vt.edu
> > >
> > > ci.icat.vt.edu
> > > l2ork.icat.vt.edu
> > > ico.bukvic.net
> >
> >
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Fwd: Odd issue with ALSA connecting directly to HDMI audio output
  2023-07-19  5:58       ` Ico Bukvic
@ 2023-07-19  8:08         ` Takashi Iwai
  2023-07-19 12:27           ` Ico Bukvic
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2023-07-19  8:08 UTC (permalink / raw)
  To: Ico Bukvic; +Cc: Geraldo Nascimento, alsa-devel

On Wed, 19 Jul 2023 07:58:17 +0200,
Ico Bukvic wrote:
> 
> Thank you for a follow-up. How would one set such a flag in alsa? Using
> alsactl or by editing a config file? The app in question seeks to open the
> audio hardware directly to minimize latency. Any examples are appreciated.

Could you show how exactly you did test?

The fact that PA works implies that the device is basically working
when running with a proper setup (e.g. with hdmi:* PCM, etc.)


Takashi

> 
> Best,
> 
> Ico
> 
> -- 
> Ivica Ico Bukvic, D.M.A.
> Director, Creativity + Innovation
> Director, Human-Centered Design iPhD
> Institute for Creativity, Arts, and Technology
> 
> Virginia Tech
> Creative Technologies in Music
> School of Performing Arts – 0141
> Blacksburg, VA 24061
> (540) 231-6139
> ico@vt.edu
> 
> ci.icat.vt.edu
> l2ork.icat.vt.edu
> ico.bukvic.net
> 
> 
> 
> On Tue, Jul 18, 2023 at 11:51 PM Geraldo Nascimento <
> geraldogabriel@gmail.com> wrote:
> 
> > On Tue, Jul 18, 2023 at 02:12:31PM -0300, Geraldo Nascimento wrote:
> > > On Tue, Jul 18, 2023 at 12:22:35PM -0400, Ico Bukvic wrote:
> > > > Hi all,
> > >
> > > Hi Ico and friends,
> > >
> > > >
> > > > I have a consumer-level setup audio question. My research project uses
> > a
> > > > Raspberry Pi in conjunction with a small portable monitor that has
> > built-in
> > > > loudspeakers that are to be used via HDMI connection. The goal here is
> > > > portability and minimal cost.
> > > >
> > > > Curiously, when trying to connect to monitor's loudspeakers (via HDMI)
> > > > using ALSA, no matter what settings I pick, at worst I cannot get
> > > > audio out, and at best, get a buzzy sound whose waveform is in the
> > attached
> > > > image. The sound is clearly periodic and impulse-like. It happens
> > every 59
> > > > samples. Changing sample rate increases pitch, suggesting 59 samples
> > remain
> > > > constant regardless of the sampling rate. When playing the actual
> > audio,
> > > > you can hear it in the background, but this buzz is easily
> > overpowering it.
> > > >
> > >
> > > Ico, just a wild guess but are you sure you are not capturing the raw
> > SPDIF
> > > signal going through HDMI instead of Linear PCM audio signal?
> >
> > Here's a comment from the VC4 HDMI driver:
> >
> >  * HDMI audio is implemented entirely within the HDMI IP block.  A
> >  * register in the HDMI encoder takes SPDIF frames from the DMA engine
> >  * and transfers them over an internal MAI (multi-channel audio
> >  * interconnect) bus to the encoder side for insertion into the video
> >  * blank regions.
> >
> > And there's this perhaps closely related old issue with the vendor
> > kernel and Android:
> > https://github.com/raspberrypi/linux/issues/4654
> >
> > >
> > > > Changing sample rate or bit depth, or buffering, makes no difference.
> > > > Selecting 8 channels for output (one of HDMI's standards, as far as I
> > can
> > > > tell), sometimes manages to output a tiny chunk of a good audio
> > sample, and
> > > > then goes silent.
> > > >
> > > > Now, even more curiously, when using the portaudio backend and
> > connecting
> > > > to the default pulseaudio sink, works just fine. What could be causing
> > this
> > > > discrepancy?
> > >
> > > Perhaps PortAudio is forcing the Linear PCM bits on the underlying ALSA
> > > backend somehow, see for example:
> > > https://fossies.org/linux/alsa-lib/src/conf/pcm/iec958.conf
> > > But this is just wild speculation, it may or may not be the case with
> > > your report. It's best if you ask Takashi Iwai and Jaroslav Kysela
> > > directly through the list with Cc: in case nobody else has any more
> > > ideas of what could be the root cause of your report.
> >
> > You're probably sending PCM data to HDMI, which expects SPDIF frames
> > instead, and PortAudio + PulseAudio seems to be aware of this. That's my
> > theory at least. Setting the necessary bits and necessary IEC958 format
> > on your ALSA playback may resolve your issue.
> >
> > >
> > > Good luck,
> > > Geraldo Nascimento
> > >
> > > >
> > > > Best,
> > > >
> > > > Ico
> > > >
> > > > --
> > > > Ivica Ico Bukvic, D.M.A.
> > > > Director, Creativity + Innovation
> > > > Director, Human-Centered Design iPhD
> > > > Institute for Creativity, Arts, and Technology
> > > >
> > > > Virginia Tech
> > > > Creative Technologies in Music
> > > > School of Performing Arts – 0141
> > > > Blacksburg, VA 24061
> > > > (540) 231-6139
> > > > ico@vt.edu
> > > >
> > > > ci.icat.vt.edu
> > > > l2ork.icat.vt.edu
> > > > ico.bukvic.net
> > >
> > >
> >

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Fwd: Odd issue with ALSA connecting directly to HDMI audio output
  2023-07-19  8:08         ` Takashi Iwai
@ 2023-07-19 12:27           ` Ico Bukvic
  2023-07-19 12:39             ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Ico Bukvic @ 2023-07-19 12:27 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Geraldo Nascimento, alsa-devel

Thank you, Takashi.

On Raspberry Pi 400 (one with built-in keyboard, although any RPi or Linux
computer with HDMI monitor with loudspeakers will do), open pd-l2ork (a
variant of pure-data available at http://bit.ly/pd-l2ork; pure-data also
has this same problem) and enable DSP. Do the same after changing audio
settings via the Preferences window (Edit->Preferences), where you can
switch among backends (ALSA vs Portaudio, vs JACK; JACK does not work with
any setting). If you have proper audio settings (0 in, 2 out, and a
supported SR, r.g. 44,1kHz), you will hear the buzz, and will also hear the
desired audio produced (e.g. by running Media->Audio Tester) faintly, with
buzz bring at the forefront. Or, you will hear everything OK (default Pulse
settings), or nothing. ALSA and PortAudio settings are default
Raspbian(RPi)/Ubuntu (desktop). Thank you.

Best,

Ico

-- 
Ivica Ico Bukvic, D.M.A.
Director, Creativity + Innovation
Institute for Creativity, Arts, and Technology

Virginia Tech
Creative Technologies in Music
School of Performing Arts – 0141
Blacksburg, VA 24061
(540) 231-6139
ico@vt.edu

ci.icat.vt.edu
l2ork.icat.vt.edu
ico.bukvic.net

On Wed, Jul 19, 2023, 04:08 Takashi Iwai <tiwai@suse.de> wrote:

> On Wed, 19 Jul 2023 07:58:17 +0200,
> Ico Bukvic wrote:
> >
> > Thank you for a follow-up. How would one set such a flag in alsa? Using
> > alsactl or by editing a config file? The app in question seeks to open
> the
> > audio hardware directly to minimize latency. Any examples are
> appreciated.
>
> Could you show how exactly you did test?
>
> The fact that PA works implies that the device is basically working
> when running with a proper setup (e.g. with hdmi:* PCM, etc.)
>
>
> Takashi
>
> >
> > Best,
> >
> > Ico
> >
> > --
> > Ivica Ico Bukvic, D.M.A.
> > Director, Creativity + Innovation
> > Director, Human-Centered Design iPhD
> > Institute for Creativity, Arts, and Technology
> >
> > Virginia Tech
> > Creative Technologies in Music
> > School of Performing Arts – 0141
> > Blacksburg, VA 24061
> > (540) 231-6139
> > ico@vt.edu
> >
> > ci.icat.vt.edu
> > l2ork.icat.vt.edu
> > ico.bukvic.net
> >
> >
> >
> > On Tue, Jul 18, 2023 at 11:51 PM Geraldo Nascimento <
> > geraldogabriel@gmail.com> wrote:
> >
> > > On Tue, Jul 18, 2023 at 02:12:31PM -0300, Geraldo Nascimento wrote:
> > > > On Tue, Jul 18, 2023 at 12:22:35PM -0400, Ico Bukvic wrote:
> > > > > Hi all,
> > > >
> > > > Hi Ico and friends,
> > > >
> > > > >
> > > > > I have a consumer-level setup audio question. My research project
> uses
> > > a
> > > > > Raspberry Pi in conjunction with a small portable monitor that has
> > > built-in
> > > > > loudspeakers that are to be used via HDMI connection. The goal
> here is
> > > > > portability and minimal cost.
> > > > >
> > > > > Curiously, when trying to connect to monitor's loudspeakers (via
> HDMI)
> > > > > using ALSA, no matter what settings I pick, at worst I cannot get
> > > > > audio out, and at best, get a buzzy sound whose waveform is in the
> > > attached
> > > > > image. The sound is clearly periodic and impulse-like. It happens
> > > every 59
> > > > > samples. Changing sample rate increases pitch, suggesting 59
> samples
> > > remain
> > > > > constant regardless of the sampling rate. When playing the actual
> > > audio,
> > > > > you can hear it in the background, but this buzz is easily
> > > overpowering it.
> > > > >
> > > >
> > > > Ico, just a wild guess but are you sure you are not capturing the raw
> > > SPDIF
> > > > signal going through HDMI instead of Linear PCM audio signal?
> > >
> > > Here's a comment from the VC4 HDMI driver:
> > >
> > >  * HDMI audio is implemented entirely within the HDMI IP block.  A
> > >  * register in the HDMI encoder takes SPDIF frames from the DMA engine
> > >  * and transfers them over an internal MAI (multi-channel audio
> > >  * interconnect) bus to the encoder side for insertion into the video
> > >  * blank regions.
> > >
> > > And there's this perhaps closely related old issue with the vendor
> > > kernel and Android:
> > > https://github.com/raspberrypi/linux/issues/4654
> > >
> > > >
> > > > > Changing sample rate or bit depth, or buffering, makes no
> difference.
> > > > > Selecting 8 channels for output (one of HDMI's standards, as far
> as I
> > > can
> > > > > tell), sometimes manages to output a tiny chunk of a good audio
> > > sample, and
> > > > > then goes silent.
> > > > >
> > > > > Now, even more curiously, when using the portaudio backend and
> > > connecting
> > > > > to the default pulseaudio sink, works just fine. What could be
> causing
> > > this
> > > > > discrepancy?
> > > >
> > > > Perhaps PortAudio is forcing the Linear PCM bits on the underlying
> ALSA
> > > > backend somehow, see for example:
> > > > https://fossies.org/linux/alsa-lib/src/conf/pcm/iec958.conf
> > > > But this is just wild speculation, it may or may not be the case with
> > > > your report. It's best if you ask Takashi Iwai and Jaroslav Kysela
> > > > directly through the list with Cc: in case nobody else has any more
> > > > ideas of what could be the root cause of your report.
> > >
> > > You're probably sending PCM data to HDMI, which expects SPDIF frames
> > > instead, and PortAudio + PulseAudio seems to be aware of this. That's
> my
> > > theory at least. Setting the necessary bits and necessary IEC958 format
> > > on your ALSA playback may resolve your issue.
> > >
> > > >
> > > > Good luck,
> > > > Geraldo Nascimento
> > > >
> > > > >
> > > > > Best,
> > > > >
> > > > > Ico
> > > > >
> > > > > --
> > > > > Ivica Ico Bukvic, D.M.A.
> > > > > Director, Creativity + Innovation
> > > > > Director, Human-Centered Design iPhD
> > > > > Institute for Creativity, Arts, and Technology
> > > > >
> > > > > Virginia Tech
> > > > > Creative Technologies in Music
> > > > > School of Performing Arts – 0141
> > > > > Blacksburg, VA 24061
> > > > > (540) 231-6139
> > > > > ico@vt.edu
> > > > >
> > > > > ci.icat.vt.edu
> > > > > l2ork.icat.vt.edu
> > > > > ico.bukvic.net
> > > >
> > > >
> > >
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Fwd: Odd issue with ALSA connecting directly to HDMI audio output
  2023-07-19 12:27           ` Ico Bukvic
@ 2023-07-19 12:39             ` Takashi Iwai
  2023-07-19 13:21               ` Geraldo Nascimento
  0 siblings, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2023-07-19 12:39 UTC (permalink / raw)
  To: Ico Bukvic; +Cc: Geraldo Nascimento, alsa-devel

On Wed, 19 Jul 2023 14:27:21 +0200,
Ico Bukvic wrote:
> 
> 
> Thank you, Takashi.
> 
> On Raspberry Pi 400 (one with built-in keyboard, although any RPi or Linux
> computer with HDMI monitor with loudspeakers will do), open pd-l2ork (a
> variant of pure-data available at http://bit.ly/pd-l2ork; pure-data also has
> this same problem) and enable DSP. Do the same after changing audio settings
> via the Preferences window (Edit->Preferences), where you can switch among
> backends (ALSA vs Portaudio, vs JACK; JACK does not work with any setting). If
> you have proper audio settings (0 in, 2 out, and a supported SR, r.g.
> 44,1kHz), you will hear the buzz, and will also hear the desired audio
> produced (e.g. by running Media->Audio Tester) faintly, with buzz bring at the
> forefront. Or, you will hear everything OK (default Pulse settings), or
> nothing. ALSA and PortAudio settings are default Raspbian(RPi)/Ubuntu
> (desktop). Thank you.

Well, the question is how the ALSA PCM device is opened, how
configured and how played.  As Geraldo already suggested, VC4 HDMI on
RPi has a special format with IEC958 encoding.  Also it has IEC958
status bit setups.  So, for example, if you'd need to play a normal
PCM stream with aplay, you'd need to open the device with "hdmi:$CARD"
device -- then the rest is done in alsa-lib's plugin, and that's
almost equivalent with what PA does.


Takashi

> 
> Best,
> 
> Ico
> 
> -- 
> Ivica Ico Bukvic, D.M.A.
> Director, Creativity + Innovation
> Institute for Creativity, Arts, and Technology
> 
> Virginia Tech
> Creative Technologies in Music
> School of Performing Arts – 0141
> Blacksburg, VA 24061
> (540) 231-6139
> ico@vt.edu
> 
> ci.icat.vt.edu
> l2ork.icat.vt.edu
> ico.bukvic.net
> 
> On Wed, Jul 19, 2023, 04:08 Takashi Iwai <tiwai@suse.de> wrote:
> 
>     On Wed, 19 Jul 2023 07:58:17 +0200,
>     Ico Bukvic wrote:
>     >
>     > Thank you for a follow-up. How would one set such a flag in alsa? Using
>     > alsactl or by editing a config file? The app in question seeks to open
>     the
>     > audio hardware directly to minimize latency. Any examples are
>     appreciated.
>    
>     Could you show how exactly you did test?
>    
>     The fact that PA works implies that the device is basically working
>     when running with a proper setup (e.g. with hdmi:* PCM, etc.)
> 
>     Takashi
>    
>     >
>     > Best,
>     >
>     > Ico
>     >
>     > --
>     > Ivica Ico Bukvic, D.M.A.
>     > Director, Creativity + Innovation
>     > Director, Human-Centered Design iPhD
>     > Institute for Creativity, Arts, and Technology
>     >
>     > Virginia Tech
>     > Creative Technologies in Music
>     > School of Performing Arts – 0141
>     > Blacksburg, VA 24061
>     > (540) 231-6139
>     > ico@vt.edu
>     >
>     > ci.icat.vt.edu
>     > l2ork.icat.vt.edu
>     > ico.bukvic.net
>     >
>     >
>     >
>     > On Tue, Jul 18, 2023 at 11:51 PM Geraldo Nascimento <
>     > geraldogabriel@gmail.com> wrote:
>     >
>     > > On Tue, Jul 18, 2023 at 02:12:31PM -0300, Geraldo Nascimento wrote:
>     > > > On Tue, Jul 18, 2023 at 12:22:35PM -0400, Ico Bukvic wrote:
>     > > > > Hi all,
>     > > >
>     > > > Hi Ico and friends,
>     > > >
>     > > > >
>     > > > > I have a consumer-level setup audio question. My research project
>     uses
>     > > a
>     > > > > Raspberry Pi in conjunction with a small portable monitor that has
>     > > built-in
>     > > > > loudspeakers that are to be used via HDMI connection. The goal
>     here is
>     > > > > portability and minimal cost.
>     > > > >
>     > > > > Curiously, when trying to connect to monitor's loudspeakers (via
>     HDMI)
>     > > > > using ALSA, no matter what settings I pick, at worst I cannot get
>     > > > > audio out, and at best, get a buzzy sound whose waveform is in the
>     > > attached
>     > > > > image. The sound is clearly periodic and impulse-like. It happens
>     > > every 59
>     > > > > samples. Changing sample rate increases pitch, suggesting 59
>     samples
>     > > remain
>     > > > > constant regardless of the sampling rate. When playing the actual
>     > > audio,
>     > > > > you can hear it in the background, but this buzz is easily
>     > > overpowering it.
>     > > > >
>     > > >
>     > > > Ico, just a wild guess but are you sure you are not capturing the
>     raw
>     > > SPDIF
>     > > > signal going through HDMI instead of Linear PCM audio signal?
>     > >
>     > > Here's a comment from the VC4 HDMI driver:
>     > >
>     > >  * HDMI audio is implemented entirely within the HDMI IP block.  A
>     > >  * register in the HDMI encoder takes SPDIF frames from the DMA engine
>     > >  * and transfers them over an internal MAI (multi-channel audio
>     > >  * interconnect) bus to the encoder side for insertion into the video
>     > >  * blank regions.
>     > >
>     > > And there's this perhaps closely related old issue with the vendor
>     > > kernel and Android:
>     > > https://github.com/raspberrypi/linux/issues/4654
>     > >
>     > > >
>     > > > > Changing sample rate or bit depth, or buffering, makes no
>     difference.
>     > > > > Selecting 8 channels for output (one of HDMI's standards, as far
>     as I
>     > > can
>     > > > > tell), sometimes manages to output a tiny chunk of a good audio
>     > > sample, and
>     > > > > then goes silent.
>     > > > >
>     > > > > Now, even more curiously, when using the portaudio backend and
>     > > connecting
>     > > > > to the default pulseaudio sink, works just fine. What could be
>     causing
>     > > this
>     > > > > discrepancy?
>     > > >
>     > > > Perhaps PortAudio is forcing the Linear PCM bits on the underlying
>     ALSA
>     > > > backend somehow, see for example:
>     > > > https://fossies.org/linux/alsa-lib/src/conf/pcm/iec958.conf
>     > > > But this is just wild speculation, it may or may not be the case
>     with
>     > > > your report. It's best if you ask Takashi Iwai and Jaroslav Kysela
>     > > > directly through the list with Cc: in case nobody else has any more
>     > > > ideas of what could be the root cause of your report.
>     > >
>     > > You're probably sending PCM data to HDMI, which expects SPDIF frames
>     > > instead, and PortAudio + PulseAudio seems to be aware of this. That's
>     my
>     > > theory at least. Setting the necessary bits and necessary IEC958
>     format
>     > > on your ALSA playback may resolve your issue.
>     > >
>     > > >
>     > > > Good luck,
>     > > > Geraldo Nascimento
>     > > >
>     > > > >
>     > > > > Best,
>     > > > >
>     > > > > Ico
>     > > > >
>     > > > > --
>     > > > > Ivica Ico Bukvic, D.M.A.
>     > > > > Director, Creativity + Innovation
>     > > > > Director, Human-Centered Design iPhD
>     > > > > Institute for Creativity, Arts, and Technology
>     > > > >
>     > > > > Virginia Tech
>     > > > > Creative Technologies in Music
>     > > > > School of Performing Arts – 0141
>     > > > > Blacksburg, VA 24061
>     > > > > (540) 231-6139
>     > > > > ico@vt.edu
>     > > > >
>     > > > > ci.icat.vt.edu
>     > > > > l2ork.icat.vt.edu
>     > > > > ico.bukvic.net
>     > > >
>     > > >
>     > >
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Fwd: Odd issue with ALSA connecting directly to HDMI audio output
  2023-07-19 12:39             ` Takashi Iwai
@ 2023-07-19 13:21               ` Geraldo Nascimento
  0 siblings, 0 replies; 8+ messages in thread
From: Geraldo Nascimento @ 2023-07-19 13:21 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Ico Bukvic, alsa-devel

On Wed, Jul 19, 2023 at 02:39:44PM +0200, Takashi Iwai wrote:
> On Wed, 19 Jul 2023 14:27:21 +0200,
> Ico Bukvic wrote:
> > 
> > 
> > Thank you, Takashi.
> > 
> > On Raspberry Pi 400 (one with built-in keyboard, although any RPi or Linux
> > computer with HDMI monitor with loudspeakers will do), open pd-l2ork (a
> > variant of pure-data available at http://bit.ly/pd-l2ork; pure-data also has
> > this same problem) and enable DSP. Do the same after changing audio settings
> > via the Preferences window (Edit->Preferences), where you can switch among
> > backends (ALSA vs Portaudio, vs JACK; JACK does not work with any setting). If
> > you have proper audio settings (0 in, 2 out, and a supported SR, r.g.
> > 44,1kHz), you will hear the buzz, and will also hear the desired audio
> > produced (e.g. by running Media->Audio Tester) faintly, with buzz bring at the
> > forefront. Or, you will hear everything OK (default Pulse settings), or
> > nothing. ALSA and PortAudio settings are default Raspbian(RPi)/Ubuntu
> > (desktop). Thank you.
> 
> Well, the question is how the ALSA PCM device is opened, how
> configured and how played.  As Geraldo already suggested, VC4 HDMI on
> RPi has a special format with IEC958 encoding.  Also it has IEC958
> status bit setups.  So, for example, if you'd need to play a normal
> PCM stream with aplay, you'd need to open the device with "hdmi:$CARD"
> device -- then the rest is done in alsa-lib's plugin, and that's
> almost equivalent with what PA does.

Hi Takashi, thanks for taking Ico's report. Perhaps the right
configuration that he needs to use aplay could be:
https://github.com/alsa-project/alsa-lib/blob/master/src/conf/cards/vc4-hdmi.conf

That is, if I understand correctly?

Thanks,
Geraldo Nascimento

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-19 13:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAJrgGbZfPYHhf+p1TJO_LQe=pxkxDtAMPsY6sXOh1xVxq0b69w@mail.gmail.com>
2023-07-18 16:22 ` Fwd: Odd issue with ALSA connecting directly to HDMI audio output Ico Bukvic
2023-07-18 17:12   ` Geraldo Nascimento
2023-07-19  3:51     ` Geraldo Nascimento
2023-07-19  5:58       ` Ico Bukvic
2023-07-19  8:08         ` Takashi Iwai
2023-07-19 12:27           ` Ico Bukvic
2023-07-19 12:39             ` Takashi Iwai
2023-07-19 13:21               ` Geraldo Nascimento

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).