public void Play()
        {
            _mainPlayer.Unload(PatternPlayer);
            _mainPlayer.Load(PatternPlayer, SilenceHelper.GetSilenceAudioFile());
            _mainPlayer.AddSection(PatternPlayer, PatternPlayer, 0, _loopLength, bpm: _targetBpm);

            var section = _mainPlayer.GetAudioSection(PatternPlayer, PatternPlayer);

            section.LoopIndefinitely = true;

            for (var channelIndex = 0; channelIndex < _sampleKeys.Count; channelIndex++)
            {
                var positions = GetPositions(channelIndex);
                var player    = _channelPlayers[channelIndex];

                foreach (var position in positions)
                {
                    var currentPosition = position.Item2;
                    _mainPlayer.AddEvent(PatternPlayer, currentPosition, position.Item1, position.Item1,
                                         EventType.PlaySolo, player);
                }
            }

            _mainPlayer.QueueSection(PatternPlayer, PatternPlayer);
            _mainPlayer.Play(PatternPlayer);
        }
        public void PlayModule(bool loopIndefinitely = false)
        {
            _mainPlayer.Pause(SongPlayer);
            _mainPlayer.Unload(SongPlayer);
            _mainPlayer.Load(SongPlayer, SilenceHelper.GetSilenceAudioFile());
            var songLength = _loopLength * Module.Sequence.Count;

            _mainPlayer.AddSection(SongPlayer, SongPlayer, 0, songLength, bpm: _targetBpm);

            var section = _mainPlayer.GetAudioSection(SongPlayer, SongPlayer);

            section.LoopIndefinitely = loopIndefinitely;

            var patternOffset = 0D;

            foreach (var sequence in Module.Sequence)
            {
                var pattern = Module.Patterns.FirstOrDefault(x => x.Key == sequence);
                if (pattern == null)
                {
                    continue;
                }

                for (var channelIndex = 0; channelIndex < Module.Channels.Count; channelIndex++)
                {
                    var channelSequence = pattern.Sequence[channelIndex];
                    var positions       = GetPositions(channelSequence);
                    var player          = _channelPlayers[channelIndex];

                    if (!positions.Any() || positions[0].Item2 != 0D)
                    {
                        _mainPlayer.AddEvent(SongPlayer, patternOffset, "", "", EventType.PauseAll, player);
                    }

                    foreach (var position in positions)
                    {
                        var currentPosition = position.Item2 + patternOffset;
                        _mainPlayer.AddEvent(SongPlayer, currentPosition, position.Item1, position.Item1,
                                             EventType.PlaySolo, player);
                    }
                }

                patternOffset += _loopLength;
            }

            if (!loopIndefinitely)
            {
                for (var channelIndex = 0; channelIndex < Module.Channels.Count; channelIndex++)
                {
                    var player = _channelPlayers[channelIndex];
                    _mainPlayer.AddEvent(SongPlayer, patternOffset, "", "", EventType.PauseAll, player);
                }
            }

            _mainPlayer.QueueSection(SongPlayer, SongPlayer);
            _mainPlayer.Play(SongPlayer);
        }
        public void PlayPatternChannel(string patternKey, string channelKey)
        {
            var pattern = Module.Patterns.FirstOrDefault(x => x.Key == patternKey);

            if (pattern == null)
            {
                return;
            }

            var channel = Module.Channels.FirstOrDefault(x => x.Key == channelKey);

            if (channel == null)
            {
                return;
            }

            var channelIndex    = Module.Channels.IndexOf(channel);
            var channelSequence = pattern.Sequence[channelIndex];
            var positions       = GetPositions(channelSequence);
            var player          = _channelPlayers[channelIndex];

            Pause();

            _mainPlayer.Unload(PatternPlayer);
            _mainPlayer.Load(PatternPlayer, SilenceHelper.GetSilenceAudioFile());
            _mainPlayer.AddSection(PatternPlayer, PatternPlayer, 0, _loopLength, bpm: _targetBpm);
            var section = _mainPlayer.GetAudioSection(PatternPlayer, PatternPlayer);

            section.LoopIndefinitely = true;

            foreach (var position in positions)
            {
                var currentPosition = position.Item2;

                _mainPlayer.AddEvent(PatternPlayer, currentPosition, position.Item1, position.Item1,
                                     EventType.PlaySolo, player);
            }

            _mainPlayer.QueueSection(PatternPlayer, PatternPlayer);
            _mainPlayer.Play(PatternPlayer);
        }