raw_sound 0.3.0+1 copy "raw_sound: ^0.3.0+1" to clipboard
raw_sound: ^0.3.0+1 copied to clipboard

A flutter plugin for playing raw PCM audio data (16-bit integer and 32-bit float).

raw_sound #

pub package License

A flutter plugin for playing raw PCM audio data (16-bit integer and 32-bit float).

Platform Support #

Android (Kotlin) iOS (Swift)
minSdkVersion 24 platform :ios, '14.0'
✔️ ✔️

Usage #

  • Create an instance of the RawSoundPlayer
  final _player = RawSoundPlayer();
  • Initialize the player instance with parameters of bufferSize, nChannels, sampleRate and pcmType
  await _player.initialize(
    // Buffer size of the underlying audio track (Android only)
    bufferSize: 4096 << 3,
    // Number of channels, either 1 or 2
    nChannels: 1,
    // Sample rate for playback in Hz
    sampleRate: 16000,
    // PCM format type, either PCMI16 (16-bit integer) or PCMF32 (32-bit float)
    pcmType: RawSoundPCMType.PCMI16,
  );
  • Start the playback
  await _player.play();
  • Feed the player instance with the raw PCM data
  // Demonstrate how to continuously feed the player until the playback is paused/stopped
  while (_player.isPlaying) {
    await _player.feed(dataBlock);
  }
  • Pause the playback
  // Pause immediately and keep queued buffers
  await _player.pause();
  • Stop the playback
  // Stop immediately and drop queued buffers
  await _player.stop();
  • Release the player instance
  // Remember to release any initialized player instances
  await _player.release();
16
likes
140
pub points
65%
popularity

Publisher

verified publishercodevalop.com

A flutter plugin for playing raw PCM audio data (16-bit integer and 32-bit float).

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface, synchronized

More

Packages that depend on raw_sound