npm install genish.jsgenish.js should run in all reasonably modern browsers; however, it runs best in Firefox, Edge, and Chrome due to their support for AudioWorklets. Other browsers will fallback to using a ScriptProcessor node, which runs on the main thread and thus may result in glitches.
``javascript`
mul( cycle( 220 ), .1 )
...genish will generate the following sample processing loop (reading from a wavetable) inside of an AudioWorklet node:
`javascript
for( let i = 0; i < len; ++i ) {
var phasor2_value = memory[2]
memory[2] += 0.004988662131519274
if( memory[2] >= 1 ) memory[2] -= 1
if( memory[2] < 0 ) memory[2] += 1
var cycle4_dataIdx = 3,
cycle4_phase = phasor2_value * 1024,
cycle4_index = cycle4_phase | 0,
cycle4_frac = cycle4_phase - cycle4_index,
cycle4_base = memory[ cycle4_dataIdx + cycle4_index ],
cycle4_next = ( cycle4_index + 1 ) & (1024 - 1),
cycle4_out = cycle4_base + cycle4_frac * ( memory[ cycle4_dataIdx + cycle4_next ] - cycle4_base )
var mul5 = cycle4_out * 0.1
memory[0] = mul5
left[ i ] = memory[0]
}
`
object that provides convenience methods for these tasks. The following example performs the necessary setup and starts a sine oscillator running:`html
`More standalone examples are also available in the examples directory. You can either use the prebuilt library in the
dist folder, or use a version served by GitCDN.develop & test
The build script is a gulpfile. With gulp installed, run gulp js or gulp watch in the top level of the repo. gulp test` will run the testing suite (mocha).