コード例 #1
0
        ///async loads a music clip
        public IEnumerator AsyncLoadClip(System.Action <bool> callback, string fileName = "")
        {
            fileName    = (fileName == "") ? "AAADefault.txt" : fileName;
            mLoadedClip = gameObject.AddComponent <SingleClip>();
#if !UNITY_EDITOR && UNITY_ANDROID
            yield return(StartCoroutine(mMusicGenerator.mMusicFileConfig.LoadClipConfigurations(fileName, (x) => { mCurrenClipSave = x; })));
#else
            mCurrenClipSave = mMusicGenerator.mMusicFileConfig.LoadClipConfigurations(fileName);
#endif //!UNITY_EDITOR && UNITY_ANDROID

            mTempo.value            = mCurrenClipSave.mTempo;
            mProgressionRate.value  = mCurrenClipSave.mProgressionRate;
            mNumberOfMeasures.value = mCurrenClipSave.mNumberOfMeasures;
            mKey.value            = (int)mCurrenClipSave.mKey;
            mScale.value          = (int)mCurrenClipSave.mScale;
            mMode.value           = (int)mCurrenClipSave.mMode;
            mClipIsRepeating.isOn = mCurrenClipSave.mClipIsRepeating;

            bool isFinished = false;
            StartCoroutine(mLoadedClip.AsyncInit(mCurrenClipSave, ((x) => { isFinished = x; })));
            yield return(new WaitUntil(() => isFinished));

            callback(isFinished);
            yield return(null);
        }
コード例 #2
0
 /// plays a single clip. Loads if necessary.
 public void PlaySingleClip(Toggle isRepeatingToggle)
 {
     if (mSingleClip == null)
     {
         mSingleClip = gameObject.AddComponent <SingleClip>();
         string clipName = "AAADefault.txt";                 /// This already exists in the IntrumentClips folder. we load it below with Init().
         mSingleClip.Init(mMusicGenerator.mMusicFileConfig.LoadClipConfigurations(clipName));
         mSingleClip.mIsRepeating = isRepeatingToggle.isOn;
     }
     //	mSingleClip.ResetClip();///Just in case it was already playing
     mSingleClip.SetState(eClipState.Play);
 }
コード例 #3
0
        /// Plays a single clips
        private IEnumerator PlaySingleClip(Toggle isRepeatingToggle)
        {
            if (mSingleClip == null)
            {
                mSingleClip = gameObject.AddComponent <SingleClip>();
                string   clipName = "AAADefault.txt";               /// This already exists in the IntrumentClips folder. we load it below with Init().
                ClipSave clipSave = null;
                yield return(StartCoroutine(mMusicGenerator.mMusicFileConfig.LoadClipConfigurations(clipName, (x) => { clipSave = x; })));

                mSingleClip.Init(clipSave);
                mSingleClip.mIsRepeating = isRepeatingToggle.isOn;
            }
            //	mSingleClip.ResetClip();///Just in case it was already playing
            mSingleClip.SetState(eClipState.Play);
        }
コード例 #4
0
        ///loads a music clip
        public void LoadClip(string fileName = "")
        {
            fileName = (fileName == "") ? "AAADefault.txt" : fileName;
            GameObject go = new GameObject();

            go.name = fileName;
            go.AddComponent <SingleClip>();
            //go.transform.parent = transform;
            mLoadedClip     = go.GetComponent <SingleClip>();
            mCurrenClipSave = mMusicGenerator.mMusicFileConfig.LoadClipConfigurations(fileName);

            mTempo.value            = mCurrenClipSave.mTempo;
            mProgressionRate.value  = mCurrenClipSave.mProgressionRate;
            mNumberOfMeasures.value = mCurrenClipSave.mNumberOfMeasures;
            mKey.value            = (int)mCurrenClipSave.mKey;
            mScale.value          = (int)mCurrenClipSave.mScale;
            mMode.value           = (int)mCurrenClipSave.mMode;
            mClipIsRepeating.isOn = mCurrenClipSave.mClipIsRepeating;

            mLoadedClip.Init(mCurrenClipSave);
        }
コード例 #5
0
        ///loads a music clip
        public IEnumerator LoadClip(string fileName = "", System.Action <bool> callback = null)
        {
            fileName = (fileName == "") ? "AAADefault.txt" : fileName;
            GameObject go = new GameObject();

            go.name = fileName;
            go.AddComponent <SingleClip>();
            //go.transform.parent = transform;
            mLoadedClip = go.GetComponent <SingleClip>();
            yield return(StartCoroutine(mMusicGenerator.mMusicFileConfig.LoadClipConfigurations(fileName, (x) => { mCurrenClipSave = x; })));

            mTempo.value            = mCurrenClipSave.mTempo;
            mProgressionRate.value  = mCurrenClipSave.mProgressionRate;
            mNumberOfMeasures.value = mCurrenClipSave.mNumberOfMeasures;
            mKey.value            = (int)mCurrenClipSave.mKey;
            mScale.value          = (int)mCurrenClipSave.mScale;
            mMode.value           = (int)mCurrenClipSave.mMode;
            mClipIsRepeating.isOn = mCurrenClipSave.mClipIsRepeating;

            mLoadedClip.Init(mCurrenClipSave);

            callback(true);
            yield return(null);
        }