public void SetPositions(double start = 0, double length = 0, double offset = 0) { _audioPlayer.Pause(StreamKey); _audioPlayer.SetSectionPositions(StreamKey, SectionKey, start, length, offset); _audioPlayer.QueueSection(StreamKey, SectionKey); _audioPlayer.Play(StreamKey); }
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 PlaySample(string sampleId) { var section = _audioPlayer.GetAudioSection(sampleId, sampleId); if (section == null) { return; } _audioPlayer.Pause(sampleId); _audioPlayer.SetSectionBpm(sampleId, sampleId, section.Bpm, targetBpm: _bpmProvider.GetCurrentBpm()); _audioPlayer.QueueSection(sampleId, sampleId); _audioPlayer.Unmute(sampleId); _audioPlayer.Play(sampleId); }