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

mosfez-faust

v0.0.22

Published

Makes dynamic compilation of Faust on the web a little easier.

Downloads

10

Readme

mosfez-faust

npm Master build

Makes dynamic compilation of Faust on the web a little easier, and has a dev project to run values through dsp offline, and preview dsp live. It's an opinionated version of some parts of Faust for webaudio, mostly just the Web Assembly Faust compiler, wrapped up in a library that has:

  • full typescript compatibility
  • ESM exports, so no need to add <script> tags
  • have any async functions chain seamlessly off any prior initialisation steps, so if a required resource is not yet ready, the API function simply waits until it is ready
  • error reporting is more idiomatic for JavaScript - error objects are thrown containing details of the problem when compilation does not work

See the dev project - but keep in mind it's intended to be used locally.

Note: "opinionated" means this library has a much narrower set of concerns than the original Faust webaudio API it's using. This is mainly just for compilation on the web, playback using AudioWorket nodes, no in-built-polyphonic compilation. Some compilation options may be inaccessible via this API.

Installation

npm install mosfez-faust or yarn add mosfez-faust

Then you'll need to copy the files from node_modules/mosfez-faust/public and put it in your projects public-facing root directory that will be accessible once deployed. e.g. if you are using Vite, put them in your Vite project's public directory. This library will make a request for libfaust-wasm.wasm and libfaust-wasm.data when it starts up, and will not work if those files can't be found.

Usage

import { compile } from "mosfez-faust/faust";
import { touchStart } from "mosfez-faust/touch-start";

const audioContext = new window.AudioContext();
touchStart(audioContext);

async function startSines() {
  const dsp = `
    import("stdfaust.lib");
    process = os.osc(440.0),os.osc(441.0);
  `;

  const node = await compile(audioContext, dsp);
  node.connect(audioContext.destination);
}

Also some general purpose web audio conversion utilities can be found at:

import { * as conversions } from "mosfez-faust/convert";

See source code for details.

The dev project

The /dev directory contains a dev project that uses Vite and allows Faust DSP development in an IDE, while hot realoading and displaying and playing the results of your DSP changes. After cloning the repo, run yarn prep then cd dev, then yarn dev to use the project.

DSP definitions can be added and browsed to. There are two types, offline and live.

  • Offline DSP is compiled on page load or file save, and values specified in the dsp definition are passed through the faust DSP and logged to the console. This makes for a very deliberate DSP development experience, where you can even define your expected output and console messages will indicate if your DSP produces the correct result.
  • Live DSP is compiled on page load or file save, and is immediately started and connected to an audiocontext in the browser so you can hear the result live.

Developing this library

This library is written in typescript, using modified code from Faust's repo and wrapping that in a typical typescript library "wrapper". It's bundled with rollup, formatted with prettier, linted with eslint and tested with jest.

You will need node@16 or greater and yarn@1 installed globally. Clone the repo and run yarn prep to install deps and build. Then you can run:

  • yarn build to build the *.ts source files into *.js files and *.d.ts type files in /dist.
  • yarn test to run tests using jest (none yet).
  • yarn pretty to run the auto-formatter prettier.
  • yarn lint to run the linter eslint.
  • cd dev && yarn dev to run the dev project