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

Commented Unassigned: Occasional AccessViolation in WDMAUD.DRV [16396]

$
0
0
Under load, I am getting an occasional AccessViolation in WDMAUD.DRV, and my application is crashing.

Comments: We are creating a new WaveIn object each time we start a recording. When we stop a recording we: * Call StopRecording() * Get and Write the remaining buffer to file * dispose the WaveIn * dereference the WaveIn There are no codecs involved.

New Post: Playing musical notes

$
0
0
Hi to everybody, I’m new in sound applications and I’m not sure if NAudio is the right choice for me.
I need to play musical notes (single at the moment but probably not in the future) with different instruments when the user push the pc keyboard buttons, through the pc sound card.
I don’t know if the best choice is NAudio or another library (I use VS C#), could someone help me?

Thank you

New Post: Wav file is corrupted - Flush vs Close

$
0
0
Hi!
When i'm recording mic and just flush wavWriter after each DataAvalible call i get corrupted wav file:

writerSound.Write(e.Buffer, 0, e.BytesRecorded);
writerSound.Flush();


But when i call .Close when my form is closing then wav file is working.
Problem is that my form process can be killed, it's possible to do Flush works?

New Post: Wav file is corrupted - Flush vs Close

$
0
0
You need the Close because it has to update the size of the data chunk in the headers. I suppose this might be a useful feature to consider for a future NAudio version.

New Post: Wav file is corrupted - Flush vs Close

$
0
0
Ok, when i'm don't closing wav file there are fmt chunk missing.
Maybe it's possible to fix that wav file using Naudio?

New Post: Wav file is corrupted - Flush vs Close

$
0
0
yes, its the chunk header sizes that aren't filled in

New Post: Playing musical notes

$
0
0
You can use NAudio to do this. Easiest route if you are a beginner to sound programming would be to have a separate WAV file for each note.

Commented Unassigned: Trying to change volume [16395]

$
0
0
Im pretty new to Naudio, and im trying to change the volume of my DirectSoundOut

When i try to change it nothing happens even if i pause and play the song again

dim stream As NAudio.Wave.BlockAlignReductionStream = Nothing
dim output As DirectSoundOut = New DirectSoundOut()

Public Sub volume(ByVal vol_in As Single)
output.Volume = vol_in
End Sub

Comments: What version of NAudio are you using? In the latest you can't set the DirectSoundOut volume property as it simply doesn't work properly. The recommended way is to adjust the values of your samples. Or use WaveOut instead.

Commented Unassigned: Occasional AccessViolation in WDMAUD.DRV [16396]

$
0
0
Under load, I am getting an occasional AccessViolation in WDMAUD.DRV, and my application is crashing.

Comments: if you are able to create a short code sample that can reproduce this issue, I may try to reproduce it.

New Post: Using a low-pass filter...

$
0
0
You'd need to pass the audio through a low pass filter. The route I would take is a BufferedWaveProvider, converted to a SampleProvider (i.e. go 32 bit), then through the BiQuad filter. I'm hoping that a future NAudio will make this a bit more straightforward to setup. but if you understand audio pipelines, you should be able to do this.

Closed Issue: Whole MF Encoder does not work [16382]

$
0
0
If I encode any file to any format using your encoder in the wpf sample on win8x64 prof. it fails. If I play the file there is just a strange noise. And on some targetformats there is an Exceptoin in MediaFoundationEncoder::PerformEncoder in line writer.BeginWriting();
Comments: with no further diagnostic information, we'll close this

Closed Issue: WasapiLoopbackCapture doesn't capture silence [16383]

$
0
0
Description:
When recording using WasapiLoopbackCapture, if all audio inputs go silent then the data available callback always returns 0 bytes recorded. This means that if you are recording to a file and you play one sound, it will record it, but then if you allow 10 seconds of silence in between and then play another sound, in the audio file the two sounds will appear right next to each other (without the 10 second silence).

Expected:
Silence should be included as data, even if it's empty data.

Repro:
1. Create a WasapiLoopbackCapture.
2. Register a DataAvailable callback and print out bytes received in callback
3. Call StartRecording
4. Turn off all audio
Note: Does not always occur, sometimes silence is recorded.

Other:
The silence case was also mentioned here: http://naudio.codeplex.com/discussions/203605
I looked into the code, it seems to be occurring in 'ReadNextPacket' where capture.GetNextPacketSize(); always returns 0 during silence, instead of returning a non-zero value and setting the silence flag. Not sure how to fix this :/
Comments: Closing this because it is a limitation of WASAPI Loopback Capture, not NAudio. Workaround is to play silence

Closed Issue: AddTrack [16336]

$
0
0
I noticed what looks like odd behavior while using the AddTrack() method... I might be misunderstanding how to use it but here is some brief debug code to illustrate the situation:

{{
MidiEventCollection collection = new MidiEventCollection(1, PulsesPerQuarterNote);

collection.AddTrack();
collection.AddEvent(new NoteEvent(1, 1, MidiCommandCode.NoteOn, 60, 100), 0);
collection.AddEvent(new NoteEvent(300, 1, MidiCommandCode.NoteOff, 60, 0), 0);


collection.AddTrack();
collection.AddEvent(new NoteEvent(1, 2, MidiCommandCode.NoteOn, 60, 100), 1);
collection.AddEvent(new NoteEvent(300, 2, MidiCommandCode.NoteOff, 60, 0), 1);

collection.AddTrack();
collection.AddEvent(new NoteEvent(1, 3, MidiCommandCode.NoteOn, 60, 100), 3);
collection.AddEvent(new NoteEvent(300, 3, MidiCommandCode.NoteOff, 60, 0), 3);


collection.PrepareForExport();
}}

After running AddTrack() for the first time, the Tracks property of collection increments to 1.

then after running AddEvent(..., 0), the Tracks property of collection increments to 2, but the notes are added to Track 1.
I would have expected the noteEvents to be added to Track 0 as specified as a parameter in the AddEvent(...., 0) method.

is there no Track 0?

Also, I would not have expected the Tracks property to increment when using AddEvent.


Proceeding, AddTrack is run a second time, the Tracks property increments to 3. (this behavior seems expected)
Running AddEvent(...,1) twice specifying destination Track as 1 results in 2 more note events added to Track 1 (this behavior seems expected).

Then AddTrack is run a third time, the Tracks property increments to 4. (this seems expected)
Running AddEvent(...,3) twice specifying destination Track as 3 results in 2 notes added to Track 3 (this seems expected).

After running prepare for export, there are only 2 tracks instead of 3 (as intended).
And there are 2 notes that I tried to put on track 0 that wound up on track 1.

Is this a bug? or am I missing some details of the usage?

Thanks for looking into it.


Comments: GenJerDan is correct. The API could do with improvement as it is not very clear, but I want to be careful not to break existing clients. Close as designed for now, and if someone wants to contribute/propose a better API in the future they can do so

Closed Issue: Crash when changing windows mixer volume [14882]

$
0
0
Hello,

I have an issue with NAudio: in simple application i'm playing for example wav file, and when I change system volume by draggin mixer manually in windows taskbar - application crashes. It doesn't throw an exception, but "stops working", even in debug mode.

Anybody have simple issue and can help?

I'm using DirectSoundOut or WaveOut (function callback).
Code for loading wav file is pasted from one of NAudio samples.

//Update: I'm using NAudio source code 63489

I will really appreciate any feedback. Thanks.

Mike
Comments: probably related to function callback, or dodgy soundcard drivers. Re-open if anyone else reports

Closed Unassigned: Trying to change volume [16395]

$
0
0
Im pretty new to Naudio, and im trying to change the volume of my DirectSoundOut

When i try to change it nothing happens even if i pause and play the song again

dim stream As NAudio.Wave.BlockAlignReductionStream = Nothing
dim output As DirectSoundOut = New DirectSoundOut()

Public Sub volume(ByVal vol_in As Single)
output.Volume = vol_in
End Sub

Comments: Adjusting volume is currently unsupported in DirectSoundOut. Recommendation is to use WaveOut instead

Edited Issue: WasapiCapture not reusable [16341]

$
0
0
I've been writing an app that records chunks of input audio to multiple files, with gaps between, but I discovered that if I try a call sequence which essentially boils down to this:

WasapiCapture client = new WasapiCapture();
// set up output processor for file 1
client.StartRecording();
// wait for end of content for file 1
client.StopRecording();
// set up output processor for file 2
client.StartRecording();





then the second StartRecording() fails inside InitializeCaptureDevice() at the call to audioClient.Initialize()

I was able to work around this by disposing of my WasapiCapture client and constructing a new one each time, because my system load was low enough that I didn't care about the needless thread destroy/create and whatever the overhead of fetching a new IAudioClient
might be. In other circumstances all that unnecessary work might be a problem though.

I see the MS documentation for IAudioClient states that "the client must successfully call
Initialize once and only once to initialize the audio stream between the client and the device" (italics mine), so I'm thinking some strategy where NAudio remembers the WaveFormat it uses in a call to audioClient.Initialize() and on
subsequent calls to InitializeCaptureDevice(), throws if a recording is active, does nothing if the WaveFormat has not changed, or disposes the old audioClient and initializes a new one if the WaveFormat has changed. Doing something like that would probably
also need some modification to CaptureThread so that it didn't exit until the WasapiCapture object is disposed.

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: With NAudio 1.7, MediaFoundationReader can be used instead, and I have done some work to try to workaround threading issues (by recreating the object on the Read thread if necessary)

Edited 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

Closed Issue: BlockAlignReductionStream.Read cannot read large chunks. [16378]

$
0
0
The BlockAlignReductionStream uses a circular buffer to allow unaligned reading from an otherwise block aligned source stream. If the user tries to read more bytes than would fit in the circular buffer, the BlockAlignReductionStream only reads the amount that fits in the circular buffer, but internally advanced the input stream by the actual requested number of bytes. Future read requests will therefore miss a portion of the input stream.

A simple fix would be to clamp the number of bytes read from the input stream to the size of the circular buffer. I could not find the svn url for the source tree or figure out where to submit a patch, so I just attached the modified source file.
Comments: proposed solution could cause problems elsewhere in NAudio, so no plan to fix this at the moment. Recommend not using BlockAlignReductionStream if you want to read large chunks

Closed Issue: (bug changeset 28539) Blockalign in WaveFormatConversionStream [10548]

$
0
0
Great code base - thanks alot for the good work!!

Found a small bug in WaveFormatConversionStream:
<code>
// we have been returned something that cannot be converted - a partial
// buffer. We will increase the size we supposedly read, and zero out
// the end.
sourceBytesRead -= (sourceBytesRead % sourceStream.BlockAlign);
sourceBytesRead += sourceStream.BlockAlign; //<- !!! THIS LINE IS INVALID - it will make the sourceBytesRead go beyond valid data. It can simply be removed
silenceBytes = SourceToDest(sourceStream.BlockAlign);
</code>
Comments: code in question no longer exists
Viewing all 5831 articles
Browse latest View live


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