Quantcast
Channel: naudio Work Item Rss Feed
Viewing all 738 articles
Browse latest View live

Created Unassigned: Changes to channel count? [16434]

$
0
0
Got the following exception:
An unhandled exception of type 'System.InvalidOperationException' occurred in NAudio.dll
Additional information: Got a frame with channel mode Mono, in an MP3 with 2 channels. Mp3FileReader does not support changes to channel count.

code looks something like this:
this.ActiveFile = "some_valid.mp3";
waveOutDevice = new WaveOut();
audioFileReader = new AudioFileReader(this.ActiveFile); <----- Exception here

Works fine for most files I throw at it, so presumably this particular file is encoded in a weird way?
Is there a way to test for this, and work around it? Other audio players have no trouble playing this particular file. I'm kind of at a loss at how to handle this.

Apologies if this has been brought up before, searching for this exception didn't yield any results :-(

Commented Unassigned: Changes to channel count? [16434]

$
0
0
Got the following exception:
An unhandled exception of type 'System.InvalidOperationException' occurred in NAudio.dll
Additional information: Got a frame with channel mode Mono, in an MP3 with 2 channels. Mp3FileReader does not support changes to channel count.

code looks something like this:
this.ActiveFile = "some_valid.mp3";
waveOutDevice = new WaveOut();
audioFileReader = new AudioFileReader(this.ActiveFile); <----- Exception here

Works fine for most files I throw at it, so presumably this particular file is encoded in a weird way?
Is there a way to test for this, and work around it? Other audio players have no trouble playing this particular file. I'm kind of at a loss at how to handle this.

Apologies if this has been brought up before, searching for this exception didn't yield any results :-(
Comments: Aha! Tricksy filenames. Its actually an .ogg file in disguise. Please disregard.

Created Unassigned: Header WAVE file problem [16435]

$
0
0
Hi,

I am creating a PCM Wave file, but looking at it with the HEX file reader you can see something is wrong.

5249464626BE020057415645666D7420
1200000001000200007D000000F40100
0400100000006461746100BE02000000

On the second line you can see at the beginning:

1200 0000 SubChunk1Size this should be (0x10) 16 decimal not (0x12) 18 decimal

And then you can see betewenn the Bits per sample and the "data" in the third line you got 2 extra bytes that they shouldn't be there:

0400 = Block allignment = 4
1000 = Bits per sample = 16
0000 = ??????????
6461 = da
7461 = ta


Why is there this extra 2 bytes, it is breaking my wav file reader checker, the SubChunk1Size shoud be 16 on a PCM .

Somehow there must be a bug somewhere that adds this 2 bytes.

Does somebody else got the same problem? is it a library bug?

I will appreciate if anyone could check this, please!!!!!!!

Many thanks,
Helios

Commented Unassigned: Header WAVE file problem [16435]

$
0
0
Hi,

I am creating a PCM Wave file, but looking at it with the HEX file reader you can see something is wrong.

5249464626BE020057415645666D7420
1200000001000200007D000000F40100
0400100000006461746100BE02000000

On the second line you can see at the beginning:

1200 0000 SubChunk1Size this should be (0x10) 16 decimal not (0x12) 18 decimal

And then you can see betewenn the Bits per sample and the "data" in the third line you got 2 extra bytes that they shouldn't be there:

0400 = Block allignment = 4
1000 = Bits per sample = 16
0000 = ??????????
6461 = da
7461 = ta


Why is there this extra 2 bytes, it is breaking my wav file reader checker, the SubChunk1Size shoud be 16 on a PCM .

Somehow there must be a bug somewhere that adds this 2 bytes.

Does somebody else got the same problem? is it a library bug?

I will appreciate if anyone could check this, please!!!!!!!

Many thanks,
Helios
Comments: nothing wrong with this at all. fmt chunk can be 16 bytes (WAVEFORMAT), 18 bytes (WAVEFORMATEX), or longer. NAudio writes a WAVEFORMATEX by default, which is quite standard.

Commented Unassigned: Header WAVE file problem [16435]

$
0
0
Hi,

I am creating a PCM Wave file, but looking at it with the HEX file reader you can see something is wrong.

5249464626BE020057415645666D7420
1200000001000200007D000000F40100
0400100000006461746100BE02000000

