Beispiel #1
0
        //#warning test wav to mp3 conversion
        //        /// <summary>
        //        /// Convert the wav file to an mp3 file
        //        /// </summary>
        //        /// <param name="filenameWAV">input file name of the wav file</param>
        //        /// <param name="filenameMP3">output file name of the mp3 file</param>
        //        /// <param name="deleteWAV">delete the wav file after conversion or not</param>
        //        /// see: https://github.com/filoe/cscore/blob/master/Samples/ConvertWavToMp3/Program.cs
        //        private void ConvertWAVToMP3(string filenameWAV, string filenameMP3, bool deleteWAV)
        //        {
        //            if (!System.IO.File.Exists(filenameWAV)) { return; }

        //            RecordState = RecordStates.CONVERTING_WAV_TO_MP3;
        //            IWaveSource source = CodecFactory.Instance.GetCodec(filenameWAV);
        //            MediaFoundationEncoder encoder = MediaFoundationEncoder.CreateMP3Encoder(source.WaveFormat, filenameMP3);

        //            byte[] buffer = new byte[source.WaveFormat.BytesPerSecond];
        //            int read;
        //            while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
        //            {
        //                encoder.Write(buffer, 0, read);
        //            }

        //            try
        //            {
        //                encoder.Dispose();
        //                source.Dispose();
        //            }
        //            catch (Exception) { }

        //            if (deleteWAV) { System.IO.File.Delete(filenameWAV); }
        //        }

        #endregion

        //***********************************************************************************************************************************************************************************************************

        #region Add tags to sound file

        /// <summary>
        /// Add additional infos to the .wav and/or .mp3 file
        /// </summary>
        private void AddTrackTags(string fileName, GenericPlayer.PlayerTrack trackInfo)
        {
            Image _albumImage = null;

            if (trackInfo.Album.Images != null && trackInfo.Album.Images.Count > 0)
            {
                _albumImage = new Bitmap(trackInfo.Album.Images.First());
            }

            if (System.IO.File.Exists(fileName))
            {
                RecordState = RecordStates.ADDING_TAGS;

#warning Tagging WAV file with title with special characters (ä, ö, ü) shows some hyroglyphical characters in file (seems to be a display problem of windows explorer (using no unicode))
                TagLib.File wavFile = TagLib.File.Create(fileName);
                wavFile.Tag.Title        = trackInfo.TrackName;
                wavFile.Tag.AlbumArtists = trackInfo.Artists.Select(a => a.ArtistName).ToArray();
                wavFile.Tag.Album        = trackInfo.Album.AlbumName;
                try
                {
                    if (_albumImage != null)
                    {
                        wavFile.Tag.Pictures = new TagLib.IPicture[] { new TagLib.Picture(new TagLib.ByteVector((byte[])new System.Drawing.ImageConverter().ConvertTo(_albumImage, typeof(byte[])))) };
                    }
                }
                catch (Exception) { /* AlbumArt couldn't be set */ }

                wavFile.Save();
            }
        }
Beispiel #2
0
        private ISoundOut _silenceOut;      //This object is used to play silence during each record. Otherwise blank parts won't be recorded. "Another oddity is that WASAPI will only push data down to the render endpoint when there are active streams. When nothing is playing, there is nothing to capture." (see: https://stackoverflow.com/questions/24135557/cscore-loopback-recording-when-muted)

        //***********************************************************************************************************************************************************************************************************

        /// <summary>
        /// Constructor of the Recorder class
        /// </summary>
        /// <param name="recorderSettings">Settings for the recorder</param>
        /// <param name="trackInfo">Track info of the record</param>
        /// <param name="logHandle">Handle that is used to write log entries</param>
        public Recorder(RecorderSettings recorderSettings, GenericPlayer.PlayerTrack trackInfo, IProgress <LogEvent> logHandle)
        {
            _logHandle          = logHandle;
            RecordState         = RecordStates.STOPPED;
            RecorderRecSettings = recorderSettings;
            TrackInfo           = trackInfo;
            AllowedDifferenceToTrackDuration = new TimeSpan(0, 0, 10);
            WasRecordPaused = false;
            MarkPausedFiles = true;
            CreateFilePath();
        }
Beispiel #3
0
 /// <summary>
 /// Constructor of the SpotifyRecorderImplementierung class
 /// </summary>
 /// <param name="recorderSettings">Settings for the recorder</param>
 /// <param name="trackInfo">Track info of the record</param>
 /// <param name="logHandle">Handle that is used to write log entries</param>
 public SpotifyRecorderImplementierung(RecorderSettings recorderSettings, GenericPlayer.PlayerTrack trackInfo, IProgress <LogEvent> logHandle) : base(recorderSettings, trackInfo, logHandle)
 {
     RecorderPostSteps += SpotifyRecorderImplementierung_RecorderPostSteps;
 }