/// Changes our time signature. public void ChangeTimeSignature(int timeSignature = -1) { if (timeSignature != -1) //if we're actually trying to force the ui to change. The UI will pass in -1. { mTimeSignatureDropdown.value = timeSignature; return; } eTimeSignature signature = (eTimeSignature)mTimeSignatureDropdown.value; InstrumentSet set = (MusicGenerator.Instance.mState >= eGeneratorState.editorInitializing) ? mMeasureEditor.mCurrentInstSet : MusicGenerator.Instance.mInstrumentSet; set.SetTimeSignature(signature); float xPos = mBarLines[0].localPosition.x; float nextPos = mTotalBarlineDistance / (set.mTimeSignature.mStepsPerMeasure - 1); for (int i = 0; i < mBarLinesImages.Count; i++) { if (i < set.mTimeSignature.mStepsPerMeasure) { mBarLinesImages[i].enabled = true; Vector3 pos = mBarLines[i].localPosition; mBarLines[i].localPosition = new Vector3(xPos, pos.y, pos.z); xPos += nextPos; } else { mBarLinesImages[i].enabled = false; } } }
/// <summary> /// Sets the time signature data: /// </summary> /// <param name="signature"></param> public void SetTimeSignature(eTimeSignature signature) { if (mData == null) { return; } mData.mTimeSignature = signature; mTimeSignature.SetTimeSignature(mData.mTimeSignature); }
/// <summary> /// Sets our time signature and adjusts values. /// </summary> /// <param name="signature"></param> public void SetTimeSignature(eTimeSignature signature) { mSignature = signature; // Apologies for all the magic numbers. This is a bit of a hacky approach. // trying to shoehorn everything to the same system. switch (mSignature) { case eTimeSignature.FourFour: { mStepsPerMeasure = 16; mTimestepNum = new int[] { 16, 8, 4, 2, 1 }; mTimestepNumInverse = new int[] { 1, 2, 4, 8, 16 }; Sixteenth = 16; Eighth = 8; Quarter = 4; Half = 2; Whole = 0; break; } case eTimeSignature.ThreeFour: { mStepsPerMeasure = 12; mTimestepNum = new int[] { 12, 6, 3, 3, 1 }; mTimestepNumInverse = new int[] { 1, 3, 3, 6, 12 }; Sixteenth = 12; Eighth = 6; Quarter = 3; Half = 3; Whole = 0; break; } case eTimeSignature.FiveFour: { mStepsPerMeasure = 20; mTimestepNum = new int[] { 20, 10, 5, 5, 1 }; mTimestepNumInverse = new int[] { 1, 5, 5, 10, 20 }; Sixteenth = 20; Eighth = 10; Quarter = 5; Half = 5; Whole = 0; break; } } MusicGenerator.Instance.ResetPlayer(); }