On the second line you can see at the beginning:

1200 0000 SubChunk1Size this should be (0x10) 16 decimal not (0x12) 18 decimal

And then you can see betewenn the Bits per sample and the "data" in the third line you got 2 extra bytes that they shouldn't be there:

0400 = Block allignment = 4
1000 = Bits per sample = 16
0000 = ??????????
6461 = da
7461 = ta


Why is there this extra 2 bytes, it is breaking my wav file reader checker, the SubChunk1Size shoud be 16 on a PCM .

Somehow there must be a bug somewhere that adds this 2 bytes.

Does somebody else got the same problem? is it a library bug?

I will appreciate if anyone could check this, please!!!!!!!

Many thanks,
Helios
Comments: Hi Mark, Thank you for your replay, Is there a way to do a CreateWaveFile in a WAVEFORMAT with NAudio? Many thanks

Commented Unassigned: Header WAVE file problem [16435]

$
0
0
Hi,

I am creating a PCM Wave file, but looking at it with the HEX file reader you can see something is wrong.

5249464626BE020057415645666D7420
1200000001000200007D000000F40100
0400100000006461746100BE02000000

On the second line you can see at the beginning:

1200 0000 SubChunk1Size this should be (0x10) 16 decimal not (0x12) 18 decimal

And then you can see betewenn the Bits per sample and the "data" in the third line you got 2 extra bytes that they shouldn't be there:

0400 = Block allignment = 4
1000 = Bits per sample = 16
0000 = ??????????
6461 = da
7461 = ta


Why is there this extra 2 bytes, it is breaking my wav file reader checker, the SubChunk1Size shoud be 16 on a PCM .

Somehow there must be a bug somewhere that adds this 2 bytes.

Does somebody else got the same problem? is it a library bug?

I will appreciate if anyone could check this, please!!!!!!!

Many thanks,
Helios
Comments: No, you'd need to make your own customisation of WaveFileWriter to do that

Commented Unassigned: WasapiLoopbackCapture - Dataavailable not working as intended. [16405]

$
0
0
Made a post in the forum about it.

Not exactly sure if it´s just me that have done something wrong, but i can´t see what the issue can be so.

When i use .Dataavailable and send it through UDP and play it on receive, it works perfectly. BUT, it stops playing after about 5 secs.

It´s always the same time, and Only when i use WasapiLoopBack. It´s like Dataavailable is looking at a buffer that´s 5 seconds, and just waiting for it to run out, even though it should be infinite as it´s a loopback and it´s recording.

How i concluded it´s not working correctly is that if i play it directly, like Asioout(Waloop);(you get it).
It will play just fine, so the "data" is there.

I have tried it both at 32bit (original float) and downsampling to 16 bit. Both at Stereo.

```
void SendWaloop(object sender, NAudio.Wave.WaveInEventArgs e)
{

byte[] newArray16Bit = new byte[e.BytesRecorded / 2];
short two;
float value;
for (int i = 0, j = 0; i < e.BytesRecorded; i += 4, j += 2)
{
value = (BitConverter.ToSingle(e.Buffer, i));
two = (short)(value * short.MaxValue);

newArray16Bit[j] = (byte)(two & 0xFF);
newArray16Bit[j + 1] = (byte)((two >> 8) & 0xFF);
}
if (connect == true && MuteMic.Checked == false)
{
udpClient.Send(newArray16Bit, newArray16Bit.Length, otherPartyIP.Address.ToString(), 1500);
}

}
```

Thre shouldn´t be any problem and i don´t receive any errors. So i can´t understand what´s wrong, the only thing i can think of, is that it´s not working correctly.
Comments: Hi mark. Mind if you share us you solution? Any help will be greatly appreciated.

Commented Unassigned: WasapiLoopbackCapture - Dataavailable not working as intended. [16405]

$
0
0
Made a post in the forum about it.

Not exactly sure if it´s just me that have done something wrong, but i can´t see what the issue can be so.

When i use .Dataavailable and send it through UDP and play it on receive, it works perfectly. BUT, it stops playing after about 5 secs.

It´s always the same time, and Only when i use WasapiLoopBack. It´s like Dataavailable is looking at a buffer that´s 5 seconds, and just waiting for it to run out, even though it should be infinite as it´s a loopback and it´s recording.

