Dobrý deň. Mám jednoduchý program na nahrávanie zvuku. Funguje, ale je tam veľmi veľký šum. Je na to nejaké riešenie? Ďakujem
using System;
using System.Drawing;
using System.Media;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SoundRecord
{
public partial class Form1 : Form
{
[DllImport("winmm.dll")]
private static extern long mciSendString(string command, StringBuilder retstring, int Returnlenth, IntPtr callback);
bool nahrava = false;
public Form1()
{
InitializeComponent();
mciSendString("open new Type waveaudio alias recsound", null, 0, IntPtr.Zero);
this.StartPosition = FormStartPosition.Manual;
Rectangle workingArea = Screen.GetWorkingArea(this);
this.Location = new Point(workingArea.Right - Size.Width, workingArea.Bottom - Size.Height);
}
private void Button1_Click(object sender, EventArgs e)
{
switch(nahrava)
{
case false:
mciSendString("record recsound", null, 0, IntPtr.Zero);
button1.ForeColor = Color.Red;
button1.Text = "Stop";
button3.Enabled = false;
nahrava = true;
break;
case true:
mciSendString("save recsound c:/SoundRecord/SoundRecord.wav", null, 0, IntPtr.Zero);
mciSendString("close recsound", null, 0, IntPtr.Zero);
button1.ForeColor = SystemColors.Desktop;
button1.Text = "Record";
button3.Enabled = true;
nahrava = false;
mciSendString("open new Type waveaudio alias recsound", null, 0, IntPtr.Zero);
break;
}
}
private void Button3_Click(object sender, EventArgs e)
{
SoundPlayer player = new SoundPlayer();
player.SoundLocation = @"c:/SoundRecord/SoundRecord.wav";
player.Play();
}
}
}
|