for 16 bit audio it would be something like this:
void waveIn_DataAvailable(object sender, WaveInEventArgs e) {for (int i = 0; i < e.BytesRecorded; i += 2) {short sampleValue = BitConverter.ToInt16(e.Buffer, i); } }
for 16 bit audio it would be something like this:
void waveIn_DataAvailable(object sender, WaveInEventArgs e) {for (int i = 0; i < e.BytesRecorded; i += 2) {short sampleValue = BitConverter.ToInt16(e.Buffer, i); } }
Hi
I would like to know if NAudio can read MIDI, and if it's possible read the values of each frequency (value of each signal) of this file
I have started with an electronic drum kit project at home and made progress to the point where I have data streaming over serial port from my kit. Now I need to play wav files to represent the drum data.
How do I load multiple wav files and play them back at the same time ? Keep in mind that a relatively long wav could be already playing and I want to play another one (or more) on top of it.
Any info would be appreciated greatly.
NAudio has classes to read MIDI events from standard MIDI files. MIDI events do not contain frequency information, but you can get the Note numbers from the Note On events.
If you have a look at the source code for the WPF Demo app you'll see a drum machine sample app which should give you a good starting point. It uses a MixingSample provider and then inserts the drum hits as new mixer inputs when needed. It automatically removes them as mixer inputs when they finish playing. This approach means you only need to open one sound device.
Ok, and the read of MIDI file is like a WAV or MP3 file ?? or is most complex ... Do iu have examples about it ???
There is a MidiFileReader class you can use. MidiFileMapper is an example of an application that uses it. You should probably also do some reading up on the difference between WAV and MIDI files, as they are very different.
Hi again,
I wanted to share updates and ask some questions :)
Bugs fixed until now:
Screenshots:
As one can see from imdct and onwards small differences are beginning to crop up. I dont know if these are errors or just the result of different implementations (uber optimised vs unoptimised). Would these differences be audible?
I am now stuck at the synthesis filterbank, dont know what is wrong yet :/
Debugging of reordering and MS stereo processing is not done yet because the file i am trying to decode has no short blocks and is stereo, not joint stereo. "RV" in the screenshots are my initials btw :)
Hello,
how can I increase Microphone boost and volume using NAudio library?
Is it possible?
I ran the pre-compiled demo and it look exactly like what i am looking for. Thank you for the info.
I downloaded the demo source, but cannot get it to compile. I get the following error in MediaTypeVieeModel.cs :
using NAudio.MediaFoundation; -- the type or namespace name 'MediaFoundation' does not exist.
Is this in version 1.6 ?
MediaFoundation is new to NAudio 1.7 (still in alpha). It's not part of the drum machine demo though, so you should be able to use that code with 1.6
wow, wish I knew enough about the inner workings of MP3 to be able to offer help with this. Good luck and let us know how you get on
Mark
NAudio does contain wrappers for the Windows mixer... APIs, which in theory can be used for this. In practice, it turns out to be incredibly hard to work out exactly which control you need to adjust for your microphone. What I found was that code which worked on XP wouldn't work on Vista and above. More concerningly, the newer audio APIs (e.g. WASAPI) seem to offer less access to these type of parameters, with Microsoft preferring you to pop open the Windows sound control panel and let the user adjust the settings themselves.
Have a look at my voice recorder app which tries to set the microphone level.
Thank you!
Hello,
I have a question:
I'm using an USB external Sound Card (http://www.sweex.com/en/assortiment/sound-vision/sound-cards/SC016/) and it's SW is not working on one of my PCs(running win XP), so I figured: I want to do a simple application. The main point is to set different volume to each speaker. So when I have 5.1 I'd like to change the volume on each speaker independently(that means control the volume on center speaker, on sub-woofer, etc.). I was able to get this working for a 2 channel output (left and right) but when I plugged 5.1 speakers it controlled them the same(so when I lowered volume for left speaker the surround left went off too, and sub-woofer too).
I used something like this to change the channel volume:
MMDeviceCollection devEnum = DevEnum.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active);
devEnum[3].AudioEndpointVolume.Channels[0].VolumeLevelScalar = (float)trackBar2.Value / 100;
And now the question: Is it even possible to get this done? Or do I need to make my own drivers for this external USB sound card?
Thanks for your answers in advance.
@MrGroovy:
The Hybrid (IMDCT) step is really close, so you may just be using too large of a datatype (NLayer and MPEG dist10 use 32-bit floats, libMAD uses 24-bit fixed point [which has about the same precision]). If that's not it, double-check that you are handling the overlap correctly, then make sure your IMDCT implementation is "correct". I think it's a "standard" 32-point IMDCT...
I *think* your frequency inversion is fine. There aren't enough data points visible in the screenshot to say for sure. It's a pretty simple algorithm, so I don't doubt yours is correct.
The synthesis filterbank is a beast. See http://doru.info/projects/programming/mpeg1l1l2/ for some pretty high-level math describing how to do it. You can also search for the MPEG dist10 source code and use theirs (it's probably the slowest algorithm, but still plenty fast enough for real-time decoding).
There are official test files for MP3 out there. Finding them might be a trick, though...
Whoohoo!!
It works :D:D
So what was the bug? I had found a usefull PDF that contained a formula but it has a flaw in it!
see: http://www.reinverberne.nl/tmp/9_error.png
so small, so deadly
congratulations, a great achievement. what are your plans for this decoder?
Thanks :)
I dont really have plans for it, it is the slowest possible decoder, no optimisations so it cant decode in real time. Maybe i will try to optimise it. Once i cleaned up the source i will share the code somewhere. Maybe blog about it on my site. Right now i am just happy it finally works :))
I haven't personally used the IAudioEndpointVolume interface, but I'd assume you can use this on any OS you can use WASAPI. However, XP does not support WASAPI, so you're options there are very limited.