Giter Club home page Giter Club logo

web-pokey's Introduction

Web POKEY

Emulates 8-bit Atari POKEY chip as WebAudio component (implemented as AudioWorkletProcessor)

Features:

  • 4 channels, 15kHz / 64kHz / 1.77Mhz clock
  • 16-bit linked channels
  • 4 / 5 / 9 / 17 bit poly noise generators
  • high-pass filters
  • volume-only mode
  • Second POKEY (stereo) emulation

Usage

This library only provides POKEY AudioWorkletProcessor, initialization of AudioContext / loading of POKEY module / creating AudioWorkletNode is your job (take a look on included examples). For now only 48000 sample rate is supported. To enable stereo (second POKEY) provide outputChannelCount: [2] parameter to POKEY AudioWorkletNode.

Example initialization (with stereo):

const audioContext = new AudioContext({
    sampleRate: 48000,
})
await audioContext.audioWorklet.addModule('../../pokey.js');
const pokeyNode = new AudioWorkletNode(audioContext, 'POKEY', {
    outputChannelCount: [2],
})
pokeyNode.connect(audioContext.destination)

To set values of POKEY registers create js array of floats as follows:

let msg = [reg_index1, reg_value1, timestamp1, reg_index2, reg_value2, timestamp2, ...]

and send it to POKEY with:

pokeyNode.port.postMessage(msg)

Single array defines values of one or more registers, lenght of array must be multiple of 3 (and minimum length of 3). For stereo, second pokey registers have indices from 0x10 .. 0x1f

Timestamp define when POKEY register needs to be updated (AudioContext time is used for scheduling these updates. It starts from 0.0, current time may be accessed via audioContext.currentTime). If timestamp is less or equal audioContext.currentTime (for example timestamp=0) register will be updated as soon as possible.

Live examples:

web-pokey's People

Contributors

mrk-its avatar vinscool avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

Forkers

ivop vinscool

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.