/// <summary> /// /// </summary> /// <param name="format"></param> /// <returns></returns> public static StreamInfo FromSoundFormat(SoundFormat format) { return(new StreamInfo() { Category = StreamCategory.Audio, Channels = 2, // as of libVLC 2.1 imem accepts only 2 channel audio Codec = SoundType.f32l, Samplerate = format.Rate, Size = 15 * 1024 // need to find a way to estimate audio frame size.... }); }
private int SetupCallback(void** data, char* format, int* rate, int* channels) { var pFormat = new IntPtr(format); var formatStr = Marshal.PtrToStringAnsi(pFormat); SoundType sType; if (!Enum.TryParse<SoundType>(formatStr, out sType)) { var exc = new ArgumentException("Unsupported sound type " + formatStr); if (_mExcHandler != null) { _mExcHandler(exc); return 1; } else { throw exc; } } _mFormat = new SoundFormat(sType, *rate, *channels); if (_mFormatSetupCb != null) { _mFormat = _mFormatSetupCb(_mFormat); } Marshal.Copy(_mFormat.Format.ToUtf8(), 0, pFormat, 4); *rate = _mFormat.Rate; *channels = _mFormat.Channels; return _mFormat.UseCustomAudioRendering == true ? 0 : 1; }
public void SetFormat(SoundFormat format) { _mFormat = format; LibVlcMethods.libvlc_audio_set_format(_mHMediaPlayer, _mFormat.Format.ToUtf8(), _mFormat.Rate, _mFormat.Channels); }
private SoundFormat SoundFormatCallback(SoundFormat sf) { if (_needsSetup) { _recordingFormat = new WaveFormat(sf.Rate, 16, sf.Channels); _waveProvider = new BufferedWaveProvider(RecordingFormat); _sampleChannel = new SampleChannel(_waveProvider); _meteringProvider = new MeteringSampleProvider(_sampleChannel); _meteringProvider.StreamVolume += MeteringProviderStreamVolume; _needsSetup = false; if (HasAudioStream != null) HasAudioStream(this, EventArgs.Empty); } return sf; }
private SoundFormat SoundFormatCallback(SoundFormat sf) { if (_needsSetup) { _recordingFormat = new WaveFormat(sf.Rate, 16, sf.Channels); _waveProvider = new BufferedWaveProvider(RecordingFormat); _sampleChannel = new SampleChannel(_waveProvider); _sampleChannel.PreVolumeMeter += SampleChannelPreVolumeMeter; _needsSetup = false; } return sf; }
private SoundFormat SoundFormatCallback(SoundFormat sf) { if (!_needsSetup) return sf; int chan = _realChannels = sf.Channels; if (chan > 1) chan = 2;//downmix _recordingFormat = new WaveFormat(sf.Rate, 16, chan); _waveProvider = new BufferedWaveProvider(RecordingFormat); _sampleChannel = new SampleChannel(_waveProvider); _sampleChannel.PreVolumeMeter += SampleChannelPreVolumeMeter; _needsSetup = false; if (HasAudioStream != null) { HasAudioStream(this, EventArgs.Empty); HasAudioStream = null; } return sf; }
private int SetupCallback(void** data, char* format, int* rate, int* channels) { IntPtr pFormat = new IntPtr(format); string formatStr = Marshal.PtrToStringAnsi(pFormat); SoundType sType; if (!Enum.TryParse<SoundType>(formatStr, out sType)) { throw new ArgumentException("Unsupported sound type " + formatStr); } m_format = new SoundFormat(sType, *rate, *channels); if (m_formatSetupCB != null) { m_format = m_formatSetupCB(m_format); } Marshal.Copy(m_format.Format.ToUtf8(), 0, pFormat, 4); *rate = m_format.Rate; *channels = m_format.Channels; return m_format.UseCustomAudioRendering == true ? 0 : 1; }