Code Monkey home page Code Monkey logo

audio-api's Introduction

GWT Audio API Wrapper for Mozilla Audio Data API

This GWT library provides classes, interfaces, and methods to implement the Mozilla Audio Data API, and provides compatibility also with the WebKit/W3C Web Audio API (but does not provide a full implementation of that API). For functional compatibility with the Web Audio API, two methods not part of the Mozilla Audio Data API are included here: Audio.connect() and Audio.disconnect().

The AudioText2 code provides a working example of a simple tone generator, which has been tested to work in both Firefox and Chromium. This just shows a "Play" button which triggers a tone at 440Hz (A above middle C in standard tuning). The code can be seen in action in a post on my Wordpress.

The directory structure and library import files are set up to work in Eclipse.

Package

edu.jsu.leathrum.audio.shared

Audio

public class Audio extends com.google.media.client.Audio
  implements HasAudioAvailableHandlers           // <-- for reference implementation

constructor is protected
methods:

public static Audio createIfSupported()          // overrides
public void setup(int channels, int sampleRate)  // mozSetup(channels, sampleRate)
public void writeAudio(float[] buffer)           // mozWriteAudio(buffer)
public int currentSampleOffset()                 // mozCurrentSampleOffset()
public int getChannels()                         // returns mozChannels
public int getSampleRate()                       // returns mozSampleRate
public int getFrameBufferLength()                // returns mozFrameBufferLength
public void connect()                            // for Webkit compatibility
public void disconnect()                         // for Webkit compatibility
public HandlerRegistration addAudioAvalableHandler(AudioAvailableHandler h) // reference implementation

AudioAvailableEvent

public class AudioAvailableEvent extends DomEvent<AudioAvailableHandler>

uses constructor from super
methods:

public DomEvent.Type<AudioAvailableHandler> getType()   // overrides
public DomEvent.Type<AudioAvailableHandler> getAvailableType()   // overrides
protected void dispatch(AudioAvailableHandler handler)  // overrides

AudioAvailableHandler

public interface AudioAvailableHandler extends EventHandler

methods:

public void onAudioAvailable(AudioAvailableEvent e)

HasAudioAvailableHandlers

public interface HasAudioAvailableHandlers

methods:

public HandlerRegistration 
    addAudioAvailableHandler(AudioAvailableHandler h)

Notes on WebKit Compatibility

WebKit compatibility is provided through a JavaScript library moz2wk-audio.js which is found in the Audio/src/edu/jsu/leathrum/audio/shared/public directory and is included automatically in any project importing the library through the Audio.gwt.xml file in the Audio/src/edu/jsu/leathrum/audio/shared directory. This JavaScript library provides implementations of the Mozilla Audio Data API methods and properties (attached to the WebKit HTMLAudioElement object) when in a WebKit browser environment, and provides empty implementations of the connect() and disconnect() methods otherwise.

Acknowledgements

Aside from the authors responsible for writing the API documentation cited above, I should note that the tone generator code was based on both the tone generator code in the Mozilla Audio Data API page and the tone generator for the Web Audio API at 0xfe.blogspot.com.

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.