@elemaudio/core
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -993,15 +993,2 @@ var __defProp = Object.defineProperty; | ||
} | ||
function renderWithDelegate(delegate, graphs) { | ||
var visitSet = /* @__PURE__ */ new Set(); | ||
var roots = mapWithIndex(fromArray(graphs), function(i, g) { | ||
return create("root", { | ||
channel: i | ||
}, [g]); | ||
}); | ||
visit(delegate, visitSet, roots); | ||
delegate.activateRoots(toArray(map(roots, function(r) { | ||
return r.hash; | ||
}))); | ||
delegate.commitUpdates(); | ||
} | ||
function stepGarbageCollector(delegate) { | ||
@@ -1020,3 +1007,2 @@ var nodeMap = delegate.getNodeMap(); | ||
if (length(deleted) > 0) { | ||
delegate.commitUpdates(); | ||
return forEach(deleted, function(n) { | ||
@@ -1027,2 +1013,18 @@ nodeMap.delete(n.hash); | ||
} | ||
function renderWithDelegate(delegate, graphs) { | ||
var visitSet = /* @__PURE__ */ new Set(); | ||
var roots = mapWithIndex(fromArray(graphs), function(i, g) { | ||
return create("root", { | ||
channel: i | ||
}, [g]); | ||
}); | ||
visit(delegate, visitSet, roots); | ||
if (delegate.getTerminalGeneration() > 1) { | ||
stepGarbageCollector(delegate); | ||
} | ||
delegate.activateRoots(toArray(map(roots, function(r) { | ||
return r.hash; | ||
}))); | ||
delegate.commitUpdates(); | ||
} | ||
@@ -1032,2 +1034,3 @@ // src/Reconciler.gen.ts | ||
var ReconcilerBS = Reconciler_bs_exports; | ||
var stepGarbageCollector2 = ReconcilerBS.stepGarbageCollector; | ||
var renderWithDelegate2 = function(Arg1, Arg2) { | ||
@@ -1037,3 +1040,2 @@ const result = Curry._2(ReconcilerBS.renderWithDelegate, Arg1, Arg2); | ||
}; | ||
var stepGarbageCollector2 = ReconcilerBS.stepGarbageCollector; | ||
@@ -1089,2 +1091,3 @@ // src/NodeRepr.gen.ts | ||
sampleseq: () => sampleseq, | ||
sampleseq2: () => sampleseq2, | ||
scope: () => scope, | ||
@@ -1194,2 +1197,5 @@ sdelay: () => sdelay, | ||
} | ||
function sampleseq2(props, time2) { | ||
return createNode("sampleseq2", props, [resolve(time2)]); | ||
} | ||
function pole(a, b, c) { | ||
@@ -1704,36 +1710,16 @@ if (typeof a === "number" || isNode3(a)) { | ||
} | ||
function polyblep(step, phase) { | ||
let leftgate = el5.le(phase, step); | ||
let rightgate = el5.ge(phase, el5.sub(1, step)); | ||
let lx = el5.div(phase, step); | ||
let rx = el5.div(el5.sub(phase, 1), step); | ||
return el5.add(el5.mul(leftgate, el5.sub(el5.mul(2, lx), el5.mul(lx, lx), 1)), el5.mul(rightgate, el5.add(el5.mul(2, rx), el5.mul(rx, rx), 1))); | ||
} | ||
function blepsaw(a, b) { | ||
let hasProps = !(typeof a === "number" || isNode3(a)); | ||
let props = hasProps ? a : {}; | ||
let rate = hasProps ? b : a; | ||
let phase = el5.phasor(props, rate, 0); | ||
let naive = el5.sub(el5.mul(2, phase), 1); | ||
let step = el5.div(rate, el5.sr()); | ||
return el5.sub(naive, polyblep(step, phase)); | ||
return createNode("blepsaw", {}, [rate]); | ||
} | ||
function blepsquare(a, b) { | ||
let hasProps = !(typeof a === "number" || isNode3(a)); | ||
let props = hasProps ? a : {}; | ||
let rate = hasProps ? b : a; | ||
let phase = el5.phasor(props, rate, 0); | ||
let trn = el5.le(phase, 0.5); | ||
let naive = el5.sub(el5.mul(2, trn), 1); | ||
let step = el5.div(rate, el5.sr()); | ||
let blep1 = polyblep(step, phase); | ||
let blep2 = polyblep(step, el5.mod(el5.add(phase, 0.5), 1)); | ||
return el5.sub(el5.add(naive, blep1), blep2); | ||
return createNode("blepsquare", {}, [rate]); | ||
} | ||
function bleptriangle(a, b) { | ||
let hasProps = !(typeof a === "number" || isNode3(a)); | ||
let props = hasProps ? a : {}; | ||
let rate = hasProps ? b : a; | ||
let gain = el5.div(el5.mul(4, rate), el5.sr()); | ||
return el5.mul(gain, el5.pole(0.995, blepsquare(props, rate))); | ||
return createNode("bleptriangle", {}, [rate]); | ||
} | ||
@@ -1754,4 +1740,7 @@ function noise(a) { | ||
// src/Events.ts | ||
import events from "events"; | ||
var EventEmitter = class extends events.EventEmitter { | ||
import EventEmitter from "eventemitter3"; | ||
var Events_default = class extends EventEmitter { | ||
constructor() { | ||
super(); | ||
} | ||
}; | ||
@@ -1773,5 +1762,6 @@ | ||
var Delegate = class { | ||
constructor() { | ||
constructor(terminalGeneration = 8) { | ||
this.nodeMap = /* @__PURE__ */ new Map(); | ||
this.currentActiveRoots = /* @__PURE__ */ new Set(); | ||
this.terminalGeneration = terminalGeneration; | ||
this.clear(); | ||
@@ -1797,3 +1787,3 @@ } | ||
getTerminalGeneration() { | ||
return 4; | ||
return this.terminalGeneration; | ||
} | ||
@@ -1844,4 +1834,4 @@ createNode(hash, type) { | ||
var Renderer = class { | ||
constructor(sendMessage) { | ||
this._delegate = new Delegate(); | ||
constructor(sendMessage, gcTerminalGeneration = 8) { | ||
this._delegate = new Delegate(gcTerminalGeneration); | ||
this._sendMessage = sendMessage; | ||
@@ -1861,3 +1851,4 @@ this._nextRefId = 0; | ||
this._delegate.commitUpdates(); | ||
this._sendMessage(this._delegate.getPackedInstructions()); | ||
const instructions = this._delegate.getPackedInstructions(); | ||
return Promise.resolve(this._sendMessage(instructions)); | ||
}; | ||
@@ -1871,9 +1862,12 @@ return [node, setter]; | ||
const t1 = now(); | ||
this._sendMessage(this._delegate.getPackedInstructions()); | ||
return { | ||
nodesAdded: this._delegate.nodesAdded, | ||
edgesAdded: this._delegate.edgesAdded, | ||
propsWritten: this._delegate.propsWritten, | ||
elapsedTimeMs: t1 - t0 | ||
}; | ||
const instructions = this._delegate.getPackedInstructions(); | ||
return Promise.resolve(this._sendMessage(instructions)).then((result) => { | ||
return { | ||
result, | ||
nodesAdded: this._delegate.nodesAdded, | ||
edgesAdded: this._delegate.edgesAdded, | ||
propsWritten: this._delegate.propsWritten, | ||
elapsedTimeMs: t1 - t0 | ||
}; | ||
}); | ||
} | ||
@@ -1883,3 +1877,3 @@ }; | ||
Delegate, | ||
EventEmitter, | ||
Events_default as EventEmitter, | ||
Renderer, | ||
@@ -1886,0 +1880,0 @@ createNode, |
@@ -1,2 +0,2 @@ | ||
import events from 'events'; | ||
import EventEmitter from 'eventemitter3'; | ||
@@ -31,4 +31,4 @@ declare abstract class EmptyList { | ||
} | ||
declare const stepGarbageCollector: (delegate: RenderDelegate_t) => void; | ||
declare const renderWithDelegate: (delegate: RenderDelegate_t, graphs: t[]) => void; | ||
declare const stepGarbageCollector: (delegate: RenderDelegate_t) => void; | ||
@@ -49,7 +49,10 @@ declare type ConstNodeProps = { | ||
declare type EventListener<E> = (event: E) => void; | ||
declare type Events = { | ||
"error": Error; | ||
"fft": { | ||
declare type EventTypes = { | ||
capture: (data: { | ||
source?: string; | ||
data: Float32Array[]; | ||
}) => void; | ||
error: (error: Error) => void; | ||
fft: (data: { | ||
source?: string; | ||
data: { | ||
@@ -59,33 +62,21 @@ real: Float32Array; | ||
}; | ||
}; | ||
"load": void; | ||
"meter": { | ||
}) => void; | ||
load: () => void; | ||
meter: (data: { | ||
source?: string; | ||
min: number; | ||
max: number; | ||
}; | ||
"scope": { | ||
}) => void; | ||
scope: (data: { | ||
source?: string; | ||
data: Float32Array[]; | ||
}; | ||
"snapshot": { | ||
}) => void; | ||
snapshot: (data: { | ||
source?: string; | ||
data: number; | ||
}; | ||
}) => void; | ||
}; | ||
declare interface EventEmitter { | ||
addListener<K extends keyof Events>(eventName: K, listener: EventListener<Events[K]>): this; | ||
listenerCount<K extends keyof Events>(eventName: K, listener?: EventListener<Events[K]>): number; | ||
listeners<K extends keyof Events>(eventName: K): Function[]; | ||
off<K extends keyof Events>(eventName: K, listener: EventListener<Events[K]>): this; | ||
on<K extends keyof Events>(eventName: K, listener: EventListener<Events[K]>): this; | ||
once<K extends keyof Events>(eventName: K, listener: EventListener<Events[K]>): this; | ||
prependListener<K extends keyof Events>(eventName: K, listener: EventListener<Events[K]>): this; | ||
prependOnceListener<K extends keyof Events>(eventName: K, listener: EventListener<Events[K]>): this; | ||
removeAllListeners<K extends keyof Events>(eventName?: K): this; | ||
removeListener<K extends keyof Events>(eventName: K, listener: EventListener<Events[K]>): this; | ||
rawListeners<K extends keyof Events>(eventName: K): Function[]; | ||
declare class export_default extends EventEmitter<EventTypes> { | ||
constructor(); | ||
} | ||
declare class EventEmitter extends events.EventEmitter { | ||
} | ||
@@ -433,2 +424,13 @@ declare const stdlib: { | ||
}, time: ElemNode): t; | ||
sampleseq2(props: { | ||
key?: string; | ||
seq?: { | ||
value: number; | ||
time: number; | ||
}[]; | ||
duration: number; | ||
path: string; | ||
stretch?: number; | ||
shift?: number; | ||
}, time: ElemNode): t; | ||
pole(p: ElemNode, x: ElemNode): t; | ||
@@ -516,4 +518,5 @@ pole(props: { | ||
private currentActiveRoots; | ||
private terminalGeneration; | ||
private batch; | ||
constructor(); | ||
constructor(terminalGeneration?: number); | ||
clear(): void; | ||
@@ -534,5 +537,6 @@ getNodeMap(): Map<number, any>; | ||
private _nextRefId; | ||
constructor(sendMessage: any); | ||
createRef(kind: any, props: any, children: any): (t | ((newProps: any) => void))[]; | ||
render(...args: any[]): { | ||
constructor(sendMessage: any, gcTerminalGeneration?: number); | ||
createRef(kind: any, props: any, children: any): (t | ((newProps: any) => Promise<any>))[]; | ||
render(...args: any[]): Promise<{ | ||
result: any; | ||
nodesAdded: number; | ||
@@ -542,5 +546,5 @@ edgesAdded: number; | ||
elapsedTimeMs: number; | ||
}; | ||
}>; | ||
} | ||
export { Delegate, ElemNode, EventEmitter, t as NodeRepr_t, Renderer, createNode, stdlib as el, isNode, renderWithDelegate, resolve, stdlib, stepGarbageCollector }; | ||
export { Delegate, ElemNode, export_default as EventEmitter, t as NodeRepr_t, Renderer, createNode, stdlib as el, isNode, renderWithDelegate, resolve, stdlib, stepGarbageCollector }; |
@@ -993,15 +993,2 @@ var __defProp = Object.defineProperty; | ||
} | ||
function renderWithDelegate(delegate, graphs) { | ||
var visitSet = /* @__PURE__ */ new Set(); | ||
var roots = mapWithIndex(fromArray(graphs), function(i, g) { | ||
return create("root", { | ||
channel: i | ||
}, [g]); | ||
}); | ||
visit(delegate, visitSet, roots); | ||
delegate.activateRoots(toArray(map(roots, function(r) { | ||
return r.hash; | ||
}))); | ||
delegate.commitUpdates(); | ||
} | ||
function stepGarbageCollector(delegate) { | ||
@@ -1020,3 +1007,2 @@ var nodeMap = delegate.getNodeMap(); | ||
if (length(deleted) > 0) { | ||
delegate.commitUpdates(); | ||
return forEach(deleted, function(n) { | ||
@@ -1027,2 +1013,18 @@ nodeMap.delete(n.hash); | ||
} | ||
function renderWithDelegate(delegate, graphs) { | ||
var visitSet = /* @__PURE__ */ new Set(); | ||
var roots = mapWithIndex(fromArray(graphs), function(i, g) { | ||
return create("root", { | ||
channel: i | ||
}, [g]); | ||
}); | ||
visit(delegate, visitSet, roots); | ||
if (delegate.getTerminalGeneration() > 1) { | ||
stepGarbageCollector(delegate); | ||
} | ||
delegate.activateRoots(toArray(map(roots, function(r) { | ||
return r.hash; | ||
}))); | ||
delegate.commitUpdates(); | ||
} | ||
@@ -1032,2 +1034,3 @@ // src/Reconciler.gen.ts | ||
var ReconcilerBS = Reconciler_bs_exports; | ||
var stepGarbageCollector2 = ReconcilerBS.stepGarbageCollector; | ||
var renderWithDelegate2 = function(Arg1, Arg2) { | ||
@@ -1037,3 +1040,2 @@ const result = Curry._2(ReconcilerBS.renderWithDelegate, Arg1, Arg2); | ||
}; | ||
var stepGarbageCollector2 = ReconcilerBS.stepGarbageCollector; | ||
@@ -1089,2 +1091,3 @@ // src/NodeRepr.gen.ts | ||
sampleseq: () => sampleseq, | ||
sampleseq2: () => sampleseq2, | ||
scope: () => scope, | ||
@@ -1194,2 +1197,5 @@ sdelay: () => sdelay, | ||
} | ||
function sampleseq2(props, time2) { | ||
return createNode("sampleseq2", props, [resolve(time2)]); | ||
} | ||
function pole(a, b, c) { | ||
@@ -1704,36 +1710,16 @@ if (typeof a === "number" || isNode3(a)) { | ||
} | ||
function polyblep(step, phase) { | ||
let leftgate = el5.le(phase, step); | ||
let rightgate = el5.ge(phase, el5.sub(1, step)); | ||
let lx = el5.div(phase, step); | ||
let rx = el5.div(el5.sub(phase, 1), step); | ||
return el5.add(el5.mul(leftgate, el5.sub(el5.mul(2, lx), el5.mul(lx, lx), 1)), el5.mul(rightgate, el5.add(el5.mul(2, rx), el5.mul(rx, rx), 1))); | ||
} | ||
function blepsaw(a, b) { | ||
let hasProps = !(typeof a === "number" || isNode3(a)); | ||
let props = hasProps ? a : {}; | ||
let rate = hasProps ? b : a; | ||
let phase = el5.phasor(props, rate, 0); | ||
let naive = el5.sub(el5.mul(2, phase), 1); | ||
let step = el5.div(rate, el5.sr()); | ||
return el5.sub(naive, polyblep(step, phase)); | ||
return createNode("blepsaw", {}, [rate]); | ||
} | ||
function blepsquare(a, b) { | ||
let hasProps = !(typeof a === "number" || isNode3(a)); | ||
let props = hasProps ? a : {}; | ||
let rate = hasProps ? b : a; | ||
let phase = el5.phasor(props, rate, 0); | ||
let trn = el5.le(phase, 0.5); | ||
let naive = el5.sub(el5.mul(2, trn), 1); | ||
let step = el5.div(rate, el5.sr()); | ||
let blep1 = polyblep(step, phase); | ||
let blep2 = polyblep(step, el5.mod(el5.add(phase, 0.5), 1)); | ||
return el5.sub(el5.add(naive, blep1), blep2); | ||
return createNode("blepsquare", {}, [rate]); | ||
} | ||
function bleptriangle(a, b) { | ||
let hasProps = !(typeof a === "number" || isNode3(a)); | ||
let props = hasProps ? a : {}; | ||
let rate = hasProps ? b : a; | ||
let gain = el5.div(el5.mul(4, rate), el5.sr()); | ||
return el5.mul(gain, el5.pole(0.995, blepsquare(props, rate))); | ||
return createNode("bleptriangle", {}, [rate]); | ||
} | ||
@@ -1754,4 +1740,7 @@ function noise(a) { | ||
// src/Events.ts | ||
import events from "events"; | ||
var EventEmitter = class extends events.EventEmitter { | ||
import EventEmitter from "eventemitter3"; | ||
var Events_default = class extends EventEmitter { | ||
constructor() { | ||
super(); | ||
} | ||
}; | ||
@@ -1773,5 +1762,6 @@ | ||
var Delegate = class { | ||
constructor() { | ||
constructor(terminalGeneration = 8) { | ||
this.nodeMap = /* @__PURE__ */ new Map(); | ||
this.currentActiveRoots = /* @__PURE__ */ new Set(); | ||
this.terminalGeneration = terminalGeneration; | ||
this.clear(); | ||
@@ -1797,3 +1787,3 @@ } | ||
getTerminalGeneration() { | ||
return 4; | ||
return this.terminalGeneration; | ||
} | ||
@@ -1844,4 +1834,4 @@ createNode(hash, type) { | ||
var Renderer = class { | ||
constructor(sendMessage) { | ||
this._delegate = new Delegate(); | ||
constructor(sendMessage, gcTerminalGeneration = 8) { | ||
this._delegate = new Delegate(gcTerminalGeneration); | ||
this._sendMessage = sendMessage; | ||
@@ -1861,3 +1851,4 @@ this._nextRefId = 0; | ||
this._delegate.commitUpdates(); | ||
this._sendMessage(this._delegate.getPackedInstructions()); | ||
const instructions = this._delegate.getPackedInstructions(); | ||
return Promise.resolve(this._sendMessage(instructions)); | ||
}; | ||
@@ -1871,9 +1862,12 @@ return [node, setter]; | ||
const t1 = now(); | ||
this._sendMessage(this._delegate.getPackedInstructions()); | ||
return { | ||
nodesAdded: this._delegate.nodesAdded, | ||
edgesAdded: this._delegate.edgesAdded, | ||
propsWritten: this._delegate.propsWritten, | ||
elapsedTimeMs: t1 - t0 | ||
}; | ||
const instructions = this._delegate.getPackedInstructions(); | ||
return Promise.resolve(this._sendMessage(instructions)).then((result) => { | ||
return { | ||
result, | ||
nodesAdded: this._delegate.nodesAdded, | ||
edgesAdded: this._delegate.edgesAdded, | ||
propsWritten: this._delegate.propsWritten, | ||
elapsedTimeMs: t1 - t0 | ||
}; | ||
}); | ||
} | ||
@@ -1883,3 +1877,3 @@ }; | ||
Delegate, | ||
EventEmitter, | ||
Events_default as EventEmitter, | ||
Renderer, | ||
@@ -1886,0 +1880,0 @@ createNode, |
{ | ||
"name": "@elemaudio/core", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"type": "module", | ||
@@ -56,7 +56,7 @@ "description": "Official Elementary Audio core package", | ||
"dependencies": { | ||
"events": "^3.3.0", | ||
"eventemitter3": "^5.0.1", | ||
"invariant": "^2.2.4", | ||
"shallowequal": "^1.1.0" | ||
}, | ||
"gitHead": "eb96b3816163dfde6de6703ddd124198003e1c00" | ||
"gitHead": "18feb963530c2c0bf3c9f71ef4ec9070b6b5e810" | ||
} |
Sorry, the diff of this file is not supported yet
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
162750
6095
+ Addedeventemitter3@^5.0.1
+ Addedeventemitter3@5.0.1(transitive)
- Removedevents@^3.3.0
- Removedevents@3.3.0(transitive)