예제 #1
0
        private void ConvertToMp3(SoundCardRecorder scr, int bitrate)
        {
            if (!File.Exists(CreateOutputFile(scr.Song, "wav")))
            {
                return;
            }

            Process process = new Process();

            process.StartInfo.UseShellExecute = false;
            //process.StartInfo.RedirectStandardOutput = true;
            //process.StartInfo.RedirectStandardError = true;
            process.StartInfo.CreateNoWindow = false;
            process.StartInfo.WindowStyle    = ProcessWindowStyle.Normal;

            Mp3Tag tag = Util.ExtractMp3Tag(scr.Song);

            process.StartInfo.FileName  = "lame.exe";
            process.StartInfo.Arguments = string.Format("-b {2} --tt \"{3}\" --ta \"{4}\"  \"{0}\" \"{1}\"",
                                                        CreateOutputFile(scr.Song, "wav"),
                                                        CreateOutputFile(scr.Song, "mp3"),
                                                        bitrate,
                                                        tag.Title,
                                                        tag.Artist);

            process.StartInfo.WorkingDirectory = new FileInfo(Application.ExecutablePath).DirectoryName;
            process.Start();
            process.WaitForExit(20000);
            if (!process.HasExited)
            {
                process.Kill();
            }
            File.Delete(CreateOutputFile(scr.Song, "wav"));
        }
예제 #2
0
        private void StopRecording()
        {
            string   filePath = string.Empty;
            string   song     = string.Empty;
            TimeSpan duration = new TimeSpan();

            if (SoundCardRecorder != null)
            {
                SoundCardRecorder.Stop();
                filePath = SoundCardRecorder.FilePath;
                song     = SoundCardRecorder.Song;
                duration = SoundCardRecorder.Duration;
                SoundCardRecorder.Dispose();
                SoundCardRecorder = null;

                if (duration.Seconds < (int)thresholdTextBox.Value && thresholdCheckBox.Checked)
                {
                    File.Delete(filePath);
                }
                else
                {
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        int newItemIndex = listBoxRecordings.Items.Add(song);
                        listBoxRecordings.SelectedIndex = newItemIndex;
                        PostProcessing(song);
                    }
                }
            }
        }
예제 #3
0
        private void StartRecording(MMDevice device, string song)
        {
            if (!string.IsNullOrEmpty(song) && device != null)
            {
                if (SoundCardRecorder != null)
                {
                    StopRecording();
                }

                SoundCardRecorder = new SoundCardRecorder(
                    device, CreateOutputFile(songLabel.Text, "wav"),
                    songLabel.Text);
                SoundCardRecorder.Start();
            }
        }
예제 #4
0
        private void StartRecording(string song)
        {
            if (!string.IsNullOrEmpty(song))
            {
                lock (locker)
                {
                    if (SoundCardRecorder != null)
                    {
                        StopRecording();
                    }

                    var file = CreateOutputFile(songLabel.Text, "wav");

                    SoundCardRecorder = new SoundCardRecorder(
                        file,
                        songLabel.Text);
                    SoundCardRecorder.Start();

                    SoundCardRecorder.PostVolumeMeter.StreamVolume += OnPostVolumeMeter;
                }
            }
        }
예제 #5
0
        private void StartRecording(MMDevice device, string song)
        {
            if (!string.IsNullOrEmpty(song) && device != null)
            {
                if (SoundCardRecorder != null)
                {
                    StopRecording();
                }

                CalculateCurrentFileExistCounter(song);

                if (File.Exists(CreateOutputFile(song, "mp3")) || File.Exists(CreateOutputFile(song + "_old" + fileExistCounter, "mp3")))
                {
                    File.Move(CreateOutputFile(song, "mp3"), CreateOutputFile(song + "_old" + fileExistCounter, "mp3"));
                    fileExistCounter += 1;
                }

                SoundCardRecorder = new SoundCardRecorder(
                    device, CreateOutputFile(song, "wav"),
                    songLabel.Text);
                SoundCardRecorder.Start();
            }
        }
예제 #6
0
 private void StopRecording()
 {
     lock (locker)
     {
         if (SoundCardRecorder != null)
         {
             SoundCardRecorder.Stop();
             var filePath = SoundCardRecorder.FilePath;
             var song     = SoundCardRecorder.Song;
             var duration = SoundCardRecorder.Duration;
             if (thresholdCheckBox.Checked && duration.Seconds < (int)thresholdTextBox.Value)
             {
                 File.Delete(filePath);
                 SoundCardRecorder.Dispose();
             }
             else
             {
                 if (!string.IsNullOrEmpty(filePath))
                 {
                     int newItemIndex = listBoxRecordings.Items.Add(song);
                     listBoxRecordings.SelectedIndex = newItemIndex;
                     int  bitrate = (int)bitrateComboBox.SelectedValue;
                     var  copy    = SoundCardRecorder;
                     Task t       = new Task(() => ConvertToMp3(copy, bitrate));
                     t.Start();
                 }
                 else
                 {
                     SoundCardRecorder.Dispose();
                 }
             }
             volumeMeter1.Amplitude = 0;
             volumeMeter2.Amplitude = 0;
             SoundCardRecorder      = null;
         }
     }
 }
예제 #7
0
        private void StopRecording()
        {
            string filePath = string.Empty;
            string song = string.Empty;
            TimeSpan duration = new TimeSpan();
            if (SoundCardRecorder != null)
            {
                SoundCardRecorder.Stop();
                filePath = SoundCardRecorder.FilePath;
                song = SoundCardRecorder.Song;
                duration = SoundCardRecorder.Duration;
                SoundCardRecorder.Dispose();
                SoundCardRecorder = null;

                if (duration.Seconds < (int) thresholdTextBox.Value && thresholdCheckBox.Checked)
                    File.Delete(filePath);
                else
                {
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        int newItemIndex = listBoxRecordings.Items.Add(song);
                        listBoxRecordings.SelectedIndex = newItemIndex;
                        PostProcessing(song);
                    }
                }
            }
        }
예제 #8
0
        private void StartRecording(MMDevice device, string song)
        {
            if (!string.IsNullOrEmpty(song) && device != null)
            {
                if(SoundCardRecorder!=null)
                    StopRecording();

                SoundCardRecorder = new SoundCardRecorder(
                                device, CreateOutputFile(songLabel.Text, "wav"),
                                songLabel.Text);
                SoundCardRecorder.Start();
            }
        }
예제 #9
0
        private void StopRecording()
        {
            string filePath = string.Empty;
            string song = string.Empty;
            TimeSpan duration = new TimeSpan();
            if (SoundCardRecorder != null)
            {
                SoundCardRecorder.Stop();
                filePath = SoundCardRecorder.FilePath;
                song = SoundCardRecorder.Song;
                duration = SoundCardRecorder.Duration;
                SoundCardRecorder.Dispose();
                SoundCardRecorder = null;

                if (duration.TotalSeconds < (int)thresholdTextBox.Value && thresholdCheckBox.Checked)
                {
                    File.Delete(filePath);
                }
                else
                {
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        //Lied wird jetzt erst in die Liste eingetragen wenn Konvertierung beendet!
                        //int newItemIndex = listBoxRecordings.Items.Add(song);
                        //listBoxRecordings.SelectedIndex = newItemIndex;
                        PostProcessing(song);
                    }
                }
            }
        }