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

New Post: ISampleProviders .read returned float[] array values tiny

$
0
0
I'm trying to sample playing audio in order to chart it. When I play the file I hear the audio well but the float array that is coming out is, I think, wrong. The values are all tiny. Any ideas what I am doing wrong?
 private void WavOutChartTimeInterrupt(object waveReader)
        {
            lock (AudioLock) //todo add skipto code, use audio lock to do it.
            {
                try
                {
                    var curPos = _waveOut.GetPositionTimeSpan(); //get currentPos
                    if (curPos <= AudioCurrentPosition)
                    {
                        AudioCurrentPosition = curPos;
                        return;
                    }
                    var bufferLength = (curPos - AudioCurrentPosition);
                    var blockAlign = _waveOutSampleProvider.WaveFormat.BlockAlign;
                    var samplesSec = _waveOutSampleProvider.WaveFormat.SampleRate;
                    var channels = _waveOut.OutputWaveFormat.Channels;
                    var length = (int)(bufferLength.TotalSeconds * samplesSec * channels) % (samplesSec * channels);//(samplesSec * channels);
                    length -= length % (blockAlign / channels);
                    var wavOutBuffer = new float[length];
                    _waveOutSampleProvider.Read(wavOutBuffer, 0, length);
                    _audioCharter.ProcessBuffer(wavOutBuffer);
                    AudioCurrentPosition = curPos; //update for vCNC with where we are
                }
                catch (Exception e)
                {
                    throw new ArgumentException(@"Wave out buffer crashed" + e + e.StackTrace);
                }
            }
        }
Image

New Post: ISampleProviders .read returned float[] array values tiny

$
0
0
Nope I think this is all bollocks, but I'll leave it here in case it's usefull:

I think I might have solved this, not sure, seems a little off. I know the float array is based on the original wave stream which is a stream of bytes.

From the waveIn stream I normally get values of up to about 20 000.

20 000 in binary is 01001110 00100000,

Now expand that out to 32 bits and you get 00000000 00000000 01001110 00100000

and that is 0.00238... which is the sort of numbers that I am seeing. <- This is actually the Mantissa or something value

Is that what's happening? I'll do a bit more digging and see if it adds up.

New Post: Audacity pan

$
0
0
Pan property is of float type. in this case it is used from -1.0f(left) to +1.0f (right).

Created Unassigned: support for CD-Audio in AudioFileReader [16507]

$
0
0
Hello,

I think it is impossible right now to read the samples of CD-Audio disc.

I suggest to add the support for the AudioFileReader.

New Post: No data from usb device

$
0
0
to check the data arrival from auiod usb device (for example tascam us-600, zoom h2n) I subscribe to event AudioAvailable of AsioOut
but sometimes data not recived long time only helps to reconnect device to usb

anybody help me?

PS: I am using Windows 8.1

New Post: To Achieve draw wave form from speaker outputs

$
0
0
Hi,

i have develop winfrom application using media file, recording and editing with wave form.
receiving input through microphone is possible draw wave form the same not possible when tried to record output of a system (Speakers) find the below code and suggest better way to achieve the same.
Mic codes used:

