Coder Social home page Coder Social logo

biner88 / metronome Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 5.0 877 KB

Efficient, accurate, cross-platform metronome; supports volume, BPM, and audio source settings.

License: BSD 3-Clause "New" or "Revised" License

Java 24.00% Ruby 7.23% Swift 26.06% Objective-C 0.07% Dart 34.29% JavaScript 4.49% HTML 3.87%

metronome's Introduction

Metronome

pub package

Efficient, accurate, cross-platform metronome; supports volume, BPM, and audio source settings.

Metronome

TODO

  • Add support for time signature #2
  • Add Windows support
  • Add CallBack function on Tick for web

Quick Start

Init

final metronome = Metronome();
metronome.init('
    assets/audio/snare.wav', 
    bpm: 120, 
    volume: 50, 
    enableTickCallback: true,
);

Play

metronome.play();

Pause

metronome.pause();

Stop

metronome.stop();

Volume

metronome.getVolume();
metronome.setVolume(50);

BPM

metronome.setBPM(120); 
metronome.getBPM(); 

get Play state

metronome.isPlaying();

setAudioFile

metronome.setAudioFile('assets/audio/snare.wav');

destroy

metronome.destroy();

Tick callback

metronome.onListenTick((_) {
    print('tick');
});

About Web

Please add the example/web/app.js file to index.html under your web. As follows:

<script src="app.js" defer></script>

metronome's People

Contributors

biner88 avatar

Stargazers

三三 avatar Verry avatar Manuel Di Criscito avatar Gilnei Junior avatar Vincent Yeung avatar

Watchers

Joey Green avatar  avatar Gilnei Junior avatar Manuel Di Criscito avatar  avatar

metronome's Issues

Proposal: CallBack function on Tick

I like the Metronome package - GREAT, however I would need one additional small functionality
Suggestion - proposal:
I would like to use Metronome in my application. I would like to display the metronome icon blinking on the screen according to the current tick. For this I would need a callback function called for each TICK.

PS. I'm also waiting for a version for macOS :)

[bug] No sound with AirPods

The current audio session block doesn't allow Bluetooth stuff such as AirPods:

do {
    try session.setActive(true)
    try session.overrideOutputAudioPort(AVAudioSession.PortOverride.speaker)
    try session.setCategory(AVAudioSession.Category.playback)
} catch {
    print(error)
}

Is it possible to "broaden" it as much as possible? Thanks

Error Android: setBMP(0) - com.sumsg.metronome.Metronome.calcSilence (Metronome.java:25)

I delivered the version to the market and...Crashlitics reports errors:

Fatal Exception: java.lang.OutOfMemoryError
Failed to allocate a 4294861232 byte allocation with 6291456 free bytes and 252MB until OOM, target footprint 10381008, growth limit 268435456
stack:
com.sumsg.metronome.Metronome.calcSilence (Metronome.java:25)
com.sumsg.metronome.Metronome.setBPM (Metronome.java:2)
com.sumsg.metronome.MetronomePlugin.metronomeInit (MetronomePlugin.java:41)

The problem was because in the function metronomeInit() I used bpm:0

On the Android this produce this error.
On Apple devices it is OK.

I propose solution for the future: The setBPM() function should be 0-tolerant

Add support for time signature

Nice package! Is it possible to add different time signatures? For example, time signature 4/4 means that we use a different sound for the first tick in 4:

Sound_1 - Sound_2 - Sound_2 - Sound_2 - Sound_1 - ...

It could be helpful for guitarists where the first beat represents a bass.

The sound coming out is corrupted

The sound is very very noisy and you can't almost hear the original sound. The problem is for sure not the sample, as it is clean and also if I change the file I get the same result.

Error: Unable to destroy activity {app.xxxx}: java.lang.NullPointerException: Attempt to invoke virtual method 'void x5.d.c()' on a null object reference

After releasing the version to the market (Android), I see a strange error reported in Crashlytics for many users:

Error: Unable to destroy activity {app.xxxx}: java.lang.NullPointerException: Attempt to invoke virtual method 'void x5.d.c()' on a null object reference

See call-stack
obraz

The error probably occurs when closing the application. But I can't reproduce it.
The error is ONLY visible on Android

Any suggestions?

Play metronome in background

Hi, do you think it is possibile to make the metronome play in background when I'm using other apps for example or maybe when the screen display is off?
That would be so useful.
Otherwise, I honestly don't know if it is possible to just wrap the metronome into a background service that always runs, so any tip would be appreciated.
Thank you!

[iOS] Configure audio session externally

Hello,

Thanks for adding the Bluetooth flag.

Is it possible to provide an additional flag in init() to skip the built-in audio session initialization block? So if the flag is true, then we can skip it and assume it's already configured and activated externally by users.

The reason is that in iOS the audio session is configured for the whole app, and sometimes I see that this plugin overrides my settings that I use https://pub.dev/packages/audio_session

In that plugin, they said it's a good practice to allow users to set audio session externally:

You may consider asking the developer of each audio plugin you use to provide an option to not overwrite these global settings and allow them be managed externally.

"volume" parameter in the init() function is ignored

I noticed that the "volume" parameter in the init() function is ignored.
How to reproduce: E.g. compile the example for this package with the variable 'vol' set to 0

line 20: int vol=0;

Then run metronome... it turns out it's quite loud :) even though volume is set to 0.
Please improve

MissingPluginException(No implementation found for method listen on channel metronome_tick)

i use the example file but i have got this error

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method enableTickCallback on channel metronome)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:332:7)

The following MissingPluginException was thrown while activating platform stream on channel metronome_tick:
MissingPluginException(No implementation found for method listen on channel metronome_tick)

When the exception was thrown, this was the stack:
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:332:7)
platform_channel.dart:332

#1 EventChannel.receiveBroadcastStream. (package:flutter/src/services/platform_channel.dart:676:9)
platform_channel.dart:676

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.