keithclark / ZzFXM

A super small music generator for use in size-limited JavaScript productions
https://keithclark.github.io/ZzFXM/
MIT License
427 stars 34 forks source link

Add support for stereo playback #3

Closed keithclark closed 4 years ago

keithclark commented 4 years ago

This PR adds support for stereo playback.

zzfxM() now returns an array of buffers, one for the left speaker and one for the right. To compliment this change, zzfxP() now accepts an array of channels. If a single channel is passed it will play mono (compatibility with zzfx()).

zzfxM() also accepts a new optional panning argument. This is used to position each song channel in stereo space. For a 4 channel song you would pass [ch1,ch2,ch3,ch4], where ch{x} is a value between -1 and 1 - with 0 being the centre channel. For more info see the README.md, which details the implementation.