示例#1
0
            /// <summary>
            /// Manages if any released notes are finished being released.
            /// </summary>
            /// <returns>The number of notes finished being released.</returns>
            public int CheckFinishedRelease()
            {
                int finished = 0;

                for (int i = this.releasingNotes.Count - 1; i >= 0; --i)
                {
                    PlayingNote             pn    = this.releasingNotes[i];
                    PxPre.Phonics.PlayState psfin = pn.generator.Finished();
                    if (psfin != PlayState.Playing)
                    {
                        pn.source.Stop();
                        pn.generator.DeconstructHierarchy();
                        this.audioSources.Add(pn.source);

                        this.releasingNotes.RemoveAt(i);
                        this.meterRecords.Remove(pn.generator);
                        ++finished;
                    }
                }

                return(finished);
            }
示例#2
0
            public bool StopNote(int idx, bool release = true)
            {
                PlayingNote pn;

                if (this.activeNotes.TryGetValue(idx, out pn) == false)
                {
                    return(false);
                }

                // It normally shouldn't be null, but can be if we instantly close
                // the app while notes are still playing.
                if (pn.source != null)
                {
                    bool rm = true;
                    if (release == true)
                    {
                        pn.generator.ReleaseHierarchy();
                        // If it's releasing, or needs to finish up regarless or release state,
                        // it's finished mode will be playing instead of anything else.
                        PxPre.Phonics.PlayState psfin = pn.generator.Finished();
                        if (psfin == PlayState.Playing)
                        {
                            // Don't remove it, transfer it to the list of released playing notes.
                            rm = false;
                            this.releasingNotes.Add(pn);
                        }
                    }

                    if (rm == true)
                    {
                        this.StopPlayingNote(pn);
                        this.meterRecords.Remove(pn.generator);
                    }
                }
                this.activeNotes.Remove(idx);
                return(true);
            }