我需要此窗口来录制麦克风的音频: XAML:
<Window x:Class="Mesius_Leitner_Professional.Record"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Record" Height="308" Width="378">
<Grid>
<Button Content="start" Height="23" HorizontalAlignment="Left" Margin="43,132,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
<Button Content="stop'n save" IsEnabled="False" Height="23" HorizontalAlignment="Right" Margin="0,132,157,0" Name="button2" VerticalAlignment="Top" Width="75" />
<Button Content="play" Height="23" IsEnabled="false" HorizontalAlignment="Left" Margin="205,132,0,0" Name="button3" VerticalAlignment="Top" Width="75" />
</Grid>
</Window>
和背后的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Mesius_Leitner_Professional
{
/// <summary>
/// Interaction logic for Record.xaml
/// </summary>
public partial class Record : Window
{
public Record()
{
InitializeComponent();
}
}
}
是否有任何标准的lib或一些额外的类我可以用一个简单的命令来录制音频?
答案 0 :(得分:0)
你可以使用winmm.dll
[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
string Resualt = @"...\Desktop\Test\test.wav";
mciSendString("save recsound " + Resualt, "", 0, 0);
mciSendString("close recsound ", "", 0, 0);
我希望它可以帮到你