-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVocalsCombiner.cs
More file actions
55 lines (45 loc) · 1.37 KB
/
Copy pathVocalsCombiner.cs
File metadata and controls
55 lines (45 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Rocksmith2014.XML;
using System.Collections.Generic;
namespace XmlCombiners
{
public sealed class VocalsCombiner
{
private List<Vocal>? CombinedVocals { get; set; }
private int SongLength { get; set; }
public void Save(string fileName)
{
if (CombinedVocals is not null)
Vocals.Save(fileName, CombinedVocals);
}
public void AddNext(List<Vocal>? next, int songLength, int trimAmount)
{
// Adding first arrangement
if (CombinedVocals is null)
{
AddFirst(next, songLength);
return;
}
if (next is null)
{
SongLength += songLength - trimAmount;
return;
}
int startTime = SongLength - trimAmount;
UpdateVocals(next, startTime);
CombinedVocals.AddRange(next);
SongLength += songLength - trimAmount;
}
private void AddFirst(List<Vocal>? next, int songLength)
{
CombinedVocals = next ?? new List<Vocal>();
SongLength = songLength;
}
private static void UpdateVocals(List<Vocal> vocals, int startTime)
{
foreach (var vocal in vocals)
{
vocal.Time += startTime;
}
}
}
}