11#include "libsnd2_internal.h"
13s16 SsUtKeyOn(s16 vab_id, s16 prog, s16 tone, s16 note, s16 fine, s16 voll, s16 volr)
20 if ( _snd_ev_flag == 1 )
23 if ( _SsVmVSetUp(vab_id, prog) )
28 _svm_cur.m_seq_sep_no = 33;
29 _svm_cur.m_note = note;
30 _svm_cur.m_fine = fine;
31 _svm_cur.m_tone = tone;
34 _svm_cur.m_unk05 = 64;
35 _svm_cur.m_voll = voll;
41 volr_lshift_6 = volr << 6;
46 voll_lshift_6 = voll << 6;
49 if ( volr == -1 && (
unsigned int)voll_lshift_6 == 0x80000000 )
51 _svm_cur.m_voll = volr;
52 _svm_cur.m_unk05 = 127 - voll_lshift_6 / volr;
58 if ( voll == -1 && (
unsigned int)volr_lshift_6 == 0x80000000 )
60 _svm_cur.m_unk05 = volr_lshift_6 / voll;
61 _svm_cur.m_voll = voll;
64 pProg = &_svm_pg[prog];
65 _svm_cur.m_mvol = pProg->mvol;
66 _svm_cur.m_mpan = pProg->mpan;
67 _svm_cur.m_sep_sep_no_tonecount = pProg->tones;
68 pVag = &_svm_tn[16 * _svm_cur.m_fake_program + _svm_cur.m_tone];
69 _svm_cur.m_prior = pVag->prior;
70 _svm_cur.m_vag_idx2 = pVag->vag;
71 _svm_cur.m_vol = pVag->vol;
72 _svm_cur.m_pan = pVag->pan;
73 _svm_cur.m_centre = pVag->center;
74 _svm_cur.m_shift = pVag->shift;
75 _svm_cur.m_mode = pVag->mode;
76 if ( !_svm_cur.m_vag_idx2 || (voice = (u8)_SsVmAlloc(), voice == _SsVmMaxVoice) )
81 voice = (u8)_SsVmAlloc();
82 if ( voice == _SsVmMaxVoice )
87 _svm_cur.m_voice_idx = voice;
88 voice_struct = &_svm_voice[voice];
89 voice_struct->m_seq_sep_no = 33;
90 voice_struct->m_vab_id = vab_id;
91 voice_struct->m_prog = prog;
92 voice_struct->m_fake_program = _svm_cur.m_fake_program;
93 voice_struct->m_vag_idx = _svm_cur.m_vag_idx2;
94 voice_struct->m_note = note;
95 voice_struct->m_tone = _svm_cur.m_tone;
96 voice_struct->m_unk1d = 1;
97 voice_struct->m_unk02 = 0;
98 voice_struct->m_voll2 = _svm_cur.m_voll;
100 if ( _svm_cur.m_vag_idx2 == 255 )
106 _SsVmKeyOnNow(1, note2pitch2(note, fine));
112s16 SsUtKeyOff(s16 vc, s16 vab_id, s16 prog, s16 tone, s16 note)
116 if ( _snd_ev_flag == 1 )
119 if ( (u16)vc >= 0x18u )
124 voice_struct = &_svm_voice[vc];
126 voice_struct->m_vab_id == vab_id && voice_struct->m_prog == prog && voice_struct->m_tone == tone
127 && voice_struct->m_note == note && voice_struct->m_vag_idx == 255 )
133 _svm_cur.m_voice_idx = vc;
136 voice_struct->m_b_auto_pan = 0;
137 voice_struct->m_b_auto_vol = 0;