Skip to content

Commit e68235c

Browse files
ossilatortiwai
authored andcommitted
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>
1 parent 19b89d1 commit e68235c

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

include/sound/emux_synth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct snd_emux_operators {
5454
#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
5555
int (*oss_ioctl)(struct snd_emux *emu, int cmd, int p1, int p2);
5656
#endif
57+
int (*get_pitch_shift)(struct snd_emux *emu);
5758
};
5859

5960

@@ -82,7 +83,6 @@ struct snd_emux {
8283
int max_voices; /* Number of voices */
8384
int mem_size; /* memory size (in byte) */
8485
int num_ports; /* number of ports to be created */
85-
int pitch_shift; /* pitch shift value (for Emu10k1) */
8686
struct snd_emux_operators ops; /* operators */
8787
void *hw; /* hardware */
8888
unsigned long flags; /* other conditions */

sound/pci/emu10k1/emu10k1_callback.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static void terminate_voice(struct snd_emux_voice *vp);
3535
static void free_voice(struct snd_emux_voice *vp);
3636
static u32 make_fmmod(struct snd_emux_voice *vp);
3737
static u32 make_fm2frq2(struct snd_emux_voice *vp);
38+
static int get_pitch_shift(struct snd_emux *emu);
3839

3940
/*
4041
* Ensure a value is between two points
@@ -58,6 +59,7 @@ static const struct snd_emux_operators emu10k1_ops = {
5859
.free_voice = free_voice,
5960
.sample_new = snd_emu10k1_sample_new,
6061
.sample_free = snd_emu10k1_sample_free,
62+
.get_pitch_shift = get_pitch_shift,
6163
};
6264

6365
void
@@ -508,3 +510,11 @@ make_fm2frq2(struct snd_emux_voice *vp)
508510
LIMITVALUE(pitch, -128, 127);
509511
return ((unsigned char)pitch << 8) | freq;
510512
}
513+
514+
static int get_pitch_shift(struct snd_emux *emu)
515+
{
516+
struct snd_emu10k1 *hw = emu->hw;
517+
518+
return (hw->card_capabilities->emu_model &&
519+
hw->emu1010.word_clock == 44100) ? 0 : -501;
520+
}

sound/pci/emu10k1/emu10k1_synth.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ static int snd_emu10k1_synth_probe(struct device *_dev)
4343
emux->hw = hw;
4444
emux->max_voices = arg->max_voices;
4545
emux->num_ports = arg->seq_ports;
46-
emux->pitch_shift = -501;
4746
emux->memhdr = hw->memhdr;
4847
/* maximum two ports */
4948
emux->midi_ports = arg->seq_ports < 2 ? arg->seq_ports : 2;

sound/synth/emux/emux_synth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,8 @@ calc_pitch(struct snd_emux_voice *vp)
845845

846846
/* 0xe000: root pitch */
847847
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);
849850
LIMITVALUE(offset, 0, 0xffff);
850851
if (offset == vp->apitch)
851852
return 0; /* unchanged */

0 commit comments

Comments
 (0)