Adaptive Music v0.8.0 release candidate
Validate and generate manual release / package (push) Waiting to run
Validate and generate manual release / package (push) Waiting to run
This commit is contained in:
1 parent
8c07a468a4
commit
95b0427aa1
48 files changed
+3631
-313
No files matched your search
@@ -39,5 +39,5 @@ test('editor uses text for catalog labels and rechecks GM on actual save event',
|
||||
test('configuration hook disposal prevents pending asynchronous render from mounting',async()=>{
|
||||
const f=fixture(),callbacks=new Map();let resolve;const off=[];
|
||||
const ui=startConfigurationInterfaces({...f,Hooks:{on(e,fn){callbacks.set(e,fn);return e;},off(...args){off.push(args);}},getChoices:()=>new Promise(r=>{resolve=r;})});
|
||||
const root=container();const pending=callbacks.get('renderSceneConfig')({document:f.document},root);ui.dispose();resolve(choices);await pending;assert.equal(root.children.length,0);assert.equal(off.length,2);
|
||||
const root=container();const pending=callbacks.get('renderSceneConfig')({document:f.document},root);ui.dispose();resolve(choices);await pending;assert.equal(root.children.length,0);assert.equal(off.length,3);
|
||||
});
|
||||
@@ -152,3 +152,29 @@ test('superseded cross-provider apply is reconciled by stopping partially touche
|
||||
const newest=f.controller.update({scene:scene()});resume();await assert.rejects(stale,{code:'stale'});await newest;
|
||||
assert.equal(cleanups,1);assert.equal(f.playback.items[0],'A');
|
||||
});
|
||||
|
||||
test('duplicate hooks during a transition share its fence and a shared playlist does not restart',async()=>{
|
||||
const {controller,log}=fixture();
|
||||
const state={scene:{id:'A',playlist:ref('same')}};
|
||||
const first=controller.update(state),duplicate=controller.update(structuredClone(state));
|
||||
assert.equal(duplicate,first);
|
||||
await first;
|
||||
assert.equal((await controller.update({scene:{id:'B',playlist:ref('same')}})).unchanged,true);
|
||||
assert.deepEqual(log,[['resolve','same'],['apply','same']]);
|
||||
});
|
||||
|
||||
test('shared ambient and combat cue retains its position when combat ends under an override',async()=>{
|
||||
const f=fixture();
|
||||
const ambient={scene:scene()};
|
||||
const fighting={...ambient,combats:[{...combat(),playlist:ambient.scene.playlist}]};
|
||||
const overrides=[{id:'manual',playlist:ref('different')}];
|
||||
await f.controller.update(ambient);
|
||||
await f.controller.update(fighting);
|
||||
const saved={...f.playback,offset:73};
|
||||
f.playback=saved;
|
||||
await f.controller.update({...fighting,overrides});
|
||||
await f.controller.update({...ambient,overrides});
|
||||
assert.equal((await f.controller.update(ambient)).restored,true);
|
||||
assert.equal(f.playback.offset,saved.offset);
|
||||
assert.deepEqual(f.playback.items,saved.items);
|
||||
});
|
||||
@@ -113,3 +113,14 @@ test('Sendspin pause emulation retains position and restores paused queues witho
|
||||
assert.deepEqual(f.writes.slice(before).map(w=>w.action),['stop','clear','repeat','play_media']);
|
||||
const again=await f.provider.snapshot({...f.ctx,generation:7});assert.equal(again.value.state,'paused');assert.equal(again.value.index,1);assert.equal(again.value.position,17);
|
||||
});
|
||||
|
||||
test('an exhausted ambient queue can be interrupted and restored without starting audio',async()=>{
|
||||
const f=fixture();
|
||||
Object.assign(f.state,{state:'idle',ended:true,current_index:2,elapsed_time:0,repeat_mode:'off'});
|
||||
const finished=await f.provider.snapshot(f.ctx);
|
||||
assert.equal(finished.value.ended,true);
|
||||
f.state.ended=false;
|
||||
await f.provider.restore(finished,{...f.ctx,generation:2});
|
||||
assert.deepEqual(f.writes.map(write=>write.action),['stop','clear','repeat','play_media']);
|
||||
assert.equal(f.state.state,'idle');
|
||||
});
|
||||
@@ -8,6 +8,6 @@ test('installable development entry defaults automation off and imports no gatew
|
||||
try{
|
||||
await import('../../src/foundry/module.mjs');once.get('init')();once.get('ready')();
|
||||
assert.equal(settings.get('enabled').default,false);assert.equal(settings.get('ownedPlaylistIds').default,'');
|
||||
assert.equal(registrations,2);assert.equal(typeof module.api.mountConfiguration,'function');assert.throws(()=>module.api.setOverrides([]));module.api.dispose();
|
||||
assert.equal(registrations,4);assert.equal(typeof module.api.mountConfiguration,'function');assert.throws(()=>module.api.setOverrides([]));module.api.dispose();
|
||||
}finally{delete globalThis.game;delete globalThis.Hooks;delete globalThis.ui;}
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import {test} from 'node:test';
|
||||
import {PcmTimeline} from '../../src/audio/pcm-timeline.mjs';
|
||||
|
||||
const sampleRate=48000;
|
||||
const packet=serverTimeUs=>({samples:[new Float32Array(960)],sampleRate,serverTimeUs});
|
||||
|
||||
function fixture(){
|
||||
const sources=[];
|
||||
const context={currentTime:1,state:'running',
|
||||
createBuffer:(_channels,frames)=>({data:new Float32Array(frames),getChannelData(){return this.data;}}),
|
||||
createBufferSource(){
|
||||
const source={playbackRate:{value:1},connect(){},disconnect(){},start(time){this.time=time;},stop(time){this.stopTime=time;}};
|
||||
sources.push(source);
|
||||
return source;
|
||||
},
|
||||
};
|
||||
return {context,sources,timeline:new PcmTimeline(context,{})};
|
||||
}
|
||||
|
||||
test('consecutive PCM stays contiguous under a jittering browser clock',()=>{
|
||||
const {context,sources,timeline}=fixture();
|
||||
for(let i=0;i<8;i++){
|
||||
context.currentTime=1+i*0.02+i%2*0.0025;
|
||||
timeline.push(packet(2000000+i*20000),1900000+i*20000);
|
||||
}
|
||||
for(let i=1;i<sources.length;i++){
|
||||
const previous=sources[i-1],current=sources[i];
|
||||
assert.ok(Math.abs(current.time-previous.time-0.02/previous.playbackRate.value)<1e-9);
|
||||
}
|
||||
assert.equal(timeline.diagnostics.sourceGaps,0);
|
||||
assert.equal(timeline.diagnostics.underruns,0);
|
||||
});
|
||||
|
||||
test('partial clear preserves only the valid span and allows replacement at its boundary',()=>{
|
||||
const {sources,timeline}=fixture();
|
||||
const start=timeline.push(packet(2000000),1900000);
|
||||
timeline.push(packet(2020000),1900000);
|
||||
timeline.push(packet(2040000),1900000);
|
||||
timeline.clear(2030000);
|
||||
assert.ok(Math.abs(sources[1].stopTime-start-0.03)<1e-9);
|
||||
assert.equal(sources[2].stopTime,undefined);
|
||||
assert.equal(timeline.push(packet(2030000),1900000),sources[1].stopTime);
|
||||
assert.equal(timeline.diagnostics.sourceOverlaps,0);
|
||||
});
|
||||
|
||||
test('source gaps and late packets are observable separately from suspension',()=>{
|
||||
const {context,timeline}=fixture();
|
||||
timeline.push(packet(2000000),1900000);
|
||||
timeline.push(packet(2030000),1900000);
|
||||
assert.equal(timeline.diagnostics.sourceGaps,1);
|
||||
assert.equal(timeline.diagnostics.gapMs,10);
|
||||
assert.equal(timeline.push(packet(1000000),1900000),false);
|
||||
assert.equal(timeline.diagnostics.droppedLate,1);
|
||||
context.state='suspended';
|
||||
assert.equal(timeline.push(packet(2080000),1900000),false);
|
||||
assert.equal(timeline.diagnostics.bufferedMs,0);
|
||||
context.state='running';
|
||||
assert.ok(timeline.push(packet(2080000),1900000)>0);
|
||||
assert.equal(timeline.diagnostics.sourceGaps,1);
|
||||
});
|
||||
Reference in new issue
Block a user