How i concluded it´s not working correctly is that if i play it directly, like Asioout(Waloop);(you get it).
It will play just fine, so the "data" is there.

I have tried it both at 32bit (original float) and downsampling to 16 bit. Both at Stereo.

```
void SendWaloop(object sender, NAudio.Wave.WaveInEventArgs e)
{

byte[] newArray16Bit = new byte[e.BytesRecorded / 2];
short two;
float value;
for (int i = 0, j = 0; i < e.BytesRecorded; i += 4, j += 2)
{
value = (BitConverter.ToSingle(e.Buffer, i));
two = (short)(value * short.MaxValue);

newArray16Bit[j] = (byte)(two & 0xFF);
newArray16Bit[j + 1] = (byte)((two >> 8) & 0xFF);
}
if (connect == true && MuteMic.Checked == false)
{
udpClient.Send(newArray16Bit, newArray16Bit.Length, otherPartyIP.Address.ToString(), 1500);
}

}
```

Thre shouldn´t be any problem and i don´t receive any errors. So i can´t understand what´s wrong, the only thing i can think of, is that it´s not working correctly.
Comments: I don't think there was an actual problem here. If you are having a similar problem, ask on the discussion section

Created Unassigned: Longer ProductName [16436]

$
0
0
The WaveOut.GetCapabilities returns an object with device capabilities. The field ProductName is limited to 31 chars. It would be nice to have it longer. Let's say 100 chars.

Commented Unassigned: Longer ProductName [16436]

$
0
0
The WaveOut.GetCapabilities returns an object with device capabilities. The field ProductName is limited to 31 chars. It would be nice to have it longer. Let's say 100 chars.
Comments: this is an inherent limitation of the WaveOut APIs in Windows, which are effectively becoming obsolete now. I doubt Microsoft will ever fix this. It is very frustrating, and there are various ways people try to find the correct name in the registry, but I've never found anything that works reliably with all soundcards.

Commented Unassigned: Remove metadata from MP3 and WAV [16433]

$
0
0
Hi,

I am using NAudio.dll for my project for converting MP3 files to WAV files and WAV files to given WAV format ( as per given BitsPerSample, Channel, and sample rate).

Now i having another task to remove metadata from MP3, WAV files. How to remove metadata from these files and save using NAudio Assembly ?

Warm Regards
Sathyanarayanan.R
Comments: For MP3, just copy all Mp3Frames (using Mp3FileReader) into a new file, and not the ID3 tags For WAV, juts use WaveFileWriter to create a new WAV File, reading the data from the old one with WaveFileReader.

Created Unassigned: initiating 4 different waveout for 4 difference output device [16437]

$
0
0
hi,

i got an issue on initiating 4 difference waveout for 4 different output devices.
The initiation of the waveout failed on the 4th call. Here is the code

foreach (WaveOut waveOut in WaveOutCollections)
{

}

Edited Unassigned: initiating 4 different waveout for 4 difference output device [16437]

$
0
0
hi,

i got an issue on initiating 4 difference waveout for 4 different output devices.
The initiation of the waveout failed on the 4th call. Here is the code

Dictionary<int, WaveOut> _WaveOutCollections = null;


// Init the 4 output device, and assign to a difference output device
private void InitDevice()
{

_WaveOutCollections = new Dictionary<int, WaveOut>();

for (int i = 0; i< 4;i++)
{
WaveOut waveOut = new WaveOut();
waveOut.deviceNumber = i; // Assign to a different device number
waveOut.WaveFormat = new WaveFormat(8000, 16, 1);

_WaveOutCollection.Add(i, waveOut); // add the waveOut object into a container to be use later in playing sound
}

}


// This function will be use on playing the received voice buffer from 4 different input source to 4 different output devices

private void PlaySound(byte[] buffer, int deviceNumber)
{
IWaveProvider waveProvider = new BufferedWaveProvider();
waveProvider.AddSamples(buffer, 0, buffer.Length);

WaveOut waveOut = null;
if (_WaveOutCollections.TryGetValue(deviceNumber, out WaveOut))
{
if (waveOut!=null)
{
waveOut.Init(waveProvider); // The Error happens on the 4th initiating....

if (waveOut.PlayBackState != PlayBackState.Playing)
waveOut.Play();

}
}
}

