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

outdated

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 : 22050 , sampleSize : 2048);
    isRecording = isRecording;
  }

  @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() ,
	       pitch != null && !isRecording ? Text("Recorded hz from mic is : $pitch") : ( isRecording ? Container() : Text( "No Pitch found.")),
               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
0
pub points
36%
popularity

Publisher

unverified uploader

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

Homepage

License

unknown (LICENSE)

Dependencies

flutter, permission_handler

More

Packages that depend on pitchdetector