@@ -573,16 +573,21 @@ Pizzicato.Sound.prototype = Object.create(Pizzicato.Events, {
573573 value : function ( ) {
574574 var currentValue = this . fadeNode . gain . value ;
575575 this . fadeNode . gain . cancelScheduledValues ( Pz . context . currentTime ) ;
576- this . fadeNode . gain . setValueAtTime ( currentValue , Pz . context . currentTime ) ;
577576
578577 if ( ! this . attack ) {
579- this . fadeNode . gain . setValueAtTime ( 1.0 , Pizzicato . context . currentTime ) ;
578+ this . fadeNode . gain . setTargetAtTime ( 1.0 , Pz . context . currentTime , 0.001 ) ;
580579 return ;
581580 }
582581
583- var remainingAttackTime = ( 1 - this . fadeNode . gain . value ) * this . attack ;
584- this . fadeNode . gain . setValueAtTime ( this . fadeNode . gain . value , Pizzicato . context . currentTime ) ;
585- this . fadeNode . gain . linearRampToValueAtTime ( 1 , Pizzicato . context . currentTime + remainingAttackTime ) ;
582+ // We can't calculate the remaining attack time
583+ // in Firefox due to https://bugzilla.mozilla.org/show_bug.cgi?id=893020
584+ var isFirefox = navigator . userAgent . toLowerCase ( ) . indexOf ( 'firefox' ) > - 1 ;
585+ var remainingAttackTime = this . attack ;
586+
587+ if ( ! isFirefox )
588+ remainingAttackTime = ( 1 - this . fadeNode . gain . value ) * this . attack ;
589+
590+ this . fadeNode . gain . setTargetAtTime ( 1.0 , Pz . context . currentTime , remainingAttackTime * 2 ) ;
586591 }
587592 } ,
588593
@@ -603,16 +608,22 @@ Pizzicato.Sound.prototype = Object.create(Pizzicato.Events, {
603608
604609 var currentValue = this . fadeNode . gain . value ;
605610 this . fadeNode . gain . cancelScheduledValues ( Pz . context . currentTime ) ;
606- this . fadeNode . gain . setValueAtTime ( currentValue , Pz . context . currentTime ) ;
607611
608612 if ( ! this . release ) {
613+ this . fadeNode . gain . setTargetAtTime ( 0.0 , Pz . context . currentTime , 0.001 ) ;
609614 stopSound ( ) ;
610615 return ;
611616 }
612617
613- var remainingReleaseTime = this . fadeNode . gain . value * this . release ;
614- this . fadeNode . gain . setValueAtTime ( this . fadeNode . gain . value , Pizzicato . context . currentTime ) ;
615- this . fadeNode . gain . linearRampToValueAtTime ( 0.00001 , Pizzicato . context . currentTime + remainingReleaseTime ) ;
618+ // We can't calculate the remaining attack time
619+ // in Firefox due to https://bugzilla.mozilla.org/show_bug.cgi?id=893020
620+ var isFirefox = navigator . userAgent . toLowerCase ( ) . indexOf ( 'firefox' ) > - 1 ;
621+ var remainingReleaseTime = this . release ;
622+
623+ if ( ! isFirefox )
624+ remainingReleaseTime = this . fadeNode . gain . value * this . release ;
625+
626+ this . fadeNode . gain . setTargetAtTime ( 0.00001 , Pz . context . currentTime , remainingReleaseTime / 5 ) ;
616627
617628 window . setTimeout ( function ( ) {
618629 stopSound ( ) ;
0 commit comments