@@ -515,11 +515,11 @@ class SoundFile {
515
515
* </code></div>
516
516
*/
517
517
playMode ( str ) {
518
- var s = str . toLowerCase ( ) ;
518
+ var s = str . toLowerCase ( ) . trim ( ) ;
519
519
520
520
// if restart, stop all other sounds from playing
521
521
if ( s === 'restart' && this . buffer && this . bufferSourceNode ) {
522
- for ( var i = 0 ; i < this . bufferSourceNodes . length - 1 ; i ++ ) {
522
+ for ( var i = 0 ; i < this . bufferSourceNodes . length ; i ++ ) {
523
523
var now = p5sound . audiocontext . currentTime ;
524
524
this . bufferSourceNodes [ i ] . stop ( now ) ;
525
525
}
@@ -715,10 +715,9 @@ class SoundFile {
715
715
this . _paused = false ;
716
716
} else if ( this . buffer && this . bufferSourceNode ) {
717
717
var now = p5sound . audiocontext . currentTime ;
718
- var t = time || 0 ;
719
718
this . pauseTime = 0 ;
720
- this . bufferSourceNode . stop ( now + t ) ;
721
- this . _counterNode . stop ( now + t ) ;
719
+ this . bufferSourceNode . stop ( now + time ) ;
720
+ this . _counterNode . stop ( now + time ) ;
722
721
this . _playing = false ;
723
722
this . _paused = false ;
724
723
}
@@ -999,7 +998,7 @@ class SoundFile {
999
998
* @return {Number } [channels]
1000
999
*/
1001
1000
channels ( ) {
1002
- return this . buffer . numberOfChannels ;
1001
+ if ( this . buffer ) return this . buffer . numberOfChannels ;
1003
1002
}
1004
1003
1005
1004
/**
@@ -1010,7 +1009,7 @@ class SoundFile {
1010
1009
* @return {Number } [sampleRate]
1011
1010
*/
1012
1011
sampleRate ( ) {
1013
- return this . buffer . sampleRate ;
1012
+ if ( this . buffer ) return this . buffer . sampleRate ;
1014
1013
}
1015
1014
1016
1015
/**
@@ -1022,7 +1021,7 @@ class SoundFile {
1022
1021
* @return {Number } [sampleCount]
1023
1022
*/
1024
1023
frames ( ) {
1025
- return this . buffer . length ;
1024
+ if ( this . buffer ) return this . buffer . length ;
1026
1025
}
1027
1026
1028
1027
/**
@@ -1045,7 +1044,7 @@ class SoundFile {
1045
1044
if ( this . buffer ) {
1046
1045
// set length to window's width if no length is provided
1047
1046
if ( ! length ) {
1048
- length = window . width * 5 ;
1047
+ length = window . innerWidth * 5 ;
1049
1048
}
1050
1049
if ( this . buffer ) {
1051
1050
var buffer = this . buffer ;
0 commit comments