473,695 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

a voice recorder for Pocket PC (need help debugging)

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*@YOUKNOWTHE DRILLmtogden.co m)
'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(L ayoutKind.Seque ntial)> _
Protected Structure CM_VOICE_RECORD ER
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 lpszRecordFileN ame As String
End Structure

'errors on next line:
'CallingConvent ion is a type and cannot be used as an expression
'Cdecl is not a member of
'System.Runtime .InteropService s.CallingConven tion'
<DllImport("voi cectl.dll", CallingConventi on =
CallingConventi on.Cdecl)> _
Private Shared Function VoiceRecorder_C reate _
(ByRef CM_VOICE_RECORD ER As VoiceRecorder) As IntPtr
End Function

Private voicerec As CM_VOICE_RECORD ER
Private handle As IntPtr

Public Sub New()
With voicerec
.cb = Marshal.SizeOf( voicerec);
.lpszRecordFile Name = "\My Documents\Voice Control.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_C reate(VoiceReco rder)
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 voicerecordercr eate 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.innovatived ss.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(La youtKind.Sequen tial)]
protected unsafe struct CM_VOICE_RECORD ER
{
public int cb;
public uint dwStyle;
public int xPos, yPos;
public IntPtr hwndParent;
public int id;
public String lpszRecordFileN ame;
};

[DllImport("voic ectl.dll", CallingConventi on=CallingConve ntion.Cdecl)]
private static extern IntPtr VoiceRecorder_C reate(ref
CM_VOICE_RECORD ER
voicerec);

//end api delcare

private CM_VOICE_RECORD ER voicerec;
private IntPtr handle;

public unsafe VoiceRecorder()
{
voicerec = new CM_VOICE_RECORD ER();
handle = new IntPtr();
voicerec.cb = (int)Marshal.Si zeOf(voicerec);
voicerec.lpszRe cordFileName = "\\My Documents\\Voic eControl.wav";

voicerec.xPos = -1;
voicerec.yPos = -1;
}
//show the voice recorder
public void Show()
{
handle = VoiceRecorder_C reate(ref voicerec);
}
}
Nov 20 '05 #1
5 4675
Hi,

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

<DllImport("voi cectl.dll", CallingConventi on =
CallingConventi on.Cdecl)> _
Private Shared Function VoiceRecorder_C reate _
(ByRef VoiceRecorder as CM_VOICE_RECORD ER) As IntPtr
End Function

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

"Mad Scientist Jr" <us************ *@yahoo.com> wrote in message
news:7a******** *************** ***@posting.goo gle.com:
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*@YOUKNOWTHE DRILLmtogden.co m)
'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(L ayoutKind.Seque ntial)> _
Protected Structure CM_VOICE_RECORD ER
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 lpszRecordFileN ame As String
End Structure

'errors on next line:
'CallingConvent ion is a type and cannot be used as an expression
'Cdecl is not a member of
'System.Runtime .InteropService s.CallingConven tion'
<DllImport("voi cectl.dll", CallingConventi on =
CallingConventi on.Cdecl)> _
Private Shared Function VoiceRecorder_C reate _
(ByRef CM_VOICE_RECORD ER As VoiceRecorder) As IntPtr
End Function

Private voicerec As CM_VOICE_RECORD ER
Private handle As IntPtr

Public Sub New()
With voicerec
.cb = Marshal.SizeOf( voicerec);
.lpszRecordFile Name = "\My Documents\Voice Control.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_C reate(VoiceReco rder)
End Sub

End Class

'---------------------------------------------------------------------------
--
original c# code:
source: wapboy
HYPERLINK
"http://www.opennetcf.o rg/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 voicerecordercr eate 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.innovatived ss.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(La youtKind.Sequen tial)]
protected unsafe struct CM_VOICE_RECORD ER
{
public int cb;
public uint dwStyle;
public int xPos, yPos;
public IntPtr hwndParent;
public int id;
public String lpszRecordFileN ame;
};

[DllImport("voic ectl.dll", CallingConventi on=CallingConve ntion.Cdecl)]
private static extern IntPtr VoiceRecorder_C reate(ref
CM_VOICE_RECORD ER
voicerec);

//end api delcare

private CM_VOICE_RECORD ER voicerec;
private IntPtr handle;

public unsafe VoiceRecorder()
{
voicerec = new CM_VOICE_RECORD ER();
handle = new IntPtr();
voicerec.cb = (int)Marshal.Si zeOf(voicerec);
voicerec.lpszRe cordFileName = "\\My Documents\\Voic eControl.wav";

voicerec.xPos = -1;
voicerec.yPos = -1;
}
//show the voice recorder
public void Show()
{
handle = VoiceRecorder_C reate(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
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("voi cectl.dll", CallingConventi on =
CallingConventi on.Cdecl)> _
Private Shared Function VoiceRecorder_C reate _
(ByRef VoiceRecorder as CM_VOICE_RECORD ER) 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
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 .InteropService s.CallingConven tion'.

any help appreciated
Nov 20 '05 #4
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.goo gle.com...
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 .InteropService s.CallingConven tion'.
any help appreciated

Nov 20 '05 #5
Thanks...I checked out the OpenNETCF.Multi media.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3115
by: Dfenestr8 | last post by:
Hi. I'm no coder. I'm just a working guy who likes to tinker with computers in my spare time. That's my hobby. My passion is: playing instruments. Combining the two, I've made a couple of event driven, GUI controlled progs in Python and tKinter before. I made an abc/midi player, using the timidity, and abc2midi packages. I also did a metronome, using the Snack sound toolkit.
14
3160
by: Matt | last post by:
Any progammers looking for a killer app to develop? How about a voice enabled forum? One of the most powerful, exciting, and engrossing experiences on the Internet is the Forum. The first great Internet forums were the Usenet newsgroups. Usenet is still a powerful force, but many different types of forums are also very popular (such as message boards like Vbulliten and XMBforum). I love forums. Love em love em love em. My web site...
1
1603
by: juan5 | last post by:
Hi I purchased an h5500 series HP pocket pc. Using VS.NET 2003 I am able to build and deploy to the Pocket PC 2002 Emulator but not to debug the app The app is "installed" in the emulator just fine but that's all that happens What's going on Thanks Juan Dent
2
1871
by: Mad Scientist Jr | last post by:
Can someone convert this code to vb.net? it is a voice recorder for pocket pc. many thanks ! source: http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=62 the code: using System;
5
9228
by: Oliver Huppert | last post by:
Hi all, can someone tell me what I need to develop applications for PPC2003 with C#? I have read several meanings about this topic. Do I need Visual Studio .NET or is Visual C# .NET Standard enough?? thanks regards
1
3866
by: Mad Scientist Jr | last post by:
hi can someone possibly convert this to vb.net ? it is c# code that lets the pocket pc access the voice recorder... many thanks... source: wapboy http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=62
0
1939
by: Emma Gumbdough | last post by:
Okay we have here a VB.NET version of the .net compact framework voice recorder sample that uses open net CF c# version at: http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=79 THIS CODE CREATES AN INSTANCE OF A VOICE RECORDER, but now how do you get it to record, save, play back, etc?
10
2009
by: Neil Wallace | last post by:
Guys, I am hopping mad. I am just a hobby programmer making little .net applications for pretty much no-one else but me to use. One application I have written would, to my mind, work best on a handheld PC. Fortunately I have a Pocket PC - an HP jornada bought 4 years ago. Doing my
1
575
by: Fab | last post by:
Hi, What is the best (or simple!) way to make some voice recording in C# ? Thanks.
0
9137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9004
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8864
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4592
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3025
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2289
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1986
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.