how to run nAudio on Windows XP? - c#

I am using nAudio on my WPF Application.
I have followed their tutorial on How to play mp3 And everything works fine.
However, in their tutorial they mention :
3) In a method – that only needs to be called once, setup the
waveOutDevice. In this example we will use WASPI – which is available
on Vista and Windows 7. A more detailed discussion on which output
device to chose and when, to come latter
waveOutDevice = new WasapiOut(AudioClientShareMode.Shared, 100);
And for some reason, they didn't discuss on how to do that.
Anyone has a clue?
And if you do know which output device i should use, do i need to check which OS
the user has and set output device accordingly or the one for XP will work on

You basically have four options for playing audio with NAudio:
AsioOut - For most things, ASIO is probably overkill. But if you need very low latency playback, this is your best bet. It requires a sound card with ASIO drivers or the program ASIO4ALL.
DirectSoundOut - Uses DirectX for playback.
WasapiOut - General purpose playback for Vista and Windows 7.
WaveOut - General purpose playback for any version of Windows.
All of them implement IWavePlayer, so once instantiated, using them is pretty much the same for each class - just call Init() and pass in your IWaveProvider. All of them except WasapiOut can be constructed without paramaters, so all you need is:
waveOutDevice = new WaveOut();

Related

Getting the input level of microphone in windows IOT Core UWP

I'm trying to get the actual input volume of a microphone while not recording.
My point is to start recording when sound go up some limit for a while.
I've found the NAudio nuget but it seems that's the wavein class dont exist in UWP.
How can i get the actual input volume of a microphone in c# whitout recording ?
I was looking for the same thing. Did you find anything?
If not, you can check this link
Windows IoT Core : Sensing Sound Levels
https://blog.falafel.com/windows-iot-core-sensing-sound/
It uses following components
1) Electret Microphone Amplifier – MAX9814 with Auto Gain Control
2) MCP3008 – 8 Channel 10-Bit ADC with SPI Interface
3) Pi Cobbler Plus
4) Your existing Raspberry Pi – Windows IoT Core Setup
In case if the above doesn't work try this Youtube URL and it might give you some hint to find the actual code: https://www.youtube.com/watch?v=f3Wt4xpkBYk
I have tried and tested the code as is in my project and it worked. Although there is hardware dependency such as you may need amplifiers to make it accurate otherwise small sounds doesn't work But then amplifiers need to be handled well otherwise smallest sounds make huge difference on the bar. I am trying to modify this to work with any USB microphone or computer so that I don't have to rely on mentioned hardware.

Change system volume in Windows Phone 8

