473,468 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Create 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.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
namespace SoundApplication
{
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()
{
InitializeComponent();

}

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 waveInGetNumDevs();
[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(object sender, EventArgs e)
{
const uint WAVE_MAPPER = unchecked((uint)(-1));
const int CALLBACK_WINDOW = 0x00010000;
const int CALLBACK_TASK = 0x00020000;
const int CALLBACK_FUNCTION = 0x00030000;
const int CALLBACK_EVENT = 0x00050000;

Winmm.WAVEFORMAT wavFmt;
wavFmt.wFormatTag = 1;
wavFmt.nChannels = 1;
wavFmt.nSamplesPerSec = 44100;
wavFmt.nAvgBytesPerSec = 44100;
wavFmt.nBlockAlign = 1;
wavFmt.wBitsPerSample = 8;
wavFmt.cbSize = 0;

wav = Winmm.waveInOpen(ref hWaveIn, WAVE_MAPPER, ref
wavFmt, dwCallback, 0, CALLBACK_WINDOW);
MessageBox.Show(wav.ToString());
wav = Winmm.waveOutOpen(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(ref m);
}

}
}

Sep 14 '07 #1
2 3600
>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.want.s...@mvps.org>
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.net/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
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...
1
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...
1
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...
4
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...
4
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...
3
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...
27
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...
3
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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.