there is no effects framework per se, but the ISampleProvider interface is designed to make it as easy as possible to implement one. Just implement ISampleProvider, and in the Read method, you can do whatever DSP you like on the samples you read out of your source sample provider.
New Post: Which version of NAudio should I use to introduce the "effects and effectstream" code used for the Skype Voice changer
New Post: NAudio 1.6 on .Net 4.0 framework
Hi Mark,
I re-built the NAudio 1.6 source code to target .Net 4.0 Client Profile. The build succeeded with no errors. My app seems to run fine with 4.0 as the target .Net framework.
Are there any gotchas you are aware of with running NAudio with .Net 4.0 ? I'd prefer not to require users to install multiple .Net versions. The app runs on Windows 8/7/Vista/XP.
I only rebuilt these two assemblies, not the whole NAudio solution or demos.
NAudio.dll
NAudio.WindowsMediaFormat.dll
New Post: Mic input to effectStream Output
Thank you for advise to modify. Now I can take an IWaveProvider into EffectStream but it have warning about effects have null parameter when I click play Mic input it had show error about effects. Please help me to take effect pass Mic real-time and show me for example to take Mic input pass effectStream. Because I have dead line to present project on 8 Feb but now it have problem. Thank you very much.
public class EffectStream : IWaveProvider
{
private EffectChain effects;
public IWaveProvider sourceIn;
private object effectLock = new object();
private object sourceLock = new object();
public EffectStream(EffectChain effects, IWaveProvider sourceStreamIn)
{
this.effects = effects;
this.sourceIn = sourceStreamIn;
//effects have null
foreach (Effect effect in effects)
{
InitialiseEffect(effect);
}
}
New Comment on "MP3"
New Post: NAudio 1.6 on .Net 4.0 framework
New Post: NAudio 1.6 on .Net 4.0 framework
BTW, my integration project with NAudio is almost complete. It's working and sounding great!! And the coding is 10 times eaiser than DirectSound. I can't wait to get rid of DirectSound as a pre-req. Most potential users don't have DirectX 9.0c installed and just give up immediately. Thanks to you and your compadres for your excellent work. You guys rock. I'll be sending a donation as soon as I get it published.
New Post: NAudio 1.6 on .Net 4.0 framework
Mark
New Post: NAudio 1.6 on .Net 4.0 framework
New Post: NAudio Error question
Can you make a simple mixing example with two wave file so when you press a button or something to mix the both sounds ?
New Post: How to increase or decrease Gain of a audio track ?
Can any one tell me if naudo have the option for increasing or decreasing Gain of a wav file? if yes, then let me know how?
New Post: How to increase or decrease Gain of a audio track ?
I guess you want to control the playback volume? If you use WaveOut you can easily control it with something like this:
WaveOut.Volume = 20
This would e.g. set a volume of 20%.New Post: NAudio API Programmers Guide.
The tutorials are great for getting started. But in some cases I just copied code from a sample not knowing what the values really mean to performance, memory usage, etc.
And if it is a wiki style, discussion members could contribute to it and correct it overtime.
Most importantly it would free up more of Mark's time to do coding rather than answering the same newbie questions for the millionth time. :-)
Just my 2 cents.
New Post: Get/access excact peak levels -> Stuck in no mans land -> but yet so close :-/
while (wave.Position < wave.Length)
{
wPosTilSecs = Convert.ToInt32(Math.Round(Convert.ToDouble(wave.Position / 88723)));
read = wave.Read(buffer, 0, 8192);
for (int i = 0; i < read / 4; i++)
{
if (i < 5000){
chart1.Series["wave"].Points.Add(BitConverter.ToSingle(buffer, Convert.ToInt32(Math.Round(secondCounter*10))));
chart1.Series["wave"].Points.Add(BitConverter.ToSingle(buffer, i*4));
}
areal += buffer[i];
if (buffer[i] > 4)
{
if (areal > 196000)
{
peaker +=1;
}
}
if (i % 512 == 0) { secondCounter += 0.0057305; optaellerIbyteCycles = 0; Console.WriteLine("sec: " + secondCounter);
}
if (i%32==0) {
if (BitConverter.ToSingle(buffer, i * 4) > 0.04 || BitConverter.ToSingle(buffer, i * 4)< 0.01)
{
sw.Write("Y-value PEAK?: " + BitConverter.ToSingle(buffer, i * 4));
sw.Write("\t\n");
sw.Write("sec PEAK?:: " + secondCounter.ToString());
sw.Write("\t");
}
else {
if (i % 16384 == 0)
{
sw.Write("Y-value no-peak: " + BitConverter.ToSingle(buffer, i * 4));
sw.Write("\t\n");
sw.Write("sec no-peak: " + secondCounter.ToString());
sw.Write("\t");
}
}
peaker = 0;
}
}
areal = 0;
textBox1.Text = Convert.ToString(countPeaks);
textBox2.Text = Convert.ToString(wp);
}
The line: if (BitConverter.ToSingle(buffer, i * 4) > 0.04 || BitConverter.ToSingle(buffer, i * 4)< 0.01)
- is the core to the solver, as the waveform I was drawing with the MS Visual Studio standard chart showed a the confusing range og -1 to 1. The 'buffer' variable outputs values from 0.003 to 0.098 (I did not see that range from buffer earlier, and I just had to amp up the detail via a txt-stream to a notepad-file in order to discover it -> otherwise my small induvidual wave-inputs did not show over a time period of 5-6 secs.)
New Post: How to increase or decrease Gain of a audio track ?
Is it possible to find the gain of a particular wav file...
Regards,
Hinshin
New Post: Audio stops playing with Wasapi driver
One some machines, the playback stops playing randomly - there is no error or exception, but I can see that a native thread is exiting with error 0 when the playback halts.
NAudio doesn't report back about a failure.
I managed to replicate this consistently, it happens with many different test cases. Important to note that an another machine (also Windows 7 Pro 64 bit) none of these issues ever happen.
So I suspected it was the sound driver and/or card.
One of the weird ways to reproduce the issue, was to run in debug mode then simply set a break point anywhere in the code in VS.NET Express, not even in a running place that triggers the break point. That would break the audio playback immediately and kill the thread !!??!!
I currently use the driver WasapiOut, and I simply changed it to WaveOut.
Now the problems never replicate.
This is the WasapiOut creation, latency was set to 125msec:
m_waveOutDevice = new WasapiOut(global::NAudio.CoreAudioApi.AudioClientShareMode.Shared, m_latency);
And the WaveOut creation:
m_waveOutDevice = new WaveOut();
I guess I can stay with WaveOut for now, but I don't like this workaround.
With DirectSoundOut I had different issues in the past, it would also get stuck occasionally
Audio initialization processing is running on a non UI thread.
Any ideas?
New Post: Convert WaveStream to double-array (or apply FFT directly)
I think I'm already doing something wrong when reading the bytestream from the mp3-file. Can you confirm that instead of byte[8] I have to use byte[16] as buffer since I'm reading 16 bit audio?
using (Mp3FileReader mp3 = new Mp3FileReader(filename))
{
//Convert byte- to double-array
double[] real = new double[mp3.Length / 8];
byte[] buffer = new byte[8];
int read;
int count = 0;
while ((read = mp3.Read(buffer, 0, buffer.Length)) > 0)
{
real[count] = BitConverter.ToInt16(buffer, 0) / 32768.0;
count++;
}
//Seperate to mono
double[] mono = new double[real.Length / 2];
for (int i = 0; i < real.Length; i += 2)
{
mono[i / 2] = real[i];
}