473,372 Members | 834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Audio Recorder

648 Expert 512MB
Hi Folks,

I was hoping to get a little help here. I have recently foun the following code (here: http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=160)

Expand|Select|Wrap|Line Numbers
  1. public class VoiceRecorder
  2.     {
  3.         #region API prototypes
  4.         [DllImport("voicectl.dll", EntryPoint = "VoiceRecorder_Create")]
  5.         private unsafe static extern IntPtr VoiceRecorder_Create(CM_VOICE_RECORDER* voicerec);
  7.         [DllImport("coredll.dll", EntryPoint = "GetForegroundWindow")]
  8.         private unsafe static extern IntPtr GetForegroundWindow();
  9.         #endregion
  11.         [StructLayout(LayoutKind.Sequential)]
  12.         public unsafe struct CM_VOICE_RECORDER
  13.         {
  14.             public int cb;
  15.             public wndStyle dwStyle;
  16.             public int xPos;
  17.             public int yPos;
  18.             public IntPtr hwndParent;
  19.             public int id;
  20.             public char* lpszRecordFileName;
  21.         }
  23.         public enum wndStyle : uint
  24.         {
  25.             VRS_NO_OKCANCEL = 0x0001, // No OK/CANCLE displayed
  26.             VRS_NO_NOTIFY = 0x0002, // No parent Notifcation
  27.             VRS_MODAL = 0x0004, // Control is Modal    
  28.             VRS_NO_OK = 0x0008, // No OK displayed
  29.             VRS_NO_RECORD = 0x0010, // No RECORD button displayed
  30.             VRS_PLAY_MODE = 0x0020, // Immediately play supplied file when launched
  31.             VRS_NO_MOVE = 0x0040, // Grip is removed and cannot be moved around by the user
  32.             VRS_RECORD_MODE = 0x0080, // Immediately record when launched
  33.             VRS_STOP_DISMISS = 0x0100 // Dismiss control when stopped
  34.         }
  36.         private unsafe CM_VOICE_RECORDER _VoiceRec;
  37.         private IntPtr _hRecorder;
  38.         private string wavFile = @"\My Documents\~VRec_0.wav";
  40.         private IntPtr _Hwnd = (IntPtr)0;
  42.         public IntPtr Hwnd
  43.         {
  44.             get { return _Hwnd; }
  45.             set
  46.             {
  47.                 _VoiceRec.hwndParent = value;
  48.                 _Hwnd = value;
  49.             }
  50.         }
  52.         public unsafe VoiceRecorder()
  53.         {
  54.             _hRecorder = new IntPtr();
  55.             char[] temp = new char[32];
  57.             this.Hwnd = GetForegroundWindow();
  59.             // Populate temp with the file path of the WAV file            
  60.             Buffer.BlockCopy(wavFile.ToCharArray(), 0, temp, 0, 2 * wavFile.Length);
  62.             fixed (char* lpszFileName = temp)
  63.             {
  64.                 _VoiceRec = new CM_VOICE_RECORDER();
  66.                 _VoiceRec.hwndParent = _Hwnd;
  67.                 _VoiceRec.dwStyle = wndStyle.VRS_NO_MOVE | wndStyle.VRS_MODAL;
  68.                 _VoiceRec.cb = (int)Marshal.SizeOf(_VoiceRec);
  69.                 _VoiceRec.xPos = -1;
  70.                 _VoiceRec.yPos = -1;
  71.                 _VoiceRec.lpszRecordFileName = lpszFileName;
  72.             }
  73.         }
  75.         // Show the voice recorder
  76.         public unsafe void Show()
  77.         {
  78.             fixed (CM_VOICE_RECORDER* _VoiceRecPtr = &_VoiceRec)
  79.             {
  80.                 _hRecorder = VoiceRecorder_Create(_VoiceRecPtr);
  81.             }
  82.         }
  83.     }
  84. }
which is for creating a voice/audio recorder on a WM5 PDA. I have included the code into my project in a VoiceRecorder.cs class, and have invoked it from the main code (i.e. VoiceRecorder vr = new VoiceRecorder(); vr.show() ) and the voice recorder app appears on screen, and beeps when I hit record, but there doesnt seem to be any file being created, nor is there any functions for playback. I was wondering if anyone could help me out here, as I really want to include this in my application. If anyone has any other ideas on a good way to include a voice recording feature from c# code I would greatly appreciate it!

Cheers folks,

Oct 2 '07 #1
3 4108
5,000 Expert 4TB
Who wrote voicectl.dll? And do you have access to the source code for it?
Oct 3 '07 #2
648 Expert 512MB
Who wrote voicectl.dll? And do you have access to the source code for it?
It's a standard component within Windows Mobile 5 (NB I think i hit the wrong button earlier and reported this post and not replying! Sorry!)
Oct 16 '07 #3
9,065 Expert Mod 8TB
Given these 2 lines

Expand|Select|Wrap|Line Numbers
  1.         private string wavFile = @"\My Documents\~VRec_0.wav";
Expand|Select|Wrap|Line Numbers
  1.             char[] temp = new char[32];
I can't help feeling that you have a file path/name error. I know nothing of cs but if the @ in the first statement equates to a balnk string then the path to the file is obviously invalid.

On the other hand assuming that the @ in the first statement equates to the current users directory (making the path valid) then the length of the wavFile is going to be rather longer than the 32 characters assigned to temp;

Either way you seem to have an error around you file path/name.
Oct 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
by: fuliopen | last post by:
I know there are three types of audio files: wav, mp3 and wma. Keeping other factors, such as KHz, bit. mono or stereo, constant, the largest type is wav, and wma is the smallest. Is this...
by: arkam | last post by:
Here is the code : public class AudioMixerHelper { public const int MMSYSERR_NOERROR = 0; public const int MAXPNAMELEN = 32; public const int MIXER_LONG_NAME_CHARS = 64; public const int...
by: Mad Scientist Jr | last post by:
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...
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...
by: Jonathon | last post by:
I am creating an app that needs to capture dictation. I am currently starting to work with the OpenNETCF library. First, are there any other (better) alternatives to this package. We can spend...
by: zenologia | last post by:
Hello, I need to write an audio recorder application, and before starting writing code I'd like to know what components are available on the market. I'm looking for one or more .net audio...
by: wwzaygvm | last post by:
audio mid recorder 3.95 and crack http://cracks.12w.net F R E E
by: Frinavale | last post by:
I'm very impressed with Ubuntu. Everything works very well with my laptop in this flavour of Linux...even the media controls that I was sure wouldn't work do. I'm having problems with Skype...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.