Audio Sampling Package
Collect noise levels and audio recordings from the phone's microphone in a CARP Mobile Sensing study.
carp_audio_package adds the phone's microphone to a CARP Mobile Sensing (CAMS) study. It measures the noise level around the participant and records audio to files, for example to study the sound environment or a participant's cough. It also defines data types for videos and images that your app captures.
The package is named after audio for historical reasons, but it is a media package. Its classes are named for media, such as MediaSamplingPackage, and its library is package:carp_audio_package/media.dart. Noise levels come from the noise_meter plugin and recordings from flutter_sound.
Recording people
AUDIO records everything the microphone picks up, including the voices of people nearby who have not agreed to take part, and stores it unchanged. The study's ethics approval and consent must cover audio recordings. When sound levels are enough, use NOISE, which stores no sound.
Features
Noise
The mean, standard deviation, minimum and maximum sound level in decibels for a short window every few minutes. No sound is stored.
Audio recordings
Recordings from the microphone, stored as AAC files on the phone and started and stopped by the study protocol or by the participant.
Video and images
Data types for videos and images that your app captures, so that they are stored and uploaded with the study data. The package does not use the camera.
Measure types
| Measure type | Data | Android | iOS |
|---|---|---|---|
dk.cachet.carp.noise | Sound level statistics in decibels for each sampling window | Yes | Yes |
dk.cachet.carp.audio | An audio recording, stored as a file | Yes | Yes |
dk.cachet.carp.video | A video that your app records | Yes | Yes |
dk.cachet.carp.image | An image that your app captures | Yes | Yes |
NOISE is event-based, AUDIO records from when its task starts until the task stops, and VIDEO and IMAGE collect nothing by themselves. For the kinds of measures, see Event-based and one-time measures.
Requirements
| Component | Requirement |
|---|---|
| Dart SDK | 3.10 or later |
| Flutter | 3.44 or later, required by noise_meter |
carp_mobile_sensing | 2.2.0 or later |
| Android | API level 24 (Android 7.0) or later |
| iOS | 16.0 or later, required by audio_streamer, which noise_meter uses |
How it works
Adding the package to a study takes three steps:
Register the package
Registering
MediaSamplingPackagemakes the four measure types and their data classes known to CAMS.Add the measures to a protocol
NOISEstarts with anImmediateTrigger()and schedules its own sampling windows. EachAUDIOrecording needs a task that stops, for example after a fixed duration.Deploy the protocol
CAMS asks the participant for microphone access, samples noise in short windows and adds an audio measurement each time a recording stops.
This example registers the package and samples the noise level for 10 seconds every 5 minutes, the default:
Next steps
Installation
Add the package to a CAMS app and configure Android and iOS.
Quickstart
Build an app that samples noise and records audio.
Noise
Sampling windows, decibel values and the noise data.
Audio recordings
Start and stop recordings, and find and upload the files.