These docs are for v1.0. Click to read the latest docs for v2.0.
Back to All

iOS - How to intercept and play each 30 seconds audio recorded during sleep

Hi guys!

When recording a sleep session we would like to intercept the recording for each sequence (.pcm or any other format), cache it locally, and play it for the user if needed. Do you have a way to do it?

What we tried until now:

  • Created Asleep.Recorder instance when session starts and call .startRecording() on it
  • Intercepted the audio data on the AsleepRecordingDelegate (recordedData(_ data: Data, sequence: Int))
  • After investigating a little bit, we found out that the provided Data is actually numpy data and we supposed that the format is actually and array of .pcm data.
  • We used a numpy decoder to extract the data as Float number and we've got data samples like: 2.099676e-09,2.1840941e-08,3.323388e-08,1.8441905e-07,9.583966e-07,9.483952e-07,3.6198898e-07,4.0044765e-07,5.342071e-07. Because they seemed to be very small floating we tried resampling them by multiplying them by 1e6.
  • We tried to play the result in Audacity for testing purposes, but with no luck.

Can you help us by providing more info about what to do next, what we did wrong, how to decode the data, what formats do you use and get it to the point of playing it for the used with AVAudioPlayer after the session ends? Or maybe you can provide a small sample app that could implement an example of this feature?


Thanks,

Vlad Preda