Coder Social home page Coder Social logo

filoe / cscore Goto Github PK

View Code? Open in Web Editor NEW
2.1K 116.0 450.0 139.83 MB

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.

License: Other

C# 96.61% Smalltalk 3.39%
audio-library dotnet audio

cscore's People

Contributors

arizonainkstudios avatar danielgilbert avatar filoe avatar ianski avatar jbarber3388 avatar joegilkey avatar magentaize avatar mikepelley avatar neolegends avatar opcon avatar raphgodart avatar seed122 avatar technoguyfication avatar tomashubelbauer avatar victorvhpg avatar wgebczyk avatar ziriax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cscore's Issues

Recording to aac.

Hi,
i'm not an expert on this topic (:
I'm trying to record the mic. input into an AAC stream/byte[]. Is this possible? Recording to an wavewriter and writing to an memorystream works quite well but it creates a huge file.
Thanks!

How to use delay, LPF and reverb in X3DAudioCore?

The X3DAudioCore.X3DAudioCalculate method can calculate not only channel mixing matrix, but also several other parameters. Unfortunately, neither the library source code nor the samples show any way of applying them to a voice - the X3DAudioSample only uses matrix.

Is there a chance of getting a sample of using more of X3DAudio functionality? Or is this functionality not yet implemented in CSCore?

WaveWriter can crash in dispose

First of all my deep appreciation for writing such a great library!

I had a crash where I passed a filename to the WaveWriter constructor. The constructor then creates a stream for you. However, if an exception is thrown here, the Dispose method will crash since it assumes that the _writer field is non-null.

I simply fixed this by replacing the _disposed field with the _writer field, so the Dispose method just checks if the _writer field is set.

I will provide a pull-request.

Audio threads running as Foreground threads

It appears that the audio threads in CSCore are running as Foreground threads, which means that if I have a long-running WasapiOut() running then I can't close the parent process until Play() has finished.

Would it be possible to make the threads Background threads, or at least expose the ability for users to choose to do so, so that they die when the parent process is killed?

WasapiOut not working with Windows 10 final

Maybe I'm missing something, but I cannot Initialize the WasapiOut, because I receive an "OutOfRangeException" for the parameter "value":

at CSCore.SoundOut.WasapiOut.InitializeInternal()
at CSCore.SoundOut.WasapiOut.Initialize(IWaveSource source)

It occurs, because in the InitializeInternal Method, the "Latency" parameter gets set to 0. That is because of the _audioClient.StreamLatency being 0. This only happens on the Release Version of Windows 10. I haven't had the Problem on Windows 7, 8, 8.1 and Windows 10 Insider Preview .

The error even occurs on a clean install of Windows 10. Any idea what could be the reason for this behaviour?

I'm initializing the WasapiOut with a WriteableBufferingSource, based on a WasapiLoopbackCapture on another device.

How to use EqualizerFilter in real-time ?

I need to apply a high-pass filter on input AudioEndPoint devices (microphones ).

Please tell me should I write a custom DSP filter? or can I use EqualizerFilter for it?

Thanks in advance.

and special thanks to autors of cscore.
(sorry for my english)

DmoException when configuring DmoWavesReverbEffect

I'm using CSCore from the latest stable NuGet package (version 1.0.0).

I'm trying to use DmoWavesReverbEffect in my code. When I set the properties of the DmoWavesReverbEffect object, I often get a DmoException thrown from SetValue, with message:
IDirectSoundFXWavesReverb::SetAllParameters caused an error: 0x80070057, "The parameter is incorrect.".

This happens in spite of all the values being in range (that is, between minimum and maximum values as specified in DmoWavesReverbEffect constants). For example, ReverbTime = 2f causes an exception (should accept anything between 0.001 and 3000); HighFrequencyRTRatio = 0.5f does, too (should accept anything between 0.001 and 0.999). ReverbMix does not accept any negative value, while the range is -96 to 0.

Allow setting of stream duration

I'm in the process of creating a native music player for the Plex ecosystem. I'm passing in the URI for the stream and the Plex API gives me the time of the stream which I'd like to pass in to the source like so...

_waveSource = CodecFactory.Instance.GetCodec(uri, streamLength);

This would allow me to query the current location to set the time bar without having to hack together some magical formula on my end. I can make the changes myself, test it, and submit a pull request if that works too.

WinForms example with Wav form?

Hey,

This is not a bug or an issue, but I wasn't quite sure where to post this question, so please delete if it doesn't meet critieria.

