pitchdetector 0.0.3+6 copy "pitchdetector: ^0.0.3+6" to clipboard
pitchdetector: ^0.0.3+6 copied to clipboard

Pitch detection for android and ios. Gets the pitch and pcm samples in HZ.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:pitchdetector/pitchdetector.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Pitchdetector detector;
  bool isRecording = false;
  double pitch;
  @override
  void initState() {
    super.initState();
    detector =  new Pitchdetector(sampleRate : 44100 , sampleSize : 4096);
    isRecording = isRecording;
    detector.onRecorderStateChanged.listen((event) {
      setState(() {
        pitch = event["pitch"];
      }); 
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: 
          Column(
            children: <Widget>[
               isRecording ? Text("Recording...") :  Container() ,
	             isRecording ? Text("Recorded hz from mic is : $pitch") : Text( "Not Recording."),
               FlatButton(
                onPressed: isRecording ?  stopRecording : startRecording, 
                child:   isRecording ?   Text("Press Me to stop") : Text("Press Me to run") 
              )
            ],
          )
          
        ),
      ),
    );
  }

  void startRecording()  async{
    await detector.startRecording();
    if(detector.isRecording){
	    setState(() {
        isRecording = true;
    	});
    }
  }
  void stopRecording() async {
    detector.stopRecording();
    setState(() {
      isRecording = false;
      pitch = detector.pitch;
    });


  }
}
6
likes
20
pub points
29%
popularity

Publisher

unverified uploader

Pitch detection for android and ios. Gets the pitch and pcm samples in HZ.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, permission_handler

More

Packages that depend on pitchdetector