* [PATCH] emu10k1: split snd_emu10k1_trigger_voice into trigger and prepare functions
@ 2005-02-11 23:16 Lee Revell
2005-02-14 15:34 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Lee Revell @ 2005-02-11 23:16 UTC (permalink / raw)
To: alsa-devel; +Cc: James Courtier-Dutton, Takashi Iwai
This patch provides better sync between multiple voices by separating
the trigger_voice function into prepare_voice which sets up the volume
and filter parameters and trigger_voice which sets pitch target, current
and initial pitch and enables the voice interrupt. For standard PCM
this should not make much of a difference but will be important for
minimizing phase error between voices for multichannel PCM.
This behavior was derived from the opensource.creative.com driver.
Signed-Off-By: Lee Revell <rlrevell@joe-job.com>
Lee
Index: alsa-cvs-default-test/alsa-kernel/pci/emu10k1/emupcm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/emu10k1/emupcm.c,v
retrieving revision 1.37
diff -u -r1.37 emupcm.c
--- alsa-cvs-default-test/alsa-kernel/pci/emu10k1/emupcm.c 10 Feb 2005 11:52:51 -0000 1.37
+++ alsa-cvs-default-test/alsa-kernel/pci/emu10k1/emupcm.c 11 Feb 2005 21:27:21 -0000
@@ -510,35 +510,50 @@
snd_emu10k1_ptr_write(emu, CCR_CACHEINVALIDSIZE, voice, ccis);
}
-static void snd_emu10k1_playback_trigger_voice(emu10k1_t *emu, emu10k1_voice_t *evoice, int master, int extra)
+static void snd_emu10k1_playback_prepare_voice(emu10k1_t *emu, emu10k1_voice_t *evoice, int master, int extra)
{
snd_pcm_substream_t *substream;
snd_pcm_runtime_t *runtime;
emu10k1_pcm_mixer_t *mix;
- unsigned int voice, pitch, pitch_target, tmp;
unsigned int attn;
+ unsigned int voice, tmp;
if (evoice == NULL) /* skip second voice for mono */
return;
substream = evoice->epcm->substream;
runtime = substream->runtime;
- mix = &emu->pcm_mixer[substream->number];
voice = evoice->number;
- pitch = snd_emu10k1_rate_to_pitch(runtime->rate) >> 8;
- pitch_target = emu10k1_calc_pitch_target(runtime->rate);
+ mix = &emu->pcm_mixer[substream->number];
+
attn = extra ? 0 : 0x00ff;
tmp = runtime->channels == 2 ? (master ? 1 : 2) : 0;
snd_emu10k1_ptr_write(emu, IFATN, voice, attn);
snd_emu10k1_ptr_write(emu, VTFT, voice, (mix->attn[tmp] << 16) | 0xffff);
snd_emu10k1_ptr_write(emu, CVCF, voice, (mix->attn[tmp] << 16) | 0xffff);
- snd_emu10k1_voice_clear_loop_stop(emu, voice);
- if (extra)
- snd_emu10k1_voice_intr_enable(emu, voice);
snd_emu10k1_ptr_write(emu, DCYSUSV, voice, 0x7f7f);
+ snd_emu10k1_voice_clear_loop_stop(emu, voice);
+}
+
+static void snd_emu10k1_playback_trigger_voice(emu10k1_t *emu, emu10k1_voice_t *evoice, int master, int extra)
+{
+ snd_pcm_substream_t *substream;
+ snd_pcm_runtime_t *runtime;
+ unsigned int voice, pitch, pitch_target, tmp;
+
+ if (evoice == NULL) /* skip second voice for mono */
+ return;
+ substream = evoice->epcm->substream;
+ runtime = substream->runtime;
+ voice = evoice->number;
+
+ pitch = snd_emu10k1_rate_to_pitch(runtime->rate) >> 8;
+ pitch_target = emu10k1_calc_pitch_target(runtime->rate);
snd_emu10k1_ptr_write(emu, PTRX_PITCHTARGET, voice, pitch_target);
if (master)
snd_emu10k1_ptr_write(emu, CPF_CURRENTPITCH, voice, pitch_target);
snd_emu10k1_ptr_write(emu, IP, voice, pitch);
+ if (extra)
+ snd_emu10k1_voice_intr_enable(emu, voice);
}
static void snd_emu10k1_playback_stop_voice(emu10k1_t *emu, emu10k1_voice_t *evoice)
@@ -573,6 +588,9 @@
snd_emu10k1_playback_invalidate_cache(emu, epcm->voices[0]);
/* follow thru */
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+ snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 1, 0);
+ snd_emu10k1_playback_prepare_voice(emu, epcm->voices[1], 0, 0);
+ snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1);
snd_emu10k1_playback_trigger_voice(emu, epcm->voices[0], 1, 0);
snd_emu10k1_playback_trigger_voice(emu, epcm->voices[1], 0, 0);
snd_emu10k1_playback_trigger_voice(emu, epcm->extra, 1, 1);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] emu10k1: split snd_emu10k1_trigger_voice into trigger and prepare functions
2005-02-11 23:16 [PATCH] emu10k1: split snd_emu10k1_trigger_voice into trigger and prepare functions Lee Revell
@ 2005-02-14 15:34 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2005-02-14 15:34 UTC (permalink / raw)
To: Lee Revell; +Cc: alsa-devel, James Courtier-Dutton
At Fri, 11 Feb 2005 18:16:40 -0500,
Lee Revell wrote:
>
> This patch provides better sync between multiple voices by separating
> the trigger_voice function into prepare_voice which sets up the volume
> and filter parameters and trigger_voice which sets pitch target, current
> and initial pitch and enables the voice interrupt. For standard PCM
> this should not make much of a difference but will be important for
> minimizing phase error between voices for multichannel PCM.
>
> This behavior was derived from the opensource.creative.com driver.
>
> Signed-Off-By: Lee Revell <rlrevell@joe-job.com>
Thanks, applied to CVS (with a trivial compile-warning fix).
Takashi
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-02-14 15:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-11 23:16 [PATCH] emu10k1: split snd_emu10k1_trigger_voice into trigger and prepare functions Lee Revell
2005-02-14 15:34 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.