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