Giter Club home page Giter Club logo

lowlatencyaudio's Introduction

LowLatencyAudio

LowLatencyAudio is a native plugin for PhoneGap. This implementation is designed to be compatible with PhoneGap 3.0 CLI deployment, and supports both iOS and Android.

Installation

The LowLatencyAudio plugin can be added to your project via the PhoneGap command line tools. Simply use the following command to add this to your project:

phonegap local plugin add https://github.com/triceam/LowLatencyAudio

Usage

  1. Preload the audio asset - Note: Make sure to wait for phonegap deviceready event before atteptimpting to load assets
  2. Play the audio asset
  3. When done, unload the audio asset

API methods

preloadFX: function ( id, assetPath, success, fail)
	params: ID - string unique ID for the audio file
			assetPath - the relative path to the audio asset within the www directory
			success - success callback function
			fail - error/fail callback function
	detail:	
			The preloadFX function loads an audio file into memory.  Assets that are loaded using preloadFX are managed/played using AudioServices methods from the AudioToolbox framework.   These are very low-level audio methods and have minimal overhead.  Audio loaded using this function is played using AudioServicesPlaySystemSound.   These assets should be short, and are not intended to be looped or stopped.   They are fully concurrent and polyphonic.
		
preloadAudio: function ( id, assetPath, voices, success, fail) 
	params: ID - string unique ID for the audio file
			assetPath - the relative path to the audio asset within the www directory
			voices - the number of polyphonic voices available
			success - success callback function
			fail - error/fail callback function
	detail:	
			The preloadAudio function loads an audio file into memory.  Assets that are loaded using preloadAudio are managed/played using AVAudioPlayer.   These have more overhead than assets laoded via preloadFX, and can be looped/stopped.   By default, there is a single "voice" - only one instance that will be stopped & restarted when you hit play.  If there are multiple voices (number greater than 0), it will cycle through voices to play overlapping audio.
	
play: function (id, success, fail) 	
	params: ID - string unique ID for the audio file
			success - success callback function
			fail - error/fail callback function
	detail:	
			Plays an audio asset
	
loop: function (id, success, fail) 	
	params: ID - string unique ID for the audio file
			success - success callback function
			fail - error/fail callback function
	detail:	
			Loops an audio asset infinitely - this only works for assets loaded via preloadAudio
	
stop: function (id, success, fail) 	
	params: ID - string unique ID for the audio file
			success - success callback function
			fail - error/fail callback function
	detail:	
			Stops an audio file - this only works for assets loaded via preloadAudio
	
unload: function (id, success, fail) 	
	params: ID - string unique ID for the audio file
			success - success callback function
			fail - error/fail callback function
	detail:	
			Unloads an audio file from memory

License

THIS SOFTWARE IS PROVIDED BY ANDREW TRICE "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANDREW TRICE OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

lowlatencyaudio's People

Contributors

kev89431 avatar

Stargazers

 avatar

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.