我正在使用NAudio库来记录系统麦克风输入 - 连续.
private void RecordStart() {
try {
_sourceStream = new WaveIn {
DeviceNumber = _recordingInstance.InputDeviceIndex,
WaveFormat =
new WaveFormat(
44100,
WaveIn.GetCapabilities(_recordingInstance.InputDeviceIndex).Channels)
};
_sourceStream.DataAvailable += SourceStreamDataAvailable;
_sourceStream.StartRecording();
} catch (Exception exception) {
Log.Error("Recording failes", exception);
}
}
Run Code Online (Sandbox Code Playgroud)
有一个事件处理程序,只要有数据,它就会从记录流中获取数据.
我能够使用现有的音频文件创建一个音频(mp3)HTTP流媒体,并在我的系统中安装VLC播放器.
const int portNumber = 8089;
const string streamName = "fstream_1789846";
const string audio = "C:\\Recording\\Audio\\1789846.wav";
const string windowQuiet = "-I dummy --dummy-quiet";
const string tanscode = ":sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}";
var stream = String.Format(@":http{{mux=mp3,dst=:{0}/{1}}}", portNumber, streamName);
const string keep = ":sout-keep"; …Run Code Online (Sandbox Code Playgroud) 我在WPF中使用一个简单的按钮.我在背景上放了按钮的图像.我的问题是,当我将鼠标指针移动到按钮时,它会获得默认的光晕并覆盖作为背景给出的图像.
<Button Grid.Column="3" Name="Play" BorderBrush="Transparent"
Focusable="False" Width="45" Height="45" Click="Play_Click"
VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,6,10,6">
<Button.Background >
<ImageBrush ImageSource="images/play.png" />
</Button.Background>
<Button.Foreground>
<ImageBrush ImageSource="images/play.png" />
</Button.Foreground>
</Button>
Run Code Online (Sandbox Code Playgroud)
请帮我.
我正在尝试用C#开发录音机.我尝试过很多方法,比如NAudio,DirectX,Microsoft.Xna.Framework.Audio等.
一切都给出了相同的结果.我们停止录制后,输出文件mp3/wav得到保存.
mp3/wav文件在开头自己创建(没有和内容 - 0字节)
我正在尝试创建一个可以实时/同时保存音频的应用程序.
private void StartRecording() {
this.WaveSource = new WaveInEvent { WaveFormat = new WaveFormat(44100, 1) };
this.WaveSource.DataAvailable += this.WaveSourceDataAvailable;
this.WaveSource.RecordingStopped += this.WaveSourceRecordingStopped;
this.WaveFile = new WaveFileWriter(@"C:\Sample.wav", this.WaveSource.WaveFormat);
this.WaveSource.StartRecording();
}
private void StopRecording() {
this.WaveSource.StopRecording();
}
void WaveSourceDataAvailable(object sender, WaveInEventArgs e) {
if (this.WaveFile != null) {
this.WaveFile.Write(e.Buffer, 0, e.BytesRecorded);
this.WaveFile.Flush();
}
}
void WaveSourceRecordingStopped(object sender, StoppedEventArgs e) {
if (this.WaveSource != null) {
this.WaveSource.Dispose();
this.WaveSource = null;
}
if (this.WaveFile != null) {
this.WaveFile.Dispose();
this.WaveFile …Run Code Online (Sandbox Code Playgroud)