Quantcast
Channel: NAudio
Viewing all 5831 articles
Browse latest View live

Commented Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}

Initialization of the WaveOut class:
this.wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback());

I've also tried it with the new WaveOutEvent class in NAudio, but the problem persists.
Comments: OK, what is the simplest code that reproduces this problem? Are you using any decoders (e.g. playing MP3 or other compressed formats)? Do you need to play for a certain length of time for it to happen etc?

New Post: Need help with exception thrown by NAudio

$
0
0

I use NuGet.  First tries were with v1.5, but now I've updated to v1.6.

Just to be clear, my program doesn't crash, and the recordings work fine, but I get this annoying dialog, which I'd want to get rid of.

Thanks for any help.

Commented Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}

Initialization of the WaveOut class:
this.wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback());

I've also tried it with the new WaveOutEvent class in NAudio, but the problem persists.
Comments: I have a hard time reproducing this with a simple piece of code. It seems that there is some multithreading involved that causes this issue. Yes, I'm using the Mp3FileReader. As for your last question, it happend always when the song has finished and I disposed the wavePlayer, but as I said, I think it has to do with multithreading. Is the WaveOut class even threadsafe? That would mean that this issue is my fault. :)

Commented Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}

Initialization of the WaveOut class:
this.wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback());

I've also tried it with the new WaveOutEvent class in NAudio, but the problem persists.
Comments: If you have any interest in digging through my source code, this commit fixed the problem in my application: https://github.com/flagbug/Espera/commit/2580ab6c61036a125176e17245e624c65466c75e

Commented Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}

Initialization of the WaveOut class:
this.wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback());

I've also tried it with the new WaveOutEvent class in NAudio, but the problem persists.
Comments: With the WaveOut class, I strongly advise against using function callbacks, and using windows messages. In this scenario, you create the WaveOut object on your GUI thread, and all work should happen on the GUI thread (including filling the buffer). With WaveOutEvent, a separate background thread is created for the purposes of filling the buffers up. However, if possible, it marshalls the PlaybackStopped event to the GUI thread.

Created Issue: WMA [16370]

$
0
0
Hello,
the WMA file only works with WaveOut () standard.

With other DriverOut, I receive an error message from WMAStream function Read
(GetNextSample).

Tested with your NAudio Demo 1.6

Commented Issue: WMA [16370]

$
0
0
Hello,
the WMA file only works with WaveOut () standard.

With other DriverOut, I receive an error message from WMAStream function Read
(GetNextSample).

Tested with your NAudio Demo 1.6
Comments: what is the error message?

Commented Issue: WMA [16370]

$
0
0
Hello,
the WMA file only works with WaveOut () standard.

With other DriverOut, I receive an error message from WMAStream function Read
(GetNextSample).

Tested with your NAudio Demo 1.6
Comments: "Impossible d'effectuer un cast d'un objet COM de type 'System.__ComObject' en type d'interface 'NAudio.WindowsMediaFormat.IWMSyncReader'. Cette opération a échoué, car l'appel QueryInterface sur le composant COM pour l'interface avec l'IID '{9397F121-7705-4DC9-B049-98B698188414}' a échoué en raison de l'erreur suivante : Cette interface n’est pas prise en charge (Exception de HRESULT : 0x80004002 (E_NOINTERFACE))."

Commented Issue: WMA [16370]

$
0
0
Hello,
the WMA file only works with WaveOut () standard.

With other DriverOut, I receive an error message from WMAStream function Read
(GetNextSample).

Tested with your NAudio Demo 1.6
Comments: glouppps English version "Unable to cast COM object of type 'System.__ComObject' to interface type 'NAudio.WindowsMediaFormat.IWMSyncReader.' This operation failed because the QueryInterface call on the COM component for the interface with IID '{9397F121-7705-4DC9-B049-98B698188414}' failed due to the following error: This interface is not supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). "

Commented Issue: WMA [16370]

$
0
0
Hello,
the WMA file only works with WaveOut () standard.

With other DriverOut, I receive an error message from WMAStream function Read
(GetNextSample).

Tested with your NAudio Demo 1.6
Comments: hmmm, I can't see why that would have anything to do at all with what output driver you are using. I guess it might be a threading issue - maybe you can only use a WMAFileReader on the stream on which it was created.

Created Issue: the Mp3FileReader should not set stream position [16371]

$
0
0
It appears that we could add a few smarts to the Mp3FileReader and make it so that it would not have to use the Position property on the stream. Not all streams (especially web streams) allow the Seek operation. Also, the Mp3FileReader makes no attempt to check the CanSeek flag on the stream.

It would be okay to set stream position if the user wanted to adjust the playback position. However, that functionality should be disabled when the stream does not allow seeking or it should only be functional in some kind of cached data.

Commented Issue: WMA [16370]

$
0
0
Hello,
the WMA file only works with WaveOut () standard.

With other DriverOut, I receive an error message from WMAStream function Read
(GetNextSample).

Tested with your NAudio Demo 1.6
Comments: The error is triggered in "audioPlayBackPanel" this procedure void OnPlaybackStopped(object sender, StoppedEventArgs e) { groupBoxDriverModel.Enabled = true; if (e.Exception != null) { MessageBox.Show(e.Exception.Message, "Playback Device Error"); } } I think this is the link with all the drivers. I think not go wrong, because I have placed several points stops and it is the only place where the debugger marks the stop

