git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorBellai Ádám <USER\adam.bellai>
Fri, 10 Nov 2017 12:38:33 +0000 (12:38 +0000)
committerBellai Ádám <USER\adam.bellai>
Fri, 10 Nov 2017 12:38:33 +0000 (12:38 +0000)
client/AudioRecorder/MainForm.cs
client/AudioRecorder/WavRecorder.cs

index 5ae83e19cf79b49012bf31d87000f80d11335d16..00165f2c73b7b6ca9b52c37b2f8709e960c57ce4 100644 (file)
@@ -168,11 +168,11 @@ namespace AudioRecorder
                 pauseButton.Enabled = false;\r
                 recorder.StopRecording();\r
                 timeCodeWorker.Stop();\r
-                copyFileToUncPath();\r
                 playButton.Enabled = true;\r
                 stopButton.BackColor = Color.White;\r
                 recordButton.BackColor = Color.Lime;\r
                 volumePanel.Refresh();\r
+                copyFileToUncPath();\r
             }\r
             catch (Exception e)\r
             {\r
index 9148bebf6d0ac0c341b896121628bcb5f2b0527c..206ac5de633f98163c79a850ca4f77917e815fec 100644 (file)
@@ -4,14 +4,12 @@ using NAudio.Wave;
 using NAudio.CoreAudioApi;\r
 using System.Diagnostics;\r
 \r
-namespace AudioRecorder\r
-{\r
-    public class WavRecorder : IRecorder\r
-    {\r
+namespace AudioRecorder {\r
+    public class WavRecorder : IRecorder {\r
         private const int MONO_CHANEL = 1;\r
 \r
         private int inputDeviceIndex;\r
-        private WaveIn sourceStream;\r
+        private IWaveIn sourceStream;\r
         private WaveFileWriter waveWriter;\r
         private String filePath;\r
         private List<String> createdWavFiles;\r
@@ -19,16 +17,14 @@ namespace AudioRecorder
         private IMainForm mainForm;\r
         private bool pausing;\r
 \r
-        public WavRecorder(int inputDeviceIndex, MMDevice device, IMainForm mainForm)\r
-        {\r
+        public WavRecorder(int inputDeviceIndex, MMDevice device, IMainForm mainForm) {\r
             this.inputDeviceIndex = inputDeviceIndex;\r
             createdWavFiles = new List<String>();\r
             this.device = device;\r
             this.mainForm = mainForm;\r
         }\r
 \r
-        public void StartRecording(String filePath)\r
-        {\r
+        public void StartRecording(String filePath) {\r
             this.filePath = filePath;\r
             sourceStream = newWaveIn();\r
             sourceStream.DataAvailable += newEventHandler();\r
@@ -37,71 +33,55 @@ namespace AudioRecorder
             createdWavFiles.Add(filePath);\r
         }\r
 \r
-        protected virtual EventHandler<WaveInEventArgs> newEventHandler()\r
-        {\r
+        protected virtual EventHandler<WaveInEventArgs> newEventHandler() {\r
             return new EventHandler<WaveInEventArgs>(SourceStreamDataAvailable);\r
         }\r
 \r
-        protected virtual WaveFileWriter newWavFileWriter()\r
-        {\r
+        protected virtual WaveFileWriter newWavFileWriter() {\r
             return new WaveFileWriter(filePath, sourceStream.WaveFormat);\r
         }\r
 \r
-        protected virtual WaveIn newWaveIn()\r
-        {\r
-            return new WaveIn\r
-            {\r
+        protected virtual WaveIn newWaveIn() {\r
+            return new WaveIn {\r
                 DeviceNumber = inputDeviceIndex,\r
                 WaveFormat =\r
-                    new WaveFormat(44100, MONO_CHANEL)\r
+                WaveFormat.CreateIeeeFloatWaveFormat(8000, MONO_CHANEL)\r
+                //new WaveFormat(8000, MONO_CHANEL)\r
             };\r
-\r
         }\r
 \r
-        public void SourceStreamDataAvailable(object sender, WaveInEventArgs e)\r
-        {\r
+        public void SourceStreamDataAvailable(object sender, WaveInEventArgs e) {\r
             if (waveWriter == null) return;\r
-            if (!pausing)\r
-            {\r
+            if (!pausing) {\r
                 waveWriter.Write(e.Buffer, 0, e.BytesRecorded);\r
                 float panelHeight = (device.AudioMeterInformation.MasterPeakValue + device.AudioSessionManager.SimpleAudioVolume.Volume) * 100;\r
-                //float panelHeight = device.AudioMeterInformation.MasterPeakValue * 1000;\r
-                Debug.WriteLine(String.Format("device.AudioMeterInformation.MasterPeakValue {0}", device.AudioMeterInformation.MasterPeakValue));\r
                 mainForm.setPanelSizeHeight(panelHeight);\r
-                //Debug.WriteLine(String.Format("device.AudioMeterInformation.MasterPeakValue {0}", device.AudioMeterInformation.MasterPeakValue));\r
-                Debug.WriteLine(String.Format("panelHeight {0}", panelHeight));\r
                 waveWriter.Flush();\r
             }\r
         }\r
 \r
-        public void StopRecording()\r
-        {\r
-            if (sourceStream != null)\r
-            {\r
+        public void StopRecording() {\r
+            if (sourceStream != null) {\r
                 sourceStream.StopRecording();\r
                 sourceStream.Dispose();\r
                 sourceStream = null;\r
             }\r
-            if (waveWriter == null)\r
-            {\r
+            if (waveWriter == null) {\r
                 return;\r
             }\r
             waveWriter.Dispose();\r
             waveWriter = null;\r
         }\r
 \r
-        public void pauseRecording(bool pausing)\r
-        {\r
+        public void pauseRecording(bool pausing) {\r
             this.pausing = pausing;\r
         }\r
 \r
-        public List<String> getCreatedFiles()\r
-        {\r
+        public List<String> getCreatedFiles() {\r
             return createdWavFiles;\r
         }\r
 \r
-        public String getCurentWavFilePath()\r
-        {\r
+        public String getCurentWavFilePath() {\r
             return filePath;\r
         }\r
     }\r