/// <summary> /// Removes and audio stream from a mixer. /// </summary> /// <param name="audioStream">The audio stream.</param> /// <param name="mixerChannel">The mixer channel.</param> public static void RemoveFromMixer(AudioStream audioStream, MixerChannel mixerChannel) { if (audioStream == null || !audioStream.IsAudioLoaded()) { return; } //throw new Exception("Audio file null or not audio not loaded"); if (mixerChannel.ChannelId == int.MinValue) { throw new Exception("Mixer channel not initialized"); } //lock (Lock) { // DebugHelper.WriteLine($"RemoveFromMixer {audioStream.Description} {audioStream.Channel}..."); BassMix.BASS_Mixer_ChannelPause(audioStream.ChannelId); Bass.BASS_ChannelLock(mixerChannel.ChannelId, true); foreach (var channel in audioStream.ChannelIds) { BassMix.BASS_Mixer_ChannelRemove(channel); } Bass.BASS_ChannelLock(mixerChannel.ChannelId, false); // DebugHelper.WriteLine("done"); if (audioStream.MixerChannelId == mixerChannel.ChannelId) { audioStream.MixerChannelId = int.MinValue; } } }
public EffectPlugin ReplacePlugin(string pluginPath, MixerChannel channel, Action <Exception> onError, EffectPlugin oldPlugin) { int idx = Plugins.IndexOf(oldPlugin ?? throw new ArgumentNullException(nameof(oldPlugin))); try { EffectPlugin plugin = new EffectPlugin(pluginPath) { EffectMix = oldPlugin.EffectMix }; RemovePlugin(oldPlugin); lock (((ICollection)Plugins).SyncRoot) { Plugins.Insert(idx, plugin); } return(plugin); } catch (Exception e) { onError?.Invoke(e); return(null); } }
public static bool Contains(MixerChannel channel) { if (channel == null) { return(false); } return(channels.Contains(channel)); }
public SyncedSamplePlayer(Channel speakerOutput, Channel monitorOutput) { _mixer = new MixerChannel(this); _mainPlayer = new AudioPlayer(); _mixer.AddInputChannel(_mainPlayer.Output); _outputSplitter = new OutputSplitter(_mixer, speakerOutput, monitorOutput); }
public ModulePlayer(string libraryFolder = "") { Output = new MixerChannel(this); _mainPlayer = new AudioPlayer(); _libraryFolder = libraryFolder; Output.AddInputChannel(_mainPlayer.Output); }
/// <summary> /// Initialises the raw loop mixer. /// </summary> private void InitialiseRawLoopMixer() { // DebugHelper.WriteLine("InitialiseRawLoopMixer"); _rawLoopMixer = new MixerChannel(this, MixerChannelOutputType.MultipleOutputs); _rawLoopOutputSplitter = new OutputSplitter(_rawLoopMixer, SpeakerOutput, MonitorOutput); // DebugHelper.WriteLine("END InitialiseRawLoopMixer"); }
public static void AddChannel(MixerChannel channel) { lock (lockObj) { if (!Contains(channel)) { channels.Add(channel); MasterChannel.AddSource(channel); } } }
public static void RemoveChannel(MixerChannel channel) { lock (lockObj) { if (Contains(channel)) { channels.Remove(channel); MasterChannel.RemoveSource(channel); } } }
public Mixer(int channelCount) { output = new WasapiOut() { Latency = 4 }; MasterChannel = new MixerChannel("Master", channelCount, output.Device.DeviceFormat.SampleRate); var w = new MixerChannelToCSCore(MasterChannel).ToWaveSource(); output.Initialize(w); output.Play(); }
private void InitialiseSampler() { // DebugHelper.WriteLine("InitialiseSampler"); // create mixer channel _samplerMixer = new MixerChannel(this); _samplerMixer.SetVolume((decimal)DefaultFadeOutStartVolume); _samplerMixer.CutBass(); _samplerOutputSplitter = new OutputSplitter(_samplerMixer, SpeakerOutput, MonitorOutput); _samplePlayer = new TrackSamplePlayer(this); _samplerMixer.AddInputChannel(_samplePlayer.Output); _samplerMixer.SetVolume(50); // DebugHelper.WriteLine("END InitialiseSampler"); }
public EffectPlugin AddPlugin(string pluginPath, MixerChannel channel, Action <Exception> onError) { try { EffectPlugin plugin = new EffectPlugin(pluginPath); lock (((ICollection)Plugins).SyncRoot) { Plugins.Add(plugin); } return(plugin); } catch (Exception e) { onError?.Invoke(e); return(null); } }
/// <summary> /// Adds an audio stream to a mixer /// </summary> /// <param name="audioStream">The audio stream.</param> /// <param name="mixerChannel">The mixer channel.</param> public static void AddToMixer(AudioStream audioStream, MixerChannel mixerChannel) { if (audioStream == null || !audioStream.IsAudioLoaded()) { throw new Exception("Audio file null or not audio not loaded"); } if (mixerChannel.ChannelId == int.MinValue) { throw new Exception("Mixer channel not initialized"); } // DebugHelper.WriteLine($"AddToMixer {audioStream.Description} {mixerChannel} {audioStream.Channel}..."); BassMix.BASS_Mixer_StreamAddChannel(mixerChannel.ChannelId, audioStream.ChannelId, BASSFlag.BASS_MIXER_PAUSE | BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_MIXER_NORAMPIN | BASSFlag.BASS_MUSIC_AUTOFREE); Thread.Sleep(1); audioStream.MixerChannelId = mixerChannel.ChannelId; // DebugHelper.WriteLine("done"); }
public AudioPlayer(IBmpProvider bpmProvider = null) { Output = new MixerChannel(bpmProvider); _streamSections = new List <AudioStreamSection>(); }