@@ -3393,7 +3393,7 @@ class EnvelopeComputer {
33933393 this . _prevNoteSizeFinal = Config . noteSizeMax ;
33943394 }
33953395
3396- public computeEnvelopes ( instrument : Instrument , currentPart : number , tickTimeStart : number , tickTimeEnd : number , secondsPassing : number , tone : Tone | null , released : boolean ) : void {
3396+ public computeEnvelopes ( instrument : Instrument , currentPart : number , tickTimeStart : number , tickTimeEnd : number , secondsPassing : number , tone : Tone | null ) : void {
33973397 const transition : Transition = instrument . getTransition ( ) ;
33983398 if ( tone != null && tone . atNoteStart && ! transition . continues ) {
33993399 this . _prevNoteSecondsEnd = this . noteSecondsEnd ;
@@ -3436,7 +3436,7 @@ class EnvelopeComputer {
34363436 let prevSlideRatioEnd : number = 0.0 ;
34373437 let nextSlideRatioStart : number = 0.0 ;
34383438 let nextSlideRatioEnd : number = 0.0 ;
3439- if ( tone != null && tone . note != null && ! released ) {
3439+ if ( tone != null && tone . note != null && ! tone . passedEndOfNote ) {
34403440 const endPinIndex : number = tone . note . getEndPinIndex ( currentPart ) ;
34413441 const startPin : NotePin = tone . note . pins [ endPinIndex - 1 ] ;
34423442 const endPin : NotePin = tone . note . pins [ endPinIndex ] ;
@@ -3607,6 +3607,7 @@ class Tone {
36073607 public freshlyAllocated : boolean = true ;
36083608 public atNoteStart : boolean = false ;
36093609 public isOnLastTick : boolean = false ;
3610+ public passedEndOfNote : boolean = false ;
36103611 public noteStart : number = 0 ;
36113612 public noteEnd : number = 0 ;
36123613 public noteLengthTicks : number = 0 ;
@@ -3871,7 +3872,7 @@ class InstrumentState {
38713872 this . chorusPhase = 0.0 ;
38723873 }
38733874
3874- public compute ( synth : Synth , instrument : Instrument , samplesPerTick : number , runLength : number , tone : Tone | null , released : boolean ) : void {
3875+ public compute ( synth : Synth , instrument : Instrument , samplesPerTick : number , runLength : number , tone : Tone | null ) : void {
38753876 this . computed = true ;
38763877
38773878 this . allocateNecessaryBuffers ( synth , instrument , samplesPerTick ) ;
@@ -3887,7 +3888,7 @@ class InstrumentState {
38873888 const secondsPerTick : number = samplesPerTick / synth . samplesPerSecond ;
38883889 const currentPart : number = synth . getCurrentPart ( ) ;
38893890
3890- this . envelopeComputer . computeEnvelopes ( instrument , currentPart , tickTimeStart , tickTimeEnd , secondsPerTick * ( tickTimeEnd - tickTimeStart ) , tone , released ) ;
3891+ this . envelopeComputer . computeEnvelopes ( instrument , currentPart , tickTimeStart , tickTimeEnd , secondsPerTick * ( tickTimeEnd - tickTimeStart ) , tone ) ;
38913892 const envelopeStarts : number [ ] = this . envelopeComputer . envelopeStarts ;
38923893 const envelopeEnds : number [ ] = this . envelopeComputer . envelopeEnds ;
38933894
@@ -4525,7 +4526,7 @@ export class Synth {
45254526
45264527 if ( instrumentState . awake ) {
45274528 if ( ! instrumentState . computed ) {
4528- instrumentState . compute ( this , instrument , samplesPerTick , runLength , null , true ) ;
4529+ instrumentState . compute ( this , instrument , samplesPerTick , runLength , null ) ;
45294530 }
45304531
45314532 Synth . effectsSynth ( this , outputDataL , outputDataR , bufferIndex , runLength , instrument , instrumentState ) ;
@@ -4653,6 +4654,7 @@ export class Synth {
46534654 private releaseTone ( instrumentState : InstrumentState , tone : Tone ) : void {
46544655 instrumentState . releasedTones . pushFront ( tone ) ;
46554656 tone . atNoteStart = false ;
4657+ tone . passedEndOfNote = true ;
46564658 }
46574659
46584660 private freeReleasedTone ( instrumentState : InstrumentState , toneIndex : number ) : void {
@@ -4862,6 +4864,7 @@ export class Synth {
48624864 tone . prevNotePitchIndex = 0 ;
48634865 tone . nextNotePitchIndex = 0 ;
48644866 tone . atNoteStart = atNoteStart ;
4867+ tone . passedEndOfNote = false ;
48654868 } else {
48664869 const transition : Transition = instrument . getTransition ( ) ;
48674870 for ( let i : number = 0 ; i < note . pitches . length ; i ++ ) {
@@ -4871,13 +4874,15 @@ export class Synth {
48714874 let noteForThisTone : Note = note ;
48724875 let nextNoteForThisTone : Note | null = ( nextNoteForThisInstrument && nextNoteForThisInstrument . pitches . length > i ) ? nextNoteForThisInstrument : null ;
48734876 let noteStart : number = noteForThisTone . start + strumOffsetParts ;
4877+ let passedEndOfNote : boolean = false ;
48744878
48754879 if ( noteStart > currentPart ) {
48764880 if ( toneList . count ( ) > i && transition . isSeamless && prevNoteForThisTone != null ) {
48774881 nextNoteForThisTone = noteForThisTone ;
48784882 noteForThisTone = prevNoteForThisTone ;
48794883 prevNoteForThisTone = null ;
48804884 noteStart = noteForThisTone . start + strumOffsetParts ;
4885+ passedEndOfNote = true ;
48814886 } else {
48824887 break ;
48834888 }
@@ -4919,6 +4924,7 @@ export class Synth {
49194924 tone . prevNotePitchIndex = i ;
49204925 tone . nextNotePitchIndex = i ;
49214926 tone . atNoteStart = atNoteStart ;
4927+ tone . passedEndOfNote = passedEndOfNote ;
49224928 }
49234929 }
49244930 this . releaseOrFreeUnusedTones ( toneList , toneCount , song , channelIndex ) ;
@@ -4951,7 +4957,7 @@ export class Synth {
49514957 instrumentState . awake = true ;
49524958 instrumentState . tonesAddedInThisTick = true ;
49534959 if ( ! instrumentState . computed ) {
4954- instrumentState . compute ( this , instrument , samplesPerTick , runLength , tone , released ) ;
4960+ instrumentState . compute ( this , instrument , samplesPerTick , runLength , tone ) ;
49554961 }
49564962
49574963 Synth . computeTone ( this , song , channelIndex , samplesPerTick , runLength , tone , released , shouldFadeOutFast ) ;
@@ -5119,7 +5125,7 @@ export class Synth {
51195125
51205126 // Compute envelopes *after* resetting the tone, otherwise the envelope computer gets reset too!
51215127 const envelopeComputer : EnvelopeComputer = tone . envelopeComputer ;
5122- envelopeComputer . computeEnvelopes ( instrument , currentPart , Config . ticksPerPart * partTimeStart , Config . ticksPerPart * partTimeEnd , secondsPerPart * ( partTimeEnd - partTimeStart ) , tone , released ) ;
5128+ envelopeComputer . computeEnvelopes ( instrument , currentPart , Config . ticksPerPart * partTimeStart , Config . ticksPerPart * partTimeEnd , secondsPerPart * ( partTimeEnd - partTimeStart ) , tone ) ;
51235129 const envelopeStarts : number [ ] = tone . envelopeComputer . envelopeStarts ;
51245130 const envelopeEnds : number [ ] = tone . envelopeComputer . envelopeEnds ;
51255131
0 commit comments