public void AddSample(string sampleKey, string path, double start, double length, double offset) { _sampleKeys.Add(sampleKey); if (_targetBpm == int.MinValue) { _targetBpm = BpmHelper.GetBpmFromLoopLength(length); } AudioPlayer channelPlayer; if (_sampleKeys.Count > _channelPlayers.Count) { channelPlayer = new AudioPlayer(); Output.AddInputChannel(channelPlayer.Output); _channelPlayers.Add(channelPlayer); } else { channelPlayer = _channelPlayers[_sampleKeys.Count - 1]; } channelPlayer.UnloadAll(); channelPlayer.Load(sampleKey, path); var section = channelPlayer.AddSection(sampleKey, sampleKey, start, length, offset, calculateBpmFromLength: true, targetBpm: _targetBpm); section.LoopIndefinitely = true; }
public SyncedSamplePlayer() { Output = new MixerChannel(this); _mainPlayer = new AudioPlayer(); Output.AddInputChannel(_mainPlayer.Output); }
public ModulePlayer(string libraryFolder = "") { Output = new MixerChannel(this); _mainPlayer = new AudioPlayer(); _libraryFolder = libraryFolder; Output.AddInputChannel(_mainPlayer.Output); }
/// <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; } }
private void LoadChannelPlayers(Module module) { _channelPlayers = new List<AudioPlayer>(); for (var channelIndex = 0; channelIndex < module.Channels.Count; channelIndex++) { var channelPlayer = new AudioPlayer(); Output.AddInputChannel(channelPlayer.Output); _channelPlayers.Add(channelPlayer); } }
public RawLoopPlayer(IBmpProvider bpmProvider = null) { _audioPlayer = new AudioPlayer(bpmProvider); }
public TrackSamplePlayer(IBmpProvider bpmProvider) { _audioPlayer = new AudioPlayer(bpmProvider); _bpmProvider = bpmProvider; }
public void AddEvent(string streamKey, double position, string targetStreamKey, string targetSectionKey, EventType eventType, AudioPlayer player = null, double length = 0) { var audioStream = GetAudioStream(streamKey); if (audioStream == null) return; if (position == double.MinValue) return; if (player == null) player = this; var audioSync = GetAudioSync(audioStream, position) ?? AddSync(audioStream, SyncType.AudioStreamEvent, position); var audioStreamEvent = new Event { SyncId = audioSync.Id, StreamKey = streamKey, TargetStreamKey = targetStreamKey, TargetSectionKey = targetSectionKey, StreamEventType = eventType, Player = player, Length = length }; lock (_audioStreamEvents) { _audioStreamEvents.Add(audioStreamEvent); } DebugHelper.WriteLine("Added event sync id " + audioSync.Id + " as " + eventType + " on " + streamKey + " to " + targetStreamKey); }
public TrackSamplePlayer(IBmpProvider bpmProvider = null) { _audioPlayer = new AudioPlayer(bpmProvider); _bpmProvider = bpmProvider; }