automation-events
Advanced tools
Comparing version 5.0.2 to 5.0.3
@@ -45,11 +45,15 @@ import { createExtendedExponentialRampToValueAutomationEvent } from '../functions/create-extended-exponential-ramp-to-value-automation-event'; | ||
if (removedAutomationEvent !== undefined && isAnyRampToValueAutomationEvent(removedAutomationEvent)) { | ||
if (isSetTargetAutomationEvent(lastAutomationEvent)) { | ||
if (lastAutomationEvent !== undefined && isSetTargetAutomationEvent(lastAutomationEvent)) { | ||
throw new Error('The internal list is malformed.'); | ||
} | ||
const startTime = isSetValueCurveAutomationEvent(lastAutomationEvent) | ||
? lastAutomationEvent.startTime + lastAutomationEvent.duration | ||
: getEventTime(lastAutomationEvent); | ||
const startValue = isSetValueCurveAutomationEvent(lastAutomationEvent) | ||
? lastAutomationEvent.values[lastAutomationEvent.values.length - 1] | ||
: lastAutomationEvent.value; | ||
const startTime = lastAutomationEvent === undefined | ||
? removedAutomationEvent.insertTime | ||
: isSetValueCurveAutomationEvent(lastAutomationEvent) | ||
? lastAutomationEvent.startTime + lastAutomationEvent.duration | ||
: getEventTime(lastAutomationEvent); | ||
const startValue = lastAutomationEvent === undefined | ||
? this._defaultValue | ||
: isSetValueCurveAutomationEvent(lastAutomationEvent) | ||
? lastAutomationEvent.values[lastAutomationEvent.values.length - 1] | ||
: lastAutomationEvent.value; | ||
const value = isExponentialRampToValueAutomationEvent(removedAutomationEvent) | ||
@@ -69,3 +73,14 @@ ? getExponentialRampValueAtTime(eventTime, startTime, startValue, removedAutomationEvent) | ||
lastAutomationEvent.startTime + lastAutomationEvent.duration > eventTime) { | ||
this._automationEvents[this._automationEvents.length - 1] = createSetValueCurveAutomationEvent(new Float32Array([6, 7]), lastAutomationEvent.startTime, eventTime - lastAutomationEvent.startTime); | ||
const duration = eventTime - lastAutomationEvent.startTime; | ||
const ratio = (lastAutomationEvent.values.length - 1) / lastAutomationEvent.duration; | ||
const length = Math.max(2, 1 + Math.ceil(duration * ratio)); | ||
const fraction = (duration / (length - 1)) * ratio; | ||
const values = lastAutomationEvent.values.slice(0, length); | ||
if (fraction < 1) { | ||
for (let i = 1; i < length; i += 1) { | ||
const factor = (fraction * i) % 1; | ||
values[i] = lastAutomationEvent.values[i - 1] * (1 - factor) + lastAutomationEvent.values[i] * factor; | ||
} | ||
} | ||
this._automationEvents[this._automationEvents.length - 1] = createSetValueCurveAutomationEvent(values, lastAutomationEvent.startTime, duration); | ||
} | ||
@@ -72,0 +87,0 @@ } |
@@ -165,7 +165,7 @@ (function (global, factory) { | ||
if (removedAutomationEvent !== undefined && isAnyRampToValueAutomationEvent(removedAutomationEvent)) { | ||
if (isSetTargetAutomationEvent(lastAutomationEvent)) { | ||
if (lastAutomationEvent !== undefined && isSetTargetAutomationEvent(lastAutomationEvent)) { | ||
throw new Error('The internal list is malformed.'); | ||
} | ||
var startTime = isSetValueCurveAutomationEvent(lastAutomationEvent) ? lastAutomationEvent.startTime + lastAutomationEvent.duration : getEventTime(lastAutomationEvent); | ||
var startValue = isSetValueCurveAutomationEvent(lastAutomationEvent) ? lastAutomationEvent.values[lastAutomationEvent.values.length - 1] : lastAutomationEvent.value; | ||
var startTime = lastAutomationEvent === undefined ? removedAutomationEvent.insertTime : isSetValueCurveAutomationEvent(lastAutomationEvent) ? lastAutomationEvent.startTime + lastAutomationEvent.duration : getEventTime(lastAutomationEvent); | ||
var startValue = lastAutomationEvent === undefined ? this._defaultValue : isSetValueCurveAutomationEvent(lastAutomationEvent) ? lastAutomationEvent.values[lastAutomationEvent.values.length - 1] : lastAutomationEvent.value; | ||
var value = isExponentialRampToValueAutomationEvent(removedAutomationEvent) ? getExponentialRampValueAtTime(eventTime, startTime, startValue, removedAutomationEvent) : getLinearRampValueAtTime(eventTime, startTime, startValue, removedAutomationEvent); | ||
@@ -179,3 +179,14 @@ var truncatedAutomationEvent = isExponentialRampToValueAutomationEvent(removedAutomationEvent) ? createExtendedExponentialRampToValueAutomationEvent(value, eventTime, this._currenTime) : createExtendedLinearRampToValueAutomationEvent(value, eventTime, this._currenTime); | ||
if (lastAutomationEvent !== undefined && isSetValueCurveAutomationEvent(lastAutomationEvent) && lastAutomationEvent.startTime + lastAutomationEvent.duration > eventTime) { | ||
this._automationEvents[this._automationEvents.length - 1] = createSetValueCurveAutomationEvent(new Float32Array([6, 7]), lastAutomationEvent.startTime, eventTime - lastAutomationEvent.startTime); | ||
var duration = eventTime - lastAutomationEvent.startTime; | ||
var ratio = (lastAutomationEvent.values.length - 1) / lastAutomationEvent.duration; | ||
var length = Math.max(2, 1 + Math.ceil(duration * ratio)); | ||
var fraction = duration / (length - 1) * ratio; | ||
var values = lastAutomationEvent.values.slice(0, length); | ||
if (fraction < 1) { | ||
for (var i = 1; i < length; i += 1) { | ||
var factor = fraction * i % 1; | ||
values[i] = lastAutomationEvent.values[i - 1] * (1 - factor) + lastAutomationEvent.values[i] * factor; | ||
} | ||
} | ||
this._automationEvents[this._automationEvents.length - 1] = createSetValueCurveAutomationEvent(values, lastAutomationEvent.startTime, duration); | ||
} | ||
@@ -182,0 +193,0 @@ } |
@@ -51,7 +51,7 @@ "use strict"; | ||
if (removedAutomationEvent !== undefined && (0, _anyRampToValueAutomationEvent.isAnyRampToValueAutomationEvent)(removedAutomationEvent)) { | ||
if ((0, _setTargetAutomationEvent.isSetTargetAutomationEvent)(lastAutomationEvent)) { | ||
if (lastAutomationEvent !== undefined && (0, _setTargetAutomationEvent.isSetTargetAutomationEvent)(lastAutomationEvent)) { | ||
throw new Error('The internal list is malformed.'); | ||
} | ||
const startTime = (0, _setValueCurveAutomationEvent.isSetValueCurveAutomationEvent)(lastAutomationEvent) ? lastAutomationEvent.startTime + lastAutomationEvent.duration : (0, _getEventTime.getEventTime)(lastAutomationEvent); | ||
const startValue = (0, _setValueCurveAutomationEvent.isSetValueCurveAutomationEvent)(lastAutomationEvent) ? lastAutomationEvent.values[lastAutomationEvent.values.length - 1] : lastAutomationEvent.value; | ||
const startTime = lastAutomationEvent === undefined ? removedAutomationEvent.insertTime : (0, _setValueCurveAutomationEvent.isSetValueCurveAutomationEvent)(lastAutomationEvent) ? lastAutomationEvent.startTime + lastAutomationEvent.duration : (0, _getEventTime.getEventTime)(lastAutomationEvent); | ||
const startValue = lastAutomationEvent === undefined ? this._defaultValue : (0, _setValueCurveAutomationEvent.isSetValueCurveAutomationEvent)(lastAutomationEvent) ? lastAutomationEvent.values[lastAutomationEvent.values.length - 1] : lastAutomationEvent.value; | ||
const value = (0, _exponentialRampToValueAutomationEvent.isExponentialRampToValueAutomationEvent)(removedAutomationEvent) ? (0, _getExponentialRampValueAtTime.getExponentialRampValueAtTime)(eventTime, startTime, startValue, removedAutomationEvent) : (0, _getLinearRampValueAtTime.getLinearRampValueAtTime)(eventTime, startTime, startValue, removedAutomationEvent); | ||
@@ -65,3 +65,14 @@ const truncatedAutomationEvent = (0, _exponentialRampToValueAutomationEvent.isExponentialRampToValueAutomationEvent)(removedAutomationEvent) ? (0, _createExtendedExponentialRampToValueAutomationEvent.createExtendedExponentialRampToValueAutomationEvent)(value, eventTime, this._currenTime) : (0, _createExtendedLinearRampToValueAutomationEvent.createExtendedLinearRampToValueAutomationEvent)(value, eventTime, this._currenTime); | ||
if (lastAutomationEvent !== undefined && (0, _setValueCurveAutomationEvent.isSetValueCurveAutomationEvent)(lastAutomationEvent) && lastAutomationEvent.startTime + lastAutomationEvent.duration > eventTime) { | ||
this._automationEvents[this._automationEvents.length - 1] = (0, _createSetValueCurveAutomationEvent.createSetValueCurveAutomationEvent)(new Float32Array([6, 7]), lastAutomationEvent.startTime, eventTime - lastAutomationEvent.startTime); | ||
const duration = eventTime - lastAutomationEvent.startTime; | ||
const ratio = (lastAutomationEvent.values.length - 1) / lastAutomationEvent.duration; | ||
const length = Math.max(2, 1 + Math.ceil(duration * ratio)); | ||
const fraction = duration / (length - 1) * ratio; | ||
const values = lastAutomationEvent.values.slice(0, length); | ||
if (fraction < 1) { | ||
for (let i = 1; i < length; i += 1) { | ||
const factor = fraction * i % 1; | ||
values[i] = lastAutomationEvent.values[i - 1] * (1 - factor) + lastAutomationEvent.values[i] * factor; | ||
} | ||
} | ||
this._automationEvents[this._automationEvents.length - 1] = (0, _createSetValueCurveAutomationEvent.createSetValueCurveAutomationEvent)(values, lastAutomationEvent.startTime, duration); | ||
} | ||
@@ -68,0 +79,0 @@ } |
@@ -19,9 +19,9 @@ { | ||
"@babel/cli": "^7.21.0", | ||
"@babel/core": "^7.21.0", | ||
"@babel/core": "^7.21.4", | ||
"@babel/plugin-external-helpers": "^7.18.6", | ||
"@babel/plugin-transform-runtime": "^7.21.0", | ||
"@babel/preset-env": "^7.20.2", | ||
"@babel/plugin-transform-runtime": "^7.21.4", | ||
"@babel/preset-env": "^7.21.4", | ||
"@babel/register": "^7.21.0", | ||
"@commitlint/cli": "^17.4.4", | ||
"@commitlint/config-angular": "^17.4.4", | ||
"@commitlint/cli": "^17.6.1", | ||
"@commitlint/config-angular": "^17.6.1", | ||
"@rollup/plugin-babel": "^6.0.3", | ||
@@ -31,7 +31,7 @@ "chai": "^4.3.7", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^8.35.0", | ||
"eslint-config-holy-grail": "^55.0.12", | ||
"eslint": "^8.38.0", | ||
"eslint-config-holy-grail": "^55.0.24", | ||
"grunt": "^1.6.1", | ||
"grunt-cli": "^1.4.3", | ||
"grunt-sh": "^0.2.0", | ||
"grunt-sh": "^0.2.1", | ||
"husky": "^8.0.3", | ||
@@ -48,14 +48,14 @@ "karma": "^6.4.1", | ||
"mocha": "^10.2.0", | ||
"prettier": "^2.8.4", | ||
"prettier": "^2.8.7", | ||
"pretty-quick": "^3.1.3", | ||
"rimraf": "^4.1.2", | ||
"rollup": "^3.17.3", | ||
"sinon": "^15.0.1", | ||
"rimraf": "^5.0.0", | ||
"rollup": "^3.20.4", | ||
"sinon": "^15.0.3", | ||
"sinon-chai": "^3.7.0", | ||
"ts-loader": "^9.4.2", | ||
"tsconfig-holy-grail": "^12.0.0", | ||
"tsconfig-holy-grail": "^12.0.4", | ||
"tslint": "^6.1.3", | ||
"tslint-config-holy-grail": "^54.0.1", | ||
"typescript": "^4.9.5", | ||
"webpack": "^5.75.0" | ||
"webpack": "^5.79.0" | ||
}, | ||
@@ -90,3 +90,3 @@ "engines": { | ||
"types": "build/es2019/module.d.ts", | ||
"version": "5.0.2" | ||
"version": "5.0.3" | ||
} |
@@ -60,12 +60,18 @@ import { createExtendedExponentialRampToValueAutomationEvent } from '../functions/create-extended-exponential-ramp-to-value-automation-event'; | ||
if (removedAutomationEvent !== undefined && isAnyRampToValueAutomationEvent(removedAutomationEvent)) { | ||
if (isSetTargetAutomationEvent(lastAutomationEvent)) { | ||
if (lastAutomationEvent !== undefined && isSetTargetAutomationEvent(lastAutomationEvent)) { | ||
throw new Error('The internal list is malformed.'); | ||
} | ||
const startTime = isSetValueCurveAutomationEvent(lastAutomationEvent) | ||
? lastAutomationEvent.startTime + lastAutomationEvent.duration | ||
: getEventTime(lastAutomationEvent); | ||
const startValue = isSetValueCurveAutomationEvent(lastAutomationEvent) | ||
? lastAutomationEvent.values[lastAutomationEvent.values.length - 1] | ||
: lastAutomationEvent.value; | ||
const startTime = | ||
lastAutomationEvent === undefined | ||
? removedAutomationEvent.insertTime | ||
: isSetValueCurveAutomationEvent(lastAutomationEvent) | ||
? lastAutomationEvent.startTime + lastAutomationEvent.duration | ||
: getEventTime(lastAutomationEvent); | ||
const startValue = | ||
lastAutomationEvent === undefined | ||
? this._defaultValue | ||
: isSetValueCurveAutomationEvent(lastAutomationEvent) | ||
? lastAutomationEvent.values[lastAutomationEvent.values.length - 1] | ||
: lastAutomationEvent.value; | ||
const value = isExponentialRampToValueAutomationEvent(removedAutomationEvent) | ||
@@ -90,6 +96,20 @@ ? getExponentialRampValueAtTime(eventTime, startTime, startValue, removedAutomationEvent) | ||
) { | ||
const duration = eventTime - lastAutomationEvent.startTime; | ||
const ratio = (lastAutomationEvent.values.length - 1) / lastAutomationEvent.duration; | ||
const length = Math.max(2, 1 + Math.ceil(duration * ratio)); | ||
const fraction = (duration / (length - 1)) * ratio; | ||
const values = lastAutomationEvent.values.slice(0, length); | ||
if (fraction < 1) { | ||
for (let i = 1; i < length; i += 1) { | ||
const factor = (fraction * i) % 1; | ||
values[i] = lastAutomationEvent.values[i - 1] * (1 - factor) + lastAutomationEvent.values[i] * factor; | ||
} | ||
} | ||
this._automationEvents[this._automationEvents.length - 1] = createSetValueCurveAutomationEvent( | ||
new Float32Array([6, 7]), | ||
values, | ||
lastAutomationEvent.startTime, | ||
eventTime - lastAutomationEvent.startTime | ||
duration | ||
); | ||
@@ -96,0 +116,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
165477
2067