Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: emu10k1: fix synthesizer pitch for E-MU cards at 44.1 kHz

This is only a very partial fix - the frequency-dependent envelope & LFO
register values aren't adjusted.

But I'm not sure they were even correct at 48 kHz to start with, as most
of them are precalculated by common code which assumes an EMU8K-specific
44.1 kHz word clock, and it seems somewhat unlikely that the hardware's
register interpretation was adjusted to compensate for the different
word clock.

In any case I'm not going to spend time on fixing that, as this code is
unlikely to be actually used by anyone today.

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230612191325.1315854-6-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Oswald Buddenhagen and committed by
Takashi Iwai
e68235c8 19b89d15

+13 -3
+1 -1
include/sound/emux_synth.h
··· 54 54 #if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS) 55 55 int (*oss_ioctl)(struct snd_emux *emu, int cmd, int p1, int p2); 56 56 #endif 57 + int (*get_pitch_shift)(struct snd_emux *emu); 57 58 }; 58 59 59 60 ··· 83 82 int max_voices; /* Number of voices */ 84 83 int mem_size; /* memory size (in byte) */ 85 84 int num_ports; /* number of ports to be created */ 86 - int pitch_shift; /* pitch shift value (for Emu10k1) */ 87 85 struct snd_emux_operators ops; /* operators */ 88 86 void *hw; /* hardware */ 89 87 unsigned long flags; /* other conditions */
+10
sound/pci/emu10k1/emu10k1_callback.c
··· 35 35 static void free_voice(struct snd_emux_voice *vp); 36 36 static u32 make_fmmod(struct snd_emux_voice *vp); 37 37 static u32 make_fm2frq2(struct snd_emux_voice *vp); 38 + static int get_pitch_shift(struct snd_emux *emu); 38 39 39 40 /* 40 41 * Ensure a value is between two points ··· 59 58 .free_voice = free_voice, 60 59 .sample_new = snd_emu10k1_sample_new, 61 60 .sample_free = snd_emu10k1_sample_free, 61 + .get_pitch_shift = get_pitch_shift, 62 62 }; 63 63 64 64 void ··· 509 507 pitch += (MOD_SENSE * modulation) / 1200; 510 508 LIMITVALUE(pitch, -128, 127); 511 509 return ((unsigned char)pitch << 8) | freq; 510 + } 511 + 512 + static int get_pitch_shift(struct snd_emux *emu) 513 + { 514 + struct snd_emu10k1 *hw = emu->hw; 515 + 516 + return (hw->card_capabilities->emu_model && 517 + hw->emu1010.word_clock == 44100) ? 0 : -501; 512 518 }
-1
sound/pci/emu10k1/emu10k1_synth.c
··· 43 43 emux->hw = hw; 44 44 emux->max_voices = arg->max_voices; 45 45 emux->num_ports = arg->seq_ports; 46 - emux->pitch_shift = -501; 47 46 emux->memhdr = hw->memhdr; 48 47 /* maximum two ports */ 49 48 emux->midi_ports = arg->seq_ports < 2 ? arg->seq_ports : 2;
+2 -1
sound/synth/emux/emux_synth.c
··· 845 845 846 846 /* 0xe000: root pitch */ 847 847 offset += 0xe000 + vp->reg.rate_offset; 848 - offset += vp->emu->pitch_shift; 848 + if (vp->emu->ops.get_pitch_shift) 849 + offset += vp->emu->ops.get_pitch_shift(vp->emu); 849 850 LIMITVALUE(offset, 0, 0xffff); 850 851 if (offset == vp->apitch) 851 852 return 0; /* unchanged */