473,657 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function WaveInOpen doesn't return meesage MM_WIM_OPEN?

Hallo,

I have problem with function WaveInOpen . This function doesn't return
meesage MM_WIM_OPEN?

Shall YOU help me pleas?

Any suggestions?

Thank you!

My code:

using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using System.IO;
using System.Runtime. InteropServices ;
namespace SoundApplicatio n
{
public partial class frmMain : Form
{
public int wav;
public IntPtr hWaveIn = IntPtr.Zero;
public IntPtr hWaveOut = IntPtr.Zero;
public IntPtr dwCallback = IntPtr.Zero;

public frmMain()
{
InitializeCompo nent();

}

public class Winmm
{
public struct WAVEFORMAT
{
public short wFormatTag;
public short nChannels;
public uint nSamplesPerSec;
public uint nAvgBytesPerSec ;
public short nBlockAlign;
public short wBitsPerSample;
public short cbSize;
}

public class WAVEHDR
{
public IntPtr lpData = IntPtr.Zero;
public uint dwBufferLength = 0;
public uint dwBytesRecorded = 0;
public uint dwUser = 0;
public uint dwFlags = 0;
public uint dwLoops = 0;
public IntPtr lpNext = IntPtr.Zero;
public uint reserved = 0;
}

private const string mmdll = "winmm.dll" ;

// WaveIn calls
[DllImport(mmdll )]
public static extern int waveInGetNumDev s();
[DllImport(mmdll )]
public static extern int waveInOpen(ref IntPtr lphWaveIn,
uint DEVICEID, ref WAVEFORMAT lpWaveFormat,
IntPtr dwCallback, uint dwInstance, uint dwFlags);

//WaveOut calls
[DllImport(mmdll )]
public static extern int waveOutOpen(ref IntPtr
lphWaveOut, uint DEVICEID, ref WAVEFORMAT lpWaveFormat,
IntPtr dwCallback, uint dwInstance, uint dwFlags);
}

private void btOpen_Click(ob ject sender, EventArgs e)
{
const uint WAVE_MAPPER = unchecked((uint )(-1));
const int CALLBACK_WINDOW = 0x00010000;
const int CALLBACK_TASK = 0x00020000;
const int CALLBACK_FUNCTI ON = 0x00030000;
const int CALLBACK_EVENT = 0x00050000;

Winmm.WAVEFORMA T wavFmt;
wavFmt.wFormatT ag = 1;
wavFmt.nChannel s = 1;
wavFmt.nSamples PerSec = 44100;
wavFmt.nAvgByte sPerSec = 44100;
wavFmt.nBlockAl ign = 1;
wavFmt.wBitsPer Sample = 8;
wavFmt.cbSize = 0;

wav = Winmm.waveInOpe n(ref hWaveIn, WAVE_MAPPER, ref
wavFmt, dwCallback, 0, CALLBACK_WINDOW );
MessageBox.Show (wav.ToString() );
wav = Winmm.waveOutOp en(ref hWaveOut, WAVE_MAPPER, ref
wavFmt, dwCallback, 0, CALLBACK_WINDOW );
}

protected override void WndProc(ref Message m)
{

const int MM_WIM_OPEN = 0x3BE;
const int MM_WIM_CLOSE = 0x3BF;
const int MM_WIM_DATA = 0x3C0;

const int MM_WOM_OPEN = 0x3BB;
const int MM_WOM_CLOSE = 0x3BC;
const int MM_WOM_DONE = 0x3BD;
if (m.Msg == MM_WIM_OPEN || m.Msg == MM_WOM_OPEN || m.Msg
== MM_WIM_CLOSE)
{
MessageBox.Show ("TEST");
}
switch (m.Msg)
{
case MM_WIM_OPEN:
MessageBox.Show ("MM_WIM_OPEN") ;
break;
case MM_WIM_CLOSE:
MessageBox.Show ("MM_WOM_OPEN") ;
break;
case MM_WOM_OPEN:
MessageBox.Show ("MM_WOM_OPEN") ;
break;
}
base.WndProc(re f m);
}

}
}

