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