Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capturing sound from TV Card with C#

Tags:

c#

wpf

directx

I have written a WPF application which is capturing display and sound from TV Card from with through C# code. I can get the display from TV card, but I can't get any sound from TV Card. BTW, I'm using .NET framework 3.5 with Visual Studio 2010. My question is how can I get the sound from the TV card?

Lastly, I tried anything like below by using DirectSound library of DirectX. However, I got the following errors.

  1. The best overloaded method match for 'Microsoft.DirectX.DirectSound.Device.SetCooperativeLevel(System.Windows.Forms.Control, Microsoft.DirectX.DirectSound.CooperativeLevel)' has some invalid arguments.
  2. Argument 1: cannot convert from 'Wpfvideo.MainWindow' to 'System.Windows.Forms.Control'

Code:

private DS.Device soundDevice;
private SecondaryBuffer buffer;
private ArrayList soundlist = new ArrayList();

private void InitializeSound()
{
     soundDevice = new DS.Device();
     soundDevice.SetCooperativeLevel(this, CooperativeLevel.Priority);

    BufferDescription description = new BufferDescription();
    description.ControlEffects = false;
    buffer = new SecondaryBuffer(CaptureDeviceName, description, soundDevice);
    buffer.Play(0, BufferPlayFlags.Default);
    SecondaryBuffer newshotsound = buffer.Clone(soundDevice);
    newshotsound.Play(0, BufferPlayFlags.Default);
} 
like image 995
MaxCoder88 Avatar asked Sep 01 '11 12:09

MaxCoder88


People also ask

Is a USB C to HDMI a capture card?

This USB-C hdmi capture card can be compatible with all 1080P 720P hdmi device, such as Wii U, PS4, PS3, Xbox One, Xbox 360, Wii, Nintendo Switch, DVD, camera, ZOSI security camera, DSLR and set top box etc.

Why can't I hear my capture card?

Make sure the sound output of the computer is not low or muted. 2. In the Game Capture Software, make sure the game sound dial is not set too low. Both Game Capture HD and 4K Capture Utility software support analog audio capture from specific capture devices.


1 Answers

Try this:

var windowInteropHelper = new WindowInteropHelper(this);
soundDevice = new DS.Device();
soundDevice.SetCooperativeLevel(windowInteropHelper.Handle, CooperativeLevel.Priority);
like image 108
Kent Boogaart Avatar answered Oct 13 '22 13:10

Kent Boogaart