I wrote the code below to pass my custom object Engine in MTAudioProcessingTapCallbacks
Here is code:
func getTap() -> MTAudioProcessingTap? {
var tap: Unmanaged<MTAudioProcessingTap>?
func onInit(tap:MTAudioProcessingTap,clientInfo:UnsafeMutableRawPointer?,tagStroageOut:UnsafeMutablePointer<UnsafeMutableRawPointer?>) {
let engine = Engine()
tagStroageOut.pointee = Unmanaged<Engine>.passUnretained(engine).toOpaque()
}
var callback = MTAudioProcessingTapCallbacks(version: kMTAudioProcessingTapCallbacksVersion_0, clientInfo:nil, init: onInit, finalize: nil, prepare: nil, unprepare: nil) { tap, numberFrames, flags, bufferListInOut, numberFramesOut, flagsOut in
guard MTAudioProcessingTapGetSourceAudio(tap, numberFrames, bufferListInOut, flagsOut, nil, numberFramesOut) == noErr else {
preconditionFailure()
}
let storage = MTAudioProcessingTapGetStorage(tap)
let engine = Unmanaged<Engine>.fromOpaque(storage).takeUnretainedValue()
// This line crashed :
// ClientProcessingTapManager (14): EXC_BAD_ACCESS (code=1, address=0x544453e46ea0)
engine.dealWith(bufferPtr: bufferListInOut)
}
guard MTAudioProcessingTapCreate(kCFAllocatorDefault, &callback, kMTAudioProcessingTapCreationFlag_PostEffects, &tap) == noErr else{
fatalError()
}
return tap?.takeRetainedValue()
}
}
How can I do it?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have an AVAudioEngine,but I don't know how to export the audio in AVAudioEngine to a file. Anyone can help?
I want to get animation interpolation during animation running.
just like code below:
Animator(begin:100,end:200).addListener({value in
//here will be called when animation updates.
print(value)
})
But I can't find any API like the code above in iOS SDK.And I don't want to use any UIView or CALayer to get presentationLayer to get this value.
So How can I do that?🤔🤔🤔
The new captureTextFromCamera API allow device to use OCR in UIResponder,but how can I know this device support OCR or not ?
eg:
iPhoneX:NO,
iPhone13:YES
What I want is to make video 's rotation be from 0 to 90 degree in 0 ~ 2s.
Here is the code:
let layerIns = AVMutableVideoCompositionLayerInstruction(assetTrack: track)
let endTransform = CGAffineTransform(rotationAngle: CGFloat(Double.pi / 2))
let timeRange = CMTimeRange(start: .zero, duration: CMTime(seconds: 2, preferredTimescale: 600))
layerIns.setTransformRamp(fromStart: .identity, toEnd: endTransform, timeRange: timeRange)
But the center of rotation is top-left corner.. Which makes rotation effect look strange.
I wonder how to change the video layer's anchor point to center point instead of top-left corner...
related question on StackOverFlow :Question Link - https://stackoverflow.com/questions/65575655/how-to-change-the-settransformramp-s-transform-anchor-point