New Post: move this DMO support to the next level: video

$
0
0

As far as I can tell, there is not much in the way of DMO and ACM wrappers for .NET. NAudio already has a lot of the functionality necessary instantiate those creatures. How would you feel about expanding NAudio's support of DMO to determine what audio items can be encoded/decoded using DMO? From there we would move on to video decoding. I recognize that's a significant jump in scope but would love the ability to decode video frames the same way NAudio does MP3 frames currently. No visual video rendering would be needed (as I would intend to use WriteableBitmapEx, etc.) Thoughts?

Commented Issue: WMA [16370]

$
0
0
Hello,
the WMA file only works with WaveOut () standard.

With other DriverOut, I receive an error message from WMAStream function Read
(GetNextSample).

Tested with your NAudio Demo 1.6
Comments: I commented concatenation delegate   private void CreateWaveOut ()          {              CloseWaveOut ();              int latency = (int) comboBoxLatency.SelectedItem;              this.waveOut SelectedOutputDevicePlugin.CreateDevice = (latency);             / / + = This.waveOut.PlaybackStopped OnPlaybackStopped;                      } I have no error message but it does not work :-(

New Post: InvalidOperationException on playing some MP3 files

$
0
0

I keep getting an exception with the message "Got a frame at sample rate 44100, in an MP3 with sample rate 48000. Mp3FileReader does not support sample rate changes." when playing some MP3 files. Is there anything else I can use to play MP3 files? Thanks in advance. I'm using version 1.6 of NAudio.


New Post: Detect current volume level while a file is playing using Naudio

$
0
0

So I have this code. There is a Stop-Button ( button1 ), which stops playback. When the form is loaded, the file is played. While the file is playing I want to get the current volume of the file by running a function.

        IWavePlayer waveOutDevice;
        WaveStream mainOutputStream;
        WaveChannel32 volumeStream;

        private WaveStream CreateInputStream(string fileName)
        {
            WaveChannel32 inputStream;
            if (fileName.EndsWith(".mp3"))
            {
                WaveStream mp3Reader = new Mp3FileReader(fileName);
                inputStream = new WaveChannel32(mp3Reader);
            }
            else
            {
                throw new InvalidOperationException("Unsupported extension");
            }
            volumeStream = inputStream;
            return volumeStream;
        }

        private void Stop()
        {
            if (waveOutDevice != null)
            {
                waveOutDevice.Stop();
            }
            if (mainOutputStream != null)
            {
                // this one really closes the file and ACM conversion
                volumeStream.Close();
                volumeStream = null;
                // this one does the metering stream
                mainOutputStream.Close();
                mainOutputStream = null;
            }
            if (waveOutDevice != null)
            {
                waveOutDevice.Dispose();
                waveOutDevice = null;
            }
        }

        private void Play(string was)
        {
            waveOutDevice = new WaveOut();
            mainOutputStream = CreateInputStream(was);
            waveOutDevice.Init(mainOutputStream);
            waveOutDevice.Play();
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Play(@"E:\Eigene Audiodateien\Musik\Alben\Pur\Abenteuerland\ -  - .mp3");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Stop();
        }

So what does a function like this has to look like at "...."?

    private int currentVolumeLevel(...some suitable parameters...)
    {
      int currentVolumeLevelValue = 0;
      //....
      return currentVolumeLevelValue;
    }

I am not talking about the volume level you can adjust with windows' sound controls. I am talking about the currently played sound file's volume at this very position it is playing right now, based on something like a byte[] array.

Thanks in advance.

New Post: Play Pause Play

$
0
0

I have an app where I do this...  Here's what I'm doing:

  • Wait for the playback buffers to drain
    • You can do this by feeding empty buffers to NAudio for long enough to ensure silence to the speakers.  No more than 150ms is required in most cases, but you can control it by setting the buffer size when you create the playback instance (WaveOut, WasapiOut, etc.).
  • Pause playback
  • Seek source
  • Resume playback

My app actually double-buffers, so instead of "Resume playback", I actually fill my primary buffer and allow that to trigger the resume.

The only downside is that the seek doesn't happen instantly.  In practice, most of the delay is waiting for the decoder to seek, so it's a non-issue for me.

New Post: Detect current volume level while a file is playing using Naudio

$
0
0

The NAudioDemo shows how to do this (see AudioPlaybackPanel.cs). You can use a MeteringSampleProvider to raise regular events with the maximum sample value.

New Post: Detect current volume level while a file is playing using Naudio

$
0
0

I do not understand your sample. Please create the function currentVolumeLevel for us.

New Post: move this DMO support to the next level: video

$
0
0

NAudio includes complete wrapping of the ACM API so you can use any ACM codec.

As for DMOs, I've provided wrappers for two - the managed resampler and the MP3 decoder. Both of these took ages, and I struggled to find the information I wanted on how they were supposed to be used. I'd love for NAudio to be able to offer you the ability to use any DMO installed on your system (and also there is now MFT as well). However, I am not currently working on this, but I am open to contributions in this area.

Viewing all 5831 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>