Any chance you could post a wav form example with seek ? Basically, load the mp3 and get an entire graphical representation of it. Then click around on different parts of the mp3 for it to start at different locations?

I see that you already have a basic example for moving around in a file, but a graphical representation would be great !

Thanks for your great work either way. This looks much more useable than naudio.

Loading file in unsupported format causes exception in Finalizer

When file in unsupported format is loaded with 'CodecFactory.Instance.GetCodec(filePath)', then MediaFoundationException is thrown with message: "Interops::MFCreateSourceReaderFromURL caused an error: 0xc00d36c4, "The byte stream type of the given URL is unsupported.". Thet error is expected and can be handled properly.

When after some time (after couple of seconds) the ArgumentNullException is thrown in Finalizer with message: 'Value cannot be null.' As it is thrown in Finalizer, it cannot be handled and causes the process to terminate. The problem occurs only in Release build and I was not able to replicate it in Debug build.

Capture input from two Microphones save to Wav

Hi,

I am trying to capture the input from two Microphone inputs and save the resulting mixed audio to disk as a wav file.

To this end I started playing around with the Recorder demo application, first just adding one sound to the mixer and trying to save it to disk. I quickly realized that the mixer doesn't have a "Data Available" event so I tried the following code using the soundInSource as the trigger. It didn't work so I guess I need to approach this in a different way. Does anyone have any suggestions about the best way to go about this?

private void StartCapture()
  {


                if (SelectedDevice == null)
                    return;

                if(CaptureMode == CaptureMode.Capture)
                    _soundIn = new WasapiCapture();
                else
                    _soundIn = new WasapiLoopbackCapture();

                _soundIn.Device = SelectedDevice;
                _soundIn.Initialize();


                const int mixerSampleRate = 8000; //44.1kHz

                var mixer = new SimpleMixer(2, mixerSampleRate) //output: stereo, 44,1kHz
                {
                    FillWithZeros = false,
                    DivideResult = true //you may play around with this
                };

                var soundInSource = new SoundInSource(_soundIn);


                mixer.AddSource(
                    soundInSource
                    .ChangeSampleRate(mixerSampleRate)
                    .ToStereo()
                    .ToSampleSource());


                var singleBlockNotificationStream = new SingleBlockNotificationStream(mixer);
                _finalSource = singleBlockNotificationStream.ToWaveSource();
                _writer = new WaveWriter("D:\\a\\Mix.wav", _finalSource.WaveFormat);

                byte[] buffer = new byte[_finalSource.WaveFormat.BytesPerSecond / 2];


                soundInSource.DataAvailable += (s, e) =>
                {
                    int read;
                    while((read = _finalSource.Read(buffer, 0, buffer.Length)) > 0) {
                        _writer.Write(buffer, 0, read);
                    }

                };

                singleBlockNotificationStream.SingleBlockRead += SingleBlockNotificationStreamOnSingleBlockRead;
                 _soundIn.Start();

        }

Regards,

Darren

AudioPlayerSample not correctly stopping at end of track

Playing an mp3 or aac track, using WasapiOut, I've found that the AudioPlayerSample doesn't correctly recognise when the track has Stopped. If you play a track that starts out as 1min 30 secs long, the track bar will get to 1:30 / 1:30 , keep going to 1:31 / 1:31, then the trackbar stops moving. What it doesn't do however is realise that playback has properly stopped and change the status of the buttons.
AudioPlayerSample.Form1 line 26 has "btnPlay.Enabled = btnStop.Enabled = btnPause.Enabled = false;" under a PlaybackStopped event and this never triggers.

I've traced this back to AudioPlayerSample.MusicPlayer and the PlaybackStopped event is never being fired, it appears to not subscribe to CSCore.SoundOut.WasapiOut.Stopped properly. I'm investigating now in your source and am happy to provide my solution if I can fix it up.

Thanks for your work on this project, it's been quick and easy to get running.

Cheers, Ian

DmoMp3Decoder does not skip ID3 Tags

DmoMp3Decoder does not skip ID3v2 tags which causes the decoder to use a wrong WaveFormat as the inital format. As a result, the whole track gets interpreted totally wrong.

Some MP3's which used to play, now throw "Could not find a supported format" CSCore.SoundOut.WasapiOut.SetupWaveFormat

I updated cscore in my music player to the latest code from cscore-master. A user of my music player complains that MP3 files which used to work, don't play anymore. I've shared 2 of the files here (in the folder "Unplayable"): https://www.dropbox.com/sh/wr36rjx0u1u2aeo/AADnfLBQZ2oJXEIgWyRQHSOZa?dl=0

