The tool for recording a .wav audio file is a MediaHandler called WaveStreamRecorder. This handle can be initialized by setting the filename (in local directory) or the file path of the file to be recorded into.
You can specify the audio file by opening a SaveFileDialog window that is a standard window used by any .NET application. In this window you can set the file name and the path (by browsing).Code:1. WaveStreamRecorder WaveStreamRecorder;
The audio stream can be recorded by pressing the Start button. You can pause and restart the recording with the same button. Pausing an audio recording means that the recording stops and when you start it again the audio data will be appended to the already saved audio.Code:1. private void buttonSave_Click(object sender, EventArgs e) 2. { 3. textBoxPlaybackFile.Text = string.Empty; 4. using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "Wave Files (*.wav)|*.wav", FileName = textBoxRecordingFile.Text }) 5. { 6. if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) 7. textBoxRecordingFile.Text = sfd.FileName; 8. } 9. }
You can stop the audio recording by pressing the Stop button. In this case the audio file will be finalized and disposed and all the used devices and tools will be stopped, closed and set to the initial value.Code:1. textBoxPlaybackFile.Text = string.Empty; 2. if (WaveStreamRecorder == null) 3. { 4. if (string.IsNullOrEmpty(textBoxRecordingFile.Text)) 5. return; // Select a file first 6. 7. WaveStreamRecorder = new WaveStreamRecorder(textBoxRecordingFile.Text); 8. WaveStreamRecorder.Stopped += (WaveStreamRecorder_Stopped); 9. microphone.Start(); 10. connector.Connect(microphone, WaveStreamRecorder); 11. WaveStreamRecorder.IsStreaming = false; 12. } 13. if (!WaveStreamRecorder.IsStreaming) 14. { 15. buttonStartRecording.Text = "Pause"; 16. WaveStreamRecorder.IsStreaming = true; 17. WaveStreamRecorder.StartStreaming(); 18. } 19. else 20. { 21. buttonStartRecording.Text = "Start"; 22. WaveStreamRecorder.PauseStreaming(); 23. WaveStreamRecorder.IsStreaming = false; 24. }
With the above mentioned methods you can record an uncompressed .wav audio file using Ozeki VoIP SIP SDK. If you want to record a phone call, you will need to connect your recorder object to the PhoneCallAudioReceiver object. In this case you can record the incoming audio data. If you want to record both parties' voice, you will need an AudioMixerMediaHandler object.Code:1. textBoxPlaybackFile.Text = string.Empty; 2. WaveStreamRecorder.StopStreaming(); 3. connector.Disconnect(microphone, WaveStreamRecorder); 4. microphone.Stop(); 5. WaveStreamRecorder.Dispose(); 6. WaveStreamRecorder = null; 7. buttonStartRecording.Text = "Start";
I hope, you’ve liked this text.
Bye,
Niko
+ Reply to Thread
Results 1 to 1 of 1
Similar Threads
-
decode 5.1 matrix surround wav file to 6 mono wav files
By Zerrax in forum AudioReplies: 2Last Post: 24th Nov 2013, 07:39 -
need help to play wav file
By adom in forum AudioReplies: 4Last Post: 7th Aug 2011, 11:47 -
how to cut a wav file precisely?
By Lastman369 in forum AudioReplies: 14Last Post: 6th Apr 2010, 23:21 -
Rescue WAV audio file
By Richard_G in forum AudioReplies: 8Last Post: 24th Sep 2008, 19:27 -
pops or clicks in wav file
By johnsees in forum AudioReplies: 7Last Post: 30th Jan 2008, 05:08