New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cacophony

Package Overview
Dependencies
Maintainers
1
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacophony - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

2

package.json
{
"name": "cacophony",
"version": "0.1.4",
"version": "0.1.5",
"description": "Typescript audio library with caching",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -35,3 +35,3 @@ Cacophony is a highly robust and versatile audio library for Typescript leveraging the WebAudio API, crafted to simplify audio management in complex applications. The core concept of Cacophony revolves around the creation and manipulation of three key elements: `Sound`, `Playback`, and `Group`.

sound.play();
sound.moveTo(1, 1, 1); // Position the sound in 3D space
sound.position = [1, 1, 1]; // Position the sound in 3D space
}

@@ -98,3 +98,3 @@

- `removeFilter(filter: BiquadFilterNode)`
- `moveTo(x: number, y: number, z: number)`
- `position`: A tuple `[x: number, y: number, z: number]` representing the position of the sound in 3D space, with both getter and setter.
- `loop(loopCount?: LoopCount)`: `LoopCount` can be a finite number or 'infinite'.

@@ -101,0 +101,0 @@

@@ -11,4 +11,6 @@ import { AudioContext, IAudioBuffer, IAudioBufferSourceNode, IAudioListener, IBiquadFilterNode, IGainNode, IPannerNode } from 'standardized-audio-context';

type LoopCount = number | 'infinite';
export type Position = [number, number, number];
export type LoopCount = number | 'infinite';
export type FadeType = 'linear' | 'exponential'

@@ -24,5 +26,4 @@

removeFilter(filter: BiquadFilterNode): void;
moveTo(x: number, y: number, z: number): void;
volume: number;
position: Position;
loop(loopCount?: LoopCount): LoopCount;

@@ -143,3 +144,3 @@ }

globalGainNode: GainNode;
position: number[] = [0, 0, 0];
private _position: Position = [0, 0, 0];
loopCount: LoopCount = 0;

@@ -152,2 +153,3 @@

this.globalGainNode = globalGainNode;
this._position = [0, 0, 0];
}

@@ -163,3 +165,3 @@

this.filters.forEach(filter => playback.addFilter(filter));
playback.moveTo(this.position[0], this.position[1], this.position[2]);
playback.position = this.position;
this.playbacks.push(playback);

@@ -191,7 +193,11 @@ return [playback];

moveTo(x: number, y: number, z: number): void {
this.position = [x, y, z];
this.playbacks.forEach(p => p.moveTo(x, y, z));
set position(position: Position) {
this._position = position;
this.playbacks.forEach(p => p.position = this._position);
}
get position(): Position {
return this._position;
}
loop(loopCount?: LoopCount): LoopCount {

@@ -398,6 +404,7 @@ if (loopCount === undefined) {

moveTo(x: number, y: number, z: number): void {
set position(position: Position) {
if (!this.panner) {
throw new Error('Cannot move a sound that has been cleaned up');
}
const [x, y, z] = position;
this.panner.positionX.value = x;

@@ -408,2 +415,9 @@ this.panner.positionY.value = y;

get position(): Position {
if (!this.panner) {
throw new Error('Cannot get position of a sound that has been cleaned up');
}
return [this.panner.positionX.value, this.panner.positionY.value, this.panner.positionZ.value];
}
private refreshFilters(): void {

@@ -423,3 +437,3 @@ if (!this.source || !this.gainNode) {

sounds: Sound[] = [];
position: number[] = [0, 0, 0];
private _position: Position = [0, 0, 0];
loopCount: LoopCount = 0;

@@ -478,9 +492,13 @@

moveTo(x: number, y: number, z: number): void {
this.position = [x, y, z];
this.sounds.forEach(sound => sound.moveTo(x, y, z));
set position(position: [number, number, number]) {
this._position = position;
this.sounds.forEach(sound => sound.position = this._position);
}
get position(): [number, number, number] {
return this._position;
}
get volume(): number {
return this.sounds[0].volume;
return this.sounds.map(sound => sound.volume).reduce((a, b) => a + b, 0) / this.sounds.length;
}

@@ -491,4 +509,3 @@

}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc