//set code values from UI values void Update() { if (mMusicGenerator == null || mMusicGenerator.mState == eGeneratorState.initializing) { return; } ChordProgressions progressions = mMusicGenerator.mChordProgressions; if (progressions.mData.TonicInfluence != mTonicInfluence.value) { progressions.mData.TonicInfluence = mTonicInfluence.value; mTonicInfluenceOutput.text = ((int)mTonicInfluence.value).ToString() + "%"; } if (progressions.mData.DominantInfluence != mDominantInfluence.value) { progressions.mData.DominantInfluence = mDominantInfluence.value; mDominantInfluenceOutput.text = ((int)mDominantInfluence.value).ToString() + "%"; } if (progressions.mData.SubdominantInfluence != mSubdominantInfluence.value) { progressions.mData.SubdominantInfluence = mSubdominantInfluence.value; mSubdominantInfluenceOutput.text = ((int)mSubdominantInfluence.value).ToString() + "%"; } if (progressions.mData.TritoneSubInfluence != mTritoneSubInfluence.value) { progressions.mData.TritoneSubInfluence = mTritoneSubInfluence.value; mTritoneSubInfluenceOutput.text = ((int)mTritoneSubInfluence.value).ToString() + "%"; } if (mMusicGenerator.mGeneratorData.mKeyChangeAscendDescend != mAscendDescendKey.value) { mMusicGenerator.mGeneratorData.mKeyChangeAscendDescend = mAscendDescendKey.value; mAscendDescendKeyOutput.text = ((int)mAscendDescendKey.value).ToString() + "%"; } mMusicGenerator.mGeneratorData.mGroupRate = (eGroupRate)mGroupRate.value; mMusicGenerator.mGeneratorData.mDynamicStyle = (eDynamicStyle)mDynamicStyle.value; if (mMusicGenerator.mGeneratorData.mVolFadeRate != mVolumeFadeRate.value) { mMusicGenerator.SetVolFadeRate(mVolumeFadeRate.value); mVolumeFadeRateOutput.text = ((int)mVolumeFadeRate.value).ToString(); } mMusicGenerator.UseAsyncLoading = mAsyncLoading.isOn; CheckAvoidSteps(); }
/// Our generator is a singleton (I know, I know, but it's for the best in this case, for a few reasons). Just grab a reference. /// Important: Never try to access the instance within Awake(). Let it initialize itself from the gameObject. Subscribe to MusicGenerator.Ready() for /// the moment you're able to access all the functions safely. /// You can use the Prefab included with the asset and put in your scene to create it, void Start() { mMusicGenerator.SetVolFadeRate(mVolumeFadeRate); ///< set the speed we fade. value multiplied against deltaT in MusicGenerator update(). }