@@ -868,7 +868,10 @@ class Bus {
868
868
* @returns {void }
869
869
*/
870
870
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
+ }
872
875
const buses = GodotAudio . buses . filter ( ( _ , i ) => i !== fromIndex ) ;
873
876
// Inserts at index.
874
877
buses . splice ( toIndex - 1 , 0 , movedBus ) ;
@@ -1424,7 +1427,10 @@ const _GodotAudio = {
1424
1427
* @returns {void }
1425
1428
*/
1426
1429
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
+ }
1428
1434
bus . clear ( ) ;
1429
1435
} ,
1430
1436
@@ -1454,8 +1460,17 @@ const _GodotAudio = {
1454
1460
* @returns {void }
1455
1461
*/
1456
1462
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 ) ;
1459
1474
} ,
1460
1475
1461
1476
/**
@@ -1465,7 +1480,10 @@ const _GodotAudio = {
1465
1480
* @returns {void }
1466
1481
*/
1467
1482
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
+ }
1469
1487
bus . setVolumeDb ( volumeDb ) ;
1470
1488
} ,
1471
1489
@@ -1476,7 +1494,10 @@ const _GodotAudio = {
1476
1494
* @returns {void }
1477
1495
*/
1478
1496
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
+ }
1480
1501
bus . solo ( enable ) ;
1481
1502
} ,
1482
1503
@@ -1487,7 +1508,10 @@ const _GodotAudio = {
1487
1508
* @returns {void }
1488
1509
*/
1489
1510
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
+ }
1491
1515
bus . mute ( enable ) ;
1492
1516
} ,
1493
1517
} ,
0 commit comments