@@ -69,4 +69,44 @@ class OscillatorAutomationTests: XCTestCase {
6969 audio. append ( engine. render ( duration: 2.0 ) )
7070 testMD5 ( audio)
7171 }
72+
73+ func testAutomationAfterDelayedConnection( ) {
74+ let engine = AudioEngine ( )
75+ let osc = Oscillator ( waveform: Table ( . triangle) )
76+ let osc2 = Oscillator ( waveform: Table ( . triangle) )
77+ let mixer = Mixer ( )
78+ let events = [ AutomationEvent ( targetValue: 1320 , startTime: 0.0 , rampDuration: 0.5 ) ]
79+ engine. output = mixer
80+ mixer. addInput ( osc)
81+ let audio = engine. startTest ( totalDuration: 2.0 )
82+ osc. play ( )
83+ osc. $frequency. automate ( events: events)
84+ audio. append ( engine. render ( duration: 1.0 ) )
85+ mixer. removeInput ( osc)
86+ mixer. addInput ( osc2)
87+ osc2. play ( )
88+ osc2. $frequency. automate ( events: events)
89+ audio. append ( engine. render ( duration: 1.0 ) )
90+ testMD5 ( audio)
91+ }
92+
93+
94+ func testDelayedAutomation( ) throws {
95+ let engine = AudioEngine ( )
96+ let osc = Oscillator ( waveform: Table ( . triangle) )
97+ engine. output = osc
98+ osc. amplitude = 0.2
99+ osc. start ( )
100+ let audio = engine. startTest ( totalDuration: 2.0 )
101+
102+ audio. append ( engine. render ( duration: 1.0 ) )
103+ let events = [ AutomationEvent ( targetValue: 1320 , startTime: 0 , rampDuration: 0.1 ) ,
104+ AutomationEvent ( targetValue: 660 , startTime: 0.1 , rampDuration: 0.1 ) ,
105+ AutomationEvent ( targetValue: 1100 , startTime: 0.2 , rampDuration: 0.1 ) ,
106+ AutomationEvent ( targetValue: 770 , startTime: 0.3 , rampDuration: 0.1 ) ,
107+ AutomationEvent ( targetValue: 880 , startTime: 0.4 , rampDuration: 0.1 ) ]
108+ osc. $frequency. automate ( events: events)
109+ audio. append ( engine. render ( duration: 1.0 ) )
110+ testMD5 ( audio)
111+ }
72112}
0 commit comments