将常规wav转换为a-law声音时遇到问题。这样做时我的质量很差:
var image: UIImage? {
guard let url = try? FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false).appendingPathComponent(self).appendingPathExtension("png"),
let data = try? Data(contentsOf: url) else { return nil }
return UIImage(data: data)
}
或者说twise减慢声音:
WaveStream stream = new WaveFileReader(in.wav);
var s = new RawSourceWaveStream(new WaveFormatConversionStream(new WaveFormat(8000, 16, 1), stream), new WaveFormat(8000, 16, 1));
var c = new WaveFormatConversionStream(WaveFormat.CreateALawFormat(8000, 1), s);
WaveFileWriter.CreateWaveFile(AppDomain.CurrentDomain.BaseDirectory + "\\out.alaw", c);
如何将wav转换为高质量的a-law?
答案 0 :(得分:1)
在任何一个示例中,您都不需要RawSourceStream
,第二个示例将无效,除非in.wav
恰好具有正确的格式。
试试这个:
var stream = new WaveFileReader(in.wav);
var s = new WaveFormatConversionStream(new WaveFormat(8000, 16, 1), stream);
var c = new WaveFormatConversionStream(WaveFormat.CreateALawFormat(8000, 1), s);
WaveFileWriter.CreateWaveFile(AppDomain.CurrentDomain.BaseDirectory + "\\out.alaw", c);