0.1.21 • Published 2 years ago

@crossaudio/core v0.1.21

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

crossaudio

This is a little runtime to make building synthesizers in javascript (native, and on the web) fun & easy. It runs on the web and locally (not in a browser.)

install

  • You can get a quick template-project with npm init crossaudio
  • You can install it in your project with npm i @crossaudio/core.
  • You can use the crossaudio CLI
  • You can use the react lib

usage

how to make synths

Essentially, you make a function that takes an audio context and a reactive set of paramaters, and the synth can respond to changes. There are some examples.

The basic flow is this:

import { play, Params } from '@crossaudio/core'
import mySynth from './synths/synth1'

// these can be whatever you want, but they need a default value, and keys shouldn't be added/removed
const params = new Params({
  cutoff: 48,
  resonance: 0
})

// play the synth
play(mySynth, params)

and your synth might look like this:

function mtof(value) {
  return 440 * Math.pow(2, (value - 69) / 12)
}

export default (context, params) => {
  const vco = context.createOscillator()
  vco.frequency.value = mtof(params.cutoff)
  vco.start()
  
  const vcf = biquadFilter = audioCtx.createBiquadFilter()
  vcf.type = 'lowpass'
  vcf.frequency.value = mtof(params.cutoff)
  vcf.q.value = params.resonance
  
  params.on('cutoff', value => {
    vcf.frequency.value = mtof(value)
  })
  
  params.on('resonance', value => {
     vcf.q.value = value
  })

  vco.connect(vcf)
  vcf.connect(context.destination)
}

See Getting Started to quickly get up to speed.

0.1.21

2 years ago

0.1.18

2 years ago

0.1.9

3 years ago

0.1.4

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.1

3 years ago

0.1.3

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago