By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,883 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

a voice recorder for Pocket PC (need help debugging)

P: n/a
I'm trying to record a voice memo on a Pocket PC (2000) from VB.NET
(smart device application from vs.net 2003).

Tom Shelton did an initial conversion to VB.NET which I am trying to
run, but am getting errors I don't quite understand (I've never done
anything like this before)...

Any help would be appreciated in getting this to work...

'-----------------------------------------------------------------------------
'ported to vb.net by
'Tom Shelton (to*@YOUKNOWTHEDRILLmtogden.com)
'Off the top of my head... I'm not sure why the original code is
using
'unsafe code. There doesn't seem to be anything used that would
require that
'- but, I don't know much about the Pocket PC environment. If the
unsafe is
'required for some reason on PPC, then you have to use C#.
'-----------------------------------------------------------------------------

Imports System
Imports System.Data
Imports System.Runtime.InteropServices

Public Class VoiceRecorder
<StructLayout(LayoutKind.Sequential)> _
Protected Structure CM_VOICE_RECORDER
Public cb As Integer
Public dwStyle As Integer
Public xPos As Integer
Public yPos As Integer
Public hwndParent As IntPtr
Public id As Integer
Public lpszRecordFileName As String
End Structure

'errors on next line:
'CallingConvention is a type and cannot be used as an expression
'Cdecl is not a member of
'System.Runtime.InteropServices.CallingConvention'
<DllImport("voicectl.dll", CallingConvention =
CallingConvention.Cdecl)> _
Private Shared Function VoiceRecorder_Create _
(ByRef CM_VOICE_RECORDER As VoiceRecorder) As IntPtr
End Function

Private voicerec As CM_VOICE_RECORDER
Private handle As IntPtr

Public Sub New()
With voicerec
.cb = Marshal.SizeOf(voicerec);
.lpszRecordFileName = "\My Documents\VoiceControl.wav"
.xPos = -1
.yPos = -1
End With
End Sub

Public Sub Show()
'error on next line:
'VoiceRecorder is a type and cannot be used as an expression.
handle = VoiceRecorder_Create(VoiceRecorder)
End Sub

End Class
'-----------------------------------------------------------------------------
original c# code:
source: wapboy
http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=62
'-----------------------------------------------------------------------------

//Q: Once we have a voice recorder object, how do you then pass
messages to it??

//A: Im working on that... Essentially the sendmessage api function
will need to
//be p/invoked. The voicerecordercreate function has returned the
hwnd so
//messages can be sent to this. The voice recorder messages are
documented in
//the sdk
//I haven't had much luck with the sendmessage function - everytime I
try to
//send a message to the voicerecorder, it just closes the
voicerecorder.....
//
//I got this code to run. This code seems to record to files in \\My
//Documents\~VRec_* where * is a number.
//Alan, did you install the Speech.NET or Speech API?
//
//The files ~VRec_* are temporary files that the voice recorder uses
to store
//the data while it is recording. Sometimes, depending on how the
recorder is
//terminated, they get converted to recording*.wav
//
//Take a look here:
//http://www.innovativedss.com/forums/topic.asp?TOPIC_ID=80
//for an example of playing .WAV sounds.
//
using System;
using System.Data;
using System.Runtime.InteropServices;

/// <summary>
/// Creates an instance of the shell voice recorder
/// </summary>
public class VoiceRecorder
{
//API Declares

[StructLayout(LayoutKind.Sequential)]
protected unsafe struct CM_VOICE_RECORDER
{
public int cb;
public uint dwStyle;
public int xPos, yPos;
public IntPtr hwndParent;
public int id;
public String lpszRecordFileName;
};

[DllImport("voicectl.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern IntPtr VoiceRecorder_Create(ref
CM_VOICE_RECORDER
voicerec);

//end api delcare

private CM_VOICE_RECORDER voicerec;
private IntPtr handle;

public unsafe VoiceRecorder()
{
voicerec = new CM_VOICE_RECORDER();
handle = new IntPtr();
voicerec.cb = (int)Marshal.SizeOf(voicerec);
voicerec.lpszRecordFileName = "\\My Documents\\VoiceControl.wav";

voicerec.xPos = -1;
voicerec.yPos = -1;
}
//show the voice recorder
public void Show()
{
handle = VoiceRecorder_Create(ref voicerec);
}
}
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi,

I think he switched the type and variable name in the dll import.

<DllImport("voicectl.dll", CallingConvention =
CallingConvention.Cdecl)> _
Private Shared Function VoiceRecorder_Create _
(ByRef VoiceRecorder as CM_VOICE_RECORDER) As IntPtr
End Function

Ken
-----------------------

"Mad Scientist Jr" <us*************@yahoo.com> wrote in message
news:7a**************************@posting.google.c om:
I'm trying to record a voice memo on a Pocket PC (2000) from VB.NET
(smart device application from vs.net 2003).

Tom Shelton did an initial conversion to VB.NET which I am trying to
run, but am getting errors I don't quite understand (I've never done
anything like this before)...

Any help would be appreciated in getting this to work...
'---------------------------------------------------------------------------
--
'ported to vb.net by
'Tom Shelton (to*@YOUKNOWTHEDRILLmtogden.com)
'Off the top of my head... I'm not sure why the original code is
using
'unsafe code. There doesn't seem to be anything used that would
require that
'- but, I don't know much about the Pocket PC environment. If the
unsafe is
'required for some reason on PPC, then you have to use C#.

