public TractUI(Trombone trombone, Tract tract) { this.trombone = trombone; this.tract = tract; SetRestDiameter(); for (var i = 0; i < this.tract.n; i++) { this.tract.diameter[i] = this.tract.targetDiameter[i] = this.tract.restDiameter[i]; } tongueLowerIndexBound = this.tract.bladeStart + 2; tongueUpperIndexBound = this.tract.tipStart - 3; tongueIndexCentre = 0.5f * (tongueLowerIndexBound + tongueUpperIndexBound); }
private void OnEnable() { trombone = target as Trombone; showGlottis = showTract = Application.isPlaying; }
public Tract(Trombone trombone, Glottis glottis) { this.trombone = trombone; this.glottis = glottis; blockTime = (float)trombone.bufferSize / trombone.sampleRate; bladeStart = (int)Mathf.Floor(bladeStart * (float)n / 44.0f); tipStart = (int)Mathf.Floor(tipStart * (float)n / 44.0f); lipStart = (int)Mathf.Floor(lipStart * (float)n / 44.0f); diameter = new float[n]; restDiameter = new float[n]; targetDiameter = new float[n]; for (int i = 0; i < n; i++) { float diam = 0.0f; if (i < 7.0f * n / 44.0f - 0.5f) { diam = 0.6f; } else if (i < 12.0f * n / 44.0f) { diam = 1.1f; } else { diam = 1.5f; } diameter[i] = restDiameter[i] = targetDiameter[i] = diam; } R = new float[n]; L = new float[n]; reflection = new float[n + 1]; newReflection = new float[n + 1]; junctionOutputR = new float[n + 1]; junctionOutputL = new float[n + 1]; A = new float[n]; noseLength = (int)Mathf.Floor(28.0f * n / 44.0f); noseStart = n - noseLength + 1; noseR = new float[noseLength]; noseL = new float[noseLength]; noseJunctionOutputR = new float[noseLength + 1]; noseJunctionOutputL = new float[noseLength + 1]; noseReflection = new float[noseLength + 1]; noseDiameter = new float[noseLength]; noseA = new float[noseLength]; for (int i = 0; i < noseLength; i++) { float diam; float d = 2.0f * ((float)i / noseLength); if (d < 1.0f) { diam = 0.4f + 1.6f * d; } else { diam = 0.5f + 1.5f * (2.0f - d); } diam = Mathf.Min(diam, 1.9f); noseDiameter[i] = diam; } newReflectionLeft = newReflectionRight = newReflectionNose = 0; CalculateReflections(); CalculateNoseReflections(); noseDiameter[0] = velumTarget; }
// Use this for initialization void Start() { trombone = GetComponent <Trombone>(); }
public Glottis(Trombone trombone) { this.trombone = trombone; SetupWaveform(0); }