linux/sound/pci/emu10k1
Oswald Buddenhagen d0440680a1 ALSA: emu10k1: fix wavetable playback position and caching, take 2
Compensate for the cache lag of 64 frames, and actually populate the
cache. Without these, the playback would start with garbage (which
would be (mostly?) masqueraded by the note's attack phase).

Note that we set the starting address only 61 frames ahead, to
compensate for the interpolator's epsilon. Unlike for PCM playback, we
don't even need to manually silence-fill the first frames in the cache,
because we insert some silence in front of each sample anyway.

A challenge are extremely short samples with a loop end below the cache
size, because a) we'd have to wrap the current address to be within the
loop and b) automatic pre-filling of the cache with the right data does
not work in this case.

We could pre-fill the cache manually, but that's slow, requires
additional code for each sample width, and is made even more complex by
the driver's virtual address space having no contiguous mapping for the
CPU.

We could have the engine fill the cache piece-wise (which is really what
happens when playback is running), but that would also be complex, and
we'd need to wait for the engine to handle each piece, so it wouldn't be
that much faster than the manual fill.

For the case of requiring only one loop iteration prior to reaching the
cache size, we could leverage the engine's looping mechanism around
CCR_CACHELOOPFLAG, but this special case doesn't seem worth the
complexity.

So we just unroll the loop as far as necessary to be able to play back
the sample without any fiddling.

Pedantically, this would be incorrect for loop-until-release samples
with a low loop end which are released very quickly, but that would be
relatively harmless, is not a plausible use case in the first place, and
SoundFont sample mode 3 isn't actually implemented anyway (it's
conflated with mode 1, infinite looping).

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Message-ID: <20240406064830.1029573-16-oswald.buddenhagen@gmx.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-04-07 08:35:52 +02:00
..
emu10k1.c ALSA: emu10k1: rework copyright statements 2023-07-17 09:30:34 +02:00
emu10k1_callback.c ALSA: emu10k1: fix wavetable playback position and caching, take 2 2024-04-07 08:35:52 +02:00
emu10k1_main.c ALSA: emu10k1: rework copyright statements 2023-07-17 09:30:34 +02:00
emu10k1_patch.c ALSA: emu10k1: fix wavetable playback position and caching, take 2 2024-04-07 08:35:52 +02:00
emu10k1_synth.c ALSA: emu10k1: remove superfluous IRQ enable state saving 2023-07-13 10:30:06 +02:00
emu10k1_synth_local.h
emu10k1x.c ALSA: emu10k1x: Fix the missing snd_card_free() call at probe error 2022-04-12 17:58:24 +02:00
emufx.c ALSA: Make control API taking controls_rwsem consistently 2023-07-20 10:05:19 +02:00
emumixer.c ALSA: emu10k1: Simplify with snd_ctl_find_id_mixer() 2023-07-21 09:10:40 +02:00
emumpu401.c ALSA: emu10k1: remove superfluous IRQ enable state saving 2023-07-13 10:30:06 +02:00
emupcm.c ALSA: emu10k1: rework copyright statements 2023-07-17 09:30:34 +02:00
emuproc.c ALSA: emu10k1: rework copyright statements 2023-07-17 09:30:34 +02:00
io.c ALSA: emu10k1: rework copyright statements 2023-07-17 09:30:34 +02:00
irq.c ALSA: emu10k1: clean up driver status comments 2023-07-17 09:29:36 +02:00
Makefile
memory.c ALSA: emu10k1: fix sample signedness issues in wavetable loader 2024-04-07 08:35:49 +02:00
p16v.c ALSA: emu10k1: use more existing defines instead of open-coded numbers 2023-04-28 11:22:51 +02:00
p16v.h ALSA: emu10k1: clean up driver status comments 2023-07-17 09:29:36 +02:00
p17v.h ALSA: emu10k1: clean up driver status comments 2023-07-17 09:29:36 +02:00
timer.c ALSA: emu10k1: rework copyright statements 2023-07-17 09:30:34 +02:00
tina2.h ALSA: emu10k1: clean up driver status comments 2023-07-17 09:29:36 +02:00
voice.c ALSA: emu10k1: rework copyright statements 2023-07-17 09:30:34 +02:00