Example #1
0
        public async Task ProcessAndSaveDisplayLines(string baseDirectory, string fileName)
        {
            try
            {
                if (_fileService.ProcessedDisplayLinesFileExists(baseDirectory, fileName))
                {
                    //nothing to do
                    return;
                }
                else
                {
                    var audioPath = _audioFileService.GetFullPathToRecording(baseDirectory, fileName);
                    var metadata  = _metadataService.GetRecordingMetadata(baseDirectory, fileName);
                    var samples   = await GetSampleValues(audioPath, metadata.AudioBitrate);

                    var displayLines = GetLinesFromSamples(ConfigService.PixelWidth, ConfigService.YAxis,
                                                           ConfigService.ChartHeight, samples);
                    _fileService.SaveProcessedDisplayLines(displayLines, fileName);
                    await _loggingService.LogAsync($"Processed file succesfully: {fileName} ");
                }
            }
            catch (Exception ex)
            {
                await _loggingService.LogAsync($"Error processing file! {fileName} {ex.Message}");

                if (!retryLog.ContainsKey(fileName) || retryLog[fileName] < retryMaxCount)
                {
                    await RetryProcessAndSaveDisplayLines(baseDirectory, fileName);
                }
                else
                {
                    await _loggingService.LogAsync($"Giving up processing. {fileName} {ex.Message}");
                }
            }
        }
Example #2
0
 public AudioPlayService(string baseDirectory, string fileName)
 {
     _metadataService  = new MetadataService();
     _audioFileService = new AudioFileService();
     _metadata         = _metadataService.GetRecordingMetadata(baseDirectory, fileName);
     _fullPathToAudio  = _audioFileService.GetFullPathToRecording(baseDirectory, fileName);
 }