Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 How to convert c to c#

views
     
TSnarf03
post Feb 27 2024, 07:56 PM, updated 2y ago

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


hardware with SDK, it comes with complex c code, wonder what options i have to get it converted to c# ?

the code wont run without the hardware, so if i get freelancer(online) to do it, they cant test run the program. any ideas ?

its very complex for me, as i dont know c, this is example of a small portion of the code i have been scratching my head for hours.

user posted image
jibpek
post Feb 27 2024, 08:28 PM

Enthusiast
*****
Junior Member
708 posts

Joined: Jul 2012
Pure C can easily compiled using C++ CLR in DotNET.

But there is no way for you to convert all those Win32 predefined symbols, and it seems like you might be using some libraries to talk to DirectSound which is already outdated in Win11.

It is almost impossible to get 3rd parties library to work together with DirectX which was still using the insane COM interface. Change to a Csharp DirectX library is easier.
TSnarf03
post Feb 27 2024, 09:08 PM

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


QUOTE(jibpek @ Feb 27 2024, 08:28 PM)
Pure C can easily compiled using C++ CLR in DotNET.

But there is no way for you to convert all those Win32 predefined symbols, and it seems like you might be using some libraries to talk to DirectSound which is already outdated in Win11.

It is almost impossible to get 3rd parties library to work together with DirectX which was still using the insane COM interface. Change to a Csharp DirectX library is easier.
*
problem is i dont know which direction to go or continue, any advice ? ask supplier for help ?
flashang
post Feb 28 2024, 10:48 AM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


Personal opinion.

Think what you want to achieve.

1. To rebuild a working software with c# ?
2. Write some UI to call existing working api / dll ?
3. Others.

Than estimate the required cost / time / skill sets and chose a reasonable solution.

smile.gif


TSnarf03
post Feb 28 2024, 12:08 PM

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


QUOTE(flashang @ Feb 28 2024, 10:48 AM)
Personal opinion.

Think what you want to achieve.

1. To rebuild a working software with c# ?
2. Write some UI to call existing working api / dll ?
3. Others.

Than estimate the required cost / time / skill sets and chose a reasonable solution.

smile.gif
*
I want to get it done. Managed to do capture video from the same hardware, they had sample code in c#, but for audio they only have c not c#

jibpek
post Feb 28 2024, 02:06 PM

Enthusiast
*****
Junior Member
708 posts

Joined: Jul 2012
QUOTE(narf03 @ Feb 28 2024, 12:08 PM)
I want to get it done. Managed to do capture video from the same hardware, they had sample code in c#, but for audio they only have c not c#
*
You trying to capture video + audio in web pr app?

If Web, we are now using WebRTC. Which is open sourced.
TSnarf03
post Feb 28 2024, 05:31 PM

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


QUOTE(jibpek @ Feb 28 2024, 02:06 PM)
You trying to capture video + audio in web pr app?

If Web, we are now using WebRTC. Which is open sourced.
*
must use their sdk, cause most load will be on the card instead of pc, imagine you have massive amount of cards. they do dma, direct memory access, direct either to ram or audio driver.
TSnarf03
post Feb 28 2024, 09:26 PM

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


QUOTE(jibpek @ Feb 28 2024, 02:06 PM)
You trying to capture video + audio in web pr app?

If Web, we are now using WebRTC. Which is open sourced.
*
sorry, misunderstood your question, capture from a capture card, like you have 2 pc, pc1 output instead of connect to monitor, connect to pc 2 instead, then the video and audio will be captured and display on pc2
flashang
post Feb 28 2024, 11:12 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(narf03 @ Feb 28 2024, 12:08 PM)
I want to get it done. Managed to do capture video from the same hardware, they had sample code in c#, but for audio they only have c not c#
*
Some sdk are able to compile into dll (or come with working dll),
for customized development.

Or you may check with supplier if they have.

smile.gif


