Comments (5)
Could you show the definition of decodedBuffer
?
from sfbaudioengine.
Sorry... both of these produce the same results and both should be big enough to hold the frames remaining:
//--- buffer is 1x the expected frames (i.e., equal in size)
let decodedBuffer = AVAudioPCMBuffer(pcmFormat: decoder.processingFormat,
frameCapacity: AVAudioFrameCount(decoder.processingFormat.sampleRate * durationOfChunkToRead))!
or
//--- buffer is 2x the expected frames
let decodedBuffer = AVAudioPCMBuffer(pcmFormat: decoder.processingFormat,
frameCapacity: AVAudioFrameCount(2 * decoder.processingFormat.sampleRate * durationOfChunkToRead))!
as in...
do {
let decoder = try AudioDecoder(url: URL("file.flac"))
try decoder.open()
let frameCapacityForOneSecond = AVAudioFrameCount(decoder.processingFormat.sampleRate)
let decodedBuffer = AVAudioPCMBuffer(pcmFormat: decoder.processingFormat, frameCapacity: frameCapacityForOneSecond)!
try decoder.seek(to: decoder.length - AVAudioFramePosition(frameCapacityForOneSecond))
try decoder.decode(into: decodedBuffer)
if decoder.inputSource.atEOF && decoder.position < decoder.length {
print("WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by \(decoder.length - decoder.position) frames - decodedBuffer.frameLength is \(decodedBuffer.frameLength) instead of \(frameCapacityForOneSecond) off by \(frameCapacityForOneSecond - decodedBuffer.frameLength) frames")
}
} catch {
print(error.localizedDescription)
}
produces the following for an album
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 2992 frames - decodedBuffer.frameLength is 41108 instead of 44100 off by 2992 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 3968 frames - decodedBuffer.frameLength is 40132 instead of 44100 off by 3968 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 3764 frames - decodedBuffer.frameLength is 40336 instead of 44100 off by 3764 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 4096 frames - decodedBuffer.frameLength is 40004 instead of 44100 off by 4096 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 1844 frames - decodedBuffer.frameLength is 42256 instead of 44100 off by 1844 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 3012 frames - decodedBuffer.frameLength is 41088 instead of 44100 off by 3012 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 2472 frames - decodedBuffer.frameLength is 41628 instead of 44100 off by 2472 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 3080 frames - decodedBuffer.frameLength is 41020 instead of 44100 off by 3080 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 2440 frames - decodedBuffer.frameLength is 41660 instead of 44100 off by 2440 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 740 frames - decodedBuffer.frameLength is 43360 instead of 44100 off by 740 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 3100 frames - decodedBuffer.frameLength is 41000 instead of 44100 off by 3100 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 512 frames - decodedBuffer.frameLength is 43588 instead of 44100 off by 512 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 2564 frames - decodedBuffer.frameLength is 41536 instead of 44100 off by 2564 frames
WARNING - inputSource.atEOF is TRUE while decoder.position < decoder.length, off by 268 frames - decodedBuffer.frameLength is 43832 instead of 44100 off by 268 frames
from sfbaudioengine.
Could you check out the proposed fix in #252 and see if it works for you?
from sfbaudioengine.
Yes, #252 in conjunction with using libFLAC 1.4.2 fixed the issue. Amazing turnaround. Thanks!
from sfbaudioengine.
I'm glad it's working now. Thanks for reporting this issue!
from sfbaudioengine.
Related Issues (20)
- Play DSD in DoP mode will heard noise in the sound HOT 13
- mpg123 header includes seemingly using incorrect include type HOT 2
- Issues with building macOS Sample Player HOT 1
- Can't run in physical device HOT 3
- The opus file is seriously distorted, and only one side of the speaker has sound. HOT 3
- When the speex file is playing, only one side of the speaker has sound, and SFBAudioPlayer.totalTime is nil HOT 3
- I keep getting an error when converting to apple native format, like m4a aac HOT 4
- Total frames not calculated for Ogg Speex streams HOT 1
- When encoding to mp3, the bitrate is always 128kbps HOT 5
- LAME encoder settings are confusing HOT 1
- Whatβs the role of SFBFFmpegDecoder HOT 1
- How to set the output sampleRate HOT 1
- OPUS file duration in milliseconds HOT 3
- Add .podspec for Cocoapods HOT 1
- Looping a decoder region doesn't work HOT 1
- Unable to stream MP3/WAV and possibly other formats HOT 3
- playReturningError failure HOT 6
- How to changed speed
- Importing Package HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sfbaudioengine.