Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create an empty blank audio file of a specific duration in AudioKit

In my project, I am using AudioKit to play beats. I want to create an empty audio file of the same length of the main beat. and and whatever starting point I choose within the duration of the main beat. it will start recording from that point and will end when the main beat is stopped. override the previously recorded part with the newly recorded file. can I achieve with this an empty audio file at the start. Please guide.

like image 691
Amalendu Kar Avatar asked May 13 '26 05:05

Amalendu Kar


1 Answers

In a documentation you can find info about silent file: https://github.com/FT-BOYS/SoundMix/blob/master/AudioKit/Common/Internals/Audio%20File/AKAudioFile%2BUtilities.swift

To create file you can provide just the number of samples to generate (equals length in seconds multiplied by sample rate). It would look something like this:

let file = try! AKAudioFile.silent(samples: sampleRate * seconds)
like image 154
Lu_ Avatar answered May 15 '26 19:05

Lu_