@@ -138,6 +138,7 @@ impl Track {
138
138
parent_spatial_track_info : Option < SpatialTrackInfo > ,
139
139
send_tracks : & mut ResourceStorage < SendTrack > ,
140
140
) {
141
+ // get info
141
142
let spatial_track_info = self
142
143
. spatial_data
143
144
. as_ref ( )
@@ -152,11 +153,14 @@ impl Track {
152
153
& listeners. 0 . resources ,
153
154
spatial_track_info,
154
155
) ;
156
+
157
+ // update volume parameters
155
158
self . volume . update ( dt * out. len ( ) as f64 , & info) ;
156
159
for ( _, route) in & mut self . sends {
157
160
route. volume . update ( dt * out. len ( ) as f64 , & info) ;
158
161
}
159
162
163
+ // update playback state
160
164
let changed_playback_state = self
161
165
. playback_state_manager
162
166
. update ( dt * out. len ( ) as f64 , & info) ;
@@ -169,6 +173,8 @@ impl Track {
169
173
}
170
174
171
175
let num_frames = out. len ( ) ;
176
+
177
+ // process sub tracks
172
178
for ( _, sub_track) in & mut self . sub_tracks {
173
179
sub_track. process (
174
180
& mut self . temp_buffer [ ..out. len ( ) ] ,
@@ -184,16 +190,22 @@ impl Track {
184
190
}
185
191
self . temp_buffer . fill ( Frame :: ZERO ) ;
186
192
}
193
+
194
+ // process sounds
187
195
for ( _, sound) in & mut self . sounds {
188
196
sound. process ( & mut self . temp_buffer [ ..out. len ( ) ] , dt, & info) ;
189
197
for ( summed_out, sound_out) in out. iter_mut ( ) . zip ( self . temp_buffer . iter ( ) . copied ( ) ) {
190
198
* summed_out += sound_out;
191
199
}
192
200
self . temp_buffer . fill ( Frame :: ZERO ) ;
193
201
}
202
+
203
+ // apply effects
194
204
for effect in & mut self . effects {
195
205
effect. process ( out, dt, & info) ;
196
206
}
207
+
208
+ // apply spatialization
197
209
if let Some ( spatial_data) = & mut self . spatial_data {
198
210
spatial_data. position . update ( dt * out. len ( ) as f64 , & info) ;
199
211
spatial_data
@@ -212,9 +224,13 @@ impl Track {
212
224
interpolated_orientation. into ( ) ,
213
225
time_in_chunk,
214
226
) ;
227
+ } else {
228
+ * frame = Frame :: ZERO ;
215
229
}
216
230
}
217
231
}
232
+
233
+ // apply volume fade
218
234
for ( i, frame) in out. iter_mut ( ) . enumerate ( ) {
219
235
let time_in_chunk = ( i + 1 ) as f64 / num_frames as f64 ;
220
236
let volume = self . volume . interpolated_value ( time_in_chunk) . as_amplitude ( ) ;
@@ -224,6 +240,8 @@ impl Track {
224
240
. as_amplitude ( ) ;
225
241
* frame *= volume * fade_volume;
226
242
}
243
+
244
+ // output to send tracks
227
245
for ( send_track_id, SendTrackRoute { volume, .. } ) in & self . sends {
228
246
let Some ( send_track) = send_tracks. get_mut ( send_track_id. 0 ) else {
229
247
continue ;
0 commit comments