Jump to content

Trying to marshal a float[,]

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
coriscow

coriscow

    Newbie

  • Members
  • Pip
  • 1 posts
Hi all!!

I am developing an app for a Pocket PC platform on C#. However, I need to make use of a C written dll. The problem arises when calling the function
.........
int capture_input( float32 ***cepstrum, int nrOfSeconds, int playBack, int *nrOfCoeff );
.........

where it returns an int (not an error code), a bidimensional array allocated within the function (cepstrum) and another integer (nrOfCoeff). I call the function from C# managed code using the following declaration and code:

.........
[DllImport ( "JanitorMobiledll.dll", EntryPoint = "capture_input" )]

private static extern int capture_input ( float[,] cepstrum, int nrOfSeconds,

int playback, ref int nrOfCepstra );
.........
int numberOfFrames = 0;

int numberOfCepstra = 0;

float[,] cepstrum;
.........
numberOfFrames = JHandShaker.capture_input ( cepstrum, maxNrOfSeconds, 1, ref numberOfCepstra );
.........

The problem arises in the unmanaged code when redirecting the received pointer to the allocated memory region
(*cepstrum=tmp_cep;).

What am I doing wrong??

Thanks!!!!

#2
BackSlash

BackSlash

    Newbie

  • Members
  • PipPip
  • 12 posts
Ok, Well I don't do to much working with unmanaged code in C# but I think I will just throw this out and if it helps it helps and if I sound like a fool please disregard.

You are trying to set up a Managed link for unmanaged code and your problem is in the cepstrum array. Have you tried maybe using a jagged array instead of a rectanguar array, arr[][]

again, I have no real clue, but thought I might throw it out there.