private void RecorderOnDataAvailable(object sender, WaveInEventArgs waveInEventArgs)
{
try
{
bufferedWaveProvider.AddSamples(waveInEventArgs.Buffer, 0, waveInEventArgs.BytesRecorded);
byte[] waveData = new byte[100 * Bytes_Per_Sample1];
short low = 0;
short high = 0;
for (int n = 0; n < waveInEventArgs.BytesRecorded; n += 2)
{
short sample = BitConverter.ToInt16(waveInEventArgs.Buffer, n);
if (sample < low)
low = sample;
if (sample > high)
high = sample;
}
float lowPercent = ((((float)low) - short.MinValue) / ushort.MaxValue);
float highPercent = ((((float)high) - short.MinValue) / ushort.MaxValue);
g.DrawLine(Draw_lIne, d, Wave_Control_Main_Player.Height * lowPercent, d, Wave_Control_Main_Player.Height * highPercent);
d++;
if (d == Wave_Control_Main_Player.Width)
{
Wave_Control_Main_Player.Invalidate();
d = 0;
}
}
Used for capturing:
WasapiLoopbackCapture class used to get the output sounds.


public void OnDataAvailable(object sender, WaveInEventArgs e)
{
_writer.Write(e.Buffer, 0, e.BytesRecorded);
//byte[] waveData = new byte[100 * Bytes_Per_Sample1];
//short low = 0;
//short high = 0;
//stream.Read(waveData, 0, waveData.Length);
//for (int n = 0; n < waveData.Length; n += 8)
//{
// short sample = BitConverter.ToInt16(waveData, n);
// if (sample < low) low = sample;
// if (sample > high)
// high = sample;
//}
//float lowPercent = ((((float)low) - short.MinValue) / ushort.MaxValue);
//float highPercent = ((((float)high) - short.MinValue) / ushort.MaxValue);
//g.DrawLine(Draw_lIne, d, Wave_Control_Main_Player.Height * lowPercent, d, Wave_Control_Main_Player.Height * highPercent);
//d++;
//if (d == Wave_Control_Main_Player.Width)
//{
// Wave_Control_Main_Player.Invalidate();
// d = 0;
//}
}

Created Unassigned: IWavePlayer not CLS compliant [16508]

$
0
0
To use `IWavePlayer` in a unit test library, it is desirable for it to be marked with `[CLSCompliant(true)]`.

Created Unassigned: Please sign NAudio [16509]

$
0
0
I would really be happy, if NAudio was a signed DLL. It is used by many, and a signed DLL cannot use an unsigned one, so you're forcing people to not sign their DLLs, or to download the source code.

It should give no problems to the existing users, as an unsigned DLL can use a signed DLL. Pretty please?

New Post: 5.1 playback with Naudio?

$
0
0
Hi guys,
is it possible to play 5.1 audio files with Naudio?
I'm getting an exception at
outputDevice.Init(mixer); 
step if trying to set channelCount = 6 creating WasapiOut or WaveOut instance.

System.ArgumentException was unhandled
HResult=-2147024809
Message=Value does not fall within the expected range.
Source=mscorlib
StackTrace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at NAudio.Wave.WasapiOut.Init(IWaveProvider waveProvider)
at NAudio.Wave.WaveExtensionMethods.Init(IWavePlayer wavePlayer, ISampleProvider sampleProvider, Boolean convertTo16Bit)....

Kind regards,
Andrei

New Post: 5.1 playback with Naudio?

$
0
0
Some hardware and driver (Asio?) might support that, but not always. When you want to ensure playback, then mix the samples to 2 channels.

New Post: Recording does not start while there is no audio signal

$
0
0
Seems to be a driver limitation.

You could try to manually create a silent sample buffer and write it to the output file when the
WaveInEventArgs.BytesRecorded property contains 0
Alternatively, grab the NAudio WasapiLoopbackCapture source and experiment with it.

New Post: 5.1 playback with Naudio?

$
0
0
But I need at least 4 channels to play.

New Post: 5.1 playback with Naudio?

$
0
0
Then you could try with Asio and ship asio drivers with your assembly.

New Post: 5.1 playback with Naudio?

$
0
0
OK. Thank you.
I will try with Asio drivers.

Commented Unassigned: IWavePlayer not CLS compliant [16508]

$
0
0
To use `IWavePlayer` in a unit test library, it is desirable for it to be marked with `[CLSCompliant(true)]`.

Comments: I don't understand why this would be the case. I have a large suite of unit tests for NAudio.

Commented Unassigned: support for CD-Audio in AudioFileReader [16507]

$
0
0
Hello,

I think it is impossible right now to read the samples of CD-Audio disc.

I suggest to add the support for the AudioFileReader.
Comments: I'm afraid this is not something I have plans to support in NAudio at the moment. I am happy to accept pull requests though

Closed Unassigned: Range for PitchWheelChangeEvent.Pitch should be 0-16383 [16485]

$
0
0
I think I found a small bug in NAudio.Midi.PitchWheelChangeEvent:

The Pitch property accepts values up to (and including) 16384.
If, however, I create the event with that maximum value, the bit-shifting part in GetAsShortMessage() comes out as 0:
```
Console.Write( ((16384 & 0x7f) << 8) + (((16384 >> 7) & 0x7f) << 16) ); //-> 0
```

I believe the maximum value should actually be 16383.

(The reason I noticed this is because the Mackie Control I work with uses PitchWheel events for its faders and when I programmatically move the fader to its top position, it always goes to the bottom.)

New Post: 5.1 playback with Naudio?

$
0
0
It works now with AsioOut. Thank you Freefall !
I wonder are there any limitations of using Naudio AsioOut in a payware project related to Steinberg property right.
Can't see nothing about that in Naudio license.

Created Unassigned: Mp3FileReader not in NAudio.Wave namespace [16510]

$
0
0
I'm trying to process an mp3 stream (from the microphone) in memory, without disk I/O, in a Windows Store app. I installed the NuGet package NAudio v1.8.0 but the Mp3FileReader class is not in the namespace NAudio.Wave. Should I be using some other function in this environment?

Commented Unassigned: Mp3FileReader not in NAudio.Wave namespace [16510]

$
0
0
I'm trying to process an mp3 stream (from the microphone) in memory, without disk I/O, in a Windows Store app. I installed the NuGet package NAudio v1.8.0 but the Mp3FileReader class is not in the namespace NAudio.Wave. Should I be using some other function in this environment?

Comments: `Mp3FileReader` is not available in Windows Store apps as it calls into APIs that are not permitted in that context.
Viewing all 5831 articles
Browse latest View live


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