![]() Therefore, if you would want to be able to play audio on. You will have to load ASP.NET Core components, Node.js and use NodeServicesto get this solution to work. NET Core on any platform, but it requires quite a few additional dependencies. There is, of course, a reliable way to play sound on. NET Core, the bulk of its functionality is still only available on Windows. Although there is a pre-release version that is available in. Unfortunately, NAudio is not fully compatible with. Likewise, NuGet packages such as NAudio added many extra audio-processing capabilities. NET Framework, you could play sound easily by using classes like SoundPlayer from the standard class library of the framework itself. One of these is the ability to play sound. This applies to those functionalities that would work radically differently on different platforms under the hood, especially the ones that weren’t the priority for the authors of. NET Core is for writing software for multiple platforms, it lacks some basic capabilities. So I added _capture.Device = captureDevice Īnd now the program properly pulls the audio data off of my non-default audio endpoint.As great as. I found that WasapiLoopbackCapture uses Windows' default device unless changed, and the code was using DefaultAudioEndpoint to get the properties of the default device. These were the magic lines: _capture = new WasapiLoopbackCapture(100, new WaveFormat(deviceFormat.SampleRate, deviceFormat.BitsPerSample, i)) However in this case, the program was not using captureDevice to bring in the audio data. MMDevice captureDevice = collection.ItemAt(2) MMDeviceEnumerator enumerator = new MMDeviceEnumerator() This showed me that the Endpoint I wanted was item number 3 (2 in an array) on my list, and instead of using GetDevice(String id) I used ItemAt(int deviceIndex). MMDeviceCollection collection = enumerator.EnumAudioEndpoints(DataFlow.Render,DeviceState.Active) Ĭonsole.WriteLine($"\nNumber of active Devices: ") To find the the Endpoint I wanted, I wrote this short program to find all the info I wanted: static void Main(string args) Then I can substitute the DefaultAudioEndpoint method with the GetDevice(String id) method, where String id is the ID of whichever Endpoint I chose from the separate program. The developer has chosen to use the CSCore Library rather than Windows' own Core Audio API.įrom continued reading of the CSCore MMDeviceEnumerator Documentation, it looks like I'll have to make a separate program that outputs all endpoints and their respective Endpoint ID Strings. I've found why the program uses MMDevice rather than IMMDevice. Is there an easier way to go about choosing a different endpoint? Am I on the right track? or am I missing the mark completely?Īlso, what is the difference between MMDevice and IMMDevice? The source only seems to use MMDevice while all the Microsoft documentation references IMMDevice. That's a bit much for me, as I have little to no C# experience. It seems to me that I'd have to enumerate the devices, and then separate out Auxillary 1 (Synchronous Audio Router) using PKEY_Device_FriendlyName. How would I go about changing DefaultAudioEndpoint?įurther Reading shows a few ways to get an IMMDevice, with DefaultAudioEnpoint being one of them. The way that I understand it from the documentation, the section MMDeviceEnumerator.DefaultAudioEndpoint(DataFlow.Render, Role.Console) is where Windows gives the application my default IMMEndpoint "Desktop Input." _audioEndpointVolume = AudioEndpointVolume.FromDevice(captureDevice) WaveFormat deviceFormat = captureDevice.DeviceFormat MMDevice captureDevice = MMDeviceEnumerator.DefaultAudioEndpoint(DataFlow.Render, Role.Console) I found in the source where the audio device is declared Lines 32-36 in CSCoreAudioInput.cs: public void Initialize() I'd like to be able change the device that the program listens to for the visualization. For instance, when I play music from Winamp it goes through the device Auxillary 1 (Synchronous Audio Router) instead of Desktop Input (Synchronous Audio Router) which I have set as Default. My audio setup is a bit more involved, and I use way more than just the default audio device. This program is an audio visualizer for an rgb keyboard that listens to windows' default audio device.
0 Comments
Leave a Reply. |