UNPKG

gibberish-dsp

Version:

Gibberish is designed to be an optimized API for audio synthesis using per-sample techniques.

33 lines (23 loc) 838 B
let g = require( 'genish.js' ), ugen = require( '../ugen.js' )() module.exports = function( Gibberish ) { const Wavetable = function( inputProps ) { const wavetable = Object.create( ugen ) const props = Object.assign({}, Gibberish.oscillators.defaults, inputProps ) const osc = g.wavetable( g.in('frequency'), props ) const graph = g.mul( osc, g.in( 'gain' ) ) Gibberish.factory( wavetable, graph, 'wavetable', props ) return wavetable } g.wavetable = function( frequency, props ) { let dataProps = { immutable:true } // use global references if applicable if( props.name !== undefined ) dataProps.global = props.name const buffer = g.data( props.buffer, 1, dataProps ) return g.peek( buffer, g.phasor( frequency, 0, { min:0 } ) ) } return Wavetable }