The cscore.dll with which the files did work in the past is also in that folder. As far as I could debug, it seems that now a "Could not find a supported format" exception is thrown in CSCore.SoundOut.WasapiOut.SetupWaveFormat. I couldn't find the changeset which caused this.

This is the stacktrace:

at CSCore.SoundOut.WasapiOut.SetupWaveFormat(IWaveSource source, AudioClient audioClient)
at CSCore.SoundOut.WasapiOut.InitializeInternal()
at CSCore.SoundOut.WasapiOut.Initialize(IWaveSource source)
at Dopamine.Core.Audio.CSCorePlayer.InitializeSoundOut() in D:\Workspaces\VSOnline\Dopamine\Dev\Dopamine\Dopamine.Core\Audio\CSCorePlayer.vb:line 110
at Dopamine.Core.Audio.CSCorePlayer._Closure$__32-0._Lambda$__0() in D:\Workspaces\VSOnline\Dopamine\Dev\Dopamine\Dopamine.Core\Audio\CSCorePlayer.vb:line 247
at System.Threading.Tasks.Task.Execute()

Events Stop WasapiOut

I am in the process of changing a project over from Naudio and and having an issue with events. In my current app I have events fireing to update the meters and waveform drawing. It works fine with Naudio but the event stops the WasapiCapture with CSCore. The example below is a quick project I threw together to show this to you.

    public partial class MainWindow : Window
    {
        private WasapiCapture wasapiCapture;
        private WasapiOut wasapiOut;
        private SoundInSource wasapiCaptureSource;
        private ISampleSource sampleSource;
        private PeakMeter peakMeter;
        private IWaveSource waveSource;

        public MainWindow()
        {
            InitializeComponent();
            wasapiCapture = new WasapiCapture();
            wasapiCapture.Initialize();
            wasapiCaptureSource = new SoundInSource(wasapiCapture);
            sampleSource = wasapiCaptureSource.ToSampleSource();
            peakMeter = new PeakMeter(sampleSource);
            peakMeter.Interval = 3000;
            peakMeter.PeakCalculated += peakMeter_PeakCalculated;
            waveSource = peakMeter.ToWaveSource();
            wasapiCapture.Start();
            wasapiOut = new WasapiOut();
            wasapiOut.Initialize(waveSource);
            Thread.Sleep(100);
            wasapiOut.Play();
        }

        void peakMeter_PeakCalculated(object sender, PeakEventArgs e)
        {
            PeakLabel.Content = "test";
        }
    }

The above will play the audio from the input for 3seconds until the event fires and then stops because wasapiCapture stops. If I comment out the PeakLabel.Content = "test"; then is works fine. I can even put a Debug.Print there and it will work fine.
Is this intended behavior?
Thanks

waitHandle not returning

I have a piece of code that generates a wave file using Microsoft Speech Synthesizer and plays it:

        SpeechSynthesizer synth = new SpeechSynthesizer();
        using (MemoryStream stream = new MemoryStream())
        {
            synth.SetOutputToWaveStream(stream);
            synth.Speak("This is a test.");
            stream.Seek(0, SeekOrigin.Begin);
            IWaveSource source = new WaveFileReader(stream);
            EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
            var soundOut = new WasapiOut();
            soundOut.Initialize(source);
            soundOut.Stopped += (s, e) => waitHandle.Set();
            soundOut.Play();
            waitHandle.WaitOne();
            soundOut.Dispose();
            source.Dispose();
        }

This works fine when I run it standalone, but when running it as part of a plugin for another program it hangs on waitHandle.WaitOne() and never returns. Is there a bug here or am I missing something in the code to avoid this potential situation?

Sound output doesn't work if assembly name is different from assembly title

Finally tracked this bug down, putting this up now in case I forget, I'll add more detail to the bug report soon.

Issue:

Attempting to play an audio file would result in no sound being outputted. This only occurred when the output device used was a virtual audio cable VAC device. Sound was shown being outputted in the windows volume mixer http://software.muzychenko.net/eng/vac.htm, but did not appear to make it to the ouput device - Line 3 in the attached screenshot.

This bug is caused by the assembly (executable) name being different from the assembly title (as shown in task manager) set in assembly information.

This bug does not occur when outputting directly to my speakers - only when going through the virtual audio cable.

Noise removal

Hi,

There is a noise removal filter in Audacity.

Is it possible to apply noise removal filter on a sound file with cscore?

XAudio 2.8 missing GetDeviceCount and GetDeviceDetails with proposed solution

