Code Monkey home page Code Monkey logo

dynamicaudio.js's Introduction

dynamicaudio.js

An interface for the Web Audio API with a Flash shim for older browsers.

Download it from the releases page.

For a basic example, see demo.html.

Usage

First, instantiate a DynamicAudio object with a dictionary of options:

var dynamicaudio = new DynamicAudio({'swf': '/static/dynamicaudio.swf'})

The swf option specifies the path of the dynamicaudio.swf file relative to the page being displayed.

The DynamicAudio object has two methods available on it:

write(samples)

Plays an array of floating point audio samples in the range -1.0 to 1.0.

They are output as 2 channels at 44.1 KHz. This means it takes 88,200 samples to play 1 second of audio. You do not need to supply this many samples in a single call, but if you don't call write() often enough with enough samples, you will get buffer underruns.

writeInt(samples)

This method is the same as write(), but is instead supplied with integer samples in the range -32,768 to 32,767. If your samples are already integers, this method is more efficient.

Build from source

To build, you will need jake:

$ sudo gem install jake

You will also need Adobe's Flex SDK. This should be placed in a flexsdk directory in the same directory as jake.yml.

Now run:

$ jake

dynamicaudio.js's People

Contributors

bfirsh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dynamicaudio.js's Issues

New buffer is created on every write

When using the Web Audio API, a new buffer is created on every write. This sucks, and means it's practically impossible to play sound than is longer than the length of the write.

Ideally, we should have a callback for filling the buffer, like the Web Audio API. As an interim solution, dynamicaudio.js should maintain its own buffer somehow.

Race Conditions When using dynamicaudio.js (in chrome)

Hello,

I have identified 2 problems with the dynamicaudio.js that stem from a common problem, which is that the SWF file maybe "loaded" according to SWFObject2, however, it may not have initialized its ExternalInterface just yet... see: http://stackoverflow.com/questions/1436722/problem-accessing-externalinterface-exposed-method-in-google-chrome/5294147#5294147

It seems like dynamicaudio.swf should be built in such a way that it can be passed a function callback that it will trigger after it has exported its ExternalInterface callbacks.

The second smaller error is that flashElement is re-used, and during the execution of dynamicaudio.js could mean either the

for the wrapper for swfobject, or the of the dynamicaudio.swf... I have corrected this in my local build by using a different variable name for the flash element reference, which seemed to help with the race condition, but there is still the small chance that the SWF is "loaded" and triggers the embedSWF callback before its external interface is loaded.

Another thought I had is that it would be awesome if dynamicaudio.js had interfaces for controlling the "buffer" sizes, either with exposed parameters, or some sort of option flag (I am looking for the lowest latency possible, at it appears that things can get buffereed in both the JS and the SWF)... Also it would be cool if there was some sort of "isReadyForAudio" function that I could use in my loop to detect when everything is ready to go, and its safe to feed audio into it...

Other than that, this framework really kicks ass, I am looking forward to seeing even more features from it in the future!

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.