'---------------------------------------------------------------------------
--

Imports System
Imports System.Data
Imports System.Runtime.InteropServices

Public Class VoiceRecorder
<StructLayout(LayoutKind.Sequential)> _
Protected Structure CM_VOICE_RECORDER
Public cb As Integer
Public dwStyle As Integer
Public xPos As Integer
Public yPos As Integer
Public hwndParent As IntPtr
Public id As Integer
Public lpszRecordFileName As String
End Structure

'errors on next line:
'CallingConvention is a type and cannot be used as an expression
'Cdecl is not a member of
'System.Runtime.InteropServices.CallingConvention'
<DllImport("voicectl.dll", CallingConvention =
CallingConvention.Cdecl)> _
Private Shared Function VoiceRecorder_Create _
(ByRef CM_VOICE_RECORDER As VoiceRecorder) As IntPtr
End Function

Private voicerec As CM_VOICE_RECORDER
Private handle As IntPtr

Public Sub New()
With voicerec
.cb = Marshal.SizeOf(voicerec);
.lpszRecordFileName = "\My Documents\VoiceControl.wav"
.xPos = -1
.yPos = -1
End With
End Sub

Public Sub Show()
'error on next line:
'VoiceRecorder is a type and cannot be used as an expression.
handle = VoiceRecorder_Create(VoiceRecorder)
End Sub

End Class

'---------------------------------------------------------------------------
--
original c# code:
source: wapboy
HYPERLINK
"http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=62"http://www.opennetcf.
org/forums/topic.asp?TOPIC_ID=62

'---------------------------------------------------------------------------
--

//Q: Once we have a voice recorder object, how do you then pass
messages to it??

//A: Im working on that... Essentially the sendmessage api function
will need to
//be p/invoked. The voicerecordercreate function has returned the
hwnd so
//messages can be sent to this. The voice recorder messages are
documented in
//the sdk
//I haven't had much luck with the sendmessage function - everytime I
try to
//send a message to the voicerecorder, it just closes the
voicerecorder.....
//
//I got this code to run. This code seems to record to files in \\My
//Documents\~VRec_* where * is a number.
//Alan, did you install the Speech.NET or Speech API?
//
//The files ~VRec_* are temporary files that the voice recorder uses
to store
//the data while it is recording. Sometimes, depending on how the
recorder is
//terminated, they get converted to recording*.wav
//
//Take a look here:
//http://www.innovativedss.com/forums/topic.asp?TOPIC_ID=80
//for an example of playing .WAV sounds.
//
using System;
using System.Data;
using System.Runtime.InteropServices;

/// <summary>
/// Creates an instance of the shell voice recorder
/// </summary>
public class VoiceRecorder
{
//API Declares

[StructLayout(LayoutKind.Sequential)]
protected unsafe struct CM_VOICE_RECORDER
{
public int cb;
public uint dwStyle;
public int xPos, yPos;
public IntPtr hwndParent;
public int id;
public String lpszRecordFileName;
};

[DllImport("voicectl.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern IntPtr VoiceRecorder_Create(ref
CM_VOICE_RECORDER
voicerec);

//end api delcare

private CM_VOICE_RECORDER voicerec;
private IntPtr handle;

public unsafe VoiceRecorder()
{
voicerec = new CM_VOICE_RECORDER();
handle = new IntPtr();
voicerec.cb = (int)Marshal.SizeOf(voicerec);
voicerec.lpszRecordFileName = "\\My Documents\\VoiceControl.wav";

voicerec.xPos = -1;
voicerec.yPos = -1;
}
//show the voice recorder
public void Show()
{
handle = VoiceRecorder_Create(ref voicerec);
}
}


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.6 - Release Date: 6/25/2004
Nov 20 '05 #2

P: n/a
On Mon, 28 Jun 2004 20:28:28 -0700, Ken Tucker [MVP] wrote:
Hi,

I think he switched the type and variable name in the dll import.

<DllImport("voicectl.dll", CallingConvention =
CallingConvention.Cdecl)> _
Private Shared Function VoiceRecorder_Create _
(ByRef VoiceRecorder as CM_VOICE_RECORDER) As IntPtr
End Function

Ken

-----------------------

Yep. That's what I did... That kind of stuff happens when you write code
off the cuff :)
--
Tom Shelton [MVP]
Nov 20 '05 #3

P: n/a
i made the changes, and am still having trouble getting this part to work,
i am getting an error

'Cdecl' is not a member of 'System.Runtime.InteropServices.CallingConvention' .

any help appreciated
Nov 20 '05 #4

P: n/a
Check out the Multimedia library aat www.opennetcf.org

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/...ity/newsgroups
"Mad Scientist Jr" <us*************@yahoo.com> wrote in message
news:7a**************************@posting.google.c om...
i made the changes, and am still having trouble getting this part to work,
i am getting an error

'Cdecl' is not a member of 'System.Runtime.InteropServices.CallingConvention' .
any help appreciated

Nov 20 '05 #5

P: n/a
Thanks...I checked out the OpenNETCF.Multimedia.Audio Namespace - it
looks like it supports what I am trying to do, although I don't see
where you specify a file name to save the voice memo to, and it is not
straightforward how to specify the bit rate, # of channels, frequency
etc.

Can someone post a sample of how to record a voice memo (say 8 KHz,
mono, 8000 Khz), save it to a WAV file, and play back the WAV file, from
VB.NET?

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.