For XAudio 2.8 the functions GetDeviceCount and GetDeviceDetails are not available anymore. This is also in the CSCore lib. I have checked for other solutions to query the devices but haven't found one in the lib.
A solution is proposed here:
http://blogs.msdn.com/b/chuckw/archive/2012/04/02/xaudio2-and-windows-8-consumer-preview.aspx
It's a pity that my C++ skill are too rusty to fix it myself.
This would enhance the CScore lib and make it possible to query the devices in 2.8 version.
Hope to see it soon.

Play beyond the end of a WAV for effect

If I add an echo effect to a wav file it all works fine except for when the source reaches its end, at which point the echo is killed. For example:

        SpeechSynthesizer synth = new SpeechSynthesizer();
        using (MemoryStream stream = new MemoryStream())
        {
            synth.SetOutputToWaveStream(stream);
            synth.Speak("This is a test.");
            stream.Seek(0, SeekOrigin.Begin);
            IWaveSource source = new WaveFileReader(stream);
            EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);
            var soundOut = new WasapiOut();
            DmoEchoEffect echoSource = new DmoEchoEffect(source);
            soundOut.Initialize(echoSource);
            soundOut.Stopped += (s, e) => waitHandle.Set();
            soundOut.Play();
            waitHandle.WaitOne();
            soundOut.Dispose();
            source.Dispose();
        }

The echo is cut off as soon as the end of the primary WAV is reached. How can I tell CSCore to play for a given time beyond the end of the WAV file to allow the effects time to run out?

Using current version in project

Thanks for fixing the DmoWavesReverbEffect! I'm having trouble using it. I downloaded the zipfile and built the project in Visual Studio 2013 and referenced the dll created by the build in my project. Now I get no audio. When I switch back to the NuGet version I get audio again. What am I doing wrong?

WaveWriter - WaveHeader is not fully valid.

https://github.com/filoe/cscore/blob/master/CSCore/Codecs/WAV/WaveWriter.cs#L249

If I read the WaveHeader the DataSize is always zero.

            waveHeader.RiffId = br.ReadBytes(4);
            waveHeader.Size = br.ReadUInt32();
            waveHeader.WavId = br.ReadBytes(4);
            waveHeader.FmtId = br.ReadBytes(4);
            waveHeader.FmtSize = br.ReadUInt32();
            waveHeader.Format = br.ReadUInt16();
            waveHeader.Channels = br.ReadUInt16();
            waveHeader.SampleRate = br.ReadUInt32();
            waveHeader.BytesPerSec = br.ReadUInt32();
            waveHeader.BlockSize = br.ReadUInt16();
            waveHeader.Bit = br.ReadUInt16();
            waveHeader.DataId = br.ReadBytes(4);
            waveHeader.DataSize = br.ReadUInt32();

So I guess _dataLength is 0 at the time of writing the header? Most playback devices ignore the wrong data length flag, but some (mine) need this flag for validity checks.

OBOE in SimplerMixer

Hi there,

Great Work!

A couple of bugs you might want to fix:

you have an OBOE in your SimpleMixer.cs