Sep 14 '07 #1
2 3610
>I have problem with function WaveInOpen . This function doesn't return
>meesage MM_WIM_OPEN?
You must pass in the window handle of the window that should process
the message as the dwCallback parameter. As far as I can see, it's
always IntPtr.Zero in your code.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 14 '07 #2
On 14 Zá , 19:15, Mattias Sjögren <mattias.dont.w ant.s...@mvps.o rg>
wrote:
I have problem with function WaveInOpen . This function doesn't return
meesage MM_WIM_OPEN?

You must pass in the window handle of the window that should process
the message as the dwCallback parameter. As far as I can see, it's
always IntPtr.Zero in your code.

Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.orghttp://www.msjogren.ne t/dotnet/|http://www.dotnetinterop.com
Please reply only to the newsgroup.
Thank You!
But I don't know how can I pass in the window handle of the window?
Shall You write me code for pass handle?
I was using Builder C++ and I'm beginner in C#.
Jarek

Sep 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4950
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
1
4462
by: Brian | last post by:
Hi there, I am trying supress an error meesage that is raised if an Access report fails during the hours of 7pm to 8am. I would assume that the NOW function would be used to achieve this somehow(Something to the effect of 'If Now > 7:00 pm then..." etc., but I can't figure out the exact syntax. Has anyone else done this successfully before? Thanks in advance.
1
4551
by: Ja | last post by:
Hello, I'm capturing audio from the soundcard, using the waveInXXX calls. I'm having no problem capturing a PCM stream. Yet, when I try to capture a GSM compressed stream, I get a failure opening the device (32). As far as I can tell, I'm doing everything according to Article ID : 153866 (http://support.microsoft.com/default.aspx?scid=kb;en-us;153866#kb2) Here's the code (as it apperas in a similar question, asked years ago):
4
4752
by: Sakharam Phapale | last post by:
Hi All, I have written following code, but waveInOpen API call gives me error no 32. Can anyone help me to solve this? Public Delegate Function callback(ByVal hw As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Public Const CALLBACK_FUNCTION = &H30000
4
9078
by: saverain | last post by:
//WaveIn.h MMRESULT IsFormatSupported(LPWAVEFORMATEX pwfx, UINT uDeviceID) { return waveInOpen ( NULL, // ptr can be NULL for query uDeviceID, // The device identifier pwfx, // Defines the requested // format. NULL, // No callback NULL, // No instance data
3
2605
by: nullstring | last post by:
Hallo Leute, gerade sitze ich vor dem problem, das ich eine Klasse schreiben muss dir mir ne Wav datei vom mikro aufnimmt und wieder abspielt. Mein Problem ist nun, das mir meine callbackfunction nie ein MM_WIM_DATA liefert und augenscheinlich auch nix aufnimmt. Tja und wie es halt so ist, bin ein newbie was Winprogrammierung
27
3111
by: Terry | last post by:
I am getting the following warning for the below function. I understand what it means but how do I handle a null reference? Then how do I pass the resulting value? Regards Warning 1 Function 'Dec2hms' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.
3
9877
by: jrumanek | last post by:
Hallo, I have a problem with function WaveInOpen. The function gives ERROR CODE 11 - MMSYSERR_INVALPARAM. Shall you help me please? Any sugestion?
3
3962
by: wizche | last post by:
Hi Everybody, I'm trying to play a little with waveIn functions... My goal is to calculate if I'm listening a specified sin frequency or not. For this reason I'm going down with the samplerate... How can I be sure of the sampling rate set on my device? If I declare waveFormat.nSamplesPerSec = 9441000; waveInOpen return NO error.. (same if I put 500 Hz) But I'm not really sure that's working (9 MHz!!)... For example if I want to find a...
0
8399
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
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
8504
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,...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6169
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
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
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.