fna-workbench

fna-workbench Commit Details


Date:2015-12-29 15:25:56 (9 years 8 months ago)
Author:Ethan Lee
Branch:master
Commit:7bb82fb4496f27330bddc629b6879b020ab20549
Parents: a6d165195b17bb3fb838716175ab854e04aeb8d6
Message:Max Cue behavior now has a buffer of ~4 frames

Changes:

File differences

src/Audio/AudioCategory.cs
229229
230230
231231
232
232
233
234
235
233236
234237
235238
......
237240
238241
239242
240
241
243
242244
243
244
245
246
247
248
249
250
245251
246252
247253
......
249255
250256
251257
258
259
260
261
252262
253263
254264
255265
256
266
267
268
269
257270
258271
259272
......
263276
264277
265278
266
267
268
269
270
271
272
273
274
275
276
279
277280
278281
279282
280283
281284
282
285
283286
284287
285
288
286289
287290
291
288292
289293
290294
291
295
292296
293297
294298
......
297301
298302
299303
300
304
301305
302306
303307
......
312316
313317
314318
319
315320
321
316322
317323
318324
}
else if (maxCueBehavior == MaxInstanceBehavior.ReplaceOldest)
{
INTERNAL_removeOldestCue(activeCues[0].Name);
if (!INTERNAL_removeOldestCue(activeCues[0].Name))
{
return false; // Just ignore us...
}
}
else if (maxCueBehavior == MaxInstanceBehavior.ReplaceQuietest)
{
int lowestIndex = -1;
for (int i = 0; i < activeCues.Count; i += 1)
{
float vol = activeCues[i].INTERNAL_calculateVolume();
if (vol < lowestVolume)
if (!activeCues[i].JustStarted)
{
lowestVolume = vol;
lowestIndex = i;
float vol = activeCues[i].INTERNAL_calculateVolume();
if (vol < lowestVolume)
{
lowestVolume = vol;
lowestIndex = i;
}
}
}
if (lowestIndex > -1)
cueInstanceCounts[activeCues[lowestIndex].Name] -= 1;
activeCues[lowestIndex].Stop(AudioStopOptions.AsAuthored);
}
else
{
return false; // Just ignore us...
}
}
else if (maxCueBehavior == MaxInstanceBehavior.ReplaceLowestPriority)
{
// FIXME: Priority?
INTERNAL_removeOldestCue(activeCues[0].Name);
if (!INTERNAL_removeOldestCue(activeCues[0].Name));
{
return false; // Just ignore us...
}
}
}
cueInstanceCounts[newCue.Name] += 1;
return true;
}
internal void INTERNAL_removeLatestCue()
{
lock (activeCues)
{
Cue toDie = activeCues[activeCues.Count - 1];
cueInstanceCounts[toDie.Name] -= 1;
activeCues.RemoveAt(activeCues.Count - 1);
}
}
internal void INTERNAL_removeOldestCue(string name)
internal bool INTERNAL_removeOldestCue(string name)
{
lock (activeCues)
{
for (int i = 0; i < activeCues.Count; i += 1)
{
if (activeCues[i].Name.Equals(name))
if (activeCues[i].Name.Equals(name) && !activeCues[i].JustStarted)
{
activeCues[i].Stop(AudioStopOptions.AsAuthored);
return;
return true;
}
}
return false;
}
}
internal void INTERNAL_removeQuietestCue(string name)
internal bool INTERNAL_removeQuietestCue(string name)
{
float lowestVolume = float.MaxValue;
int lowestIndex = -1;
{
for (int i = 0; i < activeCues.Count; i += 1)
{
if (activeCues[i].Name.Equals(name))
if (activeCues[i].Name.Equals(name) && !activeCues[i].JustStarted)
{
float vol = activeCues[i].INTERNAL_calculateVolume();
if (vol < lowestVolume)
{
cueInstanceCounts[name] -= 1;
activeCues[lowestIndex].Stop(AudioStopOptions.AsAuthored);
return true;
}
return false;
}
}
src/Audio/Cue.cs
8686
8787
8888
89
90
91
92
93
94
95
96
97
98
99
100
89101
90102
91103
......
132144
133145
134146
147
148
149
135150
136151
137152
......
329344
330345
331346
332
347
348
349
350
333351
334352
335353
336
354
355
356
357
337358
338359
339360
340361
341
362
363
364
365
342366
343367
344368
......
440464
441465
442466
467
468
443469
444470
445471
#endregion
#region Internal Properties
internal bool JustStarted
{
get
{
return INTERNAL_framesSinceStart < 4;
}
}
#endregion
#region Private Variables
private AudioEngine INTERNAL_baseEngine;
private AudioCategory INTERNAL_category;
private bool INTERNAL_isManaged;
// Arbitrary nonsense to prevent duplicate Cues
private ulong INTERNAL_framesSinceStart = 0;
// Fading
private enum FadeMode
{
}
else if (INTERNAL_data.MaxCueBehavior == MaxInstanceBehavior.ReplaceOldest)
{
INTERNAL_category.INTERNAL_removeOldestCue(Name);
if (!INTERNAL_category.INTERNAL_removeOldestCue(Name))
{
return; // Just ignore us...
}
}
else if (INTERNAL_data.MaxCueBehavior == MaxInstanceBehavior.ReplaceQuietest)
{
INTERNAL_category.INTERNAL_removeQuietestCue(Name);
if (!INTERNAL_category.INTERNAL_removeQuietestCue(Name))
{
return; // Just ignore us...
}
}
else if (INTERNAL_data.MaxCueBehavior == MaxInstanceBehavior.ReplaceLowestPriority)
{
// FIXME: Priority?
INTERNAL_category.INTERNAL_removeOldestCue(Name);
if (!INTERNAL_category.INTERNAL_removeOldestCue(Name))
{
return; // Just ignore us...
}
}
}
return true;
}
INTERNAL_framesSinceStart += 1;
// Play events when the timestamp has been hit.
for (int i = 0; i < INTERNAL_eventList.Count; i += 1)
{

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.92311s using 13 queries.