Edited Unassigned: initiating 4 different waveout for 4 difference output device [16437]

$
0
0
hi,

i got an issue on initiating 4 difference waveout for 4 different output devices.
The initiation of the waveout failed on the 4th call. Here is the code

Dictionary<int, WaveOut> _WaveOutCollections = null;


// Init the 4 output device, and assign to a difference output device
private void InitDevice()
{

_WaveOutCollections = new Dictionary<int, WaveOut>();

for (int i = 0; i< 4;i++)
{
WaveOut waveOut = new WaveOut();
waveOut.deviceNumber = i; // Assign to a different device number
waveOut.WaveFormat = new WaveFormat(8000, 16, 1);

_WaveOutCollection.Add(i, waveOut); // add the waveOut object into a container to be use later in playing sound
}

}


// This function will be use on playing the received voice buffer from 4 different input source to 4 different output devices

private void PlaySound(byte[] buffer, int deviceNumber)
{
IWaveProvider waveProvider = new BufferedWaveProvider();
waveProvider.AddSamples(buffer, 0, buffer.Length);

WaveOut waveOut = null;
if (_WaveOutCollections.TryGetValue(deviceNumber, out WaveOut))
{
if (waveOut!=null)
{
waveOut.Init(waveProvider); // The Error happens on the 4th initiating....

if (waveOut.PlayBackState != PlayBackState.Playing)
waveOut.Play();

}
}
}



I traced the error it happen on interop call on winmm.dll at "WaveInterop.cs", The Error result is "UnSpecified Error"

