gameboy-sound
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -153,4 +153,4 @@ const dutyLookup = [ | ||
computeAudioChannels, | ||
play({ freq, trigger=true, length=Infinity, duty=2, volume=15, fade=0, sweepFactor=0, sweepPeriod=7, left=true, right=true }) { | ||
frequency = freq || frequency; | ||
play({ freq=1798, trigger=true, length=Infinity, duty=2, volume=15, fade=0, sweepFactor=0, sweepPeriod=7, left=true, right=true }) { | ||
frequency = freq; | ||
FrequencyTracker = (0x800 - frequency) << 2; | ||
@@ -157,0 +157,0 @@ |
@@ -0,1 +1,3 @@ | ||
const defaultPCM = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0]; | ||
export function wav() { | ||
@@ -21,3 +23,3 @@ // cached current output sample | ||
// pcm cycle | ||
let PCM = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0]; | ||
let PCM = defaultPCM; | ||
let lastSampleLookup = 0; | ||
@@ -82,9 +84,8 @@ | ||
computeAudioChannels, | ||
play({ freq, trigger=true, length=Infinity, samples=null, downshift=0, left=true, right=true }) { | ||
const frequency = freq || frequency; | ||
frequencyPeriod = (0x800 - frequency) << 1; | ||
play({ freq=1798, trigger=true, length=Infinity, samples=defaultPCM, downshift=0, left=true, right=true }) { | ||
frequencyPeriod = (0x800 - freq) << 1; | ||
timeLeft = length; | ||
if (samples && samples !== PCM) { | ||
if (samples !== PCM) { | ||
if (samples.length !== 32 || !samples.every(n => (n & 15) === n)) { | ||
@@ -91,0 +92,0 @@ throw new Error('Expected 32 samples with values 0-15') |
{ | ||
"name": "gameboy-sound", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Easy 3 kB library for 98% accurate Gameboy audio", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
20311