Error[8]: Undefined offset: 2, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我有这个代码: func loadSoundfont(_ pitch : String) { let path: String = Bundle.main.path(forResource: "\(self.id)/\(pitch)", ofType: "f32")! let url = URL(fileURLWithPath: path) do { le 我有这个代码:

func loadSoundFont(_ pitch : String) {    let path: String = Bundle.main.path(forResource: "\(self.ID)/\(pitch)",ofType: "f32")!    let url = URL(fileURLWithPath: path)    do {        let file = try AVAudiofile(forReading: url,commonFormat: AVAudioCommonFormat.pcmFormatfloat32,interleaved: true)        let format = file.processingFormat        let capacity = AVAudioFrameCount(file.length)        self.buffer = AVAudioPCMBuffer(pcmFormat: format,frameCapacity: capacity)        try file.read(into: self.buffer!)    } catch let error as NSError {        print("ERROR HERE",error.localizedDescription)    }}

我得到以下错误:1954115647这是:kAudiofileUnsupportedfileTypeError

我的A4.f32文件包含一个PCM浮动32.这里有什么我想念的吗?我的文件中没有标题,是否可能导致此问题?

解决方法 感谢Rhythmic Fistman的评论,我自己去加载它,就这样:

func loadSoundFont(_ pitch : String) {    let path: String = Bundle.main.path(forResource: "\(self.ID)/\(pitch)",ofType: "f32")!    let url = URL(fileURLWithPath: path)    do {        let data = try Data(contentsOf: url)        let format = AVAudioFormat(commonFormat: .pcmFormatfloat32,sampleRate: 44100,channels: 2,interleaved: true)        self.buffer = AVAudioPCMBuffer(pcmFormat: format,frameCapacity: AVAudioFrameCount(data.count))        self.buffer!.floatChannelData!.pointee.withMemoryRebound(to: UInt8.self,capacity: data.count) {            let stream = OutputStream(toBuffer: [+++],capacity: data.count)            stream.open()            _ = data.withUnsafeBytes {                stream.write([+++],maxLength: data.count)            }            stream.close()        }    } catch let error as NSError {        print("ERROR HERE",error.localizedDescription)    }}
总结

以上是内存溢出为你收集整理的swift – 将pcm加载到AVAudioPCMBuffer中全部内容,希望文章能够帮你解决swift – 将pcm加载到AVAudioPCMBuffer中所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 3, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我有这个代码: func loadSoundfont(_ pitch : String) { let path: String = Bundle.main.path(forResource: "\(self.id)/\(pitch)", ofType: "f32")! let url = URL(fileURLWithPath: path) do { le 我有这个代码:

func loadSoundFont(_ pitch : String) {    let path: String = Bundle.main.path(forResource: "\(self.ID)/\(pitch)",ofType: "f32")!    let url = URL(fileURLWithPath: path)    do {        let file = try AVAudiofile(forReading: url,commonFormat: AVAudioCommonFormat.pcmFormatfloat32,interleaved: true)        let format = file.processingFormat        let capacity = AVAudioFrameCount(file.length)        self.buffer = AVAudioPCMBuffer(pcmFormat: format,frameCapacity: capacity)        try file.read(into: self.buffer!)    } catch let error as NSError {        print("ERROR HERE",error.localizedDescription)    }}

我得到以下错误:1954115647这是:kAudiofileUnsupportedfileTypeError

我的A4.f32文件包含一个PCM浮动32.这里有什么我想念的吗?我的文件中没有标题,是否可能导致此问题?

解决方法 感谢Rhythmic Fistman的评论,我自己去加载它,就这样:

func loadSoundFont(_ pitch : String) {    let path: String = Bundle.main.path(forResource: "\(self.ID)/\(pitch)",ofType: "f32")!    let url = URL(fileURLWithPath: path)    do {        let data = try Data(contentsOf: url)        let format = AVAudioFormat(commonFormat: .pcmFormatfloat32,sampleRate: 44100,channels: 2,interleaved: true)        self.buffer = AVAudioPCMBuffer(pcmFormat: format,frameCapacity: AVAudioFrameCount(data.count))        self.buffer!.floatChannelData!.pointee.withMemoryRebound(to: UInt8.self,capacity: data.count) {            let stream = OutputStream(toBuffer: ,capacity: data.count)            stream.open()            _ = data.withUnsafeBytes {                stream.write([+++],maxLength: data.count)            }            stream.close()        }    } catch let error as NSError {        print("ERROR HERE",error.localizedDescription)    }}
总结

以上是内存溢出为你收集整理的swift – 将pcm加载到AVAudioPCMBuffer中全部内容,希望文章能够帮你解决swift – 将pcm加载到AVAudioPCMBuffer中所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
swift – 将pcm加载到AVAudioPCMBuffer中_app_内存溢出

swift – 将pcm加载到AVAudioPCMBuffer中

swift – 将pcm加载到AVAudioPCMBuffer中,第1张

概述我有这个代码: func loadSoundfont(_ pitch : String) { let path: String = Bundle.main.path(forResource: "\(self.id)/\(pitch)", ofType: "f32")! let url = URL(fileURLWithPath: path) do { le 我有这个代码:

func loadSoundFont(_ pitch : String) {    let path: String = Bundle.main.path(forResource: "\(self.ID)/\(pitch)",ofType: "f32")!    let url = URL(fileURLWithPath: path)    do {        let file = try AVAudiofile(forReading: url,commonFormat: AVAudioCommonFormat.pcmFormatfloat32,interleaved: true)        let format = file.processingFormat        let capacity = AVAudioFrameCount(file.length)        self.buffer = AVAudioPCMBuffer(pcmFormat: format,frameCapacity: capacity)        try file.read(into: self.buffer!)    } catch let error as NSError {        print("ERROR HERE",error.localizedDescription)    }}

我得到以下错误:1954115647这是:kAudiofileUnsupportedfileTypeError

我的A4.f32文件包含一个PCM浮动32.这里有什么我想念的吗?我的文件中没有标题,是否可能导致此问题?

解决方法 感谢Rhythmic Fistman的评论,我自己去加载它,就这样:

func loadSoundFont(_ pitch : String) {    let path: String = Bundle.main.path(forResource: "\(self.ID)/\(pitch)",ofType: "f32")!    let url = URL(fileURLWithPath: path)    do {        let data = try Data(contentsOf: url)        let format = AVAudioFormat(commonFormat: .pcmFormatfloat32,sampleRate: 44100,channels: 2,interleaved: true)        self.buffer = AVAudioPCMBuffer(pcmFormat: format,frameCapacity: AVAudioFrameCount(data.count))        self.buffer!.floatChannelData!.pointee.withMemoryRebound(to: UInt8.self,capacity: data.count) {            let stream = OutputStream(toBuffer: ,capacity: data.count)            stream.open()            _ = data.withUnsafeBytes {                stream.write(,maxLength: data.count)            }            stream.close()        }    } catch let error as NSError {        print("ERROR HERE",error.localizedDescription)    }}
总结

以上是内存溢出为你收集整理的swift – 将pcm加载到AVAudioPCMBuffer中全部内容,希望文章能够帮你解决swift – 将pcm加载到AVAudioPCMBuffer中所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1003157.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存