以下のコード ( waveInStream.DataAvailable )の理由を理解しようとしています。
Private Sub cmbRecord_Click(sender As Object, e As EventArgs)
Dim saveFileDialog As New SaveFileDialog()
saveFileDialog.Title = "Select output file:"
saveFileDialog.Filter = "WAV Files (*.wav)|*.wav"
saveFileDialog.FileName = outputFilename
If saveFileDialog.ShowDialog() = DialogResult.OK Then
outputFilename = saveFileDialog.FileName
waveInStream = New WaveIn(44100, 2)
writer = New WaveFileWriter(outputFilename, waveInStream.WaveFormat)
waveInStream.DataAvailable += New EventHandler(Of WaveInEventArgs)(AddressOf waveInStream_DataAvailable)
waveInStream.StartRecording()
' Just controling the objects on the screen.
cmbRecord.Enabled = False
cmbStop.Enabled = True
End If
End Sub
エラーが表示されます:
Error 1 'Public Event DataAvailable(sender As Object, e As NAudio.Wave.WaveInEventArgs)'
is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
HEREの例を使用して、上記のコードをc#からVB.netに変換しています
VB に変換された c# は次のとおりです。
private void cmbRecord_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Title = "Select output file:";
saveFileDialog.Filter = "WAV Files (*.wav)|*.wav";
saveFileDialog.FileName = outputFilename;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
outputFilename = saveFileDialog.FileName;
waveInStream = new WaveIn(44100,2);
writer = new WaveFileWriter(outputFilename, waveInStream.WaveFormat);
waveInStream.DataAvailable += new EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
waveInStream.StartRecording();
// Just controling the objects on the screen.
cmbRecord.Enabled = false;
cmbStop.Enabled = true;
}
}
どんな助けでも素晴らしいでしょう!
ありがとう!