[DllImport("winmm.dll")]
public static extern MmResult waveOutOpen(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
[DllImport("winmm.dll", EntryPoint = "waveOutOpen")]
public static extern MmResult waveOutOpenWindow(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, IntPtr callbackWindowHandle, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);



thanks,

Created Unassigned: WaveViewer and 24bit wavs [16438]

$
0
0
Maybe a stupid question but can the WaveViewer control display 24 bit wav files ?
I am doing this:

WaveViewer1.SamplesPerPixel = 400
Dim fr = New NAudio.Wave.WaveFileReader(filename)
WaveViewer1.WaveStream = fr

If filename is a file with 16bit depth (or lower), everything works fine. If the file is above 16bit, I think that the values becomes too big and verticaly the whole control is drawn.

Any help?

Commented Unassigned: WaveViewer and 24bit wavs [16438]

$
0
0
Maybe a stupid question but can the WaveViewer control display 24 bit wav files ?
I am doing this:

WaveViewer1.SamplesPerPixel = 400
Dim fr = New NAudio.Wave.WaveFileReader(filename)
WaveViewer1.WaveStream = fr

If filename is a file with 16bit depth (or lower), everything works fine. If the file is above 16bit, I think that the values becomes too big and verticaly the whole control is drawn.

Any help?
Comments: No, 24 bit support is not in there at the moment. To be honest, the WaveViewer is likely to be removed, and the examples in the demo applications should be used in preference

Commented Unassigned: initiating 4 different waveout for 4 difference output device [16437]

$
0
0
hi,

i got an issue on initiating 4 difference waveout for 4 different output devices.
The initiation of the waveout failed on the 4th call. Here is the code

Dictionary<int, WaveOut> _WaveOutCollections = null;


// Init the 4 output device, and assign to a difference output device
private void InitDevice()
{

_WaveOutCollections = new Dictionary<int, WaveOut>();

for (int i = 0; i< 4;i++)
{
WaveOut waveOut = new WaveOut();
waveOut.deviceNumber = i; // Assign to a different device number
waveOut.WaveFormat = new WaveFormat(8000, 16, 1);

_WaveOutCollection.Add(i, waveOut); // add the waveOut object into a container to be use later in playing sound
}

}


// This function will be use on playing the received voice buffer from 4 different input source to 4 different output devices

private void PlaySound(byte[] buffer, int deviceNumber)
{
IWaveProvider waveProvider = new BufferedWaveProvider();
waveProvider.AddSamples(buffer, 0, buffer.Length);

WaveOut waveOut = null;
if (_WaveOutCollections.TryGetValue(deviceNumber, out WaveOut))
{
if (waveOut!=null)
{
waveOut.Init(waveProvider); // The Error happens on the 4th initiating....

if (waveOut.PlayBackState != PlayBackState.Playing)
waveOut.Play();

}
}
}



I traced the error it happen on interop call on winmm.dll at "WaveInterop.cs", The Error result is "UnSpecified Error"

[DllImport("winmm.dll")]
public static extern MmResult waveOutOpen(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
[DllImport("winmm.dll", EntryPoint = "waveOutOpen")]
public static extern MmResult waveOutOpenWindow(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, IntPtr callbackWindowHandle, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);



thanks,

Comments: sounds like an issue with your soundcard drivers

Commented Unassigned: initiating 4 different waveout for 4 difference output device [16437]

$
0
0
hi,

i got an issue on initiating 4 difference waveout for 4 different output devices.
The initiation of the waveout failed on the 4th call. Here is the code

Dictionary<int, WaveOut> _WaveOutCollections = null;


// Init the 4 output device, and assign to a difference output device
private void InitDevice()
{

_WaveOutCollections = new Dictionary<int, WaveOut>();

for (int i = 0; i< 4;i++)
{
WaveOut waveOut = new WaveOut();
waveOut.deviceNumber = i; // Assign to a different device number
waveOut.WaveFormat = new WaveFormat(8000, 16, 1);

_WaveOutCollection.Add(i, waveOut); // add the waveOut object into a container to be use later in playing sound
}

}


// This function will be use on playing the received voice buffer from 4 different input source to 4 different output devices

private void PlaySound(byte[] buffer, int deviceNumber)
{
IWaveProvider waveProvider = new BufferedWaveProvider();
waveProvider.AddSamples(buffer, 0, buffer.Length);

WaveOut waveOut = null;
if (_WaveOutCollections.TryGetValue(deviceNumber, out WaveOut))
{
if (waveOut!=null)
{
waveOut.Init(waveProvider); // The Error happens on the 4th initiating....

if (waveOut.PlayBackState != PlayBackState.Playing)
waveOut.Play();

}
}
}



I traced the error it happen on interop call on winmm.dll at "WaveInterop.cs", The Error result is "UnSpecified Error"

[DllImport("winmm.dll")]
public static extern MmResult waveOutOpen(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
[DllImport("winmm.dll", EntryPoint = "waveOutOpen")]
public static extern MmResult waveOutOpenWindow(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, IntPtr callbackWindowHandle, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);



thanks,

Comments: im using realtex high definition audio, it is a onboard sound card, do u how to check the maximum that this driver can create an instance of WaveOutOpen... is there any testing tool out there... thanks,

Commented Unassigned: WaveViewer and 24bit wavs [16438]

$
0
0
Maybe a stupid question but can the WaveViewer control display 24 bit wav files ?
I am doing this:

WaveViewer1.SamplesPerPixel = 400
Dim fr = New NAudio.Wave.WaveFileReader(filename)
WaveViewer1.WaveStream = fr

If filename is a file with 16bit depth (or lower), everything works fine. If the file is above 16bit, I think that the values becomes too big and verticaly the whole control is drawn.

Any help?
Comments: Thank you for your replying Mark. Just let me tell you that I have already started to change the WaveViewer control in order to be able to draw 24 bit waves and I think I'm getting near. In any case, what is the equivalent control for WaveViewer in the demo apps ? Because in the demo I have only seen the WaveFormPainter which does not cover my need (I need to display the wave at once not while it plays). If I am missing something please correct me.

Commented Unassigned: WaveViewer and 24bit wavs [16438]

$
0
0
Maybe a stupid question but can the WaveViewer control display 24 bit wav files ?
I am doing this:

WaveViewer1.SamplesPerPixel = 400
Dim fr = New NAudio.Wave.WaveFileReader(filename)
WaveViewer1.WaveStream = fr

If filename is a file with 16bit depth (or lower), everything works fine. If the file is above 16bit, I think that the values becomes too big and verticaly the whole control is drawn.

Any help?
Comments: I never use WaveViewer myself, I always write my own control that matches what my requirements are. Sometimes I want scrolling, sometimes I want zooming etc. So WaveViewer was only ever intended to be a simple example. I do have a couple of other WaveForm drawing control that I may make part of the NAudio demo apps at some point in the future.
Viewing all 738 articles
Browse latest View live


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