11#include "libsnd2_internal.h"
13int _SsVmPBVoice(s16 vc, s16 seq_sep_num, s16 vab_id, s16 prog, s16 pitch)
20 voice_struct = &_svm_voice[vc];
21 if ( voice_struct->m_seq_sep_no != seq_sep_num || voice_struct->m_vab_id != vab_id || voice_struct->m_prog != prog )
25 pitch_converted = pitch - 64;
26 bend_min = (u16)voice_struct->m_note;
27 if ( pitch_converted <= 0 )
29 if ( pitch_converted >= 0 )
37 pbmin_tmp = pitch_converted * _svm_tn[(u16)(voice_struct->m_tone + 16 * _svm_cur.m_fake_program)].pbmin;
38 bend_min = bend_min + pbmin_tmp / 64 - 1;
39 bend_max = 2 * (pbmin_tmp % 64) + 127;
46 pbmax_tmp = pitch_converted * _svm_tn[(u16)(voice_struct->m_tone + 16 * _svm_cur.m_fake_program)].pbmax;
47 bend_min += pbmax_tmp / 63;
48 bend_max = 2 * (pbmax_tmp % 63);
50 _svm_cur.m_voice_idx = vc;
51 _svm_cur.m_tone = voice_struct->m_tone;
52 _svm_sreg_buf[vc].m_pitch = note2pitch2(bend_min, bend_max);
53 _svm_sreg_dirty[vc] |= 4;
57int _SsVmPitchBend(s16 seq_sep_no,
int vab_id,
int prog, s16 pitch)
62 _SsVmVSetUp(vab_id, prog);
63 _svm_cur.m_seq_sep_no = seq_sep_no;
65 for ( voice_i_tmp = 0; (s16)voice_i_tmp < _SsVmMaxVoice; voice_i_tmp += 1 )
67 voice_offs_tmp += (s16)_SsVmPBVoice(voice_i_tmp, seq_sep_no, vab_id, prog, pitch);
69 return voice_offs_tmp;