gameboy-sound
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -6,2 +6,3 @@ window.AudioContext = window.AudioContext || window.webkitAudioContext; | ||
const ctx = new AudioContext(); | ||
export const audioContext = ctx; | ||
@@ -23,16 +24,6 @@ export function allow() { | ||
} | ||
globalVolumeNode.connect(ctx.destination); | ||
// filters to make it sound nicer? | ||
const less = ctx.createGain(); | ||
less.gain.setValueAtTime(.25, ctx.currentTime); | ||
const biquadFilter = ctx.createBiquadFilter(); | ||
biquadFilter.type = "lowshelf"; | ||
biquadFilter.frequency.setValueAtTime(500, ctx.currentTime); | ||
biquadFilter.gain.setValueAtTime(25, ctx.currentTime); | ||
export const audioNode = globalVolumeNode; | ||
// connect it all together | ||
globalVolumeNode.connect(less); | ||
less.connect(biquadFilter); | ||
biquadFilter.connect(ctx.destination); | ||
function baseChannel(ctx, dest=ctx.destination) { | ||
@@ -80,3 +71,3 @@ const gainNode = ctx.createGain(); | ||
if (fade === 0) break; | ||
t1 += (1/64)*fade; | ||
t1 += (1/64)*Math.abs(fade); | ||
volume -= Math.sign(fade); | ||
@@ -132,12 +123,11 @@ } | ||
if (sweepFactor < 0) { | ||
const lastShadowFreq = shadowFreq; | ||
shadowFreq -= shadowFreq >> Math.abs(sweepFactor); | ||
if (shadowFreq === lastShadowFreq) break; | ||
} else { | ||
shadowFreq += shadowFreq >> Math.abs(sweepFactor); | ||
if (shadowFreq + (shadowFreq>>Math.abs(sweepFactor)) >= 2048) { | ||
rateChanges.push({ time: t1, rate: null }); | ||
break; | ||
} | ||
const lastShadowFreq = shadowFreq; | ||
const dFreq = Math.sign(sweepFactor) * shadowFreq >> Math.abs(sweepFactor); | ||
shadowFreq += dFreq; | ||
if (shadowFreq === lastShadowFreq) break; | ||
if (shadowFreq + dFreq >= 2048) { | ||
rateChanges.push({ time: t1, rate: null }); | ||
break; | ||
} | ||
@@ -264,2 +254,3 @@ | ||
node.loopStart = loopStart; | ||
node.loopEnd = node.buffer.duration; | ||
} | ||
@@ -266,0 +257,0 @@ cb({ node, n, nextNoteAfter }); |
{ | ||
"name": "gameboy-sound", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Easy 3 kB library for 98% accurate Gameboy audio", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
14173
273