Merge branch 'develop' into develop_fk

This commit is contained in:
Flamefire committed 2013-04-30 19:42:53 +02:00
commit 5a12cb48f9
31 files changed
+239 -449

No files matched your search

+35 -64
View File
@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
@@ -266,7 +267,6 @@ namespace Vocaluxe.Base
MicConfig[p - 1] = new SMicConfig(0);
xmlReader.GetValue("//root/Record/MicConfig" + p + "/DeviceName", out MicConfig[p - 1].DeviceName, String.Empty);
xmlReader.GetValue("//root/Record/MicConfig" + p + "/DeviceDriver", out MicConfig[p - 1].DeviceDriver, String.Empty);
xmlReader.GetValue("//root/Record/MicConfig" + p + "/InputName", out MicConfig[p - 1].InputName, String.Empty);
xmlReader.TryGetIntValue("//root/Record/MicConfig" + p + "/Channel", ref MicConfig[p - 1].Channel);
}
@@ -514,13 +514,12 @@ namespace Vocaluxe.Base
for (int p = 1; p <= CSettings.MaxNumPlayer; p++)
{
if (MicConfig[p - 1].DeviceName != "" && MicConfig[p - 1].InputName != "" && MicConfig[p - 1].Channel > 0)
if (MicConfig[p - 1].DeviceName != "" && MicConfig[p - 1].Channel > 0)
{
writer.WriteStartElement("MicConfig" + p);
writer.WriteElementString("DeviceName", MicConfig[p - 1].DeviceName);
writer.WriteElementString("DeviceDriver", MicConfig[p - 1].DeviceDriver);
writer.WriteElementString("InputName", MicConfig[p - 1].InputName);
writer.WriteElementString("Channel", MicConfig[p - 1].Channel.ToString());
writer.WriteEndElement();
@@ -563,19 +562,11 @@ namespace Vocaluxe.Base
/// <returns></returns>
public static bool IsMicConfig()
{
SRecordDevice[] devices = CSound.RecordGetDevices();
ReadOnlyCollection<CRecordDevice> devices = CSound.RecordGetDevices();
if (devices == null)
return false;
for (int dev = 0; dev < devices.Length; dev++)
{
for (int inp = 0; inp < devices[dev].Inputs.Count; inp++)
{
if (devices[dev].Inputs[inp].PlayerChannel1 != 0 || devices[dev].Inputs[inp].PlayerChannel2 != 0)
return true;
}
}
return false;
return devices.Any(t => t.PlayerChannel1 != 0 || t.PlayerChannel2 != 0);
}
/// <summary>
@@ -585,19 +576,11 @@ namespace Vocaluxe.Base
/// <returns></returns>
public static bool IsMicConfig(int player)
{
SRecordDevice[] devices = CSound.RecordGetDevices();
ReadOnlyCollection<CRecordDevice> devices = CSound.RecordGetDevices();
if (devices == null)
return false;
for (int dev = 0; dev < devices.Length; dev++)
{
for (int inp = 0; inp < devices[dev].Inputs.Count; inp++)
{
if (devices[dev].Inputs[inp].PlayerChannel1 == player || devices[dev].Inputs[inp].PlayerChannel2 == player)
return true;
}
}
return false;
return devices.Any(t => t.PlayerChannel1 == player || t.PlayerChannel2 == player);
}
public static int GetMaxNumMics()
@@ -620,65 +603,53 @@ namespace Vocaluxe.Base
{
//Look for (usb-)mic
//SRecordDevice[] Devices = new SRecordDevice[CSound.RecordGetDevices().Length];
SRecordDevice[] devices = CSound.RecordGetDevices();
ReadOnlyCollection<CRecordDevice> devices = CSound.RecordGetDevices();
if (devices == null)
return false;
for (int dev = 0; dev < devices.Length; dev++)
foreach (CRecordDevice device in devices)
{
//Has Device some signal-names in name -> This could be a (usb-)mic
if (Regex.IsMatch(devices[dev].Name, "Usb|Wireless", RegexOptions.IgnoreCase))
if (Regex.IsMatch(device.Name, "Usb|Wireless", RegexOptions.IgnoreCase))
{
//Check if there are inputs.
if (devices[dev].Inputs.Count >= 1)
//Check if there is one or more channels
if (device.Channels >= 2)
{
//Check if there is one or more channels
if (devices[dev].Inputs[0].Channels >= 2)
{
//Set this device to player 1
MicConfig[0].DeviceName = devices[dev].Name;
MicConfig[0].DeviceDriver = devices[dev].Driver;
MicConfig[0].InputName = devices[dev].Inputs[0].Name;
MicConfig[0].Channel = 1;
//Set this device to player 2
MicConfig[1].DeviceName = devices[dev].Name;
MicConfig[1].DeviceDriver = devices[dev].Driver;
MicConfig[1].InputName = devices[dev].Inputs[0].Name;
MicConfig[1].Channel = 2;
//Set this device to player 1
MicConfig[0].DeviceName = device.Name;
MicConfig[0].DeviceDriver = device.Driver;
MicConfig[0].Channel = 1;
//Set this device to player 2
MicConfig[1].DeviceName = device.Name;
MicConfig[1].DeviceDriver = device.Driver;
MicConfig[1].Channel = 2;
return true;
}
return true;
}
}
}
//If no usb-mics found -> Look for Devices with "mic" or "mik"
for (int dev = 0; dev < devices.Length; dev++)
foreach (CRecordDevice device in devices)
{
//Has Device some signal-names in name -> This could be a mic
if (Regex.IsMatch(devices[dev].Name, "Mic|Mik", RegexOptions.IgnoreCase))
if (Regex.IsMatch(device.Name, "Mic|Mik", RegexOptions.IgnoreCase))
{
//Check if there are inputs.
if (devices[dev].Inputs.Count >= 1)
//Check if there is one or more channels
if (device.Channels >= 1)
{
//Check if there is one or more channels
if (devices[dev].Inputs[0].Channels >= 1)
//Set this device to player 1
MicConfig[0].DeviceName = device.Name;
MicConfig[0].DeviceDriver = device.Driver;
MicConfig[0].Channel = 1;
if (device.Channels >= 2)
{
//Set this device to player 1
MicConfig[0].DeviceName = devices[dev].Name;
MicConfig[0].DeviceDriver = devices[dev].Driver;
MicConfig[0].InputName = devices[dev].Inputs[0].Name;
MicConfig[0].Channel = 1;
//Set this device to player 2
MicConfig[1].DeviceName = device.Name;
MicConfig[1].DeviceDriver = device.Driver;
MicConfig[1].Channel = 2;
if (devices[dev].Inputs[0].Channels >= 2)
{
//Set this device to player 2
MicConfig[1].DeviceName = devices[dev].Name;
MicConfig[1].DeviceDriver = devices[dev].Driver;
MicConfig[1].InputName = devices[dev].Inputs[0].Name;
MicConfig[1].Channel = 2;
return true;
}
return true;
}
}
}
@@ -23,56 +23,56 @@ using VocaluxeLib.Menu;
namespace Vocaluxe.Base
{
static class CInput
static class CController
{
private static IInput _Input;
private static IController _Controller;
public static void Init()
{
_Input = new CWiiMote();
_Controller = new CWiiMote();
_Input.Init();
_Controller.Init();
}
public static void Close()
{
_Input.Close();
_Input = null;
_Controller.Close();
_Controller = null;
}
public static void Connect()
{
_Input.Connect();
_Controller.Connect();
}
public static void Disconnect()
{
_Input.Disconnect();
_Controller.Disconnect();
}
public static bool IsConnected()
{
return _Input.IsConnected();
return _Controller.IsConnected();
}
public static void Update()
{
_Input.Update();
_Controller.Update();
}
public static bool PollKeyEvent(ref SKeyEvent keyEvent)
{
return _Input.PollKeyEvent(ref keyEvent);
return _Controller.PollKeyEvent(ref keyEvent);
}
public static bool PollMouseEvent(ref SMouseEvent mouseEvent)
{
return _Input.PollMouseEvent(ref mouseEvent);
return _Controller.PollMouseEvent(ref mouseEvent);
}
public static void SetRumble(float duration)
{
_Input.SetRumble(duration);
_Controller.SetRumble(duration);
}
}
}
+5 -11
View File
@@ -708,17 +708,9 @@ namespace Vocaluxe.Base
}
//This is a USDX 1.01 DB
if (!dateExists)
{
command.CommandText =
"INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', '0', '0', '0', Difficulty from US_Scores";
}
else
{
// This is a CMD 1.01 DB
command.CommandText =
"INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', Date, '0', '0', Difficulty from US_Scores";
}
command.CommandText = !dateExists
? "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', '0', '0', '0', Difficulty from US_Scores"
: "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, Difficulty) SELECT SongID, Player, Score, '0', Date, '0', '0', Difficulty from US_Scores";
command.ExecuteNonQuery();
command.CommandText = "INSERT INTO Songs SELECT ID, Artist, Title, TimesPlayed from US_Songs";
@@ -763,7 +755,9 @@ namespace Vocaluxe.Base
stmt = new Sqlite3.Vdbe();
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression
if (!dateExists)
// ReSharper restore ConvertIfStatementToConditionalTernaryExpression
res = Sqlite3.sqlite3_prepare_v2(oldDB, "SELECT id, PlayerName FROM Scores", -1, ref stmt, 0);
else
res = Sqlite3.sqlite3_prepare_v2(oldDB, "SELECT id, PlayerName, Date FROM Scores", -1, ref stmt, 0);
+5 -5
View File
@@ -320,7 +320,7 @@ namespace Vocaluxe.Base
CVideo.Update();
CSound.Update();
CBackgroundMusic.Update();
CInput.Update();
CController.Update();
if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC && _CurrentScreen != EScreens.ScreenSing)
CSongs.LoadCover();
@@ -512,7 +512,7 @@ namespace Vocaluxe.Base
bool resume = true;
bool eventsAvailable;
bool inputEventsAvailable = CInput.PollKeyEvent(ref inputKeyEvent);
bool inputEventsAvailable = CController.PollKeyEvent(ref inputKeyEvent);
while ((eventsAvailable = keys.PollEvent(ref keyEvent)) || inputEventsAvailable)
{
@@ -617,10 +617,10 @@ namespace Vocaluxe.Base
}
if (!eventsAvailable)
inputEventsAvailable = CInput.PollKeyEvent(ref inputKeyEvent);
inputEventsAvailable = CController.PollKeyEvent(ref inputKeyEvent);
}
inputEventsAvailable = CInput.PollMouseEvent(ref inputMouseEvent);
inputEventsAvailable = CController.PollMouseEvent(ref inputMouseEvent);
while ((eventsAvailable = mouse.PollEvent(ref mouseEvent)) || inputEventsAvailable)
{
@@ -678,7 +678,7 @@ namespace Vocaluxe.Base
resume &= _Screens[(int)_CurrentScreen].HandleMouse(mouseEvent);
if (!eventsAvailable)
inputEventsAvailable = CInput.PollMouseEvent(ref inputMouseEvent);
inputEventsAvailable = CController.PollMouseEvent(ref inputMouseEvent);
}
return resume;
}
+2 -6
View File
@@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using VocaluxeLib.Menu;
@@ -168,12 +169,7 @@ namespace Vocaluxe.Base
List<string> files = new List<string>();
files.AddRange(CHelper.ListFiles(path, "*.xml", true, true));
foreach (string file in files)
{
if (!_LoadPartyLanguageFile(partyModeID, file))
return false;
}
return true;
return files.All(file => _LoadPartyLanguageFile(partyModeID, file));
}
private static bool _LoadLanguageEntries(CXMLReader xmlReader, out Dictionary<string, string> texts)
+4 -4
View File
@@ -46,13 +46,13 @@ namespace Vocaluxe.Base
private static readonly ISound _Sound = new CBsound();
private static readonly ICover _Cover = new CBcover();
private static readonly IDataBase _DataBase = new CBdataBase();
private static readonly IInputs _Input = new CBinputs();
private static readonly IControllers _Controller = new CBcontrollers();
private static readonly IPlaylist _Playlist = new CBplaylist();
public static void Init()
{
CBase.Assign(_Config, _Settings, _Theme, _Log, _BackgroundMusic, _Draw, _Graphics, _Fonts, _Language,
_Game, _Profiles, _Record, _Songs, _Video, _Sound, _Cover, _DataBase, _Input, _Playlist);
_Game, _Profiles, _Record, _Songs, _Video, _Sound, _Cover, _DataBase, _Controller, _Playlist);
}
}
@@ -770,11 +770,11 @@ namespace Vocaluxe.Base
}
}
class CBinputs : IInputs
class CBcontrollers : IControllers
{
public void SetRumble(float duration)
{
CInput.SetRumble(duration);
CController.SetRumble(duration);
}
}
+15 -15
View File
@@ -67,17 +67,17 @@ namespace Vocaluxe.Base
{
CCategory lastCategory = null;
CCategory notLetterCat = null;
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
foreach (CSongPointer songPointer in CSongs.Sorter.SortedSongs)
{
Char firstLetter = Char.ToUpper(CSongs.Sorter.SortedSongs[i].SortString.Normalize(NormalizationForm.FormD)[0]);
Char firstLetter = Char.ToUpper(songPointer.SortString.Normalize(NormalizationForm.FormD)[0]);
if (Char.IsLetter(firstLetter))
{
if (lastCategory == null || CSongs.Sorter.SortedSongs[i].SortString != lastCategory.Name)
if (lastCategory == null || songPointer.SortString != lastCategory.Name)
{
lastCategory = new CCategory(CSongs.Sorter.SortedSongs[i].SortString);
lastCategory = new CCategory(songPointer.SortString);
_Categories.Add(lastCategory);
}
lastCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]);
lastCategory.Songs.Add(songPointer);
}
else
{
@@ -86,7 +86,7 @@ namespace Vocaluxe.Base
notLetterCat = new CCategory("#");
_Categories.Add(notLetterCat);
}
notLetterCat.Songs.Add(CSongs.Sorter.SortedSongs[i]);
notLetterCat.Songs.Add(songPointer);
}
}
}
@@ -95,16 +95,16 @@ namespace Vocaluxe.Base
{
CCategory lastCategory = null;
CCategory noCategory = null;
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
foreach (CSongPointer songPointer in CSongs.Sorter.SortedSongs)
{
if (CSongs.Sorter.SortedSongs[i].SortString != "")
if (songPointer.SortString != "")
{
if (lastCategory == null || CSongs.Sorter.SortedSongs[i].SortString != lastCategory.Name)
if (lastCategory == null || songPointer.SortString != lastCategory.Name)
{
lastCategory = new CCategory(CSongs.Sorter.SortedSongs[i].SortString);
lastCategory = new CCategory(songPointer.SortString);
_Categories.Add(lastCategory);
}
lastCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]);
lastCategory.Songs.Add(songPointer);
}
else
{
@@ -113,7 +113,7 @@ namespace Vocaluxe.Base
noCategory = new CCategory(noCategoryName);
_Categories.Add(noCategory);
}
noCategory.Songs.Add(CSongs.Sorter.SortedSongs[i]);
noCategory.Songs.Add(songPointer);
}
}
}
@@ -149,13 +149,13 @@ namespace Vocaluxe.Base
{
if (sorting == ESongSorting.TR_CONFIG_DECADE)
{
for (int i = 0; i < CSongs.Sorter.SortedSongs.Length; i++)
foreach (CSongPointer songPointer in CSongs.Sorter.SortedSongs)
{
string year = CSongs.Sorter.SortedSongs[i].SortString;
string year = songPointer.SortString;
if (year != "")
{
year = year.Substring(0, 3);
CSongs.Sorter.SortedSongs[i].SortString = year + "0 - " + year + "9";
songPointer.SortString = year + "0 - " + year + "9";
}
}
}
+8 -17
View File
@@ -18,6 +18,7 @@
#endregion
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using Vocaluxe.Lib.Sound;
@@ -226,9 +227,7 @@ namespace Vocaluxe.Base
public static bool RecordStart()
{
SRecordDevice[] devices = RecordGetDevices();
return _Record.Start(devices);
return _Record.Start();
}
public static bool RecordStop()
@@ -276,23 +275,16 @@ namespace Vocaluxe.Base
return _Record.ToneWeigth(player);
}
public static SRecordDevice[] RecordGetDevices()
public static ReadOnlyCollection<CRecordDevice> RecordGetDevices()
{
SRecordDevice[] devices = _Record.RecordDevices();
ReadOnlyCollection<CRecordDevice> devices = _Record.RecordDevices();
if (devices != null)
{
for (int dev = 0; dev < devices.Length; dev++)
foreach (CRecordDevice device in devices)
{
for (int inp = 0; inp < devices[dev].Inputs.Count; inp++)
{
SInput input = devices[dev].Inputs[inp];
input.PlayerChannel1 = _GetPlayerFromMicConfig(devices[dev].Name, devices[dev].Driver, input.Name, 1);
input.PlayerChannel2 = _GetPlayerFromMicConfig(devices[dev].Name, devices[dev].Driver, input.Name, 2);
devices[dev].Inputs[inp] = input;
}
device.PlayerChannel1 = _GetPlayerFromMicConfig(device.Name, device.Driver, 1);
device.PlayerChannel2 = _GetPlayerFromMicConfig(device.Name, device.Driver, 2);
}
return devices;
}
@@ -300,14 +292,13 @@ namespace Vocaluxe.Base
return null;
}
private static int _GetPlayerFromMicConfig(string device, string devicedriver, string input, int channel)
private static int _GetPlayerFromMicConfig(string device, string devicedriver, int channel)
{
for (int p = 0; p < CSettings.MaxNumPlayer; p++)
{
if (CConfig.MicConfig[p].Channel != 0 &&
CConfig.MicConfig[p].DeviceName == device &&
CConfig.MicConfig[p].DeviceDriver == devicedriver &&
CConfig.MicConfig[p].InputName == input &&
CConfig.MicConfig[p].Channel == channel)
return p + 1;
}
-1
View File
@@ -20,7 +20,6 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Windows.Forms;
using VocaluxeLib.Menu;
-3
View File
@@ -17,10 +17,7 @@
// */
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
@@ -32,7 +32,7 @@ namespace Vocaluxe.Lib.Input
ScrollUp
}
interface IInput
interface IController
{
void Init();
void Close();
+1 -1
View File
@@ -27,7 +27,7 @@ using VocaluxeLib.Menu;
namespace Vocaluxe.Lib.Input.WiiMote
{
class CWiiMote : IInput, IDisposable
class CWiiMote : IController, IDisposable
{
private CWiiMoteLib _WiiMote;
+25 -36
View File
@@ -17,6 +17,7 @@
// */
#endregion
using System.Collections.ObjectModel;
using SlimDX.DirectSound;
using SlimDX.Multimedia;
using System;
@@ -29,8 +30,7 @@ namespace Vocaluxe.Lib.Sound
class CDirectSoundRecord : IRecord
{
private bool _Initialized;
private List<SRecordDevice> _Devices;
private SRecordDevice[] _DeviceConfig;
private List<CRecordDevice> _Devices;
private List<CSoundCardSource> _Sources;
private readonly CBuffer[] _Buffer;
@@ -47,7 +47,7 @@ namespace Vocaluxe.Lib.Sound
public bool Init()
{
DeviceCollection devices = DirectSoundCapture.GetDevices();
_Devices = new List<SRecordDevice>();
_Devices = new List<CRecordDevice>();
_Sources = new List<CSoundCardSource>();
int id = 0;
@@ -55,21 +55,17 @@ namespace Vocaluxe.Lib.Sound
{
using (DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid))
{
SRecordDevice device = new SRecordDevice {Driver = dev.DriverGuid.ToString(), ID = id, Name = dev.Description, Inputs = new List<SInput>()};
CRecordDevice device = new CRecordDevice {Driver = dev.DriverGuid.ToString(), ID = id, Name = dev.Description, Channels = ds.Capabilities.Channels};
SInput inp = new SInput {Name = "Default", Channels = ds.Capabilities.Channels};
if (device.Channels > 2)
device.Channels = 2; //more are not supported in vocaluxe
if (inp.Channels > 2)
inp.Channels = 2; //more are not supported in vocaluxe
device.Inputs.Add(inp);
_Devices.Add(device);
id++;
}
}
_DeviceConfig = _Devices.ToArray();
_Initialized = true;
return true;
@@ -85,7 +81,7 @@ namespace Vocaluxe.Lib.Sound
//System.IO.File.WriteAllBytes("test0.raw", _Buffer[0].Buffer);
}
public bool Start(SRecordDevice[] deviceConfig)
public bool Start()
{
if (!_Initialized)
return false;
@@ -93,21 +89,16 @@ namespace Vocaluxe.Lib.Sound
foreach (CBuffer buffer in _Buffer)
buffer.Reset();
_DeviceConfig = deviceConfig;
bool[] active = new bool[deviceConfig.Length];
Guid[] guid = new Guid[deviceConfig.Length];
short[] channels = new short[deviceConfig.Length];
for (int dev = 0; dev < deviceConfig.Length; dev++)
bool[] active = new bool[_Devices.Count];
Guid[] guid = new Guid[_Devices.Count];
short[] channels = new short[_Devices.Count];
for (int dev = 0; dev < _Devices.Count; dev++)
{
active[dev] = false;
for (int inp = 0; inp < deviceConfig[dev].Inputs.Count; inp++)
{
if (deviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 ||
deviceConfig[dev].Inputs[inp].PlayerChannel2 > 0)
active[dev] = true;
guid[dev] = new Guid(deviceConfig[dev].Driver);
channels[dev] = (short)deviceConfig[dev].Inputs[0].Channels;
}
if (_Devices[dev].PlayerChannel1 > 0 || _Devices[dev].PlayerChannel2 > 0)
active[dev] = true;
guid[dev] = new Guid(_Devices[dev].Driver);
channels[dev] = (short)_Devices[dev].Channels;
}
for (int i = 0; i < _Devices.Count; i++)
@@ -121,8 +112,6 @@ namespace Vocaluxe.Lib.Sound
_Sources.Add(source);
}
}
_DeviceConfig = deviceConfig;
return true;
}
@@ -189,7 +178,7 @@ namespace Vocaluxe.Lib.Sound
return _Buffer[player].ToneValid;
}
public SRecordDevice[] RecordDevices()
public ReadOnlyCollection<CRecordDevice> RecordDevices()
{
if (!_Initialized)
return null;
@@ -197,7 +186,7 @@ namespace Vocaluxe.Lib.Sound
if (_Devices.Count == 0)
return null;
return _Devices.ToArray();
return _Devices.AsReadOnly();
}
public int NumHalfTones(int player)
@@ -232,21 +221,21 @@ namespace Vocaluxe.Lib.Sound
rightBuffer[i] = e.Data[i * 2 - (i % 2) + 2];
}
for (int i = 0; i < _DeviceConfig.Length; i++)
foreach (CRecordDevice device in _Devices)
{
if (_DeviceConfig[i].Driver == e.Guid.ToString())
if (device.Driver == e.Guid.ToString())
{
if (_DeviceConfig[i].Inputs[0].PlayerChannel1 > 0)
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer);
if (device.PlayerChannel1 > 0)
_Buffer[device.PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer);
if (_DeviceConfig[i].Inputs[0].PlayerChannel2 > 0)
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer);
if (device.PlayerChannel2 > 0)
_Buffer[device.PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer);
}
}
}
}
public class CSampleDataEventArgs : EventArgs
private class CSampleDataEventArgs : EventArgs
{
public CSampleDataEventArgs(byte[] data, Guid guid)
{
@@ -258,7 +247,7 @@ namespace Vocaluxe.Lib.Sound
public Guid Guid { get; private set; }
}
public class CSoundCardSource : IDisposable
private class CSoundCardSource : IDisposable
{
private volatile bool _Running;
private readonly int _BufferSize;
+23 -37
View File
@@ -17,6 +17,7 @@
// */
#endregion
using System.Collections.ObjectModel;
using System.Threading;
using System;
using System.Collections.Generic;
@@ -29,8 +30,7 @@ namespace Vocaluxe.Lib.Sound
class CPortAudioRecord : IRecord
{
private bool _Initialized;
private List<SRecordDevice> _Devices;
private SRecordDevice[] _DeviceConfig;
private List<CRecordDevice> _Devices;
private CPortAudio.PaStreamCallbackDelegate _MyRecProc;
private IntPtr[] _RecHandle;
@@ -39,7 +39,7 @@ namespace Vocaluxe.Lib.Sound
public CPortAudioRecord()
{
_DeviceConfig = null;
_Devices = null;
_Buffer = new CBuffer[CSettings.MaxNumPlayer];
for (int i = 0; i < _Buffer.Length; i++)
@@ -54,7 +54,7 @@ namespace Vocaluxe.Lib.Sound
/// <returns>true if success</returns>
public bool Init()
{
_Devices = new List<SRecordDevice>();
_Devices = new List<CRecordDevice>();
try
{
@@ -73,22 +73,17 @@ namespace Vocaluxe.Lib.Sound
CPortAudio.SPaDeviceInfo info = CPortAudio.PaGetDeviceInfo(i);
if (info.HostApi == hostAPI && info.MaxInputChannels > 0)
{
SRecordDevice dev = new SRecordDevice {ID = i, Name = info.Name, Driver = info.Name + i, Inputs = new List<SInput>()};
CRecordDevice dev = new CRecordDevice {ID = i, Name = info.Name, Driver = info.Name + i, Channels = info.MaxInputChannels};
SInput inp = new SInput {Name = "Default", Channels = info.MaxInputChannels};
if (dev.Channels > 2)
dev.Channels = 2; //more are not supported in vocaluxe
if (inp.Channels > 2)
inp.Channels = 2; //more are not supported in vocaluxe
dev.Inputs.Add(inp);
_Devices.Add(dev);
}
}
_RecHandle = new IntPtr[_Devices.Count];
_MyRecProc = MyPaStreamCallback;
_DeviceConfig = _Devices.ToArray();
_MyRecProc = _MyPaStreamCallback;
}
catch (Exception e)
{
@@ -103,16 +98,12 @@ namespace Vocaluxe.Lib.Sound
/// <summary>
/// Start Voice Capturing
/// </summary>
/// <param name="deviceConfig"></param>
/// <returns></returns>
public bool Start(SRecordDevice[] deviceConfig)
public bool Start()
{
if (!_Initialized)
return false;
if (deviceConfig == null)
return false;
if (_RecHandle == null || _RecHandle.Length == 0)
return false;
@@ -132,17 +123,12 @@ namespace Vocaluxe.Lib.Sound
for (int i = 0; i < _RecHandle.Length; i++)
_RecHandle[i] = IntPtr.Zero;
_DeviceConfig = deviceConfig;
bool[] active = new bool[deviceConfig.Length];
for (int dev = 0; dev < deviceConfig.Length; dev++)
bool[] active = new bool[_Devices.Count];
for (int dev = 0; dev < _Devices.Count; dev++)
{
active[dev] = false;
for (int inp = 0; inp < deviceConfig[dev].Inputs.Count; inp++)
{
if (deviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 ||
deviceConfig[dev].Inputs[inp].PlayerChannel2 > 0)
active[dev] = true;
}
if (_Devices[dev].PlayerChannel1 > 0 || _Devices[dev].PlayerChannel2 > 0)
active[dev] = true;
}
for (int i = 0; i < _RecHandle.Length; i++)
@@ -151,10 +137,10 @@ namespace Vocaluxe.Lib.Sound
{
CPortAudio.SPaStreamParameters inputParams = new CPortAudio.SPaStreamParameters
{
ChannelCount = _DeviceConfig[i].Inputs[0].Channels,
Device = _DeviceConfig[i].ID,
ChannelCount = _Devices[i].Channels,
Device = _Devices[i].ID,
SampleFormat = CPortAudio.EPaSampleFormat.PaInt16,
SuggestedLatency = CPortAudio.PaGetDeviceInfo(_DeviceConfig[i].ID).DefaultLowInputLatency
SuggestedLatency = CPortAudio.PaGetDeviceInfo(_Devices[i].ID).DefaultLowInputLatency
};
if (_ErrorCheck("OpenStream (rec)", CPortAudio.Pa_OpenStream(
@@ -273,7 +259,7 @@ namespace Vocaluxe.Lib.Sound
return _Buffer[player].ToneWeigth;
}
public SRecordDevice[] RecordDevices()
public ReadOnlyCollection<CRecordDevice> RecordDevices()
{
if (!_Initialized)
return null;
@@ -281,10 +267,10 @@ namespace Vocaluxe.Lib.Sound
if (_Devices.Count == 0)
return null;
return _Devices.ToArray();
return _Devices.AsReadOnly();
}
public CPortAudio.EPaStreamCallbackResult MyPaStreamCallback(
private CPortAudio.EPaStreamCallbackResult _MyPaStreamCallback(
IntPtr input,
IntPtr output,
uint frameCount,
@@ -315,11 +301,11 @@ namespace Vocaluxe.Lib.Sound
{
if (new IntPtr(i) == userData)
{
if (_DeviceConfig[i].Inputs[0].PlayerChannel1 > 0)
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer);
if (_Devices[i].PlayerChannel1 > 0)
_Buffer[_Devices[i].PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer);
if (_DeviceConfig[i].Inputs[0].PlayerChannel2 > 0)
_Buffer[_DeviceConfig[i].Inputs[0].PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer);
if (_Devices[i].PlayerChannel2 > 0)
_Buffer[_Devices[i].PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer);
break;
}
+4 -12
View File
@@ -18,23 +18,17 @@
#endregion
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Vocaluxe.Lib.Sound
{
struct SRecordDevice
class CRecordDevice
{
public int ID;
public string Name;
public string Driver;
public List<SInput> Inputs;
}
struct SInput
{
public string Name;
public int Channels;
public int PlayerChannel1;
public int PlayerChannel2;
}
@@ -43,7 +37,6 @@ namespace Vocaluxe.Lib.Sound
{
public string DeviceName;
public string DeviceDriver;
public string InputName;
public int Channel;
// ReSharper disable UnusedParameter.Local
@@ -52,7 +45,6 @@ namespace Vocaluxe.Lib.Sound
{
DeviceName = String.Empty;
DeviceDriver = String.Empty;
InputName = String.Empty;
Channel = 0;
}
}
@@ -62,7 +54,7 @@ namespace Vocaluxe.Lib.Sound
bool Init();
void CloseAll();
bool Start(SRecordDevice[] deviceConfig);
bool Start();
bool Stop();
void AnalyzeBuffer(int player);
@@ -74,6 +66,6 @@ namespace Vocaluxe.Lib.Sound
int NumHalfTones(int player);
float[] ToneWeigth(int player);
SRecordDevice[] RecordDevices();
ReadOnlyCollection<CRecordDevice> RecordDevices();
}
}
+3 -3
View File
@@ -185,8 +185,8 @@ namespace Vocaluxe
// Init Input
CLog.StartBenchmark(0, "Init Input");
CInput.Init();
CInput.Connect();
CController.Init();
CController.Connect();
CLog.StopBenchmark(0, "Init Input");
// Init Game;
@@ -220,7 +220,7 @@ namespace Vocaluxe
try
{
CLog.CloseAll();
CInput.Close();
CController.Close();
CSound.RecordCloseAll();
CSound.CloseAllStreams();
CVideo.VdCloseAll();
+41 -90
View File
@@ -18,6 +18,7 @@
#endregion
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows.Forms;
using Vocaluxe.Base;
@@ -37,12 +38,11 @@ namespace Vocaluxe.Screens
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
{
get { return 2; }
get { return 3; }
}
private const float _MaxDelayTime = 1f;
private const string _SelectSlideRecordDevices = "SelectSlideRecordDevices";
private const string _SelectSlideRecordInputs = "SelectSlideRecordInputs";
private const string _SelectSlideRecordChannel1 = "SelectSlideRecordChannel1";
private const string _SelectSlideRecordChannel2 = "SelectSlideRecordChannel2";
@@ -63,9 +63,8 @@ namespace Vocaluxe.Screens
private readonly string[] _StaticEnergyChannel = new string[] {"StaticEnergyChannel1", "StaticEnergyChannel2"};
private float[] _ChannelEnergy;
private SRecordDevice[] _Devices;
private ReadOnlyCollection<CRecordDevice> _Devices;
private int _DeviceNr;
private int _InputNr;
private SDelayTest[] _DelayTest;
private bool _DelayTestRunning;
@@ -81,7 +80,7 @@ namespace Vocaluxe.Screens
_ThemeTexts = new string[] {_TextWarning, _TextDelayChannel1, _TextDelayChannel2};
_ThemeButtons = new string[] {_ButtonExit, _ButtonDelayTest};
_ThemeSelectSlides = new string[] {_SelectSlideRecordDevices, _SelectSlideRecordInputs, _SelectSlideRecordChannel1, _SelectSlideRecordChannel2, _SelectSlideDelay};
_ThemeSelectSlides = new string[] {_SelectSlideRecordDevices, _SelectSlideRecordChannel1, _SelectSlideRecordChannel2, _SelectSlideDelay};
_ThemeEqualizers = new string[] {_EqualizerChannel1, _EqualizerChannel2};
}
@@ -160,9 +159,6 @@ namespace Vocaluxe.Screens
if (_SelectSlides[_SelectSlideRecordDevices].Selected)
_OnDeviceEvent();
if (_SelectSlides[_SelectSlideRecordInputs].Selected)
_OnInputEvent();
if (_SelectSlides[_SelectSlideRecordChannel1].Selected ||
_SelectSlides[_SelectSlideRecordChannel2].Selected)
_SetMicConfig();
@@ -175,9 +171,6 @@ namespace Vocaluxe.Screens
if (_SelectSlides[_SelectSlideRecordDevices].Selected)
_OnDeviceEvent();
if (_SelectSlides[_SelectSlideRecordInputs].Selected)
_OnInputEvent();
if (_SelectSlides[_SelectSlideRecordChannel1].Selected ||
_SelectSlides[_SelectSlideRecordChannel2].Selected)
_SetMicConfig();
@@ -205,9 +198,6 @@ namespace Vocaluxe.Screens
if (_SelectSlides[_SelectSlideRecordDevices].Selected)
_OnDeviceEvent();
if (_SelectSlides[_SelectSlideRecordInputs].Selected)
_OnInputEvent();
if (_SelectSlides[_SelectSlideRecordChannel1].Selected ||
_SelectSlides[_SelectSlideRecordChannel2].Selected)
_SetMicConfig();
@@ -311,28 +301,22 @@ namespace Vocaluxe.Screens
base.OnShow();
_SelectSlides[_SelectSlideRecordDevices].Clear();
_SelectSlides[_SelectSlideRecordInputs].Clear();
for (int i = 0; i < _ChannelEnergy.Length; i++)
_ChannelEnergy[i] = 0f;
_DeviceNr = -1;
_InputNr = -1;
_Devices = CSound.RecordGetDevices();
if (_Devices != null)
{
_DeviceNr = 0;
_InputNr = 0;
_GetFirstConfiguredRecordDevice(ref _DeviceNr, ref _InputNr);
_GetFirstConfiguredRecordDevice(ref _DeviceNr);
for (int dev = 0; dev < _Devices.Length; dev++)
_SelectSlides[_SelectSlideRecordDevices].AddValue(_Devices[dev].Name);
foreach (CRecordDevice device in _Devices)
_SelectSlides[_SelectSlideRecordDevices].AddValue(device.Name);
_SelectSlides[_SelectSlideRecordDevices].Selection = _DeviceNr;
for (int inp = 0; inp < _Devices[0].Inputs.Count; inp++)
_SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[0].Inputs[inp].Name);
_SelectSlides[_SelectSlideRecordInputs].Selection = _InputNr;
_UpdateChannels();
}
@@ -416,24 +400,7 @@ namespace Vocaluxe.Screens
{
if (_SelectSlides[_SelectSlideRecordDevices].Selection != _DeviceNr)
{
_SelectSlides[_SelectSlideRecordInputs].Clear();
_DeviceNr = _SelectSlides[_SelectSlideRecordDevices].Selection;
_InputNr = 0;
for (int inp = 0; inp < _Devices[_DeviceNr].Inputs.Count; inp++)
_SelectSlides[_SelectSlideRecordInputs].AddValue(_Devices[_DeviceNr].Inputs[inp].Name);
_InputNr = 0;
_SelectSlides[_SelectSlideRecordInputs].Selection = 0;
_UpdateChannels();
}
}
private void _OnInputEvent()
{
if (_SelectSlides[_SelectSlideRecordInputs].Selection != _InputNr)
{
_InputNr = _SelectSlides[_SelectSlideRecordInputs].Selection;
_UpdateChannels();
}
}
@@ -457,25 +424,20 @@ namespace Vocaluxe.Screens
for (int p = 0; p < CSettings.MaxNumPlayer; p++)
CConfig.MicConfig[p].Channel = 0;
for (int dev = 0; dev < _Devices.Length; dev++)
foreach (CRecordDevice device in _Devices)
{
for (int inp = 0; inp < _Devices[dev].Inputs.Count; inp++)
if (device.PlayerChannel1 > 0)
{
if (_Devices[dev].Inputs[inp].PlayerChannel1 > 0)
{
CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel1 - 1].Channel = 1;
CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel1 - 1].DeviceName = _Devices[dev].Name;
CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel1 - 1].DeviceDriver = _Devices[dev].Driver;
CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel1 - 1].InputName = _Devices[dev].Inputs[inp].Name;
}
CConfig.MicConfig[device.PlayerChannel1 - 1].Channel = 1;
CConfig.MicConfig[device.PlayerChannel1 - 1].DeviceName = device.Name;
CConfig.MicConfig[device.PlayerChannel1 - 1].DeviceDriver = device.Driver;
}
if (_Devices[dev].Inputs[inp].PlayerChannel2 > 0)
{
CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel2 - 1].Channel = 2;
CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel2 - 1].DeviceName = _Devices[dev].Name;
CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel2 - 1].DeviceDriver = _Devices[dev].Driver;
CConfig.MicConfig[_Devices[dev].Inputs[inp].PlayerChannel2 - 1].InputName = _Devices[dev].Inputs[inp].Name;
}
if (device.PlayerChannel2 > 0)
{
CConfig.MicConfig[device.PlayerChannel2 - 1].Channel = 2;
CConfig.MicConfig[device.PlayerChannel2 - 1].DeviceName = device.Name;
CConfig.MicConfig[device.PlayerChannel2 - 1].DeviceDriver = device.Driver;
}
}
CConfig.SaveConfig();
@@ -487,16 +449,15 @@ namespace Vocaluxe.Screens
{
if (_DeviceNr < 0)
return;
SInput input = _Devices[_DeviceNr].Inputs[_InputNr];
input.PlayerChannel1 = _SelectSlides[_SelectSlideRecordChannel1].Selection;
input.PlayerChannel2 = _SelectSlides[_SelectSlideRecordChannel2].Selection;
_Devices[_DeviceNr].Inputs[_InputNr] = input;
CRecordDevice device = _Devices[_DeviceNr];
device.PlayerChannel1 = _SelectSlides[_SelectSlideRecordChannel1].Selection;
device.PlayerChannel2 = _SelectSlides[_SelectSlideRecordChannel2].Selection;
}
private void _UpdateChannels()
{
_SelectSlides[_SelectSlideRecordChannel1].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel1;
_SelectSlides[_SelectSlideRecordChannel2].Selection = _Devices[_DeviceNr].Inputs[_InputNr].PlayerChannel2;
_SelectSlides[_SelectSlideRecordChannel1].Selection = _Devices[_DeviceNr].PlayerChannel1;
_SelectSlides[_SelectSlideRecordChannel2].Selection = _Devices[_DeviceNr].PlayerChannel2;
_SaveMicConfig();
}
@@ -510,25 +471,22 @@ namespace Vocaluxe.Screens
if (_Devices == null)
return true;
for (int dev = 0; dev < _Devices.Length; dev++)
foreach (CRecordDevice device in _Devices)
{
for (int inp = 0; inp < _Devices[dev].Inputs.Count; inp++)
if (device.PlayerChannel1 > 0)
{
if (_Devices[dev].Inputs[inp].PlayerChannel1 > 0)
{
if (isSet[_Devices[dev].Inputs[inp].PlayerChannel1 - 1])
return false;
if (isSet[device.PlayerChannel1 - 1])
return false;
isSet[_Devices[dev].Inputs[inp].PlayerChannel1 - 1] = true;
}
isSet[device.PlayerChannel1 - 1] = true;
}
if (_Devices[dev].Inputs[inp].PlayerChannel2 > 0)
{
if (isSet[_Devices[dev].Inputs[inp].PlayerChannel2 - 1])
return false;
if (device.PlayerChannel2 > 0)
{
if (isSet[device.PlayerChannel2 - 1])
return false;
isSet[_Devices[dev].Inputs[inp].PlayerChannel2 - 1] = true;
}
isSet[device.PlayerChannel2 - 1] = true;
}
}
return true;
@@ -545,7 +503,7 @@ namespace Vocaluxe.Screens
_DelayTestRunning = true;
}
private void _GetFirstConfiguredRecordDevice(ref int device, ref int input)
private void _GetFirstConfiguredRecordDevice(ref int device)
{
if (_Devices == null)
return;
@@ -553,22 +511,15 @@ namespace Vocaluxe.Screens
if (CConfig.MicConfig == null)
return;
for (int i = 0; i < _Devices.Length; i++)
if (CConfig.MicConfig[0].Channel <= 0)
return;
for (int i = 0; i < _Devices.Count; i++)
{
if (_Devices[i].Name == CConfig.MicConfig[0].DeviceName && _Devices[i].Driver == CConfig.MicConfig[0].DeviceDriver)
{
for (int j = 0; j < _Devices[i].Inputs.Count; j++)
{
if (_Devices[i].Inputs[j].Name == CConfig.MicConfig[0].InputName)
{
if (CConfig.MicConfig[0].Channel > 0)
{
device = i;
input = j;
return;
}
}
}
device = i;
return;
}
}
}
-1
View File
@@ -17,7 +17,6 @@
// */
#endregion
using System;
using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Base.Font;
+12 -2
View File
@@ -177,6 +177,7 @@ namespace Vocaluxe.Screens
if (!_PartyModeInfos[index].Playable)
{
_Buttons[_ButtonStart].Visible = false;
_Texts[_TextError].Text = "TR_SCREENPARTY_ERROR";
_Texts[_TextError].Visible = true;
}
else
@@ -193,10 +194,19 @@ namespace Vocaluxe.Screens
int index = _SelectSlides[_SelectSlideModes].Selection;
if (index >= _PartyModeInfos.Count)
return;
{
_Buttons[_ButtonStart].Visible = false;
_Texts[_TextError].Text = "TR_SCREENPARTY_ERROR";
_Texts[_TextError].Visible = true;
}
if (CConfig.GetMaxNumMics() == 0)
return; //TODO: Add message!
{
_Buttons[_ButtonStart].Visible = false;
_Texts[_TextError].Text = CLanguage.Translate("TR_SCREENNAMES_WARNING_MICS_PL").Replace("%v", "");
_Texts[_TextError].Visible = true;
return;
}
CParty.SetPartyMode(_PartyModeInfos[index].PartyModeID);
CGraphics.FadeTo(EScreens.ScreenPartyDummy);
+2
View File
@@ -384,7 +384,9 @@ namespace Vocaluxe.Screens
for (int p = 0; p < CGame.NumPlayer; p++)
{
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression
if (CGame.Players[p].Points < 10000)
// ReSharper restore ConvertIfStatementToConditionalTernaryExpression
_Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Players[p].Points.ToString("0000");
else
_Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Players[p].Points.ToString("00000");
+2
View File
@@ -1157,7 +1157,9 @@ namespace Vocaluxe.Screens
if (_SelectSlides[_SelectSlideOptionsPlaylistOpen].NumValues > 0)
_SelectSlides[_SelectSlideOptionsPlaylistOpen].Visible = true;
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression
if (_Buttons[_ButtonOptionsRandom].Visible)
// ReSharper restore ConvertIfStatementToConditionalTernaryExpression
_SetInteractionToButton(_Buttons[_ButtonOptionsRandom]);
else
_SetInteractionToButton(_Buttons[_ButtonOptionsRandomCategory]);
+2 -2
View File
@@ -178,7 +178,7 @@
<Compile Include="Base\CDraw.cs" />
<Compile Include="Base\Font\CFont.cs" />
<Compile Include="Base\CGame.cs" />
<Compile Include="Base\CInput.cs" />
<Compile Include="Base\CController.cs" />
<Compile Include="Base\CLanguage.cs" />
<Compile Include="Base\CLog.cs" />
<Compile Include="Base\CMain.cs" />
@@ -217,7 +217,7 @@
</Compile>
<Compile Include="Lib\Draw\IDraw.cs" />
<Compile Include="Lib\Input\CHIDAPI.cs" />
<Compile Include="Lib\Input\IInput.cs" />
<Compile Include="Lib\Input\IController.cs" />
<Compile Include="Lib\Input\WiiMote\CWiiMote.cs" />
<Compile Include="Lib\Input\WiiMote\WiiMoteLib.cs" />
<Compile Include="Lib\Playlist\CPlaylistFile.cs" />