Reputation: 3526
I need to add this functionality in one of my app in swift, I want the user to adjust the threshold and so it'll be only recorded when it crosses the limit set by the user and stop automatically or in a given time when the user stops.
It would be great if you can share your expertise in how to collect all the data in one file like when a user will pause and continue it'll keep all the audio in one file.
Thanks.
Upvotes: 1
Views: 1089
Reputation: 186
I don't have much expertise in audio recordings, but I may be able to at least guide you in the right direction.
For your first question of "Starting the actual recording on a user pre-set threshold":
Audio is measured using a unit called Decibels or 'dB' for short. The threshold varies slightly between devices and microphones, so your users will have to pick a level depending on a toggle or sound they hear. For example you can provide a toggle that shows current changing audio levels and have the user slide to a certain value. You can check Discord iOS App or Decibel Meter on the App Store to get an idea.
Here is a great example in Swift showing how to track decibel levels and perform an action above a certain threshold. (You can Pause and Resume an Audio session for example) Response on this
For your second question on "How to pause and resume and collect in one file":
As I understand, an Audio session outputs everything to the same file even if you Pause and Resume it multiple time.
Apple has an excellent draft on how to handle external system interruptions like Calls for example
I hope I helped with your Quest
Upvotes: 1