File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change 2929/**************************************************************************/
3030
3131class GodotPositionReportingProcessor extends AudioWorkletProcessor {
32+ static get parameterDescriptors ( ) {
33+ return [
34+ {
35+ name : 'reset' ,
36+ defaultValue : 0 ,
37+ minValue : 0 ,
38+ maxValue : 1 ,
39+ automationRate : 'k-rate' ,
40+ } ,
41+ ] ;
42+ }
43+
3244 constructor ( ...args ) {
3345 super ( ...args ) ;
3446 this . position = 0 ;
35-
36- this . port . onmessage = ( event ) => {
37- switch ( event ?. data ?. type ) {
38- case 'reset' :
39- this . position = 0 ;
40- break ;
41- default :
42- // Do nothing.
43- }
44- } ;
4547 }
4648
47- process ( inputs , _outputs , _parameters ) {
49+ process ( inputs , _outputs , parameters ) {
50+ if ( parameters [ 'reset' ] [ 0 ] > 0 ) {
51+ this . position = 0 ;
52+ }
53+
4854 if ( inputs . length > 0 ) {
4955 const input = inputs [ 0 ] ;
5056 if ( input . length > 0 ) {
Original file line number Diff line number Diff line change @@ -643,6 +643,7 @@ class SampleNode {
643643 'godot-position-reporting-processor'
644644 ) ;
645645 }
646+ this . _playbackPosition = this . offset ;
646647 this . _positionWorklet . port . onmessage = ( event ) => {
647648 switch ( event . data [ 'type' ] ) {
648649 case 'position' :
@@ -652,7 +653,11 @@ class SampleNode {
652653 // Do nothing.
653654 }
654655 } ;
655- this . _positionWorklet . port . postMessage ( 'reset' ) ;
656+
657+ const resetParameter = this . _positionWorklet . parameters . get ( 'reset' ) ;
658+ resetParameter . setValueAtTime ( 1 , GodotAudio . ctx . currentTime ) ;
659+ resetParameter . setValueAtTime ( 0 , GodotAudio . ctx . currentTime + 1 ) ;
660+
656661 return this . _positionWorklet ;
657662 }
658663
You can’t perform that action at this time.
0 commit comments