I need to receive UDP data on a specified IP address and port, and convert it into a WAV file using C# and VS 2017. I did some Google’ing and read that NAudio can help do this. So I downloaded the NAudioDemo on https://github.com/naudio/NAudio, and opened the NAudioDemo project in VS 2017. After ensuring the NAudio NuGet package was restored I ran the project, selected the Network Chat demo to load and clicked the Load button.
This loaded the Network Chat demo.
I entered the correct IP Address and Port number in the text boxes, and made sure the Compression and Protocol values were set correctly.
You will notice in the screen shot the Input Device drop down hasn’t been set. This is because I’m running the demo on Windows Server 2012 R2, and the server doesn’t have any input devices setup and there is nothing in the drop down to select.
When I click the Start Streaming button it calls the NetworkChatPanel.Connect method, and this instantiates a new NetworkAudioPlayer object. Inside the constructor of the NetworkAudioPlayer class it runs the following code:
public NetworkAudioPlayer(INetworkChatCodec codec, IAudioReceiver receiver)
{
this.codec = codec;
this.receiver = receiver;
receiver.OnReceived(OnDataReceived);
waveOut = new WaveOut();
waveProvider = new BufferedWaveProvider(codec.RecordFormat);
waveOut.Init(waveProvider);
waveOut.Play();
}
It creates a new WaveOut object instance and calls the waveOut.Init method. This causes the following exception to be thrown:
An unhandled exception of type 'NAudio.MmException' occurred in
NAudio.dll BadDeviceId calling waveOutOpen occurred
I’m wondering if the exception was thrown because the server I’m running on has no input device(s). Or it could be something else.
Can you please help me get this running and working on Windows Server 2012 R2 with no input device(s), so I can save the UDP data as a WAV file?
Thank you.
Obviously with no soundcard you can't play audio. So get rid of all code relating to WaveOut, and create a WaveFileWriter instead. When you get a DataReceived event, write the received audio into the WaveFileWriter (with the Write method). Then make sure to Dispose the WaveFileWriter when you're done
Related
I use and install zkteco 's SDK on my pc.
I have tested to remote open with zkaccess 3.5 standalone software.It is OK.
I have to know some of my development code.
I try to remote open door with ACUnlock method by passing machineNo and Delay time .
ACUnlock Method is return true but door does not open.
Is ACUnlock to open door ?and may need to configure or register door data or other event to fire in my development code?
I also found DisableDeviceWithTimeOut Method in SDK .It can be use to open door?
if (axCZKEM.ACUnlock(iMachineNumber, iDelay)) {
axCZKEM.RefreshData(iMachineNumber);
}enter image description here
I have a project under source control and I'm using a dynamic view. This project uses sockets. When I run the program I get an exception using this line of code:
var addresses = Dns.GetHostAddresses(Dns.GetHostName());
I get a socket exception with the following information:
Error Code: 11003
Message: "A non-recoverable error occurred during a database lookup"
Socket Error Code: NonRecovery
I don't have this issue running locally or on another windows network share (non-Clearcase). I believe this is a security issue related to sockets and network drives. I have a workaround but would really like to resolve this issue. I'm on Windows 7.
The first workaround would be to use a snapshot view instead of a dynamic one.
That way, you would be directly on the C drive instead of an MVFS mount point.
If you have to use dynamic view, make sure it is being accessed through its full path (no subst, no setview): M:\myview\myVob\...
Finally, it can depend on your exact ClearCase version: with ClearCase 7.x, there was socket error on Windows before: see "Unable to run executable that opens a socket on Microsoft Windows Vista, Windows Server 2008 or Windows 7"
I am trying to play an M4A (MP4 Audio) file directly from the internet using a URL.
I'm using NAudio with the MediaFoundation to achieve this:
using (var reader = new MediaFoundationReader(audioUrl)) //exception
using (var wave = new WaveOutEvent())
{
wave.Init(reader);
wave.Play();
}
This works well on two test systems with Windows 8.1 and Windows 10. But on my Windows 7 machine it is not working, I am getting an exception from inside the MediaFoundationReader constructor.
Initially, I was getting an ArgumentOutOfRangeException. I tested playing this m4a file in WMP and it was also unable to play it. I downloaded a codec pack and installed it. That helped with WMP but my code was still throwing an exception, albeit another one:
An unchecked exception of type
'System.Runtime.InteropServices.COMException' occurred in NAudio.dll
Additional information: There is more data available. (Exception from
HRESULT: 0x800700EA)
Any ideas what could be causing this and how I can fix it?
With some research i identified this
0X800700ea can occur when your Windows operating system becomes
corrupted. There can be numerous reason that this error occur
including excessive startup entries, registry errors, hardware/RAM
decline, fragmented files, unnecessary or redundant program
installations and so on.
Can you try you program in another system and verify
Sometimes the user doesn't have enough privileges to run COM Methods.
Try to run the application as Administrator.
I am trying to create a simple Windows Phone 8.1 (hence Windows.Networking.Sockets) socket client, and Windows 8 server. Unfortunately I am quite new to this task, so I am having problems understanding the obstacles that appear.
I am using http://msdn.microsoft.com/pl-pl/library/fx6588te(v=vs.110).aspx this code as a server. However when it comes to the Windows Phone 8.1, it turned out that http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202858(v=vs.105).aspx this tutorial won't work, as there is no way to use the following import:
using System.Net.Sockets.
Which is the reason why i switched to the following code:
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj150599.aspx (which is btw quite sloppy, and full of errors)
So I embedded the Windows Phone 8.1 part of the code into my application, and it seems to connect correctly to the server, and it even sends data to the server, however the app crashes right after the following statement.
"Trying to send data"
And the output is exactly like the following:
A first chance exception of type 'System.ArgumentException' occured in Project.exe
WinRT information: count
Please help me solve the error, as I have vainly spent many hours trying to fix this..
EDIT
Here is the part of code from the mentioned tutorial, that throws the described error
// Now try to receive data from server
try
{
OutputView.Text = "";
StatusText.Text = "Trying to receive data ...";
DataReader reader = new DataReader(clientSocket.InputStream);
// Set inputstream options so that we don't have to know the data size
reader.InputStreamOptions = Partial;
await reader.LoadAsync(reader.UnconsumedBufferLength);
}
So I am trying to connect a bluetooth speakers from a script. I am using 32feet.net and I have successfully found the device but it doesn't work when I try to pair and connect to it.
This is the code im using to pair to device, this always fails not sure why:
private static void connected(BluetoothDeviceInfo[] dev)
{
// dev[foundIndex];
bool paired=false;
paired = BluetoothSecurity.PairRequest(dev[foundIndex].DeviceAddress, "1166");
if (paired)
Console.WriteLine("Passed, Device is connected.");
else
Console.WriteLine("Failed....");
}
Here is the code called after connected to actually connect to the device: bc is my bluetooth client var.
bc.BeginConnect(devInfo[foundIndex].DeviceAddress, BluetoothService.SerialPort, new AsyncCallback(Connect), devInfo[foundIndex]);
private static void Connect(IAsyncResult result)
{
if (result.IsCompleted)
{
Console.Write("Connected... ");
}
}
Any help would be appreciated. I am new to 32feet.net so i dont know much about this, i tried following code online to get where im at.
Try BluetoothDeviceInfo.SetServiceState. That will ask Windows to connect to the audio service on the device -- hopefully that'll do the job.
See https://32feet.codeplex.com/wikipage?title=Connecting%20to%20Bluetooth%20Services
Sometimes we don’t want our application to itself send data to/from a remote service but we want instead the local operating system to do so. This is the case for keyboard/mouse/etc with HID, networking with DUN/NAP/PAN/etc, Headset/Handsfree etc.
and then
The short answer in this case is to use BluetoothDeviceInfo.SetServiceState. This is the API equivalent to manually checking the respective checkbox on the “Services” tab of the Device dialog in Bluetooth Control panel.
Also, in these days of Secure Simple Pairing, using PairRequest is fine only if all peer devices will use old style PIN code authentication, otherwise instantiate a BluetoothWin32Authentication and then do the connect (here indirectly via SetServiceState) and handle the authentication in the authentication callback.