/// <summary> /// Converts the specified wav file to MP3 /// </summary> /// <param name="filePath"></param> /// <param name="bitrate"></param> /// <param name="songTag"></param> private void ConvertToMp3(string bitrate, Mp3Tag songTag) { string wavFile = CreateOutputFile(songTag.ToString(), "wav"); // If the original wav recording doesn't exist, exit if (!File.Exists(wavFile)) { return; } string mp3File = CreateOutputFile(songTag.ToString(), "mp3"); addToLog("Converting to mp3... "); Process process = new Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //Mp3Tag tag = Util.ExtractMp3Tag(filePath); process.StartInfo.FileName = "lame.exe"; process.StartInfo.Arguments = string.Format("{2} --tt \"{3}\" --ta \"{4}\" --tc \"{5}\" \"{0}\" \"{1}\"", wavFile, mp3File, bitrate, songTag.Title, songTag.Artist, ""); process.StartInfo.WorkingDirectory = new FileInfo(Application.ExecutablePath).DirectoryName; addToLog("Starting LAME..."); process.Start(); //process.WaitForExit(20000); process.WaitForExit(); addToLog(" LAME exit code: " + process.ExitCode); if (!process.HasExited) { addToLog("Killing LAME process!"); process.Kill(); } addToLog("LAME finished!"); addToLog("Deleting wav file... "); try { File.Delete(wavFile); } catch (Exception) { addToLog("Error while deleting wav file"); } addToLog("Mp3 ready: " + mp3File); AddSongToList(mp3File); }
private void StartRecording(MMDevice device) { if (device != null) { if (soundCardRecorder != null) { StopRecording(); } recordingTrack = new Mp3Tag(currentTrack.Title, currentTrack.Artist); string song = recordingTrack.ToString(); string file = CreateOutputFile(song, "wav"); soundCardRecorder = new SoundCardRecorder( device, file, recordingTrack); soundCardRecorder.Start(); addToLog("Recording!"); } }