npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@splice/shabushabu

v0.1.7

Published

Web Audio engine

Downloads

10

Readme

Shabu Shabu audio engine

Setup

The code for this "audio engine" is written in TypeScript, you therefore need the typescript compiler installed.

Make sure you have yarn installed.

Install dependencies:

$ yarn

Compile / start server

$ yarn demo

This will compile the files, start a local server and monitor file changes and reload whatever page you're on.

The demo/index.html contains demo code.

Open your browser to:

http://localhost:8080/webpack-dev-server/demo/index.html

The code will auto-transpile and reload.

Goals

The main goal of this library is to focus on audio tasks and not do any UI rendering. Features:

  • step sequencer
  • audio dynamics
  • MIDI support
  • synthesizer modules

The idea is that various kind of graphic interfaces can be hooked to the engine to do different things. The first implementation of such a concept would be a drum step sequencer.

API

You need an instance of the engine to start, and from there, you can add a sequencer with a given tempo:

var engine = NewEngine()
var bpm = 120
var seq = new Sequencer(engine, bpm);

The engine can load remote sounds and cache them so they can be used by the sequencer:

engine.loadSample("kick", "sounds/kick.wav", function() {
	seq.addSampleTrack("kick", engine.samples["kick"], [1,0,0,0, 0,0,0,0, 1,0,0.5,0, 0,0,0,0])
})

A loaded sample becomes available via its key (first argument of the loadSample function) The second argument is the URL of the sound source and finally the third one is a closure that gets called once the remote sound was processed and is available.

Cached samples are available in engine.samples[keyName].

The sequencer's addSampleTrack method is a convenient way to create a stepper sequencer track using a given audio sample. it takes 3 arguments, the track name, the audio buffer to use and the step sequence.

Note that the step sequence can contain values between 0 and 1 where 0 is a muted sound (noop) and 1 plays the sound at full volume.

A sequencer can be started using the start() and stop() methods and patterns can be changed live.

You can access the pattern tracks (to modify them for instance) via the patternTracks attribute on the sequence. This would return an array of tracks and each track has:

  • a name
  • steps
  • an optional sample (audio buffer)

If a sample isn't attached, the default synth gets triggered on each step.

Modules

The audio engine provides multiple modules to do different things.

Sequencer

The sequencer role is to trigger connections in a scheduled manner. A sequencer instance doesn't generate any sound instead it sends triggers coming from its pattern tracks.

The sequencer has a tempo/bpm and multiple pattern tracks. Each pattern track contains the pattern (steps to play and when to play them).

The connect method allows a sequencer to drive a receiver (like the pad sampler). Controls are basic: start() and stop().

The sequencer has a convenient addSampleTrack helper method allowing the quick addition of a pattern track.

Like other module, this module has a debugger that can be turned on. Pattern tracks and BPM can be changed while playing the sequencer is supposed to handle such changes without any issues.

PatternTrack

A pattern track represents a track within the sequence. It has a reference to the audio sample being triggered, an overall volume, a name and a list of steps.

PadSampler

The Pad sampler is a sampler with basic playback features. Each pad contains an audio buffer and attributes to play it. A pad can be triggered by user inputs via keyboard keys, notes or programmatically. A pad can be triggered multiple times in a row, if the cutSelf attribute is on, new triggers will stop currently playing sounds, otherwise a new instance will be started in conjunction with the existing one.

Synth