Up until now I thought that changing the system volume from your app is impossible, until recently a new app called Quite Hours (http://www.windowsphone.com/en-us/store/app/quiet-hours/f347a36b-80c0-430f-8631-e55046ee5a2a) actually did just that in a very neat way.
Does anyone please know how to do that programmatically? I tried using the MediaElement or the xna MediaPlayer and the backgroundAudioPlayer and nothing worked. Any help would be appreciated!
Thank you!
The developers of the apps mentioned in the OP were able to change system volume under WP8.0. Apparently whatever method they used has now been disabled under WP8.1. The following apps now display disclaimers that they no longer work on Windows Phone 8.1: Quiet Hours and Volume Manager
They direct to the following page to vote to allow this functionality: Windows Phone Dev User Voice
Additionally please read the following thread on the MSDN forum: MSDN change system volume Windows Phone 8. This functionality was likely achieved using WASAPI (which I have personally tried, and failed, it does not work, comment if you want my code to try it.), or the developers of the volume apps might have had access to AudioClientRestricted.h. If one had that h file, one would have access to system volume under WP8.1, so I somehow doubt the developers used the h file designated for OEMs because it would work un 8.1.
Talking with James Dailey (who works # MSFT) indicates it is technically possible using WASAPI ISimpleAudioVolume If you read # the bottom of that page there is a comment indicating you must use IAudioEndpointVolume
Added note from James Dailey # MSFT:
AFAIK there is no good way to manipulate the global audio level on
Windows Phone 8.1 (WP8.1). Theoretically you can change the audio
volume of any app that uses the default audio session “zero”. However,
if the app chooses to initialize it’s audio session with a custom
GUID you will not have access to the session volume for its custom
audio session. Again this is theoretical based on my knowledge of the
inner workings of WASAPI. I’ve never actually tried it on the phone.
To manipulate the audio volume of apps using audio session “zero” you
simply initialize your IAudioClient with an AudioSessionGuid parameter
of “{00000000-0000-0000-0000-000000000000}”. You can then use
ISimpleAudioVolume::SetMasterVolume to set the volume for this audio
session. You will need to use C++ / Cx since we do not support
calling WASAPI from managed code.
There currently is no API available for controlling the system volume. You can however control the volume in the elements of your application (via the classes MediaElement, BackgroundAudioAgent).
You can also control the volume on sound effects of your application using XNA API.
See http://msdn.microsoft.com/en-us/library/bb195052%28v=xnagamestudio.30%29.aspx

Should I use DirectSound or WASAPI for my audio project?

I am starting a project where minimum requirements will be Windows 7. I'll be using NAudio as my interface to audio. I am not sure what I should be using: DirectSound or WASAPI? I am going to be doing the following:
Manipulating volume/mute on multiple USB sound cards for both speaker and the microphone.
Rerouting input from sound card 2 into the output of the sound card 2 (if that's possible).
Manipulating the audio input of the sound card with some effects.
I understand that behind the scenes DirectSound processes all the audio via WASAPI anyway and it sounds like DirectSound has joined the list of deprecated technologies.
However, my question is more from a functional level: which API will let me do what I described above.
where minimum requirements will be Windows 7
Certainly WASAPI - you have better control over things, WASAPI interfaces/API are well made and easier to use, less overhead if you need to be close to real time. There is nothing on th elist that DirectSound can give you and WASAPI can not.
The only reason to use DirectSound if you need pre-Vista systems where WASAPI was just not available.

Using emguCV (OpenCV) to capture video in 2 different program from the firewire camera?

I'm looking for a way to use OpenCV (or specifically emguCV in C#) to capture video from the same firewire on 2 different programs simultaneously. Some posts here said that it can't be done since the source driver would be locked into one application at a time.
I found some answers here suggesting the use of SplitCam, but it seems to only work with Webcam. Also I don't like the ads on SplitCam (but I can't complain since it's a freeware).
SplitCam seems to be using the source signal and creates a virtual driver for other programs to use. Is there a way to do the same thing as SplitCam does using OpenCV? OpenCV can access firewire camera and I have no issue using it in emguCV with a single program running.
After searching for a while, I found 2 different solutions.
1) Implement DirectShow Virtual Video Capture Source Filter. This project has been documented quite well over at CodeProject. This method takes a bit of a learning curve since I don't know much about DirectShow.
2) Use a 3rd Party component. I found one from e2esoft that works like SplitCam but it's an SDK that you can use in your own project. They already have a CSharp example. I did have a little bit of issue (Error 80040154) using the COM object provided with this example since it's a 32-bit COM object but I'm running a 64-bit Windows 7. I found a work around here using the registry hack.
I ended up going with solution #2 since it's easy to implement quickly. I use the component to create a virtual device that grabs the video from the main firewire camera device. After that my program that uses the emguCV to grab frame can just grab from the virtual device. The virtual device can be used by multiple sources and so far I have 3 instances of my program grabbing from the virtual device and I don't see any lag in frame rates (granted that this firewire camera is only running 15FPS max). The downside to this solution is that I would have to pay for the license to get rid of the water mark on the video. I'll update this when I found out how much it is since they don't post the price of SDK on the website. If it's really expensive, I'll have to go to the first solution and learn to implement the DirectShow filter.
Edit 1-16-2013: The price of the VCam SDK is $699.

Get sample of sound from stereo mix in Windows

Is there a way in Windows using C# to record a sample of the stereo mix?
In other words, record all pings, beeps and music being played via any application? I've had a look at NAudio which will record the microphone as it's source, but I can't figure out how to point it at Windows' stereo mix?
Or, if anyone knows, any pointers on how to target and record sound from a specific application? For this I'm only concerned with Vista or Windows 7, as both the aforementioned operating systems support mixing applications separately - so I wasn't sure if there was a way to tap into that.
I've looked at WINMM and COREDLL too, but I'm a bit lost.
I think first you have to activate the stereo mix device in the control panel, then you should be able to record from it. Check this msdn thread: How to record from 'Wave' or 'Stereo Mix' in Vista.

Categories