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

Created Issue: heap corruption for MixerControl.GetControlDetails when MIXERCONTROL_CONTROLF_MULTIPLE flag is set. [16390]

$
0
0
According to msdn, the size of the MIXERCONTROLDETAILS.paDetails buffer should be:

_For MIXERCONTROL_CONTROLF_MULTIPLE controls, the size of this buffer should be the product of the __cChannels, cMultipleItems and cbDetails__ members of the MIXERCONTROLDETAILS structure. For controls other than MIXERCONTROL_CONTROLF_MULTIPLE types, the size of this buffer is the product of the cChannels and cbDetails members of the MIXERCONTROLDETAILS structure._

But the buffer size is now calculated as: __mixerControlDetails.cbDetails * mixerControlDetails.cChannels__
This will make the mixerGetControlDetails method to write beyond the allocated memory, and thereby corrupting the heap.

Attached is a patch file that will calculate the buffer size correctly.

Edited Issue: heap corruption for MixerControl.GetControlDetails when MIXERCONTROL_CONTROLF_MULTIPLE flag is set. [16390]

$
0
0
According to msdn, the size of the MIXERCONTROLDETAILS.paDetails buffer should be:

(http://msdn.microsoft.com/en-us/library/dd757294(v=vs.85).aspx)
_For MIXERCONTROL_CONTROLF_MULTIPLE controls, the size of this buffer should be the product of the __cChannels, cMultipleItems and cbDetails__ members of the MIXERCONTROLDETAILS structure. For controls other than MIXERCONTROL_CONTROLF_MULTIPLE types, the size of this buffer is the product of the cChannels and cbDetails members of the MIXERCONTROLDETAILS structure._

But the buffer size is now calculated as: __mixerControlDetails.cbDetails * mixerControlDetails.cChannels__
This will make the mixerGetControlDetails method to write beyond the allocated memory, and thereby corrupting the heap.

Attached is a patch file that will calculate the buffer size correctly.

New Post: MIDI Bank Select

$
0
0
Does anyone know how to do a "Normal" Bank select in code?

I can do a Controller 0 select:
ControlChangeEvent BSelect = new ControlChangeEvent(AbsoluteTime, Channel, (MidiController)0, BankNumber);

And a Controller 32 works the same way.

But the "Normal" method eludes me. I've seen conflicting expanations of it, but the latest was "send a 0 and Bank number, then a 32 and Patch number. I tried

ControlChangeEvent BSelect1 = new ControlChangeEvent(AbsoluteTime, Channel, (MidiController)0, BankNumber);
Tracks.AddEvent(BSelect1, TrackNumber);
ControlChangeEvent BSelect2 = new ControlChangeEvent(AbsoluteTime+1, Channel, (MidiController)32, PatchNumber);
Tracks.AddEvent(BSelect2, TrackNumber);

but that didn't work.

Any ideas?

Source code checked in, #994ce9aace97

Source code checked in, #6f1b14b12d0d

$
0
0
updating for a new nuget pre-release

Source code checked in, #a2092ffde43a

$
0
0
fixing issue 16390, correctly allocating size for MixerControl.GetControlDetails. Thanks to owoudenb

Edited Issue: heap corruption for MixerControl.GetControlDetails when MIXERCONTROL_CONTROLF_MULTIPLE flag is set. [16390]

$
0
0
According to msdn, the size of the MIXERCONTROLDETAILS.paDetails buffer should be:

(http://msdn.microsoft.com/en-us/library/dd757294(v=vs.85).aspx)
_For MIXERCONTROL_CONTROLF_MULTIPLE controls, the size of this buffer should be the product of the __cChannels, cMultipleItems and cbDetails__ members of the MIXERCONTROLDETAILS structure. For controls other than MIXERCONTROL_CONTROLF_MULTIPLE types, the size of this buffer is the product of the cChannels and cbDetails members of the MIXERCONTROLDETAILS structure._

But the buffer size is now calculated as: __mixerControlDetails.cbDetails * mixerControlDetails.cChannels__
This will make the mixerGetControlDetails method to write beyond the allocated memory, and thereby corrupting the heap.

Attached is a patch file that will calculate the buffer size correctly.

New Post: MIDI Bank Select

$
0
0
If you are able to find or create a MIDI file that contains a correct bank change, then you can use NAudio to read it and see what messages it contains

New Post: MIDI Bank Select

$
0
0
markheath wrote:
If you are able to find or create a MIDI file that contains a correct bank change, then you can use NAudio to read it and see what messages it contains
I'll see what I can find. Thanks.

But I think the mistake I made is not doing an atual PatchChange event after the 0 & 32.

New Post: Get a Stream from WaveIn

$
0
0
I don't figure out how to get a Stream from WaveIn.

This stream is needed for this method: System.Speech.SpeechRecognitionEngine.SetInputToWaveStream(Stream in)

Msdn says
"A valid Stream instance connected to an audio source in Wave format.
If the recognizer reaches the end of the input stream during a recognition operation, the recognition operation finalizes with the available input."

So i'd like to prevent recoengine to reach the end of the stream.

Do you think it is possible?
But my main question still : how to get a Stream from waveIn, i didn't found sample or doc regarding this.

New Post: SOLVED! It wasn't NAudio.

$
0
0
I've developed a recorder/player using NAudio, the problem that I'm having is that I can only record for 1 minute and about 43 seconds continuously. I would like to know how to remove this time limit or increase the recording time. I'll appreciate any help.

New Post: SOLVED! It wasn't NAudio.

$
0
0
what happens after 1 minute and 43 seconds? There is no limit built into NAudio

New Post: SOLVED! It wasn't NAudio.

$
0
0
Im getting an exception on the following method after a 1:43 recording.
    private void SourceStream_DataAvailable(object sender, WaveInEventArgs e)
    {
        try
        {
            if (WaveWriter != null)
            {
                WaveWriter.Write(e.Buffer, 0, e.BytesRecorded);
                int secondsRecorded = (int)(WaveWriter.Length / WaveWriter.WaveFormat.AverageBytesPerSecond);
                recordingProgressBar.Value = secondsRecorded;
                WaveWriter.Flush();
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("An error occurred." + ex.Message, "Audio File Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }

ArgumentOutOfRange Exception:

Value of '101' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.
Parameter name: Value

New Post: SOLVED! It wasn't NAudio.

$
0
0
that's your progress bar. Don't set it to a value greater than maximum. Or don't use a progress bar.

New Post: SOLVED! It wasn't NAudio.

$
0
0
Im getting an exception on the following method
    private void SourceStream_DataAvailable(object sender, WaveInEventArgs e)
    {
        try
        {
            if (WaveWriter != null)
            {
                WaveWriter.Write(e.Buffer, 0, e.BytesRecorded);
                int secondsRecorded = (int)(WaveWriter.Length / WaveWriter.WaveFormat.AverageBytesPerSecond);
                recordingProgressBar.Value = secondsRecorded;
                WaveWriter.Flush();
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("An error occurred." + ex.Message, "Audio File Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }

ArgumentOutOfRange Exception:

Value of '101' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.
Parameter name: Value


New Post: SOLVED! It wasn't NAudio.

$
0
0
Man, I just found out. I was about to leave you a comment telling yo to forget about it...shame on me!!!! I've been trying to figure out since yesterday. I thought it was the library. Thank you anyways. Sometimes we have the problem in our face and we don't see it. Thank you so much for the help anyways.

New Post: Generating random numbers using NAudio

$
0
0
Here is some C# source code that can be used to generate random 32-bit unsigned integers.

http://pastebin.com/vmhGzKP7

It could form the basis for an official NAudio method - assuming that such a method does not already exist.

~~
Clive Tooth

New Post: How can I select the output device with NAudio

$
0
0
Hi,
I am able to select the input device, eg. one of four microphones with the input deviceNumber:
sourceStream.WaveFormat = new WaveFormat(44100,   WaveIn.GetCapabilities(deviceNumber).Channels);
But how can I also select the output device (e.g. one of four speakers) ?
      public void StartMicro(int deviceNumber)
      {
         sourceStream = new WaveIn();
         sourceStream.DeviceNumber = deviceNumber;
         sourceStream.WaveFormat = new WaveFormat(44100,    WaveIn.GetCapabilities(deviceNumber).Channels);

         waveIn = new WaveInProvider(sourceStream);
         waveOut = new DirectSoundOut();
         waveOut.Init(waveIn);

         sourceStream.StartRecording();
         waveOut.Play();
      }
Right now it takes only the default output device (speaker). I have chosen the DirectSoundOut Api for the output device because of less latency as against the WaveOut device. I have already the device number for my output device. But how can I select with the device number (index) the output device ?

It must be like this:
waveOut = new DirectSoundOut(outDeviceNumber);
but it doesn't work.

Regards,
Lestan

New Post: Generating random numbers using NAudio

$
0
0
hi, that's certainly an interesting approach to creating random numbers. I would be worried that a soundcard with a noise gate would end up creating a sequence of all 0 values. It's not really the type of feature that I would include in NAudio, as NAudio is focused on audio tasks rather than general programming utilities, but thanks for sharing your code.

best regards

Mark

New Post: Convert WaveIn buffer to PCM integers

$
0
0
Hello,
Writing NAudio.Wave.WaveInEventArgs buffer to new byte array, then (attempting to)convert those elements to PCM values via BitConverter.ToInt16. However, the signal is littered with peaks and noise. When I dumped into excel to view output from converted array(just recorded single tone) it had the semblence of correct sine wave/frequency buried amidst all sorts of errant samples. (I also tried reversing to account for endianess). When I choose WaveFileWriter and render as .wav, it sounds perfect. So something is getting lost in translation.

What object would convert the buffer to Linear PCM samples?

Thank You
Viewing all 5831 articles
Browse latest View live


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