Beispiel #1
0
 public void StartRecording(RecordingCandidate candidateFile, IOptionsService optionsService)
 {
     if (_status == RecordingStatus.NotRecording)
     {
         _status = RecordingStatus.Recording;
         OnStartedEvent();
         _timer.Start();
     }
 }
Beispiel #2
0
        /// <summary>
        /// Gets the full path of the next recording file (non-existent)
        /// </summary>
        /// <param name="optionsService">Options service</param>
        /// <param name="dt">Recording date</param>
        /// <param name="commandLineIdentifier">identifier passed on commandline to differentiate settings and folders</param>
        /// <returns>Candidate path</returns>
        public RecordingCandidate GetRecordingFileCandidate(
            IOptionsService optionsService,
            DateTime dt,
            string commandLineIdentifier)
        {
            var destFolder        = FileUtils.GetDestinationFolder(dt, commandLineIdentifier, optionsService.Options.DestinationFolder);
            var finalPathAndTrack = GetNextAvailableFile(optionsService, destFolder, dt);

            var result = new RecordingCandidate
            {
                RecordingDate = dt,
                TrackNumber   = finalPathAndTrack.TrackNumber,
                TempPath      = GetTempRecordingFile(),
                FinalPath     = finalPathAndTrack.FilePath
            };

            Log.Logger.Information("New candidate = {@Candidate}", result);
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Starts recording
        /// </summary>
        /// <param name="candidateFile">The candidate recording file</param>
        /// <param name="optionsService">The options service</param>
        public void StartRecording(RecordingCandidate candidateFile, IOptionsService optionsService)
        {
            _currentRecording = candidateFile;

            RecordingConfig recordingConfig = new RecordingConfig
            {
                RecordingDevice = optionsService.Options.RecordingDevice,
                RecordingDate   = candidateFile.RecordingDate,
                TrackNumber     = candidateFile.TrackNumber,
                DestFilePath    = candidateFile.TempPath,
                SampleRate      = optionsService.Options.SampleRate,
                ChannelCount    = optionsService.Options.ChannelCount,
                Mp3BitRate      = optionsService.Options.Mp3BitRate,
                TrackTitle      = GetTrackTitle(candidateFile),
                AlbumName       = GetAlbumName(candidateFile),
                Genre           = optionsService.Options.Genre
            };

            _audioRecorder.Start(recordingConfig);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the full path of the next recording file (non-existent)
        /// </summary>
        /// <param name="optionsService">Options service</param>
        /// <param name="dt">Recording date</param>
        /// <param name="commandLineIdentifier">identifier passed on commandline to differentiate settings and folders</param>
        /// <returns>Candidate path</returns>
        public RecordingCandidate GetRecordingFileCandidate(
            IOptionsService optionsService,
            DateTime dt,
            string?commandLineIdentifier)
        {
            var destFolder        = FileUtils.GetDestinationFolder(dt, commandLineIdentifier, optionsService.Options.DestinationFolder);
            var finalPathAndTrack = GetNextAvailableFile(optionsService, destFolder, dt);

            if (finalPathAndTrack == null)
            {
                throw new NotSupportedException("Unable to get recording candidate!");
            }

            var result = new RecordingCandidate(
                dt,
                finalPathAndTrack.TrackNumber,
                GetTempRecordingFile(),
                finalPathAndTrack.FilePath);

            Log.Logger.Information("New candidate = {@Candidate}", result);
            return(result);
        }
Beispiel #5
0
 private static string GetTrackTitle(RecordingCandidate candidate)
 {
     return(Path.GetFileNameWithoutExtension(candidate.FinalPath));
 }
Beispiel #6
0
 private static string GetAlbumName(RecordingCandidate candidate)
 {
     return(candidate.RecordingDate.ToString("MMM yyyy"));
 }
Beispiel #7
0
 private void OnStoppedEvent()
 {
     StoppedEvent?.Invoke(this, EventArgs.Empty);
     CopyFileToFinalDestination();
     _currentRecording = null;
 }