コード例 #1
0
        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);
        }
コード例 #2
0
        private void LoadSample(Track track, TrackSample trackSample)
        {
            var sampleId = track.Description + " - " + trackSample.Key;

            var filename = trackSample.IsExternalLoop ? Path.Combine(LoopFolder, trackSample.Key) : track.Filename;

            if (!File.Exists(filename))
            {
                return;
            }

            var sample = (Sample)_audioPlayer.Load(sampleId, filename);

            sample.LinkedTrackDescription = track.Description;
            sample.Gain        = trackSample.IsExternalLoop ? 0 : track.Gain;
            sample.SampleKey   = trackSample.Key;
            sample.IsLooped    = trackSample.IsExternalLoop || trackSample.IsLooped;
            sample.Bpm         = trackSample.CalculateBpm(track);
            sample.Description = trackSample.Description;

            _audioPlayer.AddSection(sampleId,
                                    sampleId,
                                    start: trackSample.Start,
                                    length: trackSample.Length,
                                    bpm: sample.Bpm,
                                    loopIndefinitely: trackSample.IsLooped);

            _audioPlayer.QueueSection(sampleId, sampleId);
        }
コード例 #3
0
        public void LoadAudio(string filename)
        {
            _audioPlayer.UnloadAll();
            _audioPlayer.Load(StreamKey, filename);
            var section = _audioPlayer.AddSection(StreamKey, SectionKey);

            section.LoopIndefinitely = true;
        }
コード例 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="module"></param>
        /// <param name="channelPlayer"></param>
        /// <param name="audioFile"></param>
        private void LoadSamples(Module module, AudioPlayer channelPlayer, Module.AudioFile audioFile)
        {
            if (!File.Exists(audioFile.Path)
                && _libraryFolder != ""
                && _libraryFolder.EndsWith("Library")
                && audioFile.Path.Contains("Library"))
            {
                var index = audioFile.Path.IndexOf("Library", StringComparison.Ordinal) + "Libary".Length + 1;
                var path = _libraryFolder + audioFile.Path.Substring(index);
                audioFile.Path = path;
            }

            foreach (var sample in audioFile.Samples)
            {
                var fullSampleKey = audioFile.Key + "." + sample.Key;
                channelPlayer.Load(fullSampleKey, audioFile.Path);
                var section = channelPlayer.AddSection(fullSampleKey,
                    fullSampleKey,
                    sample.Start,
                    sample.Length,
                    sample.Offset,
                    calculateBpmFromLength: true,
                    targetBpm: module.Bpm);

                section.LoopIndefinitely = true;
            }
        }