From: David Henningsson <coding@diwic.se>
To: alsa-devel@alsa-project.org, tiwai@suse.de, perex@perex.cz
Cc: David Henningsson <coding@diwic.se>
Subject: [PATCH 0/1] sound: rawmidi: Add framing mode
Date: Wed, 24 Mar 2021 06:31:53 +0100 [thread overview]
Message-ID: <20210324053154.34107-1-coding@diwic.se> (raw)
Hi,
When writing an application that records midi (and e g saves it to disk), ultra-low latency isn't really needed, all we need to know is exactly when the midi message came in. The application can then wake up once a second or so, to write the incoming data, including an accurate timestamp for every event, to disk.
As far as I can see, the rawmidi interface does not support such a feature at all. There is a snd_rawmidi_status syscall, but its timestamp field is not even filled by the kernel (!). But even if that was fixed, it would not fix the problem as there could be several midi events in the buffer with different timestamps.
You could use the seq interface, it does support timestamps, but I can see at least two potential problems with this:
First, the seq code runs in a work queue, not in the actual IRQ. This means that midi event is timestamped too late, especially so if the work is delayed for some reason.
Second, seq hard-codes the timestamp type to monotonic - there is no monotonic_raw, so the timestamp would be affected by NTP changes.
Also, the timespec uses 32-bit for sec and nsec, but I suspect this is less of a problem (unless people constantly record midi for sixty years or so...).
So here's a patch that adds a new "framing" mode that stuffs all MIDI data into 16 byte frames, 8 bytes of timestamp, one byte length, up to seven bytes of data. I'll follow up with an alsa-lib patch if this gets merged.
David Henningsson (1):
sound: rawmidi: Add framing mode
include/sound/rawmidi.h | 1 +
include/uapi/sound/asound.h | 18 ++++++++++++++-
sound/core/rawmidi.c | 45 ++++++++++++++++++++++++++++++++++++-
3 files changed, 62 insertions(+), 2 deletions(-)
--
2.25.1
next reply other threads:[~2021-03-24 5:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-24 5:31 David Henningsson [this message]
2021-03-24 5:31 ` [PATCH 1/1] sound: rawmidi: Add framing mode David Henningsson
2021-03-24 16:06 ` Jaroslav Kysela
2021-03-24 16:17 ` David Henningsson
2021-03-25 20:47 ` Jaroslav Kysela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210324053154.34107-1-coding@diwic.se \
--to=coding@diwic.se \
--cc=alsa-devel@alsa-project.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox