To get the noise level from an Apple Watch in Swift, you can use the AVAudioRecorder and AVAudioSession classes from the AVFoundation framework.
ViewController.swift:main.swift223 chars10 lines
AVAudioRecorder object to start recording sound:main.swift803 chars22 linesaveragePower(forChannel: 0) function of the AVAudioRecorder object to get the noise level. Here's an example:main.swift85 chars3 linesRemember to stop recording when you're done:
main.swift50 chars4 linesNote that you will need to add the AVFoundation framework to your project in order to use these classes.
gistlibby LogSnag