TSnarf03
post Feb 29 2024, 01:07 AM

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


QUOTE(flashang @ Feb 28 2024, 11:12 PM)
Some sdk are able to compile into dll (or come with working dll),
for customized development.

Or you may check with supplier if they have.

smile.gif
*
they have dll, but they use the c code to make use of the dll, i want to use c# code to make use of the dll.
jibpek
post Feb 29 2024, 07:34 AM

Enthusiast
*****
Junior Member
708 posts

Joined: Jul 2012
QUOTE(narf03 @ Feb 29 2024, 01:07 AM)
they have dll, but they use the c code to make use of the dll, i want to use c# code to make use of the dll.
*
First find out if their DLL is COM or ActiveX, or pure C++ DLL with Header file?

Since DirectX era, all video and audio capturing or output devices had already been standardized. Very seldom find proprietary devices anymore.

And because of the high throughput rate, video / audio i/o using DMA is a norm.
TSnarf03
post Feb 29 2024, 02:41 PM

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


QUOTE(jibpek @ Feb 29 2024, 07:34 AM)
First find out if their DLL is COM or ActiveX, or pure C++ DLL with Header file?

Since DirectX era, all video and audio capturing or output devices had already been standardized. Very seldom find proprietary devices anymore.

And because of the high throughput rate, video / audio i/o using DMA is a norm.
*
dont really matter what it is, in order to make use of the dll, we need to understand how to call and pass in, its not just basic variables (integer, etc) need to pass in, but need very complex structure to be passed in, like memory address that has been allocated, callback function(that will be called when capture is done, will happen like 60 times per second, per input), handles of program itself, etc into the structure, 1 wrong param, program will just crash, and hardware(card) might stop functioning, need to reboot.


its a professional capture card, not consumer level, mainly used in control room or medical, i dont want to go down that path.

this is 1 of the "structure" i need to figure out their values when running in c, if any of those values are wrong, like 32bit integer in c is 64bit unsigned long in c#, then ill be in trouble, cause dll read them in raw, directly reading bits in the memory, no auto conversion

CODE

typedef struct {
  /* Thread parms */
  HANDLE               HThread;
  HANDLE               HStartEvent;
  DWORD                DWThreadID;
  HRESULT              Error;
  /* External parms */
  ULONG                Input;
  /* Internal parms */
  BOOL                 BClose;
  HAUDIO               HAudio;
#if AUDIO_WAIT_FOR_DATA
  HANDLE               HBitsInList;
#endif
  ULONG                FormatCount;
  ULONG                FormatIndex;
  PAUDIOCAPS           PFormats;
  WAVEFORMATEXTENSIBLE WaveEx;
  REFERENCE_TIME       BufferDuration;
  ULONG                BufferSize;
  AUDIOCAPTURESTATE    State;
  ULONG                Event;
} AUDIOPARMS, *PAUDIOPARMS;


This post has been edited by narf03: Feb 29 2024, 02:52 PM
jibpek
post Feb 29 2024, 06:04 PM

Enthusiast
*****
Junior Member
708 posts

Joined: Jul 2012
Seems like you have little experience with C.

In 32 bits CPU, all data structures (except char) are PRAGMA ALIGN to 32 bits. Event though they appears as 16 bits. This is to improve the CPU performance (avoid paneity in accessing data address that is not aligned to the CPU bus). (Google for PARGMA ALIGN) and you will know what I mean.

Besides, COM is difficult to program and consume in MSVC but made easy in CSharp, because COM or DLL can be easily imported into Csharp. While a traditional C++ DLL can't

But again, most likely it is was programmed in 32bits environment. So your C# has to compile in 32bits as well.
TSnarf03
post Mar 26 2024, 09:09 PM

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


status update, asked so many things, this is the result so far




 

Change to:
| Lo-Fi Version
0.0234sec    0.88    5 queries    GZIP Disabled
Time is now: 20th December 2025 - 08:21 AM