@@ -868,7 +868,10 @@ class Bus {
868868 * @returns {void }
869869 */
870870 static move ( fromIndex , toIndex ) {
871- const movedBus = GodotAudio . Bus . getBus ( fromIndex ) ;
871+ const movedBus = GodotAudio . Bus . getBusOrNull ( fromIndex ) ;
872+ if ( movedBus == null ) {
873+ return ;
874+ }
872875 const buses = GodotAudio . buses . filter ( ( _ , i ) => i !== fromIndex ) ;
873876 // Inserts at index.
874877 buses . splice ( toIndex - 1 , 0 , movedBus ) ;
@@ -1424,7 +1427,10 @@ const _GodotAudio = {
14241427 * @returns {void }
14251428 */
14261429 remove_sample_bus : function ( index ) {
1427- const bus = GodotAudio . Bus . getBus ( index ) ;
1430+ const bus = GodotAudio . Bus . getBusOrNull ( index ) ;
1431+ if ( bus == null ) {
1432+ return ;
1433+ }
14281434 bus . clear ( ) ;
14291435 } ,
14301436
@@ -1454,8 +1460,17 @@ const _GodotAudio = {
14541460 * @returns {void }
14551461 */
14561462 set_sample_bus_send : function ( busIndex , sendIndex ) {
1457- const bus = GodotAudio . Bus . getBus ( busIndex ) ;
1458- bus . setSend ( GodotAudio . Bus . getBus ( sendIndex ) ) ;
1463+ const bus = GodotAudio . Bus . getBusOrNull ( busIndex ) ;
1464+ if ( bus == null ) {
1465+ // Cannot send from an invalid bus.
1466+ return ;
1467+ }
1468+ let targetBus = GodotAudio . Bus . getBusOrNull ( sendIndex ) ;
1469+ if ( targetBus == null ) {
1470+ // Send to master.
1471+ targetBus = GodotAudio . Bus . getBus ( 0 ) ;
1472+ }
1473+ bus . setSend ( targetBus ) ;
14591474 } ,
14601475
14611476 /**
@@ -1465,7 +1480,10 @@ const _GodotAudio = {
14651480 * @returns {void }
14661481 */
14671482 set_sample_bus_volume_db : function ( busIndex , volumeDb ) {
1468- const bus = GodotAudio . Bus . getBus ( busIndex ) ;
1483+ const bus = GodotAudio . Bus . getBusOrNull ( busIndex ) ;
1484+ if ( bus == null ) {
1485+ return ;
1486+ }
14691487 bus . setVolumeDb ( volumeDb ) ;
14701488 } ,
14711489
@@ -1476,7 +1494,10 @@ const _GodotAudio = {
14761494 * @returns {void }
14771495 */
14781496 set_sample_bus_solo : function ( busIndex , enable ) {
1479- const bus = GodotAudio . Bus . getBus ( busIndex ) ;
1497+ const bus = GodotAudio . Bus . getBusOrNull ( busIndex ) ;
1498+ if ( bus == null ) {
1499+ return ;
1500+ }
14801501 bus . solo ( enable ) ;
14811502 } ,
14821503
@@ -1487,7 +1508,10 @@ const _GodotAudio = {
14871508 * @returns {void }
14881509 */
14891510 set_sample_bus_mute : function ( busIndex , enable ) {
1490- const bus = GodotAudio . Bus . getBus ( busIndex ) ;
1511+ const bus = GodotAudio . Bus . getBusOrNull ( busIndex ) ;
1512+ if ( bus == null ) {
1513+ return ;
1514+ }
14911515 bus . mute ( enable ) ;
14921516 } ,
14931517 } ,
0 commit comments