minisound 1.6.0 copy "minisound: ^1.6.0" to clipboard
minisound: ^1.6.0 copied to clipboard

A high-level real-time audio playback library based on Miniaudio.

example/lib/main.dart

import "package:example/widgets/generator_example.dart";
import "package:example/widgets/playback_example.dart";
import "package:example/widgets/recorder_example.dart";
import "package:flutter/material.dart";
import "package:minisound/engine.dart";
import "package:minisound/generator.dart";
import "package:minisound/recorder.dart";

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(const MaterialApp(title: "Minisound Example", home: ExamplePage()));
}

class ExamplePage extends StatefulWidget {
  const ExamplePage({super.key});

  @override
  State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {
  final engine = Engine();
  late final recorder = Recorder();
  late final generator = Generator(mainEngine: engine);

  late final initFuture = engine
      .init()
      .then((_) => recorder.initStream(channels: 1))
      .then((_) => generator.init());

  @override
  void dispose() {
    recorder.dispose();
    generator.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    const space = SizedBox(height: 20);
    return Scaffold(
      appBar: AppBar(title: const Text("Minisound Example")),
      body: Center(
        child: SingleChildScrollView(
          child: FutureBuilder(
            future: initFuture,
            builder: (_, snapshot) => switch (snapshot) {
              AsyncSnapshot(
                connectionState: ConnectionState.done,
                hasError: false
              ) =>
                Column(children: [
                  PlaybackExample(engine),
                  space,
                  RecorderExample(engine, recorder),
                  space,
                  GeneratorExample(engine, generator),
                ]),
              AsyncSnapshot(connectionState: ConnectionState.waiting) =>
                const Center(child: CircularProgressIndicator()),
              AsyncSnapshot(:final error) =>
                Center(child: Text("Error: $error")),
            },
          ),
        ),
      ),
    );
  }
}
9
likes
150
pub points
67%
popularity

Publisher

unverified uploader

A high-level real-time audio playback library based on Miniaudio.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, minisound_ffi, minisound_platform_interface, minisound_web

More

Packages that depend on minisound