Giter VIP home page Giter VIP logo

pfseq's Introduction

Precision Timing Audio Sequencer Module

For audio tools like drum machines, samplers, metronomes, etc.

Overview

The requirements that led to this module:

  • playing clips with timing precison and accuracy that is good enough for recording a track for production
  • doing this for multiple simultaneous AudioTracks
  • able to change tempo while playing
  • able to change audio content while playing
  • able to define time position of audio clips relative to beats and bars, consistent with musical notation
  • content can be provided as looping or non-looping
  • runs in service (able to run in background)
  • error info sent to activity from service
  • module easily includable in an android app

Precision is achieved by:

  • streaming PCM audio data to AudioTrack instances and not allowing AudioTrack to underrun
  • keeping count of frames written to an AudioTrack
  • mapping frame-position to JVM nanotime with an AudioTimestamp
  • the time of a given item is calculated relative to the tempo start time and with adequate precision

Installation

Add the pfseq AAR module to your Android project and make it a dependency for the project's app module. You can get the AAR from this demo app's pfseq\build\outputs\aar directory. You may need to run "rebuild project" in Android Studio to generate this.

Usage

  1. Extend PFSeq and implement the abstract method getNotification(). It will need to return a Notification object unless the RUN_IN_FOREGROUND config value is set to false.
  2. Extend PFSeqActivity for any activity that will interact with your sequencer service. Abstract methods:
  • receiveMessage() - The sequencer service sends error messages to the activity. Do what you want with them here.
  • onConnect() - Called when the activity becomes bound. This is where you set up UI listeners that call public methods on your sequencer service (if bound).
  • getServiceClass() - Just return YourPFSeqBaseClass.class. It tells PFSeqActivity the name of your PFSeq base class.
  1. Call YourPFSeqBaseClass.setUpSequencer(config). Pass it a PFSeqConfig object. See PFSeqConfig class for how to override default config settings.
  2. Add at least one track to the sequencer, and add at least one "piano roll item" with an audio clip to the track.
  3. Call play() on the sequencer.

License

Copyright (c) 2019 People's Feelings
Licensed under GPL v2
https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html

Requirements

  • API level 24

Other features

  • Includes decoder to get raw PCM data from encoded files such as MP3s
  • Length of audio clips can be specified as absolute or relative to tempo
  • Velocity of clips can be set
  • all mathematical operations pertinent to timing accuracy are marked in the code with "adjust to taste" comments

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.