From: Bellai Ádám Date: Fri, 10 Nov 2017 12:38:33 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=2d055b23ebd65f6278c337f4063b945dd764dfc5;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30706 --- diff --git a/client/AudioRecorder/MainForm.cs b/client/AudioRecorder/MainForm.cs index 5ae83e19..00165f2c 100644 --- a/client/AudioRecorder/MainForm.cs +++ b/client/AudioRecorder/MainForm.cs @@ -168,11 +168,11 @@ namespace AudioRecorder pauseButton.Enabled = false; recorder.StopRecording(); timeCodeWorker.Stop(); - copyFileToUncPath(); playButton.Enabled = true; stopButton.BackColor = Color.White; recordButton.BackColor = Color.Lime; volumePanel.Refresh(); + copyFileToUncPath(); } catch (Exception e) { diff --git a/client/AudioRecorder/WavRecorder.cs b/client/AudioRecorder/WavRecorder.cs index 9148bebf..206ac5de 100644 --- a/client/AudioRecorder/WavRecorder.cs +++ b/client/AudioRecorder/WavRecorder.cs @@ -4,14 +4,12 @@ using NAudio.Wave; using NAudio.CoreAudioApi; using System.Diagnostics; -namespace AudioRecorder -{ - public class WavRecorder : IRecorder - { +namespace AudioRecorder { + public class WavRecorder : IRecorder { private const int MONO_CHANEL = 1; private int inputDeviceIndex; - private WaveIn sourceStream; + private IWaveIn sourceStream; private WaveFileWriter waveWriter; private String filePath; private List createdWavFiles; @@ -19,16 +17,14 @@ namespace AudioRecorder private IMainForm mainForm; private bool pausing; - public WavRecorder(int inputDeviceIndex, MMDevice device, IMainForm mainForm) - { + public WavRecorder(int inputDeviceIndex, MMDevice device, IMainForm mainForm) { this.inputDeviceIndex = inputDeviceIndex; createdWavFiles = new List(); this.device = device; this.mainForm = mainForm; } - public void StartRecording(String filePath) - { + public void StartRecording(String filePath) { this.filePath = filePath; sourceStream = newWaveIn(); sourceStream.DataAvailable += newEventHandler(); @@ -37,71 +33,55 @@ namespace AudioRecorder createdWavFiles.Add(filePath); } - protected virtual EventHandler newEventHandler() - { + protected virtual EventHandler newEventHandler() { return new EventHandler(SourceStreamDataAvailable); } - protected virtual WaveFileWriter newWavFileWriter() - { + protected virtual WaveFileWriter newWavFileWriter() { return new WaveFileWriter(filePath, sourceStream.WaveFormat); } - protected virtual WaveIn newWaveIn() - { - return new WaveIn - { + protected virtual WaveIn newWaveIn() { + return new WaveIn { DeviceNumber = inputDeviceIndex, WaveFormat = - new WaveFormat(44100, MONO_CHANEL) + WaveFormat.CreateIeeeFloatWaveFormat(8000, MONO_CHANEL) + //new WaveFormat(8000, MONO_CHANEL) }; - } - public void SourceStreamDataAvailable(object sender, WaveInEventArgs e) - { + public void SourceStreamDataAvailable(object sender, WaveInEventArgs e) { if (waveWriter == null) return; - if (!pausing) - { + if (!pausing) { waveWriter.Write(e.Buffer, 0, e.BytesRecorded); float panelHeight = (device.AudioMeterInformation.MasterPeakValue + device.AudioSessionManager.SimpleAudioVolume.Volume) * 100; - //float panelHeight = device.AudioMeterInformation.MasterPeakValue * 1000; - Debug.WriteLine(String.Format("device.AudioMeterInformation.MasterPeakValue {0}", device.AudioMeterInformation.MasterPeakValue)); mainForm.setPanelSizeHeight(panelHeight); - //Debug.WriteLine(String.Format("device.AudioMeterInformation.MasterPeakValue {0}", device.AudioMeterInformation.MasterPeakValue)); - Debug.WriteLine(String.Format("panelHeight {0}", panelHeight)); waveWriter.Flush(); } } - public void StopRecording() - { - if (sourceStream != null) - { + public void StopRecording() { + if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } - if (waveWriter == null) - { + if (waveWriter == null) { return; } waveWriter.Dispose(); waveWriter = null; } - public void pauseRecording(bool pausing) - { + public void pauseRecording(bool pausing) { this.pausing = pausing; } - public List getCreatedFiles() - { + public List getCreatedFiles() { return createdWavFiles; } - public String getCurentWavFilePath() - { + public String getCurentWavFilePath() { return filePath; } }