public void UpdatedBoardHandler(FloatReference size) { RectTransform rectTransform = GetComponent <RectTransform>(); Image image = GetComponent <Image>(); // Set position rectTransform.sizeDelta = new Vector2(size.value, size.value); rectTransform.anchoredPosition = new Vector2(Cell.Position.X * size.value, Cell.Position.Y * size.value); // Set Color bool blackCell = (Cell.Position.Y + Cell.Position.X) % 2 == 0; image.color = blackCell ? new Color32(128, 128, 128, 255) : new Color32(230, 230, 230, 255); }
public void OnEnable() { Input.simulateMouseWithTouches = false; Input.backButtonLeavesApp = false; MovementForCancelTouch = Screen.dpi * MovementForCancelTouch; PrimaryClick.Value.OnKeyDown += OnPrimaryKeyDown; SecondaryClick.Value.OnKeyDown += OnSecondaryKeyDown; MiddleClick.Value.OnKeyDown += OnKeyMiddleDown; MiddleClick.Value.OnKeyUp += OnKeyMiddleUp; MiddleClick.Value.OnKey += OnKeyMiddle; ScrollWheel.Value.OnKey += OnScroll; }
///// <summary> State on which this Speed Modifier can be used </summary> //public int state; public MSpeed(MSpeed newSpeed) { name = newSpeed.name; position = newSpeed.position; animator = newSpeed.animator; lerpPosition = newSpeed.lerpPosition; lerpAnimator = newSpeed.lerpAnimator; rotation = newSpeed.rotation; lerpRotation = newSpeed.lerpRotation; Vertical = newSpeed.Vertical; nameHash = name.GetHashCode(); sprint = newSpeed.sprint; //active = false; }
public MSpeed(string name, float lerpPos, float lerpanim) { this.name = name; position = 0; animator = 1; rotation = 0; lerpPosition = lerpPos; lerpAnimator = lerpanim; lerpRotation = 4; Vertical = 1; nameHash = name.GetHashCode(); sprint = true; //active = false; }
protected void MovementY(float movementInputY, FloatReference speedToMoveY, BoolVariable canJump, BoolVariable isGrounded) { if (canJump.boolState == true) { FastFall(); rb2d.gravityScale = 1; Jump(); } if (Physics2D.OverlapCircle((Vector2)transform.position + Vector2.up * checkForCeelingAtHeight, checkRadius, whatIsCelling) && rb2d.velocity.y > 0) { rb2d.velocity = new Vector2(rb2d.velocity.x, 0); ResetJump(false); } }
public void Start() { if (!Started) { Started = true; foreach (FloatReference reference in GetComponents <FloatReference>()) { if (reference.ReferenceTag == HealthReferenceTag) { healthReference = reference; } } } }
public FakeCoroutineMindReader(MonoBehaviour holder, float updateInterval) { _holder = holder; _updateInterval = updateInterval; Meditation = new FloatReference { useConstantValue = true }; Focus = new FloatReference { useConstantValue = true }; SignalStrength = SignalStrength.GoodSignal; _coroutine = _holder.StartCoroutine(MindReaderCoroutine()); }
protected void MovementX(float movementInputX, FloatReference speedToMoveX, BoolVariable isGrounded) { isGrounded.boolState = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround); rb2d.velocity = new Vector2(movementInputX * speedToMoveX.Value, rb2d.velocity.y); if (facingRight.boolState == false && movementInputX > 0) { Flip(); } else if (facingRight.boolState == true && movementInputX < 0) { Flip(); } }
public IEnumerator cShake(float duration, float magnitude) { float endTime = Time.time + duration; while (Time.time < endTime) { Camera.main.orthographicSize = Random.Range(4.5f, 5.0f); duration -= Time.deltaTime; yield return(null); } Camera.main.orthographicSize = camSize; ShakeBehaviour.isShaking = false; }
public void SetVariablesForDifficultyLevel(EnemyBehaviour enemy, FloatReference difficulty) { if (enemy != null) { enemy.Health = HealthFormula.Calculate(difficulty.Value, InitialHealth); enemy.Damage = DamageFormula.Calculate(difficulty.Value, InitialDamage); enemy.Speed = SpeedFormula.Calculate(difficulty.Value, InitialSpeed); enemy.Value = ValueFormula.Calculate(difficulty.Value, InitialValue); enemy.ViewingRange = ViewingRange; enemy.AIIdle = IdleAI; enemy.AIPursuit = PursuitAI; enemy.AICurrent = IdleAI; enemy.OnDeathEvent = OnDeathEvent; enemy.OnPlayerHitEvent = OnPlayerHitEvent; } }
public void Start() { if (!Started) { Started = true; area = GetComponentInParent <PersonalityQuarksArea>(); foreach (FloatReference reference in GetComponents <FloatReference>()) { if (reference.ReferenceTag == "health") { healthReference = reference; healthReference.Set(MaxHealth); } } } }
public void FloatReferenceTest_FloatVariableIsTheSameValue() { FloatVariable expected = ScriptableObject.CreateInstance <FloatVariable>(); expected.SetValue(123f); FloatReference actual = new FloatReference(); actual.UseConstant = false; actual.Variable = ScriptableObject.CreateInstance <FloatVariable>(); actual.Variable.SetValue(123f); Assert.IsFalse(actual.UseConstant); Assert.AreEqual(expected.Value, actual.Value); Assert.IsInstanceOf <FloatVariable>(actual.Variable); }
public MSpeed(string name, float lerpPos, float lerpanim) { this.name = name; Vertical = 1; position = 0; lerpPosition = lerpPos; lerpPosAnim = 4; rotation = 0; strafeSpeed = 0; lerpRotation = 4; lerpRotAnim = 4; lerpStrafe = 4; animator = 1; lerpAnimator = lerpanim; nameHash = name.GetHashCode(); }
private void FollowTarget(FloatReference targetX, FloatReference targetY) { if (targetX.Value < transform.position.x - deadzoneBounds.bounds.extents.x || targetX.Value > transform.position.x + deadzoneBounds.bounds.extents.x) { Vector3 moveVelocity = new Vector3(targetX.Value - transform.position.x, 0, 0); transform.Translate(moveVelocity * moveSpeedMultiplier * Time.deltaTime); } if (targetY.Value > transform.position.y + deadzoneBounds.bounds.extents.y) { Vector3 moveVelocity = new Vector3(0, targetY.Value - transform.position.y, 0); transform.Translate(moveVelocity * moveSpeedMultiplier * Time.deltaTime); } else if (targetY.Value < transform.position.y) { Vector3 moveVelocity = new Vector3(0, playerFallingSpeed.Value, 0); transform.Translate(moveVelocity * Time.deltaTime); } }
public void Start() { animator = GetComponent <Animator>(); rb = GetComponent <Rigidbody>(); foreach (BoolReference reference in GetComponents <BoolReference>()) { if (reference.ReferenceTag == "attacking") { attacking = reference; } } foreach (FloatReference reference in GetComponents <FloatReference>()) { if (reference.ReferenceTag == "health") { health = reference; } } }
public MSpeed(MSpeed newSpeed) { name = newSpeed.name; position = newSpeed.position; lerpPosition = newSpeed.lerpPosition; lerpPosAnim = newSpeed.lerpPosAnim; rotation = newSpeed.rotation; lerpRotation = newSpeed.lerpRotation; lerpRotAnim = newSpeed.lerpRotAnim; animator = newSpeed.animator; lerpAnimator = newSpeed.lerpAnimator; Vertical = newSpeed.Vertical; strafeSpeed = newSpeed.strafeSpeed; strafeSpeed = newSpeed.strafeSpeed; lerpStrafe = newSpeed.lerpStrafe; nameHash = name.GetHashCode(); }
/// <summary>This is Executed when the Asset is created for the first time </summary> public override void Reset() { ID = MalbersTools.GetInstance <StateID>("Fall"); General = new AnimalModifier() { RootMotion = false, AdditivePosition = true, Grounded = false, Sprint = false, OrientToGround = false, Colliders = true, Gravity = true, CustomRotation = false, modify = (modifier)(-1), }; LowerBlendDistance = 0.1f; FallRayForward = 0.1f; fallRayMultiplier = 1f; FallSpeed.name = "FallSpeed"; ExitFrame = false; //IMPORTANT }
/** * Encoder routine ( speech data should be in new_speech ). * * @param ana output: analysis parameters */ public void coder_ld8k( int[] ana ) { /* LPC coefficients */ var r = new float[MP1]; /* Autocorrelations low and hi */ var A_t = new float[MP1 * 2]; /* A(z) unquantized for the 2 subframes */ var Aq_t = new float[MP1 * 2]; /* A(z) quantized for the 2 subframes */ var Ap1 = new float[MP1]; /* A(z) with spectral expansion */ var Ap2 = new float[MP1]; /* A(z) with spectral expansion */ float[] A, Aq; /* Pointer on A_t and Aq_t */ int A_offset, Aq_offset; /* LSP coefficients */ float[] lsp_new = new float[M], lsp_new_q = new float[M]; /* LSPs at 2th subframe */ var lsf_int = new float[M]; /* Interpolated LSF 1st subframe. */ var lsf_new = new float[M]; /* Variable added for adaptive gamma1 and gamma2 of the PWF */ var rc = new float[M]; /* Reflection coefficients */ var gamma1 = new float[2]; /* Gamma1 for 1st and 2nd subframes */ var gamma2 = new float[2]; /* Gamma2 for 1st and 2nd subframes */ /* Other vectors */ var synth = new float[L_FRAME]; /* Buffer for synthesis speech */ var h1 = new float[L_SUBFR]; /* Impulse response h1[] */ var xn = new float[L_SUBFR]; /* Target vector for pitch search */ var xn2 = new float[L_SUBFR]; /* Target vector for codebook search */ var code = new float[L_SUBFR]; /* Fixed codebook excitation */ var y1 = new float[L_SUBFR]; /* Filtered adaptive excitation */ var y2 = new float[L_SUBFR]; /* Filtered fixed codebook excitation */ var g_coeff = new float[5]; /* Correlations between xn, y1, & y2: * <y1,y1>, <xn,y1>, <y2,y2>, <xn,y2>,<y1,y2>*/ /* Scalars */ int i, j, i_gamma, i_subfr; var iRef = new IntReference(); int T_op, t0; IntReference t0_min = new IntReference(), t0_max = new IntReference(), t0_frac = new IntReference(); int index, taming; float gain_pit, gain_code = 0.0f; FloatReference _gain_pit = new FloatReference(), _gain_code = new FloatReference(); var ana_offset = 0; /*------------------------------------------------------------------------* * - Perform LPC analysis: * * * autocorrelation + lag windowing * * * Levinson-durbin algorithm to find a[] * * * convert a[] to lsp[] * * * quantize and code the LSPs * * * find the interpolated LSPs and convert to a[] for the 2 * * subframes (both quantized and unquantized) * *------------------------------------------------------------------------*/ /* LP analysis */ Lpc.autocorr(p_window, p_window_offset, M, r); /* Autocorrelations */ Lpc.lag_window(M, r); /* Lag windowing */ Lpc.levinson(r, A_t, MP1, rc); /* Levinson Durbin */ Lpc.az_lsp(A_t, MP1, lsp_new, lsp_old); /* From A(z) to lsp */ /* LSP quantization */ quaLsp.qua_lsp(lsp_new, lsp_new_q, ana); ana_offset += 2; /* Advance analysis parameters pointer */ /*--------------------------------------------------------------------* * Find interpolated LPC parameters in all subframes (both quantized * * and unquantized). * * The interpolated parameters are in array A_t[] of size (M+1)*4 * * and the quantized interpolated parameters are in array Aq_t[] * *--------------------------------------------------------------------*/ Lpcfunc.int_lpc(lsp_old, lsp_new, lsf_int, lsf_new, A_t); Lpcfunc.int_qlpc(lsp_old_q, lsp_new_q, Aq_t); /* update the LSPs for the next frame */ for (i = 0; i < M; i++) { lsp_old[i] = lsp_new[i]; lsp_old_q[i] = lsp_new_q[i]; } /*----------------------------------------------------------------------* * - Find the weighting factors * *----------------------------------------------------------------------*/ pwf.perc_var(gamma1, gamma2, lsf_int, lsf_new, rc); /*----------------------------------------------------------------------* * - Find the weighted input speech w_sp[] for the whole speech frame * * - Find the open-loop pitch delay for the whole speech frame * * - Set the range for searching closed-loop pitch in 1st subframe * *----------------------------------------------------------------------*/ Lpcfunc.weight_az(A_t, 0, gamma1[0], M, Ap1); Lpcfunc.weight_az(A_t, 0, gamma2[0], M, Ap2); Filter.residu(Ap1, 0, speech, speech_offset, wsp, wsp_offset, L_SUBFR); Filter.syn_filt(Ap2, 0, wsp, wsp_offset, wsp, wsp_offset, L_SUBFR, mem_w, 0, 1); Lpcfunc.weight_az(A_t, MP1, gamma1[1], M, Ap1); Lpcfunc.weight_az(A_t, MP1, gamma2[1], M, Ap2); Filter.residu(Ap1, 0, speech, speech_offset + L_SUBFR, wsp, wsp_offset + L_SUBFR, L_SUBFR); Filter.syn_filt(Ap2, 0, wsp, wsp_offset + L_SUBFR, wsp, wsp_offset + L_SUBFR, L_SUBFR, mem_w, 0, 1); /* Find open loop pitch lag for whole speech frame */ T_op = Pitch.pitch_ol(wsp, wsp_offset, PIT_MIN, PIT_MAX, L_FRAME); /* range for closed loop pitch search in 1st subframe */ t0_min.value = T_op - 3; if (t0_min.value < PIT_MIN) { t0_min.value = PIT_MIN; } t0_max.value = t0_min.value + 6; if (t0_max.value > PIT_MAX) { t0_max.value = PIT_MAX; t0_min.value = t0_max.value - 6; } /*------------------------------------------------------------------------* * Loop for every subframe in the analysis frame * *------------------------------------------------------------------------* * To find the pitch and innovation parameters. The subframe size is * * L_SUBFR and the loop is repeated L_FRAME/L_SUBFR times. * * - find the weighted LPC coefficients * * - find the LPC residual signal * * - compute the target signal for pitch search * * - compute impulse response of weighted synthesis filter (h1[]) * * - find the closed-loop pitch parameters * * - encode the pitch delay * * - update the impulse response h1[] by including fixed-gain pitch * * - find target vector for codebook search * * - codebook search * * - encode codebook address * * - VQ of pitch and codebook gains * * - find synthesis speech * * - update states of weighting filter * *------------------------------------------------------------------------*/ A = A_t; /* pointer to interpolated LPC parameters */ A_offset = 0; Aq = Aq_t; /* pointer to interpolated quantized LPC parameters */ Aq_offset = 0; i_gamma = 0; for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) { /*---------------------------------------------------------------* * Find the weighted LPC coefficients for the weighting filter. * *---------------------------------------------------------------*/ Lpcfunc.weight_az(A, A_offset, gamma1[i_gamma], M, Ap1); Lpcfunc.weight_az(A, A_offset, gamma2[i_gamma], M, Ap2); i_gamma++; /*---------------------------------------------------------------* * Compute impulse response, h1[], of weighted synthesis filter * *---------------------------------------------------------------*/ for (i = 0; i <= M; i++) { ai_zero[i] = Ap1[i]; } Filter.syn_filt(Aq, Aq_offset, ai_zero, 0, h1, 0, L_SUBFR, zero, zero_offset, 0); Filter.syn_filt(Ap2, 0, h1, 0, h1, 0, L_SUBFR, zero, zero_offset, 0); /*------------------------------------------------------------------------* * * * Find the target vector for pitch search: * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * * * |------| res[n] * * speech[n]---| A(z) |-------- * * |------| | |--------| error[n] |------| * * zero -- (-)--| 1/A(z) |-----------| W(z) |-- target * * exc |--------| |------| * * * * Instead of subtracting the zero-input response of filters from * * the weighted input speech, the above configuration is used to * * compute the target vector. This configuration gives better performance * * with fixed-point implementation. The memory of 1/A(z) is updated by * * filtering (res[n]-exc[n]) through 1/A(z), or simply by subtracting * * the synthesis speech from the input speech: * * error[n] = speech[n] - syn[n]. * * The memory of W(z) is updated by filtering error[n] through W(z), * * or more simply by subtracting the filtered adaptive and fixed * * codebook excitations from the target: * * target[n] - gain_pit*y1[n] - gain_code*y2[n] * * as these signals are already available. * * * *------------------------------------------------------------------------*/ Filter.residu( Aq, Aq_offset, speech, speech_offset + i_subfr, exc, exc_offset + i_subfr, L_SUBFR); /* LPC residual */ Filter.syn_filt(Aq, Aq_offset, exc, exc_offset + i_subfr, error, error_offset, L_SUBFR, mem_err, 0, 0); Filter.residu(Ap1, 0, error, error_offset, xn, 0, L_SUBFR); Filter.syn_filt(Ap2, 0, xn, 0, xn, 0, L_SUBFR, mem_w0, 0, 0); /* target signal xn[]*/ /*----------------------------------------------------------------------* * Closed-loop fractional pitch search * *----------------------------------------------------------------------*/ t0 = Pitch.pitch_fr3( exc, exc_offset + i_subfr, xn, h1, L_SUBFR, t0_min.value, t0_max.value, i_subfr, t0_frac); index = Pitch.enc_lag3(t0, t0_frac.value, t0_min, t0_max, PIT_MIN, PIT_MAX, i_subfr); ana[ana_offset] = index; ana_offset++; if (i_subfr == 0) { ana[ana_offset] = PParity.parity_pitch(index); ana_offset++; } /*-----------------------------------------------------------------* * - find unity gain pitch excitation (adaptive codebook entry) * * with fractional interpolation. * * - find filtered pitch exc. y1[]=exc[] convolve with h1[]) * * - compute pitch gain and limit between 0 and 1.2 * * - update target vector for codebook search * * - find LTP residual. * *-----------------------------------------------------------------*/ PredLt3.pred_lt_3(exc, exc_offset + i_subfr, t0, t0_frac.value, L_SUBFR); Filter.convolve(exc, exc_offset + i_subfr, h1, y1, L_SUBFR); gain_pit = Pitch.g_pitch(xn, y1, g_coeff, L_SUBFR); /* clip pitch gain if taming is necessary */ taming = this.taming.test_err(t0, t0_frac.value); if (taming == 1) { if (gain_pit > GPCLIP) { gain_pit = GPCLIP; } } for (i = 0; i < L_SUBFR; i++) { xn2[i] = xn[i] - y1[i] * gain_pit; } /*-----------------------------------------------------* * - Innovative codebook search. * *-----------------------------------------------------*/ iRef.value = i; index = acelpCo.ACELP_codebook(xn2, h1, t0, sharp, i_subfr, code, y2, iRef); i = iRef.value; ana[ana_offset] = index; /* Positions index */ ana_offset++; ana[ana_offset] = i; /* Signs index */ ana_offset++; /*-----------------------------------------------------* * - Quantization of gains. * *-----------------------------------------------------*/ CorFunc.corr_xy2(xn, y1, y2, g_coeff); _gain_pit.value = gain_pit; _gain_code.value = gain_code; ana[ana_offset] = quaGain.qua_gain(code, g_coeff, L_SUBFR, _gain_pit, _gain_code, taming); gain_pit = _gain_pit.value; gain_code = _gain_code.value; ana_offset++; /*------------------------------------------------------------* * - Update pitch sharpening "sharp" with quantized gain_pit * *------------------------------------------------------------*/ sharp = gain_pit; if (sharp > SHARPMAX) { sharp = SHARPMAX; } if (sharp < SHARPMIN) { sharp = SHARPMIN; } /*------------------------------------------------------* * - Find the total excitation * * - find synthesis speech corresponding to exc[] * * - update filters' memories for finding the target * * vector in the next subframe * * (update error[-m..-1] and mem_w0[]) * * update error function for taming process * *------------------------------------------------------*/ for (i = 0; i < L_SUBFR; i++) { exc[exc_offset + i + i_subfr] = gain_pit * exc[exc_offset + i + i_subfr] + gain_code * code[i]; } this.taming.update_exc_err(gain_pit, t0); Filter.syn_filt(Aq, Aq_offset, exc, exc_offset + i_subfr, synth, i_subfr, L_SUBFR, mem_syn, 0, 1); for (i = L_SUBFR - M, j = 0; i < L_SUBFR; i++, j++) { mem_err[j] = speech[speech_offset + i_subfr + i] - synth[i_subfr + i]; mem_w0[j] = xn[i] - gain_pit * y1[i] - gain_code * y2[i]; } A_offset += MP1; /* interpolated LPC parameters for next subframe */ Aq_offset += MP1; } /*--------------------------------------------------* * Update signal for next frame. * * -> shift to the left by L_FRAME: * * speech[], wsp[] and exc[] * *--------------------------------------------------*/ Util.copy(old_speech, L_FRAME, old_speech, L_TOTAL - L_FRAME); Util.copy(old_wsp, L_FRAME, old_wsp, PIT_MAX); Util.copy(old_exc, L_FRAME, old_exc, PIT_MAX + L_INTERPOL); }
/** * Quantization of pitch and codebook gains * * @param code input : fixed codebook vector * @param g_coeff input : correlation factors * @param l_subfr input : fcb vector length * @param gain_pit output: quantized acb gain * @param gain_code output: quantized fcb gain * @param tameflag input : flag set to 1 if taming is needed * @return quantizer index */ public int qua_gain( float[] code, float[] g_coeff, int l_subfr, FloatReference gain_pit, FloatReference gain_code, int tameflag ) { var FLT_MAX_G729 = Ld8k.FLT_MAX_G729; var GP0999 = Ld8k.GP0999; var GPCLIP2 = Ld8k.GPCLIP2; var NCAN1 = Ld8k.NCAN1; var NCAN2 = Ld8k.NCAN2; var NCODE2 = Ld8k.NCODE2; var gbk1 = TabLd8k.gbk1; var gbk2 = TabLd8k.gbk2; var map1 = TabLd8k.map1; var map2 = TabLd8k.map2; /* * MA prediction is performed on the innovation energy (in dB with mean * * removed). * * An initial predicted gain, g_0, is first determined and the correction * * factor alpha = gain / g_0 is quantized. * * The pitch gain and the correction factor are vector quantized and the * * mean-squared weighted error criterion is used in the quantizer search. * * CS Codebook , fast pre-selection version * */ int i, j, index1 = 0, index2 = 0; int cand1, cand2; float gcode0; float dist, dist_min, g_pitch, g_code; var best_gain = new float[2]; float tmp; /*---------------------------------------------------* *- energy due to innovation -* *- predicted energy -* *- predicted codebook gain => gcode0[exp_gcode0] -* *---------------------------------------------------*/ gcode0 = Gainpred.gain_predict(past_qua_en, code, l_subfr); /*-- pre-selection --*/ tmp = -1.0f / (4.0f * g_coeff[0] * g_coeff[2] - g_coeff[4] * g_coeff[4]); best_gain[0] = (2.0f * g_coeff[2] * g_coeff[1] - g_coeff[3] * g_coeff[4]) * tmp; best_gain[1] = (2.0f * g_coeff[0] * g_coeff[3] - g_coeff[1] * g_coeff[4]) * tmp; if (tameflag == 1) { if (best_gain[0] > GPCLIP2) { best_gain[0] = GPCLIP2; } } /*----------------------------------------------* * - presearch for gain codebook - * *----------------------------------------------*/ var cand1Ref = new IntReference(); var cand2Ref = new IntReference(); gbk_presel(best_gain, cand1Ref, cand2Ref, gcode0); cand1 = cand1Ref.value; cand2 = cand2Ref.value; /*-- selection --*/ dist_min = FLT_MAX_G729; if (tameflag == 1) { for (i = 0; i < NCAN1; i++) { for (j = 0; j < NCAN2; j++) { g_pitch = gbk1[cand1 + i][0] + gbk2[cand2 + j][0]; if (g_pitch < GP0999) { g_code = gcode0 * (gbk1[cand1 + i][1] + gbk2[cand2 + j][1]); dist = g_pitch * g_pitch * g_coeff[0] + g_pitch * g_coeff[1] + g_code * g_code * g_coeff[2] + g_code * g_coeff[3] + g_pitch * g_code * g_coeff[4]; if (dist < dist_min) { dist_min = dist; index1 = cand1 + i; index2 = cand2 + j; } } } } } else { for (i = 0; i < NCAN1; i++) { for (j = 0; j < NCAN2; j++) { g_pitch = gbk1[cand1 + i][0] + gbk2[cand2 + j][0]; g_code = gcode0 * (gbk1[cand1 + i][1] + gbk2[cand2 + j][1]); dist = g_pitch * g_pitch * g_coeff[0] + g_pitch * g_coeff[1] + g_code * g_code * g_coeff[2] + g_code * g_coeff[3] + g_pitch * g_code * g_coeff[4]; if (dist < dist_min) { dist_min = dist; index1 = cand1 + i; index2 = cand2 + j; } } } } gain_pit.value = gbk1[index1][0] + gbk2[index2][0]; g_code = gbk1[index1][1] + gbk2[index2][1]; gain_code.value = g_code * gcode0; /*----------------------------------------------* * update table of past quantized energies * *----------------------------------------------*/ Gainpred.gain_update(past_qua_en, g_code); return(map1[index1] * NCODE2 + map2[index2]); }
/** * Decode the adaptive and fixed codebook gains. * * @param index input : quantizer index * @param code input : fixed code book vector * @param l_subfr input : subframe size * @param bfi input : bad frame indicator good = 0 * @param gain_pit output: quantized acb gain * @param gain_code output: quantized fcb gain */ public void dec_gain( int index, float[] code, int l_subfr, int bfi, FloatReference gain_pit, FloatReference gain_code ) { var NCODE2 = Ld8k.NCODE2; var gbk1 = TabLd8k.gbk1; var gbk2 = TabLd8k.gbk2; var imap1 = TabLd8k.imap1; var imap2 = TabLd8k.imap2; int index1, index2; float gcode0, g_code; /*----------------- Test erasure ---------------*/ if (bfi != 0) { gain_pit.value *= 0.9f; if (gain_pit.value > 0.9f) { gain_pit.value = 0.9f; } gain_code.value *= 0.98f; /*----------------------------------------------* * update table of past quantized energies * * (frame erasure) * *----------------------------------------------*/ Gainpred.gain_update_erasure(past_qua_en); return; } /*-------------- Decode pitch gain ---------------*/ index1 = imap1[index / NCODE2]; index2 = imap2[index % NCODE2]; gain_pit.value = gbk1[index1][0] + gbk2[index2][0]; /*-------------- Decode codebook gain ---------------*/ /*---------------------------------------------------* *- energy due to innovation -* *- predicted energy -* *- predicted codebook gain => gcode0[exp_gcode0] -* *---------------------------------------------------*/ gcode0 = Gainpred.gain_predict(past_qua_en, code, l_subfr); /*-----------------------------------------------------------------* * *gain_code = (gbk1[indice1][1]+gbk2[indice2][1]) * gcode0; * *-----------------------------------------------------------------*/ g_code = gbk1[index1][1] + gbk2[index2][1]; gain_code.value = g_code * gcode0; /*----------------------------------------------* * update table of past quantized energies * *----------------------------------------------*/ Gainpred.gain_update(past_qua_en, g_code); }
public Movement(Rigidbody2D movingObject, FloatReference movSpeed) : this(movingObject) { movementSpeed = movSpeed; }
public void SetPixelsPerScale(FloatReference newPixelsPerScale) => _pixelsPerScale = newPixelsPerScale;
private void Start() => _pixelsPerScale = pixelsPerScale;
public EnemySpotted(Character character, Transform thisTransform, FloatReference viewAngle, FloatReference viewRange, Act act) { _character = character; _thisTransform = thisTransform; _viewAngle = viewAngle; _viewRange = viewRange; _act = act; }
public TimeMindReader() { _meditation = new FloatReference(); _focus = new FloatReference(); }
public StatModifier(StatModifier mod) { ID = mod.ID; modify = mod.modify; Value = new FloatReference(mod.Value.Value); }
public DestroyOnInput(GameObject targetObject, FloatReference destroyDelayInSecs, AudioClip destroySoundEffect, FloatReference destroySoundEffectVolume) { this.targetObject = targetObject; this.destroyDelayInSecs = destroyDelayInSecs; this.destroySoundEffect = destroySoundEffect; this.destroySoundEffectVolume = destroySoundEffectVolume; }
public StatModifier() { ID = null; modify = StatOption.None; Value = new FloatReference(0); }
float SetValue(FloatReference varRef) { return(varRef.Value); }
public ToggleAppearWithinRadius(GameObject targetObject, FloatReference toggleTimeInSecs) { meshRenderer = targetObject.GetComponent <MeshRenderer>(); this.toggleTimeInSecs = toggleTimeInSecs; }