@@ -6,6 +6,10 @@ import { applyInsertSettings } from "./core/applyInsertSettings";
66import { createMixerInsertNodes } from "./core/createMixerInsertNodes" ;
77import { computeSamplePlaybackParams } from "./core/computeSamplePlaybackParams" ;
88import { createSamplePlaybackNodes } from "./core/createSamplePlaybackNodes" ;
9+ import {
10+ applySampleGainAutomation ,
11+ computeSampleFadeParams ,
12+ } from "./core/sampleGainAutomation" ;
913import { DEFAULT_SAMPLE_MIDI_PITCH , midiPitchToPlaybackRate } from "./domain/pitch" ;
1014import { getSafeSampleSettings } from "./domain/sampleSettings" ;
1115import { getTimeStretchProfile } from "./domain/timeStretch" ;
@@ -747,7 +751,6 @@ export async function renderPlaylistArrangementToFile(options) {
747751 playDuration * playbackRate ,
748752 ) ,
749753 ) ;
750- const fadeOutAt = clipStartTime + Math . max ( 0 , playDuration - 0.012 ) ;
751754 const clipGain = Math . max (
752755 MIN_DURATION_SEC ,
753756 Number ( channel ?. volume ?? 0.75 ) *
@@ -764,9 +767,13 @@ export async function renderPlaylistArrangementToFile(options) {
764767
765768 source . buffer = scheduledBuffer ;
766769 source . playbackRate . setValueAtTime ( playbackRate , clipStartTime ) ;
767- gain . gain . setValueAtTime ( clipGain , clipStartTime ) ;
768- gain . gain . setValueAtTime ( clipGain , fadeOutAt ) ;
769- gain . gain . linearRampToValueAtTime ( 0.0001 , clipStartTime + playDuration ) ;
770+ applySampleGainAutomation (
771+ gain . gain ,
772+ clipStartTime ,
773+ playDuration ,
774+ clipGain ,
775+ computeSampleFadeParams ( playDuration , settings ) ,
776+ ) ;
770777 panner . pan . setValueAtTime ( clipPan , clipStartTime ) ;
771778
772779 source . connect ( gain ) ;
0 commit comments