Add a new option -u to specify the UMP MIDI1 or MIDI2 mode. As
default (-u 0), the program reads the legacy MIDI 1.0 byte stream,
while in UMP mode, it reads as UMP packets and send to the target.
The UMP packet bytes are encoded in big endian.
So far, aplaymidi2 passes the MIDI1/MIDI2 channel voice UMP messages
to the target while processing other UMP messages internally. But
sometimes we'd like to pass all UMP messages as is and let the
receiver processes.
This patch adds a new option -a (or --passall) to pass the all UMP
packets included in the given MIDI Clip file to the target as-is.
For convenience, add more options to embed the meta data texts given
via command line. The song name etc can be given directly via the
respective option directly, e.g. --song="text..."
Allow to add arbitrary profile UMP data to be put into the
configuration of the recorded stream via --profile option.
The file must contain valid UMP data encoded in big-endian.
It turned out that the failure was rather in alsa-lib API; the
input and output have been incorrectly implemented.
Now that the alsa-lib code got fixed, let's revert the bad fix.
Now aplaymidi2 shows the meta data texts embedded in Flex Data
messages such as copyright and lyrics. The text output isn't
synchronized yet with the actual position, though.
The recorded tick is incorrectly converted for 1us tempo-base on the
old kernels. Since we correct the queue tempo, we don't have to
adjust the returned tick value any longer. The current code applies
it doubly, resulting in 100 times slower.
The queue should be started at the very same time of the start of the
stream itself in the interactive mode. Otherwise it'll get bogus long
waits until the start of the clip.
Move the code to start the queue in start_bar(), so that it's always
tied with the start sequence.
arecordmidi2: Add passive mode and interactive mode
Allow arecordmidi2 running without specifying the source ports via -p
option. This will create a UMP Endpoint with the full 16 FBs, and
simply reads from the input ports via subscribers. User needs to
connect to the ports manually, though.
Also, add -r option to run in the interactive mode. In the
interactive mode, arecordmidi2 waits for the RETURN key entered from
the terminal to start the recording, and the recording ends after
another RETURN key.
arecordmidi2 is a similar program like arecordmidi for recording the
incoming MIDI events, but storing in a MIDI Clip file for MIDI 2.0.
Most options are kept from arecordmidi, but some are dropped: namely,
the -l, -m and -f options are dropped for code simplicity.
Also -s option is dropped as well, as there is no need for split for
MIDI Clip file unlike SMF.
aplaymidi2 is a program similar like aplaymidi, but intended for
playing back a MIDI Clip file that was introduced for handling UMP.
MIDI Clip file contains UMP packets, and its structure is much simpler
than SMF.
The options are mostly same as aplaymidi, but I omitted -l option for
simplifying the code.
Seppo Ingalsuo [Tue, 18 Jun 2024 12:47:05 +0000 (15:47 +0300)]
Topology: NHLT: Intel: Fix compile warning in dmic-process.c
This patch fixes warnings like:
intel/dmic/dmic-process.c: In function 'select_mode':
intel/dmic/dmic-process.c:498:35: warning:
format '%s' expects a matching 'char *' argument [-Wformat=]
The intended __func__ string is missing from the two fprintf()
prints for errors.
Closes: https://github.com/alsa-project/alsa-utils/pull/270 Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Miroslav Kovac [Sun, 28 Apr 2024 13:53:15 +0000 (15:53 +0200)]
aseqsend: initial version
aseqsend is a command-line utility which allows one to send SysEx
(system exclusive) data to ALSA MIDI seqencer port. It can also send
any other MIDI commands.
Closes: https://github.com/alsa-project/alsa-utils/pull/257 Signed-off-by: Miroslav Kovac <mixxoo@gmail.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Masatake YAMATO [Thu, 16 May 2024 19:29:58 +0000 (04:29 +0900)]
alsactl: don't free a card pointing NULL
alsactl distributed as part of Fedora 40 got a SEGV:
# journalctl
...
May 17 00:55:58 dev64.localdomain kernel: alsactl[1923]: segfault at 28 ip 00005600705b3373 sp 00007ffd9712bef0 error 4 in alsactl[5600705af000+13000] likely on CPU 5 (core 8, socket 0)
...
As the following output of the debug session, card_free() tried a card
pointing NULL:
GNU gdb (Fedora Linux) 14.2-1.fc40
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/sbin/alsactl...
Reading symbols from /usr/lib/debug/usr/sbin/alsactl-1.2.11-1.fc40.x86_64.debug...
[New LWP 1923]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `/usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --init'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 free_list (list=0x20) at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/daemon.c:73
73 for (i = 0; i < list->size; i++)
(gdb) where
#0 free_list (list=0x20) at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/daemon.c:73
#1 card_free (card=card@entry=0x5600707455f0) at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/daemon.c:82
#2 0x00005600705c0e54 in state_daemon (file=file@entry=0x5600705c31a1 "/var/lib/alsa/asound.state", cardname=cardname@entry=0x0, period=period@entry=300,
pidfile=pidfile@entry=0x5600705c3170 "/var/run/alsactl.pid") at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/daemon.c:455
#3 0x00005600705b2339 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/alsactl.c:459
(gdb) list
68
69 static void free_list(struct id_list *list)
70 {
71 int i;
72
73 for (i = 0; i < list->size; i++)
74 free(list->list[i]);
75 free(list->list);
76 }
77
(gdb) up
#1 card_free (card=card@entry=0x5600707455f0) at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/daemon.c:82
82 free_list(&c->blacklist);
(gdb) p c
$1 = (struct card *) 0x0
(gdb)
Closes: https://github.com/alsa-project/alsa-utils/pull/267 Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Jaroslav Kysela [Thu, 23 May 2024 11:13:42 +0000 (13:13 +0200)]
alsamixer: fix calculation in set_normalized_volume (overflow)
Lowering volume below 0 causes overflow spike to 100% volume (volume goes
below 0 and back to 100 repeatedly). 0 overflows past infinity when holding
down z,x,c.
> value = lrint_dir(6000.0 * log10(volume), dir) + max;
(where volume = 0 , and dir = -1 . min = -9999999 , and max = -6)
> log10(0) is negative infinity = error
Fixes: https://github.com/alsa-project/alsa-utils/pull/266 Reported-by: genr8eofl <genBTC@gmx.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
As noted by reviewers, the script reports everything exposed in
ACPI. In practice some of the devices listed may not be physically
populated in hardware, or be listed as attached on a link that's
disabled by the manager. The drivers can cope with this case, it's not
technically an error.
Closes: https://github.com/alsa-project/alsa-utils/pull/264 Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Peter Suti [Wed, 20 Mar 2024 08:40:21 +0000 (09:40 +0100)]
aplay: fix S24_LE wav header
S24_LE is 32 bits in width storing 24 bits of data and 8 bits of padding
So wav header needs to be 32 bits not 24
Closes: https://github.com/alsa-project/alsa-utils/pull/260 Signed-off-by: Peter Suti <peter.suti@streamunlimited.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Jaroslav Kysela [Wed, 24 Jan 2024 17:59:31 +0000 (18:59 +0100)]
speaker-test: Use smaller periods in the default settings
We would like to break the speaker test using Ctrl-C (SIGINT) more early.
In the default settings, the periods are too big and the responsivity
of the speaker-test utility may be several seconds.
Rick Sayre [Sun, 31 Dec 2023 03:11:48 +0000 (19:11 -0800)]
speaker-test: Add bandwidth-limited pink noise at -18.5dB AES FS Based
Closes: https://github.com/alsa-project/alsa-utils/pull/251 Signed-off-by: Rick Sayre <whorfin@gmail.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Jyri Sarha [Wed, 27 Dec 2023 17:18:45 +0000 (19:18 +0200)]
topology: nhlt: Fix dmic configuration blob building
The dmic configuration functions are called for each dmic DAI (or
FIFO) separately, and each dmic DAI is configured in their own
configuration rounds. However, the later configured dmic FIFO may
change the common clock divider and thus affect the FIR configuration
of the first configured DAI. However, the first configured FIR blob is
not touched after it is configured for the first time.
To overcome this problem always check the both FIR configurations, no
matter which DAI we are configuring.
Closes: https://github.com/alsa-project/alsa-utils/pull/250 Suggested-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
John K. Luebs [Sun, 7 Jan 2024 19:33:33 +0000 (13:33 -0600)]
aplaymidi: Set event completely for tempo event
After UMP support was added in b399fb8 ev.type setting was inadvertently
dropped in the code path handling tempo meta event.
This is causing tempo meta events to not be handled at all.
Moreover, snd_seq_ev_set_fixed is also missing so MIDI files with
variable events such as SYSEX before the tempo meta event usually are
causing a segfault.
When the '-v' or '--test-position' options are used, the 'tstamp' is
shown as zero. Unconditionally enable the timestamps and choose the
timestamp time based on the 'monotonic' variable.
aplay: log pcm status before reporting a fatal error
When the --fatal-errors happen, nothing is provided to the user even
when the '-v' verbose option is specified. This patch adds the fatal
error exit after dumping the logs. No functionality change, just
better information on what just happened.
Closes: https://github.com/alsa-project/alsa-utils/pull/242 Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Cezary Rojewski [Fri, 4 Aug 2023 08:26:50 +0000 (10:26 +0200)]
aplay: Add option for specifying subformat
Make subformat first-class citizen by allowing users to specify it just
like it is the case for the format. Default to SND_PCM_SUBFORMAT_STD so
they are no surprises.
Closes: https://github.com/alsa-project/alsa-utils/pull/228 Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Tianyi Liu [Tue, 21 Nov 2023 15:19:35 +0000 (23:19 +0800)]
misc: fix incorrect usages of `strerror`
`strerror` takes the `errno` directly as its argument,
negating it will result in an "Unknown error".
This fixes such usages across multiple modules.
Fixes: https://github.com/alsa-project/alsa-utils/pull/245 Signed-off-by: Tianyi Liu <i.pear@outlook.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Mingjie Shen [Wed, 6 Dec 2023 21:09:58 +0000 (16:09 -0500)]
aplay: fix buffer overflow and tainted format string
Prior this commit, memcpy from names[0] to format[] will overwrite if
strlen(names[0]) is greater than 1024. Also, the length of malloc()ed
names[channel] is insufficient, leading to another buffer overwriting
when calling sprintf(). Moreover, the format string of sprintf()
can be controlled by user input. An attacker can exploit this weakness
to crash the program, disclose information or even execute arbitrary
code.
Fix by allocating enough space for arrays and using constant expressions
as the format strings.
Fixes: https://github.com/alsa-project/alsa-utils/pull/246/ Signed-off-by: Mingjie Shen <shen497@purdue.edu> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Andy Ross [Thu, 7 Dec 2023 17:17:57 +0000 (09:17 -0800)]
nhlt: Revert SSP_ANALOG device_type field
This partially reverts commit 3a47ef2487ed ("topology: nhlt: intel:
support more device types and directions"), which changed the default
device_type in the endpoint descriptor from zero to SSP_ANALOG.
This change breaks the Linux kernel NHLT parser (which AFAICT doesn't
recognize SSP_ANALOG at all), producing errors like:
[56458.583812] sof-audio-pci-intel-mtl 0000:00:1f.3: no matching blob for sample rate: 48000 sample width: 32 channels: 2
[56458.583833] sof-audio-pci-intel-mtl 0000:00:1f.3: failed to prepare widget dai-copier.SSP.SSP0-Codec.playback
[56458.583840] sof-audio-pci-intel-mtl 0000:00:1f.3: Failed to prepare connected widgets
[56458.583847] sof-audio-pci-intel-mtl 0000:00:1f.3: error: failed widget list set up for pcm 1 dir 0
[56458.583853] sof-audio-pci-intel-mtl 0000:00:1f.3: ASoC: error at snd_soc_pcm_component_hw_params on 0000:00:1f.3: -22
Revert for compatibility.
Fixes: https://github.com/alsa-project/alsa-utils/pull/248 Signed-off-by: Andy Ross <andyross@google.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Sam James [Thu, 7 Sep 2023 20:24:16 +0000 (21:24 +0100)]
nhlt: use stdint.h types
u_int_* aren't standard, but uint* are. Use those instead for musl compat.
Closes: https://github.com/alsa-project/alsa-utils/pull/234
Bug: https://bugs.gentoo.org/913758 Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
bat: really skip analysis of the first period and update related comment
Prior to this change bat/analyze.c would skip the last period of the recording, contrary to
what the comment in the code which stated the first period was meant to be skipped.
The comment has been updated to state that both the first and last period are skipped and the code
has been updated to match.
Closes: https://github.com/alsa-project/alsa-utils/pull/237 Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Bernd Kuhls [Fri, 13 Oct 2023 18:32:32 +0000 (20:32 +0200)]
configure.ac: fix UMP support detection
https://github.com/alsa-project/alsa-utils/commit/b399fb85a919636b7da34e8bcf17f484dd9046f7
added usage of alsa/ump_msg.h without checking whether alsa-lib was
compiled with rawmidi support:
https://github.com/alsa-project/alsa-lib/blob/master/include/Makefile.am#L37
Fixes a build error when alsa-lib was compiled with --disable-rawmidi
aplaymidi.c:34:10: fatal error: alsa/ump_msg.h: No such file or directory
34 | #include <alsa/ump_msg.h>
Closes: https://github.com/alsa-project/alsa-utils/pull/240 Signed-off-by: Bernd Kuhls <bernd@kuhls.net> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Fixes: https://github.com/alsa-project/alsa-utils/issues/238 Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This solves an issue compiling with the musl libc.
Fixes: https://github.com/alsa-project/alsa-utils/issues/239 Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Rudi Heitbaum [Mon, 15 May 2023 16:27:59 +0000 (02:27 +1000)]
alsactl: fix compilation when building in a subdir
Fixes: 613372d Fixes: cff2d1c
Compile errors when building in a subdir:
alsactl/alsactl.c:33:10: fatal error: os_compat.h: No such file or directory
33 | #include "os_compat.h"
| ^~~~~~~~~~~~~
alsactl/lock.c:34:10: fatal error: os_compat.h: No such file or directory
34 | #include "os_compat.h"
| ^~~~~~~~~~~~~
Fixes: https://github.com/alsa-project/alsa-utils/pull/213 Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>