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);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="module"></param>
 /// <param name="channelPlayer"></param>
 /// <param name="audioFile"></param>
 private static void LoadSamples(Module module, AudioPlayer channelPlayer, Module.AudioFile audioFile)
 {
     foreach (var sample in audioFile.Samples)
     {
         var fullSampleKey = audioFile.Key + "." + sample.Key;
         channelPlayer.Load(fullSampleKey, audioFile.Path);
         channelPlayer.AddSection(fullSampleKey,
                                  fullSampleKey,
                                  sample.Start,
                                  sample.Length,
                                  sample.Offset,
                                  calculateBpmFromLength: true,
                                  targetBpm: module.Bpm);
     }
 }