The GarageBand app can import both midi and recorded audio file into a single player to play.
Just like this:
My App have the same feature but I don't know how to implement it.
I have tried the AVAudioSequencer,but it only can load and play MIDI file.
I have tried the AVPlayer and AVPlayerItem,but it seems that it can't load the MIDI file.
So How to combine MIDI file and audio file into a single AVPlayerItem or anything else to play?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
This is the crash log from Firebase.
Fatal Exception: NSInvalidArgumentException
*** -[AVAssetWriter addInput:] Format ID 'lpcm' is not compatible with file type com.apple.m4a-audio
But I can't reproduce the crash ...
This is the demo code
Does anyone know where the problem is ?
let normalOutputSettings:[String:Any] = [
AVFormatIDKey : kAudioFormatLinearPCM,
AVSampleRateKey : 44100,
AVNumberOfChannelsKey : 2,
AVLinearPCMBitDepthKey : 16,
AVLinearPCMIsNonInterleaved : false,
AVLinearPCMIsFloatKey : false,
AVLinearPCMIsBigEndianKey : false
]
let writerInput = AVAssetWriterInput(mediaType: .audio, outputSettings: outputSettings)
let outputURL = URL(fileURLWithPath: NSTemporaryDirectory() + UUID().uuidString + ".m4a")
self.writer = try! AVAssetWriter(outputURL: outputURL, fileType: fileType)
writer?.add(writerInput)
On iOS 18 we can see there is a colorful wave around screen when using siri, I want to implement one in my app. But I tried many ways but not succeed. Any idea?
I'm using AVFoundation to make a multi-track editor app, which can insert multiple track and clip, including scale some clip to change the speed of the clip, (also I'm not sure whether AVFoundation the best choice for me) but after making the scale with scaleTimeRange API, there is some short noise sound in play back. Also, sometimes it's fine when play AVMutableCompostion using AVPlayer with AVPlayerItem, but after exporting with AVAssetReader, will catch some short noise sounds in result file.... Not sure why.
Here is the example project, which can build and run directly. https://github.com/luckysmg/daily_images/raw/refs/heads/main/TestDemo.zip