Exemple #1
0
        public void RemoveMelody()
        {
            if (Melody != null)
            {
                _engine.StopOnNextBeat(_melodyMetadata.Active);

                Melody = null;
                _melodyMetadata = null;
                _currentBeatCount = 0l;
                _targetBeatCount = 0l;
                _lastBeatCount = 0l;
            }
        }
Exemple #2
0
        public void ChangeMelody(SoundEffect newMelody, long beatCount)
        {
            if (Melody == newMelody)
            {
                return;
            }

            if (Melody != null)
            {
                _engine.StopOnNextBeat(_melodyMetadata.Active);
            }

            _melodyMetadata = GetMelodyFromCacheOrCreate(newMelody);

            Melody = newMelody;
            if (Melody != null)
            {
                _engine.PlayOnNextBeat(_melodyMetadata.Active);
            }

            _currentBeatCount = 0L;
            _targetBeatCount = beatCount;
            _lastBeatCount = _engine.PatternPlayer.BeatsPlayed;
        }
Exemple #3
0
        private RhythmMelodyMetadata GetMelodyFromCacheOrCreate(SoundEffect effect)
        {
            RhythmMelodyMetadata cached;
            if (!_effectInstanceCache.TryGetValue(effect, out cached))
            {
                cached = new RhythmMelodyMetadata(effect.CreateInstance(), effect.CreateInstance());
                _effectInstanceCache[effect] = cached;
            }

            return cached;
        }