WaveInOpen

  • Thread starter Thread starter jrumanek
  • Start date Start date
J

jrumanek

Hallo,

I have a problem with function WaveInOpen.

The function gives ERROR CODE 11 - MMSYSERR_INVALPARAM.

Shall you help me please?

Any sugestion?

Thank You! Jarek


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 frmMain()
{
InitializeComponent();

}

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 Winmm
{
[DllImport("winmm.dll")]
public static extern int waveInGetNumDevs();
[DllImport("winmm.dll")]
public static extern int waveInOpen(ref IntPtr lphWaveIn,
uint DEVICEID, WAVEFORMAT lpWaveFormat,
IntPtr dwCallback, uint dwInstance, uint dwFlags);
}

private void btOpen_Click(object sender, EventArgs e)
{
const uint WAVE_MAPPER = unchecked((uint)(-1));


const uint CALLBACK_WINDOW = 0x00010000; /*
dwCallback is a HWND */


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

int wav;
IntPtr hWaveIn = IntPtr.Zero;
IntPtr dwCallback = IntPtr.Zero;
wav = Winmm.waveInOpen(ref hWaveIn, WAVE_MAPPER, wavFmt,
dwCallback, 0, CALLBACK_WINDOW);
MessageBox.Show(wav.ToString());
}

}
 
[DllImport("winmm.dll")]
public static extern int waveInOpen(ref IntPtr lphWaveIn,
uint DEVICEID, WAVEFORMAT lpWaveFormat,
IntPtr dwCallback, uint dwInstance, uint dwFlags);

Make that

...., ref WAVEFORMAT lpWaveFormat, ...


Mattias
 
[DllImport("winmm.dll")]
public static extern int waveInOpen(ref IntPtr lphWaveIn,
uint DEVICEID, WAVEFORMAT lpWaveFormat,
IntPtr dwCallback, uint dwInstance, uint dwFlags);

Make that

..., ref WAVEFORMAT lpWaveFormat, ...

Mattias


Thank You for your help!
Jarek
 
[DllImport("winmm.dll")]
public static extern int waveInOpen(ref IntPtr lphWaveIn,
uint DEVICEID, WAVEFORMAT lpWaveFormat,
IntPtr dwCallback, uint dwInstance, uint dwFlags);

Make that

..., ref WAVEFORMAT lpWaveFormat, ...

Mattias

Thank You for zour help!
Jarek
 
Back
Top