/* * hexter_instance_update_fc */ public void hexter_instance_update_fc(int opnum, int value) { int i; dx7_voice voice; int fc = value / 4; /* frequency coarse is 0 to 31 */ /* update edit buffer */ //if (!pthread_mutex_trylock(&this.patches_mutex)) { this.current_patch_buffer[((5 - opnum) * 21) + 18] = (byte)fc; // pthread_mutex_unlock(&this.patches_mutex); //} else { /* In the unlikely event that we get here, it means another thread is * currently updating the current patch buffer. We could do something * like the 'pending_program_change' mechanism to cache this change * until we can lock the mutex, if it's really important. */ //} /* check if any playing voices need updating */ for (i = 0; i < hexter_synth.Instance.global_polyphony; i++) { voice = hexter_synth.Instance.voice[i]; if (voice.instance == this && voice._PLAYING) { dx7_op op = voice.op[opnum]; op.coarse = (byte)fc; op.dx7_op_recalculate_increment(this); } } }
public int mod(int _i, Int32 _p) { dx7_op op = this.op[_i]; Int32 eg_value = op.eg.value - ampmod[op.amp_mod_sens]; Int32 phase = (Int32)op.phase + _p; Int32 index, mod_index, outx; index = (eg_value >> Constants.FP_SHIFT); mod_index = Data.dx7_voice_eg_ol_to_mod_index_table[index + 128]; mod_index += (Int32)(((Int64)(Data.dx7_voice_eg_ol_to_mod_index_table[index + 129] - mod_index) * (Int64)(eg_value & Constants.FP_MASK)) >> Constants.FP_SHIFT); index = (Int32)((phase >> Constants.FP_TO_SINE_SHIFT) & Constants.SINE_MASK); outx = Data.dx7_voice_sin_table[index]; outx += (Int32)((((Int64)(Data.dx7_voice_sin_table[index + 1] - outx) * (Int64)(phase & Constants.FP_TO_SINE_MASK)) >> (Constants.FP_SHIFT_PLUS_FP_TO_SINE_SHIFT))); return((Int32)(((Int64)mod_index * (Int64)outx) >> Constants.FP_SHIFT)); }
public int car_sfb(int _i, Int32 _p) { dx7_op op = this.op[_i]; Int32 eg_value = op.eg.value - ampmod[op.amp_mod_sens]; Int32 phase = (Int32)op.phase + _p; Int32 index, amp, outx; Int64 out64; index = (eg_value >> Constants.FP_SHIFT); amp = Data.dx7_voice_eg_ol_to_amp_table[index + 128]; amp += (Int32)(((Int64)(Data.dx7_voice_eg_ol_to_amp_table[index + 129] - amp) * (Int64)(eg_value & Constants.FP_MASK)) >> Constants.FP_SHIFT); index = (Int32)((phase >> Constants.FP_TO_SINE_SHIFT) & Constants.SINE_MASK); outx = Data.dx7_voice_sin_table[index]; out64 = outx + (((Int64)(Data.dx7_voice_sin_table[index + 1] - outx) * (Int64)(phase & Constants.FP_TO_SINE_MASK)) >> (Constants.FP_SHIFT_PLUS_FP_TO_SINE_SHIFT)); this.feedback = (Int32)((((out64 * (Int64)eg_value) >> Constants.FP_SHIFT) * (Int64)this.feedback_multiplier) >> Constants.FP_SHIFT); return((Int32)(((Int64)amp * (Int64)out64) >> Constants.FP_SHIFT)); }