carp_audio_package 0.30.0 copy "carp_audio_package: ^0.30.0" to clipboard
carp_audio_package: ^0.30.0 copied to clipboard

outdated

CARP Audio Sampling Package. Samples audio recording and noise.

example/lib/example.dart

import 'package:carp_core/carp_protocols/carp_core_protocols.dart';
import 'package:carp_mobile_sensing/carp_mobile_sensing.dart';
import 'package:carp_audio_package/audio.dart';

/// This is a very simple example of how this sampling package is used with
/// CARP Mobile Sensing (CAMS).
/// NOTE, however, that the code below will not run.
/// See the documentation on how to use CAMS: https://github.com/cph-cachet/carp.sensing-flutter/wiki
void main() async {
  // register this sampling package before using its measures
  SamplingPackageRegistry().register(AudioSamplingPackage());

  // Create a study protocol
  StudyProtocol protocol = StudyProtocol(
    ownerId: 'owner@dtu.dk',
    name: 'Context Sensing Example',
  );

  // define which devices are used for data collection
  // in this case, its only this smartphone
  Smartphone phone = Smartphone();
  protocol.addMasterDevice(phone);

  // Add an automatic task that immediately starts collecting audio and noise.
  protocol.addTriggeredTask(
      ImmediateTrigger(),
      AutomaticTask()
        ..addMeasures(SensorSamplingPackage().common.getMeasureList(
          types: [
            AudioSamplingPackage.AUDIO,
            AudioSamplingPackage.NOISE,
          ],
        )),
      phone);
}