Post

Replies

Boosts

Views

Activity

Comment on How to do offset on AVAudioPCMBuffer? (AVFoundation)
Before all thanks for the explanation, but I didn't get your idea about the byte count, doesn't it really a byte count? I mean it is a number of bytes in the memory, no? Also, I would like to clarify that the method getAudioByteData retrieves the entire track in one step, so there is no need to call it multiple times in order to reach the actual start of the data (hence my seek logic is going to be simpler). Also following your advice I got the idea and I think that seek logic could work the next way: user start the playback and after (eg:) 5 sec click on seek +10sec so first of all I know the number of playback samples that have already passed ` internal var currentFrame: AVAudioFramePosition {    guard     let lastRenderTime = player.lastRenderTime,     let playerTime = player.playerTime(forNodeTime: lastRenderTime)    else {     return 0    }    return playerTime.sampleTime   } ` then I just need to add + 10 sec offset like this bytes_seek_offset = samples_offset * num_channels * 2 and the result will be like this fullOffset = currentFrame + bytes_seek_offset, right? The final step will be to get the orig unsafeRawPointer and create the new one but with fullOffset Does it look good?
Nov ’21