@@ -74,7 +74,7 @@ namespace SimpleMixerSample
int read = sampleSource.Read(_mixerBuffer, 0, count);
for (int i = offset, n = 0; n < read; i++, n++)
{
(remove) if (numberOfStoredSamples < i)
(add) if (numberOfStoredSamples <= i)

Also, I think you need this change:

@@ -152,7 +152,7 @@ namespace SimpleMixerSample
{
lock (_lockObj)
{
(remove) foreach (var sampleSource in _sampleSources)
(add) foreach (var sampleSource in _sampleSources.ToArray())
{
sampleSource.Dispose();
_sampleSources.Remove(sampleSource);

otherwise, it will throw exceptions (the mixer will try to remove sources that have already been removed).

Lastly, I think that FillWithZeros causes more problems than it solves. In particular, the stop event is not raised when FillWithZeros = true.

Schoene Gruesse :)

Record only one channel

Hi,

Would it be possible to only capture 1 channel of a specific device and replay it to 2 channels (just mono)?

Changing Position causes Exception

I get a "from must not equal to." Argument exception
when trying to set Position of a IWaveSource and then initializing it.
I assume that mean's the position is greater than the length of the audio file, but that is impossible if I can trust my console output using this:

Console.WriteLine(startTime + "/" + soundSource.Length);
soundSource.Position = startTime;
soundOut.Initialize(soundSource);

Tells me:
30293491/45365376

So the position should be fine and below the max, and is definitely not equal to current position.

Any information on that?

Edit:
Further research brought me to the exception source:
public static ChannelMatrix GetMatrix(ChannelMask from, ChannelMask to)
{ if (from == to)
throw new ArgumentException("from must not equal to.");

But I can't really do anything with that information, "Channel matrix" is beyond my skills.

EDIT2:
Ironically, using the newest cscore from github, compiling that
and in Extensions.cs adding a try/catch to the code below, catches a new issue of github-version and makes skipping work.

(ORIGINAL:

internal static byte[] ReadBytes(this IWaveSource waveSource, int count)
        {
                if (waveSource == null)
                    throw new ArgumentNullException("waveSource");
                if (count <= 0 || (count % waveSource.WaveFormat.BlockAlign) != 0)
                    throw new ArgumentOutOfRangeException("count");


                byte[] buffer = new byte[count];
                int read = waveSource.Read(buffer, 0, buffer.Length);
                if (read < count)
                    Array.Resize(ref buffer, read);
                return buffer;
}

)
(NEW:

internal static byte[] ReadBytes(this IWaveSource waveSource, int count)
        {
            try
            {
                if (waveSource == null)
                    throw new ArgumentNullException("waveSource");
                if (count <= 0 || (count % waveSource.WaveFormat.BlockAlign) != 0)
                    throw new ArgumentOutOfRangeException("count");


                byte[] buffer = new byte[count];
                int read = waveSource.Read(buffer, 0, buffer.Length);
                if (read < count)
                    Array.Resize(ref buffer, read);
                return buffer;
            }
            catch(Exception e)
            {
                byte[] buffer = new byte[1];
                int read = waveSource.Read(buffer, 0, buffer.Length);
                if (read < count)
                    Array.Resize(ref buffer, read);
                return buffer;
            }
        }

)

Switch from MS-PL to GPL?

Would it be feasible at all to switch to using the GPL? I'd like to integrate the cscore binaries into my own GPL licensed project, but the MS-PL copyleft leaves it incompatible.

(I fully expect this to get shot down, but I figure it doesn't hurt to ask.)

SessionManager2.GetSessionEnumerator() not working as Windows service

I have a program that uses the CSCore library to detect applications which are playing audio and makes some info about them retrievable via web service.

It worked create as a console application but I wanted to have it run as a windows service. I changed it over to a windows service and only moved a few lines that called some initialization and shutdown function.

Not that I have done this the AudioSessionManager2.GetSessionEnumerator().Count is always 1. The only session it is returning is a process with ID 0. (Note: My working console version of the program always returns process 0, along with all other processes which play audio).

My VolumeManager class is the exact same as the console application version but it isn't working. I am don't know how I can debug it more. I checked for null objects and made sure everything is being called.

public List<AudioSessionControl2> GetSessions()
{
    List<AudioSessionControl2> sessions = new List<AudioSessionControl2>();

    if (sessionManager != null)
    {
        Log("Session Count: " + sessionManager.GetSessionEnumerator().Count);  //THIS IS AWAYS 1
    }

    foreach (var session in sessionManager.GetSessionEnumerator())
    {
        AudioSessionControl2 session2 = session.QueryInterface<AudioSessionControl2>();
        Log("Session2 Process: " + session2.Process.Id); //AWAYS 0

        if (session2 != null && session2.Process != null && session2.Process.MainWindowTitle != null && session2.Process.MainWindowTitle != "")
        {
            Log("Added session"); //NOT CALLED BECAUSE THE PROCESS WITH ID 0 HAS NO TITLE
            sessions.Add(session2);
        }
    }

    return sessions;
}

Why isn't this working as a service?

Thanks

FLAC Decoder can't handle files encoded with bit depth 24 and compression level >= 3

As in title, the FLAC decoder spits out various errors when attempting to decode 24 bit files encoded with a compression level >= 3. A summary of various combinations and exceptions is shown below.

Compression Level / Bit Depth Result
0/24 Works
1/24 Works
2/24 Works
3/24 "Quantized linear predictor coefficient shift needed." was negative.
5/24 RICE not supported (Invalid2)
6/24 "Quantized linear predictor coefficient shift needed." was negative.
7/24 RICE not supported (Invalid3)
8/24 "Quantized linear predictor coefficient shift needed." was negative.

Looking at the varied exceptions and the difference between various compression levels, I believe that that the cause of this bug lies in the different block sizes used.

Compression levels 0-2 use a block size of 1152 while compression levels 3-8 use a block size of 4096.

WritableBufferingSource: Return value of Write(byte[],int,int)

What ist the Return Value of the Write Method in WritableBufferingSource used for?
Against all MSDN conventions, this Write Method has a return value of type Int32. In every .NET (Stream)Classes, I found, there was the signature "void Write(...)"
I assume, according to the Read method, this value indicates, how much bytes are written, but I'm not sure.
Thanks!

I can not play .wav music.

Running FadingSample will throw an exception at CSCore\Codecs\WAV.cs :line 64. when choose .wav music. I am a new learner and don't wha't wrong with this problem, would you known the reason?

WasapiCapture's ReadData method might fail although recording is still running

Hi,

sometimes, an odd error occurs when recording using loopback capture: The recording only contains the header - without any data in it, and the header being in the state it was when it was written.

This error occurs randomly, on different devices, on different occasions - but never on my dev machine. Of course.

So I started digging around, and I might have found the reason for the error. It's in line 314 in WasapiCapture.cs:

IntPtr nativeBuffer = captureClient.GetBuffer(out framesAvailable, out flags);

This call is kinda wrong - which on the other is related to the underlying implementation of this call. Every return value unequal zero will trigger an exception. According to IAudioCaptureClient::GetBuffer method (Windows), it is perfectly fine for the function to return AUDCLNT_S_BUFFER_EMPTY (which translates to 0x08890001, clearly not being 0).

The caller should check again a few times if data is available. If that's not the case, or another error occurs, it should leave the routine.

The same applies to int nextPacketSize = captureClient.GetNextPacketSize(); - a commenter points that out in the corresponding MSDN article (IAudioCaptureClient::GetNextPacketSize method (Windows)):

can return 0

If it sets pNumFramesInNextPacket to 0, this means "nothing new ready to capture quite yet" [even if something is really playing and capture is occurring normally] so you should (possibly sleep then) try to capture again.

I'd like to solve that - but I'm not sure if adding exception handling might slow down the method significantly ( others don't know either ) - any idea on that?

I think it might make sense to add some kind of threshold when to exit the function.

Playing Samples

Is it possible to write samples to an output in a IWaveSource. I am pulling the audio through my application using a buffer so it will still work if there is no audio output available but I would like to allow the user to monitor if there ia an audio out. So, can I play audio from a IWaveSource. I hope this makes sense.

Thanks,
Dan

Semantic Versioning

Since this library is approaching a major release with breaking changes, I suggest this project switch to semver. It provides a clean and concise versioning scheme, which clearly states when an update to a library is backward compatible or not. This would mean the next release be 2.0.0, since lots of classes and interfaces have been renamed or have different properties.

Semver is seeing increased use throughout the open source community - the entire npm ecosystem uses it - because it makes consuming libraries so simple and convenient for developers.

WaveForm display in WPF and streaming

Hi!

How is it possible to display the WaveForm of an IWaveSource?

Also I'd like to know, how to stream music to a streaming service like Shoutcast?

Thanks in advance!

DirectSoundOut is not initialized.

My code like this,but it‘s not work

public void Play(string fileName)
{
using (var ss = CodecFactory.Instance.GetCodec(fileName))
{
using (var so = new DirectSoundOut())
{
so.Initialize(ss);
var time = ss.GetTime(ss.Length);

                so.Play();
                Thread.Sleep((int)time.TotalSeconds * 1000);
                so.Stop();
            }
        }
    }

thank you!

FLAC decoder and the Left/Side channel assignment

I encoded a FLAC file (with the official encoder) and the FLAC decoder in CSCore doesn't decode it properly.
The left channel plays back properly but the right channel doesn't. In VLC both play back correctly.
This is probably because the file uses Left/Side channel assignment (https://www.xiph.org/flac/format.html#frame_header) (This was decided by the encoder, I just used the default settings.)
Since this can't be reproduced with most files, here is a link to the file: http://www.mediafire.com/download/f2i46rczmlefctb/mpm8.flac

EDIT: Seems to work in CSCore v1.1.0 alpha... sorry for wasting your time

WasapiOut crashes when used in Windows Phone app

Platform: Windows Phone 8.1
Project: Debug and Release, different framework versions

Using WasapiOut.IsSupportedOnCurrentPlatform or trying to instantiate a WasapiOut object causes an exception to be thrown on the native side, before the actual code that uses WasapiOut, during the initial page creation. Problem cannot be debugged ("external code").

What may be the cause of this? AFAIK Wasapi is supported on Windows Phone.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.