Lines Matching refs:vp
34 static void terminate_voice(struct snd_emux *emu, struct snd_emux_voice *vp, int free);
35 static void update_voice(struct snd_emux *emu, struct snd_emux_voice *vp, int update);
36 static void setup_voice(struct snd_emux_voice *vp);
37 static int calc_pan(struct snd_emux_voice *vp);
38 static int calc_volume(struct snd_emux_voice *vp);
39 static int calc_pitch(struct snd_emux_voice *vp);
50 struct snd_emux_voice *vp;
89 vp = emu->ops.get_voice(emu, port);
90 if (vp == NULL || vp->ch < 0)
92 if (STATE_IS_PLAYING(vp->state))
93 emu->ops.terminate(vp);
95 vp->time = emu->use_time++;
96 vp->chan = chan;
97 vp->port = port;
98 vp->key = key;
99 vp->note = note;
100 vp->velocity = vel;
101 vp->zone = table[i];
102 if (vp->zone->sample)
103 vp->block = vp->zone->sample->block;
105 vp->block = NULL;
107 setup_voice(vp);
109 vp->state = SNDRV_EMUX_ST_STANDBY;
111 vp->state = SNDRV_EMUX_ST_OFF;
112 if (emu->ops.prepare(vp) >= 0)
113 vp->state = SNDRV_EMUX_ST_STANDBY;
119 vp = &emu->voices[i];
120 if (vp->state == SNDRV_EMUX_ST_STANDBY &&
121 vp->chan == chan) {
122 emu->ops.trigger(vp);
123 vp->state = SNDRV_EMUX_ST_ON;
124 vp->ontime = jiffies; /* remember the trigger timing */
149 struct snd_emux_voice *vp;
163 vp = &emu->voices[ch];
164 if (STATE_IS_PLAYING(vp->state) &&
165 vp->chan == chan && vp->key == note) {
166 vp->state = SNDRV_EMUX_ST_RELEASED;
167 if (vp->ontime == jiffies) {
173 vp->state = SNDRV_EMUX_ST_PENDING;
180 emu->ops.release(vp);
194 struct snd_emux_voice *vp;
200 vp = &emu->voices[ch];
201 if (vp->state == SNDRV_EMUX_ST_PENDING) {
202 if (vp->ontime == jiffies)
205 emu->ops.release(vp);
206 vp->state = SNDRV_EMUX_ST_RELEASED;
226 struct snd_emux_voice *vp;
240 vp = &emu->voices[ch];
241 if (vp->state == SNDRV_EMUX_ST_ON &&
242 vp->chan == chan && vp->key == note) {
243 vp->velocity = vel;
244 update_voice(emu, vp, SNDRV_EMUX_UPDATE_VOLUME);
258 struct snd_emux_voice *vp;
271 vp = &emu->voices[i];
272 if (vp->chan == chan)
273 update_voice(emu, vp, update);
285 struct snd_emux_voice *vp;
298 vp = &emu->voices[i];
299 if (vp->port == port)
300 update_voice(emu, vp, update);
367 struct snd_emux_voice *vp;
372 vp = &emu->voices[i];
373 if (STATE_IS_PLAYING(vp->state) && vp->chan == chan &&
374 vp->key == note)
375 terminate_voice(emu, vp, free);
409 struct snd_emux_voice *vp;
414 vp = &emu->voices[i];
415 if (STATE_IS_PLAYING(vp->state))
416 terminate_voice(emu, vp, 0);
417 if (vp->state == SNDRV_EMUX_ST_OFF) {
419 emu->ops.free_voice(vp);
423 vp->time = 0;
440 struct snd_emux_voice *vp;
451 vp = &emu->voices[i];
452 if (STATE_IS_PLAYING(vp->state) &&
453 vp->port == port)
454 terminate_voice(emu, vp, 0);
455 if (vp->state == SNDRV_EMUX_ST_OFF) {
457 emu->ops.free_voice(vp);
473 struct snd_emux_voice *vp;
479 vp = &emu->voices[i];
480 if (STATE_IS_PLAYING(vp->state) && vp->port == port &&
481 vp->reg.exclusiveClass == exclass) {
482 terminate_voice(emu, vp, 0);
493 terminate_voice(struct snd_emux *emu, struct snd_emux_voice *vp, int free)
495 emu->ops.terminate(vp);
496 vp->time = emu->use_time++;
497 vp->chan = NULL;
498 vp->port = NULL;
499 vp->zone = NULL;
500 vp->block = NULL;
501 vp->state = SNDRV_EMUX_ST_OFF;
503 emu->ops.free_voice(vp);
511 update_voice(struct snd_emux *emu, struct snd_emux_voice *vp, int update)
513 if (!STATE_IS_PLAYING(vp->state))
516 if (vp->chan == NULL || vp->port == NULL)
519 calc_volume(vp);
521 calc_pitch(vp);
523 if (! calc_pan(vp) && (update == SNDRV_EMUX_UPDATE_PAN))
526 emu->ops.update(vp, update);
546 setup_voice(struct snd_emux_voice *vp)
552 vp->reg = vp->zone->v;
555 snd_emux_setup_effect(vp);
559 vp->apan = -1;
560 vp->avol = -1;
561 vp->apitch = -1;
563 calc_volume(vp);
564 calc_pitch(vp);
565 calc_pan(vp);
567 parm = &vp->reg.parm;
572 pitch = (HI_BYTE(parm->pefe) << 4) + vp->apitch;
576 vp->ftarget = parm->cutoff + LO_BYTE(parm->pefe);
577 LIMITVALUE(vp->ftarget, 0, 255);
578 vp->ftarget <<= 8;
580 vp->ftarget = parm->cutoff;
581 vp->ftarget <<= 8;
582 pitch = vp->apitch;
587 vp->ptarget = 1 << (pitch >> 12);
588 if (pitch & 0x800) vp->ptarget += (vp->ptarget*0x102e)/0x2710;
589 if (pitch & 0x400) vp->ptarget += (vp->ptarget*0x764)/0x2710;
590 if (pitch & 0x200) vp->ptarget += (vp->ptarget*0x389)/0x2710;
591 vp->ptarget += (vp->ptarget >> 1);
592 if (vp->ptarget > 0xffff) vp->ptarget = 0xffff;
594 vp->ptarget = 0xffff;
602 vp->vtarget = 0;
606 vp->vtarget = voltarget[vp->avol % 0x10] >> (vp->avol >> 4);
639 calc_pan(struct snd_emux_voice *vp)
641 struct snd_midi_channel *chan = vp->chan;
645 if (vp->reg.fixpan > 0) /* 0-127 */
646 pan = 255 - (int)vp->reg.fixpan * 2;
649 if (vp->reg.pan >= 0) /* 0-127 */
650 pan += vp->reg.pan - 64;
655 if (vp->emu->linear_panning) {
657 if (pan != vp->apan) {
658 vp->apan = pan;
660 vp->aaux = 0xff;
662 vp->aaux = (-pan) & 0xff;
668 if (vp->apan != (int)pan_volumes[pan]) {
669 vp->apan = pan_volumes[pan];
670 vp->aaux = pan_volumes[255 - pan];
740 calc_volume(struct snd_emux_voice *vp)
744 struct snd_midi_channel *chan = vp->chan;
745 struct snd_emux_port *port = vp->port;
748 LIMITMAX(vp->velocity, 127);
753 vol = (vp->velocity * main_vol * expression_vol) / (127*127);
754 vol = vol * vp->reg.amplitude / 127;
762 main_vol = chan->control[MIDI_CTL_MSB_MAIN_VOLUME] * vp->reg.amplitude / 127;
765 vol = voltab1[main_vol] + voltab2[vp->velocity];
767 vol += vp->reg.attenuation;
784 if (vp->avol == vol)
787 vp->avol = vol;
789 && LO_BYTE(vp->reg.parm.volatkhld) < 0x7d) {
791 if (vp->velocity < 70)
794 atten = vp->velocity;
795 vp->acutoff = (atten * vp->reg.parm.cutoff + 0xa0) >> 7;
797 vp->acutoff = vp->reg.parm.cutoff;
811 calc_pitch(struct snd_emux_voice *vp)
813 struct snd_midi_channel *chan = vp->chan;
817 if (vp->reg.fixkey >= 0) {
818 offset = (vp->reg.fixkey - vp->reg.root) * 4096 / 12;
820 offset = (vp->note - vp->reg.root) * 4096 / 12;
822 offset = (offset * vp->reg.scaleTuning) / 100;
823 offset += vp->reg.tune * 4096 / 1200;
847 offset += 0xe000 + vp->reg.rate_offset;
848 if (vp->emu->ops.get_pitch_shift)
849 offset += vp->emu->ops.get_pitch_shift(vp->emu);
851 if (offset == vp->apitch)
853 vp->apitch = offset;
917 struct snd_emux_voice *vp;
923 vp = &emu->voices[i];
924 vp->ch = -1; /* not used */
925 vp->state = SNDRV_EMUX_ST_OFF;
926 vp->chan = NULL;
927 vp->port = NULL;
928 vp->time = 0;
929 vp->emu = emu;
930 vp->hw = emu->hw;