本文介绍了我如何获得麦克风的当前值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想在没有可视化的情况下获得麦克风的当前值。
录音应该是这样的,或者我错了?
I just want to get the current value of the microphone without the visualization.
It should be something like this from recording, or am I wrong?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("winmm.dll")]
private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
[System.Runtime.InteropServices.DllImport("winmm.dll")]
private static extern bool mciGetErrorString(int fdwError, StringBuilder lpszErrorText, int cchErrorText);
Timer tm1 = new Timer();
private void button1_Click(object sender, EventArgs e)
{
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("set recsound CHANNELS 2", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
tm1.Interval = 10000;
tm1.Start();
tm1.Tick += new EventHandler(tm1_Tick);
}
void tm1_Tick(object sender, EventArgs e)
{
string outs = "";
int i = mciSendString(@"save recsound C:\Users\Daniel\Desktop\abcf.wav", outs, 0, 0);
MessageBox.Show("" + i);
StringBuilder buffer = new StringBuilder(128);
bool returnValue = mciGetErrorString(i, buffer, buffer.Capacity);
string err = buffer.ToString();
MessageBox.Show(buffer.ToString());
Close();
}
}
}
推荐答案
这篇关于我如何获得麦克风的当前值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!