Some fixes and support for more than 2 voices
This commit is contained in:
1 parent
8890176e97
commit
bf1c00b5d1
10 files changed
+144
-62
No files matched your search
@@ -110,7 +110,7 @@ namespace Vocaluxe.Base
|
||||
return CConfig.CoverSize;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetSongFolder()
|
||||
public IEnumerable<string> GetSongFolders()
|
||||
{
|
||||
return CConfig.SongFolder;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Songs;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
@@ -597,6 +598,8 @@ namespace Vocaluxe.Screens
|
||||
_CheckMics();
|
||||
_CheckPlayers();
|
||||
|
||||
CSong firstSong = CGame.GetSong(0);
|
||||
|
||||
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
|
||||
{
|
||||
_Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.IsProfileIDValid(CGame.Players[i].ProfileID) ?
|
||||
@@ -607,8 +610,9 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].Clear();
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].Visible = i + 1 <= CGame.NumPlayer;
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart1);
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(CGame.GetSong(1).DuetPart2);
|
||||
|
||||
for (int j = 0; j < firstSong.Notes.VoiceCount; j++)
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].AddValue(firstSong.Notes.VoiceNames[j]);
|
||||
_SelectSlides[_SelectSlideDuetPlayer[i]].Selection = i % 2;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -297,10 +297,8 @@ namespace Vocaluxe.Screens
|
||||
string name = CProfiles.GetPlayerName(players[p].ProfileID, p);
|
||||
if (song != null && song.IsDuet)
|
||||
{
|
||||
if (players[p].VoiceNr == 0 && song.DuetPart1 != "Part 1")
|
||||
name += " (" + song.DuetPart1 + ")";
|
||||
else if (players[p].VoiceNr == 1 && song.DuetPart2 != "Part 2")
|
||||
name += " (" + song.DuetPart2 + ")";
|
||||
if (song.Notes.VoiceNames.IsSet(players[p].VoiceNr))
|
||||
name += " (" + song.Notes.VoiceNames[players[p].VoiceNr] + ")";
|
||||
}
|
||||
_Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = name;
|
||||
|
||||
|
||||
@@ -634,8 +634,9 @@ namespace Vocaluxe.Screens
|
||||
|
||||
if (song.IsDuet)
|
||||
{
|
||||
_Texts[_TextDuetName1].Text = song.DuetPart1;
|
||||
_Texts[_TextDuetName2].Text = song.DuetPart2;
|
||||
//TODO: Show more than 2 voicenames
|
||||
_Texts[_TextDuetName1].Text = song.Notes.VoiceNames[0];
|
||||
_Texts[_TextDuetName2].Text = song.Notes.VoiceNames[1];
|
||||
//More than one song: Player is not assigned to line by user
|
||||
//Otherwise, this is done by CScreenNames
|
||||
if (CGame.GetNumSongs() > 1)
|
||||
@@ -781,7 +782,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
|
||||
_CurrentBeat = CGame.CurrentBeat;
|
||||
for (int i = 0; i < song.Notes.LinesCount; i++)
|
||||
for (int i = 0; i < song.Notes.VoiceCount; i++)
|
||||
{
|
||||
if (i > 1)
|
||||
break; // for later
|
||||
@@ -1093,7 +1094,7 @@ namespace Vocaluxe.Screens
|
||||
var alpha = new float[song.Notes.Voices.Length * 2];
|
||||
float currentTime = _CurrentTime - song.Gap;
|
||||
|
||||
for (int i = 0; i < song.Notes.LinesCount; i++)
|
||||
for (int i = 0; i < song.Notes.VoiceCount; i++)
|
||||
{
|
||||
CVoice voice = song.Notes.GetVoice(i);
|
||||
CSongLine[] lines = voice.Lines;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace VocaluxeLib
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Resizes the given list to the given size. Removes elements or adds default values
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
public static void Resize<T>(this List<T> list, int size, T defaultValue = default(T))
|
||||
{
|
||||
int curSize = list.Count;
|
||||
if (size < curSize)
|
||||
list.RemoveRange(size, curSize - size);
|
||||
else if (size > curSize)
|
||||
list.AddRange(Enumerable.Repeat(defaultValue, size - curSize));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes the list at least the given size adding the given default values.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
public static void EnsureSize<T>(this List<T> list, int size, T defaultValue)
|
||||
{
|
||||
int curSize = list.Count;
|
||||
if (size > curSize)
|
||||
list.AddRange(Enumerable.Repeat(defaultValue, size - curSize));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes the list at least the given size adding a new instance of T
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="size"></param>
|
||||
public static void EnsureSize<T>(this List<T> list, int size) where T : new()
|
||||
{
|
||||
if (size > list.Count)
|
||||
list.Add(new T());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace VocaluxeLib
|
||||
|
||||
int GetCoverSize();
|
||||
|
||||
IEnumerable<string> GetSongFolder();
|
||||
IEnumerable<string> GetSongFolders();
|
||||
ESongSorting GetSongSorting();
|
||||
EOffOn GetTabs();
|
||||
EOffOn GetIgnoreArticles();
|
||||
|
||||
+51
-10
@@ -21,26 +21,65 @@ namespace VocaluxeLib.Songs
|
||||
{
|
||||
public class CNotes
|
||||
{
|
||||
public class CVoiceNames
|
||||
{
|
||||
private readonly List<string> _Names = new List<string>();
|
||||
|
||||
public CVoiceNames() {}
|
||||
|
||||
public CVoiceNames(CVoiceNames names)
|
||||
{
|
||||
_Names.AddRange(names._Names);
|
||||
}
|
||||
|
||||
public string this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsSet(index))
|
||||
return _Names[index];
|
||||
return "Part " + (index + 1);
|
||||
}
|
||||
set
|
||||
{
|
||||
_Names.EnsureSize(index + 1, null);
|
||||
_Names[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSet(int index)
|
||||
{
|
||||
return _Names.Count > index && !string.IsNullOrEmpty(_Names[index]);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_Names.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<CVoice> _Voices = new List<CVoice>();
|
||||
public readonly CVoiceNames VoiceNames = new CVoiceNames();
|
||||
|
||||
public CNotes() {}
|
||||
|
||||
public CNotes(CNotes notes)
|
||||
{
|
||||
foreach (CVoice voice in notes._Voices)
|
||||
_Voices.Add(new CVoice(voice));
|
||||
VoiceNames = new CVoiceNames(notes.VoiceNames);
|
||||
}
|
||||
|
||||
public CVoice[] Voices
|
||||
{
|
||||
get { return _Voices.ToArray(); }
|
||||
}
|
||||
|
||||
public CNotes() {}
|
||||
|
||||
public int LinesCount
|
||||
public int VoiceCount
|
||||
{
|
||||
get { return _Voices.Count; }
|
||||
}
|
||||
|
||||
public CNotes(CNotes notes)
|
||||
{
|
||||
foreach (CVoice voice in notes._Voices)
|
||||
_Voices.Add(new CVoice(voice));
|
||||
}
|
||||
|
||||
public CVoice GetVoice(int index)
|
||||
{
|
||||
while (index >= _Voices.Count)
|
||||
@@ -79,9 +118,11 @@ namespace VocaluxeLib.Songs
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
public void Reset(bool resetVoices = false)
|
||||
{
|
||||
_Voices.Clear();
|
||||
if (resetVoices)
|
||||
VoiceNames.Reset();
|
||||
}
|
||||
|
||||
public void SetMedley(int startBeat, int endBeat)
|
||||
|
||||
+22
-34
@@ -124,9 +124,6 @@ namespace VocaluxeLib.Songs
|
||||
public float Gap;
|
||||
public float VideoGap;
|
||||
|
||||
public string DuetPart1 = String.Empty;
|
||||
public string DuetPart2 = String.Empty;
|
||||
|
||||
private readonly List<string> _Comment = new List<string>();
|
||||
|
||||
// Sorting
|
||||
@@ -192,8 +189,6 @@ namespace VocaluxeLib.Songs
|
||||
PreviewStart = song.PreviewStart;
|
||||
|
||||
ShortEnd = song.ShortEnd;
|
||||
DuetPart1 = song.DuetPart1;
|
||||
DuetPart2 = song.DuetPart2;
|
||||
|
||||
Encoding = song.Encoding;
|
||||
Folder = song.Folder;
|
||||
@@ -268,7 +263,7 @@ namespace VocaluxeLib.Songs
|
||||
if (Folder == null)
|
||||
return false;
|
||||
|
||||
foreach (string folder in CBase.Config.GetSongFolder())
|
||||
foreach (string folder in CBase.Config.GetSongFolders())
|
||||
{
|
||||
if (!Folder.Contains(folder))
|
||||
continue;
|
||||
@@ -318,7 +313,7 @@ namespace VocaluxeLib.Songs
|
||||
sr = null;
|
||||
sr = new StreamReader(filePath, Encoding);
|
||||
|
||||
//Scip everything till encoding
|
||||
//Skip everything till encoding
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
line = sr.ReadLine();
|
||||
@@ -362,12 +357,12 @@ namespace VocaluxeLib.Songs
|
||||
case "DUETSINGERP1":
|
||||
case "P1":
|
||||
if (value != "")
|
||||
DuetPart1 = value;
|
||||
Notes.VoiceNames[0] = value;
|
||||
break;
|
||||
case "DUETSINGERP2":
|
||||
case "P2":
|
||||
if (value != "")
|
||||
DuetPart2 = value;
|
||||
Notes.VoiceNames[1] = value;
|
||||
break;
|
||||
case "MP3":
|
||||
if (File.Exists(Path.Combine(Folder, value)))
|
||||
@@ -462,7 +457,7 @@ namespace VocaluxeLib.Songs
|
||||
CalculateMedley = false;
|
||||
break;
|
||||
case "RELATIVE":
|
||||
if (value.ToUpper() == "YES" && value.ToUpper() != "NO")
|
||||
if (value.ToUpper() == "YES")
|
||||
Relative = EOffOn.TR_CONFIG_ON;
|
||||
break;
|
||||
}
|
||||
@@ -569,7 +564,7 @@ namespace VocaluxeLib.Songs
|
||||
int currentPos = 0;
|
||||
bool isNewSentence = false;
|
||||
|
||||
int player = 0;
|
||||
int player = 1;
|
||||
int fileLineNo = 0;
|
||||
|
||||
StreamReader sr = null;
|
||||
@@ -611,14 +606,7 @@ namespace VocaluxeLib.Songs
|
||||
char chr;
|
||||
while ((chr = (char)sr.Read()) == ' ') {}
|
||||
|
||||
int.TryParse(chr.ToString(), out param1);
|
||||
if (param1 == 1)
|
||||
player = 0;
|
||||
else if (param1 == 2)
|
||||
player = 1;
|
||||
else if (param1 == 3)
|
||||
player = 2;
|
||||
else
|
||||
if (!int.TryParse(chr.ToString(), out player))
|
||||
{
|
||||
CBase.Log.LogError("Error loading song. Line No.: " + fileLineNo + ". Wrong or missing number after \"P\": " + filePath);
|
||||
return false;
|
||||
@@ -652,14 +640,19 @@ namespace VocaluxeLib.Songs
|
||||
if (Relative == EOffOn.TR_CONFIG_ON)
|
||||
param1 += currentPos;
|
||||
|
||||
if (player != 2)
|
||||
// one singer
|
||||
_ParseNote(player, noteType, param1, param2, param3, paramS);
|
||||
else
|
||||
int curPlayer = 0;
|
||||
int tmpPlayer = player;
|
||||
//Evaluate as bitset
|
||||
while (tmpPlayer > 0)
|
||||
{
|
||||
// both singer
|
||||
_ParseNote(0, noteType, param1, param2, param3, paramS);
|
||||
_ParseNote(1, noteType, param1, param2, param3, paramS);
|
||||
if ((tmpPlayer & 1) != 0)
|
||||
{
|
||||
if (!_ParseNote(curPlayer, noteType, param1, param2, param3, paramS))
|
||||
CBase.Log.LogError("Warning! Ignored note for player " + (curPlayer + 1) + " in song because it overlaps with other note. Line No.: " +
|
||||
fileLineNo + ": " + filePath);
|
||||
}
|
||||
tmpPlayer >>= 1;
|
||||
curPlayer++;
|
||||
}
|
||||
isNewSentence = false;
|
||||
break;
|
||||
@@ -789,15 +782,10 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
private void _CheckDuet()
|
||||
{
|
||||
if (DuetPart1 == "")
|
||||
for (int i = 0; i < Notes.VoiceCount; i++)
|
||||
{
|
||||
DuetPart1 = "Part 1";
|
||||
CBase.Log.LogError("Warning: Can't find #P1-tag for duets in \"" + Artist + " - " + Title + "\".");
|
||||
}
|
||||
if (DuetPart2 == "")
|
||||
{
|
||||
DuetPart2 = "Part 2";
|
||||
CBase.Log.LogError("Warning: Can't find #P2-tag for duets in \"" + Artist + " - " + Title + "\".");
|
||||
if (!Notes.VoiceNames.IsSet(i))
|
||||
CBase.Log.LogError("Warning: Can't find #P" + (i + 1) + "-tag for duets in \"" + Artist + " - " + Title + "\".");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,11 +90,8 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
public void SetMedley(int startBeat, int endBeat)
|
||||
{
|
||||
foreach (CSongNote note in _Notes)
|
||||
{
|
||||
if (note.StartBeat < startBeat || note.EndBeat > endBeat)
|
||||
note.NoteType = ENoteType.Freestyle;
|
||||
}
|
||||
foreach (CSongNote note in _Notes.Where(note => note.StartBeat < startBeat || note.EndBeat > endBeat))
|
||||
note.NoteType = ENoteType.Freestyle;
|
||||
|
||||
VisibleInTimeLine = FirstNoteBeat >= startBeat && LastNoteBeat <= endBeat;
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
<Reference Include="System.XML" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="IBasic.cs" />
|
||||
<Compile Include="Menu\CBackground.cs" />
|
||||
@@ -195,4 +196,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
Reference in new issue
Block a user