soundtouch_sdk 0.0.1 copy "soundtouch_sdk: ^0.0.1" to clipboard
soundtouch_sdk: ^0.0.1 copied to clipboard

A Flutter plugin for SoundTouch audio processing

example/lib/main.dart

import 'dart:math';
import 'package:flutter/material.dart';
import 'package:soundtouch_sdk/soundtouch_sdk.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _soundTouchSdk = SoundtouchSdk();
  String _status = 'Not initialized';
  bool _isInitialized = false;

  @override
  void initState() {
    super.initState();
    _initializeSoundTouch();
  }

  Future<void> _initializeSoundTouch() async {
    try {
      debugPrint('Initializing SoundTouch...');
      await _soundTouchSdk.initialize();
      setState(() {
        _status = 'SoundTouch initialized successfully';
        _isInitialized = true;
      });
      debugPrint('SoundTouch initialized successfully');
    } catch (e, stackTrace) {
      debugPrint('Error initializing SoundTouch: $e');
      debugPrint('StackTrace: $stackTrace');
      setState(() {
        _status = 'Failed to initialize SoundTouch: $e';
        _isInitialized = false;
      });
    }
  }

  Future<void> _processSampleData() async {
    if (!_isInitialized) {
      setState(() {
        _status = 'Please initialize SoundTouch first';
      });
      debugPrint('Attempted to process samples before initialization.');
      return;
    }

    try {
      debugPrint('Generating sample data...');
      List<double> sampleData = List.generate(1024, (i) => sin(i * 0.1));
      debugPrint('Sample data generated, processing...');
      await _soundTouchSdk.processSamples(sampleData);
      setState(() {
        _status = 'Samples processed successfully';
      });
      debugPrint('Samples processed successfully');
    } catch (e, stackTrace) {
      debugPrint('Error processing samples: $e');
      debugPrint('StackTrace: $stackTrace');
      setState(() {
        _status = 'Error processing samples: $e';
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('SoundTouch SDK Example'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(_status),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: _isInitialized ? null : _initializeSoundTouch,
                child: const Text('Initialize SoundTouch'),
              ),
              const SizedBox(height: 10),
              ElevatedButton(
                onPressed: _isInitialized ? _processSampleData : null,
                child: const Text('Process Sample Data'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
120
points
7
downloads

Publisher

verified publishernexusdev.uk

Weekly Downloads

A Flutter plugin for SoundTouch audio processing

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

ffi, flutter, path, plugin_platform_interface

More

Packages that depend on soundtouch_sdk

Packages that implement soundtouch_sdk