Exemplo n.º 1
0
        public string ConvertToWav(string fileName)
        {
            FileInfo outputFormat = new FileInfo
            {
                FileType = FileType.Wav,
                Channels = 1,
                SampleSizeInBits = 8,
                SamplingRate = _samplingRate,
                EncodingType = EncodingType.UnsignedInteger
            };

            var fileNameExt = Path.GetExtension(fileName);
            ConvertOptions convertOptions = new ConvertOptions
            {
                InputFileInfo = new FileInfo
                {
                    FileType = Sox.GetFileTypeFromExtension(fileNameExt)
                },
                OutputFileInfo = outputFormat
            };
            using (Stream input = File.OpenRead(fileName))
            {
                string resultFileName = Path.GetTempFileName();
                _sox.Convert(input, convertOptions).WriteToFile(resultFileName);
                return resultFileName;
            }
        }
Exemplo n.º 2
0
        public Stream Convert(string fileName)
        {
            FileInfo rawFileFormat = new FileInfo
            {
                FileType = FileType.RawUnsignedInteger8,
                Channels = 1,
                SampleSizeInBits = 8,
                SamplingRate = _samplingRate,
                EncodingType = EncodingType.UnsignedInteger
            };

            var fileNameExt = Path.GetExtension(fileName);
            ConvertOptions convertOptions = new ConvertOptions
            {
                InputFileInfo = new FileInfo
                {
                    FileType = Sox.GetFileTypeFromExtension(fileNameExt)
                },
                OutputFileInfo = rawFileFormat
            };
            using (Stream input = File.OpenRead(fileName))
            {
                return _sox.Convert(input, convertOptions);
            }
        }
Exemplo n.º 3
0
        public Stream Convert(string fileName)
        {
            FileInfo rawFileFormat = new FileInfo
            {
                FileType         = FileType.RawUnsignedInteger8,
                Channels         = 1,
                SampleSizeInBits = 8,
                SamplingRate     = _samplingRate,
                EncodingType     = EncodingType.UnsignedInteger
            };

            var            fileNameExt    = Path.GetExtension(fileName);
            ConvertOptions convertOptions = new ConvertOptions
            {
                InputFileInfo = new FileInfo
                {
                    FileType = Sox.GetFileTypeFromExtension(fileNameExt)
                },
                OutputFileInfo = rawFileFormat
            };

            using (Stream input = File.OpenRead(fileName))
            {
                return(_sox.Convert(input, convertOptions));
            }
        }
Exemplo n.º 4
0
        public string ConvertToWav(string fileName)
        {
            FileInfo outputFormat = new FileInfo
            {
                FileType         = FileType.Wav,
                Channels         = 1,
                SampleSizeInBits = 8,
                SamplingRate     = _samplingRate,
                EncodingType     = EncodingType.UnsignedInteger
            };

            var            fileNameExt    = Path.GetExtension(fileName);
            ConvertOptions convertOptions = new ConvertOptions
            {
                InputFileInfo = new FileInfo
                {
                    FileType = Sox.GetFileTypeFromExtension(fileNameExt)
                },
                OutputFileInfo = outputFormat
            };

            using (Stream input = File.OpenRead(fileName))
            {
                string resultFileName = Path.GetTempFileName();
                _sox.Convert(input, convertOptions).WriteToFile(resultFileName);
                return(resultFileName);
            }
        }
Exemplo n.º 5
0
        public string ConvertToWav(string sourceFileName, string destinationFileName, bool highQuality = false)
        {
            _log.Debug(string.Format("Atempting to convert '{0}' to '{1}'", sourceFileName, destinationFileName));
            FileInfo outputFormat = new FileInfo
            {
                FileType         = FileType.Wav,
                Channels         = 1,
                SampleSizeInBits = 8,
                SamplingRate     = highQuality ? SAMPLING_RATE * 2 : SAMPLING_RATE,
                EncodingType     = EncodingType.UnsignedInteger
            };

            var            fileNameExt    = Path.GetExtension(sourceFileName);
            ConvertOptions convertOptions = new ConvertOptions
            {
                InputFileInfo = new FileInfo
                {
                    FileType = Sox.GetFileTypeFromExtension(fileNameExt)
                },
                OutputFileInfo = outputFormat
            };

            using (Stream input = File.OpenRead(sourceFileName))
            {
                string resultFileName = string.IsNullOrEmpty(destinationFileName) ? Path.GetTempFileName() : destinationFileName;
                using (var tempConvertedFileStream = _sox.Convert(input, convertOptions))
                {
                    tempConvertedFileStream.WriteToFile(resultFileName);
                };
                return(resultFileName);
            }
        }
Exemplo n.º 6
0
        public string ConvertToWav(string sourceFileName, string destinationFileName, bool highQuality = false)
        {
            _log.Debug(string.Format("Atempting to convert '{0}' to '{1}'", sourceFileName, destinationFileName));
            FileInfo outputFormat = new FileInfo
            {
                FileType = FileType.Wav,
                Channels = 1,
                SampleSizeInBits = 8,
                SamplingRate = highQuality ? SAMPLING_RATE * 2 : SAMPLING_RATE,
                EncodingType = EncodingType.UnsignedInteger
            };

            var fileNameExt = Path.GetExtension(sourceFileName);
            ConvertOptions convertOptions = new ConvertOptions
            {
                InputFileInfo = new FileInfo
                {
                    FileType = Sox.GetFileTypeFromExtension(fileNameExt)
                },
                OutputFileInfo = outputFormat
            };
            using (Stream input = File.OpenRead(sourceFileName))
            {
                string resultFileName = string.IsNullOrEmpty(destinationFileName) ? Path.GetTempFileName() : destinationFileName;
                using (var tempConvertedFileStream = _sox.Convert(input, convertOptions))
                {
                    tempConvertedFileStream.WriteToFile(resultFileName);
                };
                return resultFileName;
            }
        }