From 3f4a2fbb817a8abd11ce20561ceb6f9407576bf3 Mon Sep 17 00:00:00 2001 From: Jiiniasu Date: Sun, 6 Mar 2016 12:28:47 +0100 Subject: [PATCH 1/3] Add support for multichannel recording Support for "unlimited" amount of channels per recording device. Upped ScreenOptionsRecord version and added neccessary lines to be able to configure n channels per device. Added language strings for Player 1-6. Tested on a machine with Tascam US-16x08 audio interface and Singstar Wireless Microphones used simultaneously. --- Output/Languages/English.xml | 8 +- .../Ambient/Screens/ScreenOptionsRecord.xml | 468 ++++++++++++++++-- .../Changelog_ScreenOptionsRecord.txt | 18 +- Vocaluxe/Base/CConfig.cs | 4 +- Vocaluxe/Base/CRecord.cs | 4 +- Vocaluxe/Lib/Sound/Record/CRecordBase.cs | 38 +- .../Record/DirectSound/CDirectSoundRecord.cs | 10 +- Vocaluxe/Lib/Sound/Record/IRecord.cs | 8 +- .../Record/PortAudio/CPortAudioRecord.cs | 26 +- Vocaluxe/Screens/CScreenOptionsRecord.cs | 234 ++++----- 10 files changed, 595 insertions(+), 223 deletions(-) diff --git a/Output/Languages/English.xml b/Output/Languages/English.xml index 8827da1a..4a783eef 100644 --- a/Output/Languages/English.xml +++ b/Output/Languages/English.xml @@ -182,8 +182,12 @@ Record Options Device Input - Channel 1 - Channel 2 + Player 1 + Player 2 + Player 3 + Player 4 + Player 5 + Player 6 Mic Delay Warning: At least one player is assigned to two mics. Delay Test diff --git a/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml b/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml index 95b8464d..c7357bae 100644 --- a/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml +++ b/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml @@ -91,7 +91,7 @@ 0 - + EnergyBeam @@ -102,7 +102,7 @@ 0 - + EnergyBeam @@ -112,6 +112,50 @@ 16 0 + + + EnergyBeam + + + 390 + 354 + 100 + 16 + 0 + + + + EnergyBeam + + + 390 + 416 + 100 + 16 + 0 + + + + EnergyBeam + + + 390 + 474 + 100 + 16 + 0 + + + + EnergyBeam + + + 390 + 536 + 100 + 16 + 0 + @@ -145,7 +189,7 @@ 75 - 347 + 167 0 27 0 @@ -159,7 +203,7 @@ 640 - 537 + 615 0 27 970 @@ -171,7 +215,7 @@ Outline TR_SCREENORECORD_MIC_WARNING - + 75 227 0 @@ -183,9 +227,9 @@ Center Outline - TR_SCREENORECORD_CHANNEL_1 + TR_SCREENORECORD_PLAYER_1 - + 75 287 0 @@ -197,31 +241,143 @@ Center Outline - TR_SCREENORECORD_CHANNEL_2 - - - 330 - 227 - -1 + TR_SCREENORECORD_PLAYER_2 + + + 75 + 347 + 0 27 0 - Right + Left + Center + + Outline + TR_SCREENORECORD_PLAYER_3 + + + 75 + 407 + 0 + 27 + 0 + + + Left + Center + + Outline + TR_SCREENORECORD_PLAYER_4 + + + 75 + 467 + 0 + 27 + 0 + + + Left + Center + + Outline + TR_SCREENORECORD_PLAYER_5 + + + 75 + 527 + 0 + 27 + 0 + + + Left + Center + + Outline + TR_SCREENORECORD_PLAYER_6 + + + 320 + 227 + -2 + 27 + 100 + + + Center Center Outline - - 330 + + 320 287 - -1 + -2 27 - 0 + 100 - Right + Center + Center + + Outline + + + + 320 + 347 + -2 + 27 + 100 + + + Center + Center + + Outline + + + + 320 + 407 + -2 + 27 + 100 + + + Center + Center + + Outline + + + + 320 + 467 + -2 + 27 + 100 + + + Center + Center + + Outline + + + + 320 + 527 + -2 + 27 + 100 + + + Center Center Outline @@ -268,7 +424,7 @@ Button Button - 355 + 985 600 150 50 @@ -345,7 +501,7 @@ Bold 1 - + SelectSlideArrowLeft SelectSlideArrowRight @@ -387,7 +543,7 @@ Bold 7 - + SelectSlideArrowLeft SelectSlideArrowRight @@ -429,7 +585,7 @@ Bold 7 - + SelectSlideArrowLeft SelectSlideArrowRight @@ -466,6 +622,174 @@ 27 50 0 + 154 + Outline + Bold + 7 + + + + SelectSlideArrowLeft + SelectSlideArrowRight + SelectSlide + SelectSlideArrowLeft + SelectSlideArrowRight + + 500 + 400 + 700 + 50 + 0 + + + 505 + 405 + 40 + 40 + 0 + + + 1170 + 405 + 40 + 40 + 0 + + + + + + + + 27 + 50 + 0 + 154 + Outline + Bold + 7 + + + + SelectSlideArrowLeft + SelectSlideArrowRight + SelectSlide + SelectSlideArrowLeft + SelectSlideArrowRight + + 500 + 460 + 700 + 50 + 0 + + + 505 + 465 + 40 + 40 + 0 + + + 1170 + 465 + 40 + 40 + 0 + + + + + + + + 27 + 50 + 0 + 154 + Outline + Bold + 7 + + + + SelectSlideArrowLeft + SelectSlideArrowRight + SelectSlide + SelectSlideArrowLeft + SelectSlideArrowRight + + 500 + 520 + 700 + 50 + 0 + + + 505 + 525 + 40 + 40 + 0 + + + 1170 + 525 + 40 + 40 + 0 + + + + + + + + 27 + 50 + 0 + 154 + Outline + Bold + 7 + + + + SelectSlideArrowLeft + SelectSlideArrowRight + SelectSlide + SelectSlideArrowLeft + SelectSlideArrowRight + + 500 + 160 + 700 + 50 + 0 + + + 505 + 165 + 40 + 40 + 0 + + + 1170 + 165 + 40 + 40 + 0 + + + + + + + + 27 + 50 + 0 123.2 Outline Bold @@ -475,13 +799,13 @@ - + - 50 - 400 - 230 - 150 + 270 + 220 + 100 + 40 -1 12 @@ -490,18 +814,15 @@ TR_CONFIG_OFF - - 26 - 10 - + - + - 400 - 400 - 230 - 150 + 270 + 280 + 100 + 40 -1 12 @@ -510,10 +831,75 @@ TR_CONFIG_OFF - - 26 - 10 - + + + + + + 270 + 340 + 100 + 40 + -1 + + 12 + 2 + + TR_CONFIG_OFF + + + + + + + + 270 + 400 + 100 + 40 + -1 + + 12 + 2 + + TR_CONFIG_OFF + + + + + + + + 270 + 460 + 100 + 40 + -1 + + 12 + 2 + + TR_CONFIG_OFF + + + + + + + + 270 + 520 + 100 + 40 + -1 + + 12 + 2 + + TR_CONFIG_OFF + + + diff --git a/Output/Themes/Changelog/Changelog_ScreenOptionsRecord.txt b/Output/Themes/Changelog/Changelog_ScreenOptionsRecord.txt index 1eb9f362..b41f8990 100644 --- a/Output/Themes/Changelog/Changelog_ScreenOptionsRecord.txt +++ b/Output/Themes/Changelog/Changelog_ScreenOptionsRecord.txt @@ -9,4 +9,20 @@ This is a new theme-element. Check ScreenOptionsRecord.xml for style-possibiliti ++++++++++ Version 4: Rename Text 3/4 to TextChannel1/2 -Rename Text5 to Text3 \ No newline at end of file +Rename Text5 to Text3 +++++++++++ +Version 5: + +Added: +StaticEnergyPlayer1-6 +TextPlayer1-6 +TextDelayPlayer1-6 +SelectSlideRecordPlayer1-6 +EqualizerPlayer1-6 + +Removed: +StaticEnergyChannel1-2 +TextChannel1-2 +TextDelayChannel1-2 +SelectSlideRecordChannel1-2 +EqualizerChannel1-2 \ No newline at end of file diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index ea133582..b64dd215 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -530,7 +530,7 @@ namespace Vocaluxe.Base if (devices == null) return false; - return devices.Any(t => t.PlayerChannel1 != 0 || t.PlayerChannel2 != 0); + return devices.Any(t => t.PlayerChannel[0] != 0 || t.PlayerChannel[1] != 0); } /// @@ -544,7 +544,7 @@ namespace Vocaluxe.Base if (devices == null) return false; - return devices.Any(t => t.PlayerChannel1 == player || t.PlayerChannel2 == player); + return devices.Any(t => t.PlayerChannel.Contains(player)); } public static int GetMaxNumMics() diff --git a/Vocaluxe/Base/CRecord.cs b/Vocaluxe/Base/CRecord.cs index 8c55f6e8..cd82e459 100644 --- a/Vocaluxe/Base/CRecord.cs +++ b/Vocaluxe/Base/CRecord.cs @@ -126,8 +126,8 @@ namespace Vocaluxe.Base { foreach (CRecordDevice device in devices) { - device.PlayerChannel1 = _GetPlayerFromMicConfig(device.Name, device.Driver, 1); - device.PlayerChannel2 = _GetPlayerFromMicConfig(device.Name, device.Driver, 2); + for(int ch = 0; ch < device.Channels; ++ch) + device.PlayerChannel[ch] = _GetPlayerFromMicConfig(device.Name, device.Driver, ch+1); } return devices; } diff --git a/Vocaluxe/Lib/Sound/Record/CRecordBase.cs b/Vocaluxe/Lib/Sound/Record/CRecordBase.cs index dde798fe..eb8b2391 100644 --- a/Vocaluxe/Lib/Sound/Record/CRecordBase.cs +++ b/Vocaluxe/Lib/Sound/Record/CRecordBase.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using Vocaluxe.Base; +using System; namespace Vocaluxe.Lib.Sound.Record { @@ -76,32 +77,25 @@ namespace Vocaluxe.Lib.Sound.Record /// Recorded samples, assume Int16 and interleaved for multi-channels protected void _HandleData(CRecordDevice device, byte[] data) { - byte[] leftBuffer; - byte[] rightBuffer; - if (device.Channels == 2) + int totalChannels = device.Channels; + int doubleChannels = totalChannels * 2; + byte[][] allBuffers = new byte[totalChannels][]; + + for (int currChannel = 0; currChannel < totalChannels; ++currChannel) + allBuffers[currChannel] = new byte[data.Length / totalChannels]; + + for (int i = 0; i < data.Length / doubleChannels; ++i) { - leftBuffer = new byte[data.Length / 2]; - rightBuffer = new byte[data.Length / 2]; - //[]: Sample, L: Left channel R: Right channel - //[LR][LR][LR][LR][LR][LR] - //The data is interleaved and needs to be demultiplexed - for (int i = 0; i < data.Length / 4; i++) - { - leftBuffer[i * 2] = data[i * 4]; - leftBuffer[i * 2 + 1] = data[i * 4 + 1]; - rightBuffer[i * 2] = data[i * 4 + 2]; - rightBuffer[i * 2 + 1] = data[i * 4 + 3]; - } + for (int j = 0; j < doubleChannels; ++j) + allBuffers[(int)Math.Floor(j / (double)2)][i * 2 + (j % 2)] = data[i * doubleChannels + j]; } - else - leftBuffer = rightBuffer = data; - if (device.PlayerChannel1 > 0) - _Buffer[device.PlayerChannel1 - 1].ProcessNewBuffer(leftBuffer); - - if (device.PlayerChannel2 > 0) - _Buffer[device.PlayerChannel2 - 1].ProcessNewBuffer(rightBuffer); + for (int ch = 0; ch < totalChannels; ++ch) + { + if (device.PlayerChannel[ch] > 0) + _Buffer[device.PlayerChannel[ch] - 1].ProcessNewBuffer(allBuffers[ch]); + } } /// diff --git a/Vocaluxe/Lib/Sound/Record/DirectSound/CDirectSoundRecord.cs b/Vocaluxe/Lib/Sound/Record/DirectSound/CDirectSoundRecord.cs index 43e501bf..1c8def06 100644 --- a/Vocaluxe/Lib/Sound/Record/DirectSound/CDirectSoundRecord.cs +++ b/Vocaluxe/Lib/Sound/Record/DirectSound/CDirectSoundRecord.cs @@ -68,9 +68,15 @@ namespace Vocaluxe.Lib.Sound.Record.DirectSound foreach (CRecordDevice device in _Devices) { - if (device.PlayerChannel1 > 0 || device.PlayerChannel2 > 0) + bool usingDevice = false; + for (int ch = 0; ch < device.Channels; ++ch) { - var source = new CSoundCardSource(device.Driver, (short)device.Channels) {SampleRateKhz = 44.1}; + if (device.PlayerChannel[ch] > 0) + usingDevice = true; + } + if (usingDevice) + { + var source = new CSoundCardSource(device.Driver, (short)device.Channels) { SampleRateKhz = 44.1 }; source.SampleDataReady += _OnDataReady; source.Start(); diff --git a/Vocaluxe/Lib/Sound/Record/IRecord.cs b/Vocaluxe/Lib/Sound/Record/IRecord.cs index 7f020daa..e8166dae 100644 --- a/Vocaluxe/Lib/Sound/Record/IRecord.cs +++ b/Vocaluxe/Lib/Sound/Record/IRecord.cs @@ -27,19 +27,15 @@ namespace Vocaluxe.Lib.Sound.Record public readonly string Driver; public readonly int Channels; - public int PlayerChannel1; - public int PlayerChannel2; + public int[] PlayerChannel; public CRecordDevice(int id, string name, string driver, int channels) { ID = id; Name = name; Driver = driver; - - if (channels > 2) - channels = 2; //more are not supported in vocaluxe - Channels = channels; + PlayerChannel = new int[channels]; } } diff --git a/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs b/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs index da2eaf9d..4702e400 100644 --- a/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs +++ b/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs @@ -99,16 +99,21 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio for (int dev = 0; dev < _Devices.Count; dev++) { - if (_Devices[dev].PlayerChannel1 > 0 || _Devices[dev].PlayerChannel2 > 0) + bool usingDevice = false; + for (int ch = 0; ch < _Devices[dev].Channels; ++ch) { + if (_Devices[dev].PlayerChannel[ch] > 0) + usingDevice = true; + } + if (usingDevice) { PortAudioSharp.PortAudio.PaStreamParameters? inputParams = new PortAudioSharp.PortAudio.PaStreamParameters - { - channelCount = _Devices[dev].Channels, - device = _Devices[dev].ID, - sampleFormat = PortAudioSharp.PortAudio.PaSampleFormat.paInt16, - suggestedLatency = PortAudioSharp.PortAudio.Pa_GetDeviceInfo(_Devices[dev].ID).defaultLowInputLatency, - hostApiSpecificStreamInfo = IntPtr.Zero - }; + { + channelCount = _Devices[dev].Channels, + device = _Devices[dev].ID, + sampleFormat = PortAudioSharp.PortAudio.PaSampleFormat.paInt16, + suggestedLatency = PortAudioSharp.PortAudio.Pa_GetDeviceInfo(_Devices[dev].ID).defaultLowInputLatency, + hostApiSpecificStreamInfo = IntPtr.Zero + }; if (!_PaHandle.OpenInputStream( out _RecHandle[dev], ref inputParams, @@ -181,10 +186,7 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio { CRecordDevice dev = _Devices[userData.ToInt32()]; uint numBytes; - if (dev.Channels == 2) - numBytes = frameCount * 4; - else - numBytes = frameCount * 2; + numBytes = frameCount * (uint)dev.Channels * 2; byte[] recbuffer = new byte[numBytes]; diff --git a/Vocaluxe/Screens/CScreenOptionsRecord.cs b/Vocaluxe/Screens/CScreenOptionsRecord.cs index dca9586b..da838eda 100644 --- a/Vocaluxe/Screens/CScreenOptionsRecord.cs +++ b/Vocaluxe/Screens/CScreenOptionsRecord.cs @@ -31,13 +31,13 @@ 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 4; } + get { return 5; } } private const string _SelectSlideRecordDevices = "SelectSlideRecordDevices"; - private const string _SelectSlideRecordChannel1 = "SelectSlideRecordChannel1"; - private const string _SelectSlideRecordChannel2 = "SelectSlideRecordChannel2"; + private readonly string[] _SelectSlideRecordPlayer = { "SelectSlideRecordPlayer1", "SelectSlideRecordPlayer2", "SelectSlideRecordPlayer3", "SelectSlideRecordPlayer4", "SelectSlideRecordPlayer5", "SelectSlideRecordPlayer6" }; + private const string _SelectSlideDelay = "SelectSlideDelay"; private const string _StaticWarning = "StaticWarning"; @@ -46,22 +46,19 @@ namespace Vocaluxe.Screens private const string _ButtonExit = "ButtonExit"; private const string _ButtonDelayTest = "ButtonDelayTest"; - private const string _TextChannel1 = "TextChannel1"; - private const string _TextChannel2 = "TextChannel2"; + private readonly string[] _TextPlayer = { "TextPlayer1", "TextPlayer2", "TextPlayer3", "TextPlayer4", "TextPlayer5", "TextPlayer6" }; - private const string _TextDelayChannel1 = "TextDelayChannel1"; - private const string _TextDelayChannel2 = "TextDelayChannel2"; + private readonly string[] _TextDelayPlayer = { "TextDelayPlayer1", "TextDelayPlayer2", "TextDelayPlayer3", "TextDelayPlayer4", "TextDelayPlayer5", "TextDelayPlayer6" }; - private const string _EqualizerChannel1 = "EqualizerChannel1"; - private const string _EqualizerChannel2 = "EqualizerChannel2"; + private readonly string[] _EqualizerPlayer = { "EqualizerPlayer1", "EqualizerPlayer2", "EqualizerPlayer3", "EqualizerPlayer4", "EqualizerPlayer5", "EqualizerPlayer6" }; - private readonly string[] _StaticEnergyChannel = new string[] {"StaticEnergyChannel1", "StaticEnergyChannel2"}; + private readonly string[] _StaticEnergyPlayer = new string[] { "StaticEnergyPlayer1", "StaticEnergyPlayer2", "StaticEnergyPlayer3", "StaticEnergyPlayer4", "StaticEnergyPlayer5", "StaticEnergyPlayer6" }; private float[] _ChannelEnergy; private ReadOnlyCollection _Devices; private int _DeviceNr; - private readonly CDelayTest _DelayTest = new CDelayTest(2); + private readonly CDelayTest _DelayTest = new CDelayTest(6); public override EMusicType CurrentMusicType { @@ -73,43 +70,27 @@ namespace Vocaluxe.Screens base.Init(); var values = new List {_StaticWarning}; - values.AddRange(_StaticEnergyChannel); + values.AddRange(_StaticEnergyPlayer); _ThemeStatics = values.ToArray(); - _ThemeTexts = new string[] {_TextWarning, _TextChannel1, _TextChannel2, _TextDelayChannel1, _TextDelayChannel2}; + _ThemeTexts = new string[] {_TextWarning, _TextPlayer[0], _TextPlayer[1], _TextPlayer[2], _TextPlayer[3], _TextPlayer[4], _TextPlayer[5], _TextDelayPlayer[0], _TextDelayPlayer[1], _TextDelayPlayer[2], _TextDelayPlayer[3], _TextDelayPlayer[4], _TextDelayPlayer[5] }; _ThemeButtons = new string[] {_ButtonExit, _ButtonDelayTest}; - _ThemeSelectSlides = new string[] {_SelectSlideRecordDevices, _SelectSlideRecordChannel1, _SelectSlideRecordChannel2, _SelectSlideDelay}; - _ThemeEqualizers = new string[] {_EqualizerChannel1, _EqualizerChannel2}; + _ThemeSelectSlides = new string[] {_SelectSlideRecordDevices, _SelectSlideRecordPlayer[0], _SelectSlideRecordPlayer[1], _SelectSlideRecordPlayer[2], _SelectSlideRecordPlayer[3], _SelectSlideRecordPlayer[4], _SelectSlideRecordPlayer[5], _SelectSlideDelay }; + _ThemeEqualizers = new string[] {_EqualizerPlayer[0], _EqualizerPlayer[1], _EqualizerPlayer[2], _EqualizerPlayer[3], _EqualizerPlayer[4], _EqualizerPlayer[5]}; } public override void LoadTheme(string xmlPath) { base.LoadTheme(xmlPath); - int max = CSettings.MaxNumPlayer + 1; - if (max > 7) - max = 7; - - _SelectSlides[_SelectSlideRecordChannel1].NumVisible = max; - _SelectSlides[_SelectSlideRecordChannel2].NumVisible = max; - - _SelectSlides[_SelectSlideRecordChannel1].AddValue(CLanguage.Translate("TR_CONFIG_OFF")); - _SelectSlides[_SelectSlideRecordChannel2].AddValue(CLanguage.Translate("TR_CONFIG_OFF")); - - for (int i = 1; i <= CSettings.MaxNumPlayer; i++) - { - _SelectSlides[_SelectSlideRecordChannel1].AddValue(i.ToString()); - _SelectSlides[_SelectSlideRecordChannel2].AddValue(i.ToString()); - } - for (int i = 0; i < 26; i++) _SelectSlides[_SelectSlideDelay].AddValue((i * 20) + " ms"); - _ChannelEnergy = new float[_StaticEnergyChannel.Length]; + _ChannelEnergy = new float[_StaticEnergyPlayer.Length]; for (int i = 0; i < _ChannelEnergy.Length; i++) { - _Statics[_StaticEnergyChannel[i]].Visible = false; + _Statics[_StaticEnergyPlayer[i]].Visible = false; _ChannelEnergy[i] = 0f; } } @@ -151,27 +132,11 @@ namespace Vocaluxe.Screens break; case Keys.Left: - if (_SelectSlides[_SelectSlideRecordDevices].Selected) - _OnDeviceEvent(); - - if (_SelectSlides[_SelectSlideRecordChannel1].Selected || - _SelectSlides[_SelectSlideRecordChannel2].Selected) - _SetMicConfig(); - - if (_SelectSlides[_SelectSlideDelay].Selected) - _SaveDelayConfig(); + _SelectSlideAction(); break; case Keys.Right: - if (_SelectSlides[_SelectSlideRecordDevices].Selected) - _OnDeviceEvent(); - - if (_SelectSlides[_SelectSlideRecordChannel1].Selected || - _SelectSlides[_SelectSlideRecordChannel2].Selected) - _SetMicConfig(); - - if (_SelectSlides[_SelectSlideDelay].Selected) - _SaveDelayConfig(); + _SelectSlideAction(); break; } } @@ -190,15 +155,7 @@ namespace Vocaluxe.Screens if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { - if (_SelectSlides[_SelectSlideRecordDevices].Selected) - _OnDeviceEvent(); - - if (_SelectSlides[_SelectSlideRecordChannel1].Selected || - _SelectSlides[_SelectSlideRecordChannel2].Selected) - _SetMicConfig(); - - if (_SelectSlides[_SelectSlideDelay].Selected) - _SaveDelayConfig(); + _SelectSlideAction(); if (_Buttons[_ButtonExit].Selected) { @@ -220,42 +177,32 @@ namespace Vocaluxe.Screens if (_DelayTest.Running) { _DelayTest.Update(); - _Texts[_TextDelayChannel1].Text = (_DelayTest.Delays[0] == 0) ? "???" : _DelayTest.Delays[0].ToString("000") + " ms"; - _Texts[_TextDelayChannel2].Text = (_DelayTest.Delays[1] == 0) ? "???" : _DelayTest.Delays[1].ToString("000") + " ms"; + for (int p = 0; p < CSettings.MaxNumPlayer; ++p) + _Texts[_TextDelayPlayer[p]].Text = (_DelayTest.Delays[p] == 0) ? "??? ms" : _DelayTest.Delays[p].ToString("000") + " ms"; } if (_CheckMicConfig()) { - int player = _SelectSlides[_SelectSlideRecordChannel1].Selection - 1; - if (player >= 0) + for (int p = 0; p < CSettings.MaxNumPlayer; ++p) { - _ChannelEnergy[0] = CRecord.GetMaxVolume(player); - _Equalizers[_EqualizerChannel1].Update(CRecord.ToneWeigth(player), CRecord.GetMaxVolume(player)); - } - else - { - _ChannelEnergy[0] = 0f; - _Equalizers[_EqualizerChannel1].Reset(); - } - - player = _SelectSlides[_SelectSlideRecordChannel2].Selection - 1; - if (player >= 0) - { - _ChannelEnergy[1] = CRecord.GetMaxVolume(player); - _Equalizers[_EqualizerChannel2].Update(CRecord.ToneWeigth(player), CRecord.GetMaxVolume(player)); - } - else - { - _ChannelEnergy[1] = 0f; - _Equalizers[_EqualizerChannel2].Reset(); + if(_SelectSlides[_SelectSlideRecordPlayer[p]].Selection > 0) + { + _ChannelEnergy[p] = CRecord.GetMaxVolume(p); + _Equalizers[_EqualizerPlayer[p]].Update(CRecord.ToneWeigth(p), CRecord.GetMaxVolume(p)); + } + else + { + _ChannelEnergy[p] = 0f; + _Equalizers[_EqualizerPlayer[p]].Reset(); + } } } else { for (int i = 0; i < _ChannelEnergy.Length; i++) _ChannelEnergy[i] = 0f; - _Equalizers[_EqualizerChannel1].Reset(); - _Equalizers[_EqualizerChannel2].Reset(); + for (int p = 0; p < CSettings.MaxNumPlayer; ++p) + _Equalizers[_EqualizerPlayer[p]].Reset(); } bool showWarning = !_CheckMicConfig(); @@ -288,9 +235,8 @@ namespace Vocaluxe.Screens _UpdateChannels(); } - - _SelectSlides[_SelectSlideRecordChannel1].Visible = _Devices != null; - _SelectSlides[_SelectSlideRecordChannel2].Visible = _Devices != null; + for (int p = 0; p < CSettings.MaxNumPlayer; ++p) + _SelectSlides[_SelectSlideRecordPlayer[p]].Visible = _Devices != null; _Statics[_StaticWarning].Visible = false; _Texts[_TextWarning].Visible = false; @@ -309,17 +255,17 @@ namespace Vocaluxe.Screens { base.Draw(); - for (int i = 0; i < _StaticEnergyChannel.Length; i++) + for (int i = 0; i < _StaticEnergyPlayer.Length; i++) { if (_ChannelEnergy[i] > 0f) { - var rect = new SRectF(_Statics[_StaticEnergyChannel[i]].Rect.X, - _Statics[_StaticEnergyChannel[i]].Rect.Y, - _Statics[_StaticEnergyChannel[i]].Rect.W * _ChannelEnergy[i], - _Statics[_StaticEnergyChannel[i]].Rect.H, - _Statics[_StaticEnergyChannel[i]].Rect.Z); + var rect = new SRectF(_Statics[_StaticEnergyPlayer[i]].Rect.X, + _Statics[_StaticEnergyPlayer[i]].Rect.Y, + _Statics[_StaticEnergyPlayer[i]].Rect.W * _ChannelEnergy[i], + _Statics[_StaticEnergyPlayer[i]].Rect.H, + _Statics[_StaticEnergyPlayer[i]].Rect.Z); - CDraw.DrawTexture(_Statics[_StaticEnergyChannel[i]].Texture, _Statics[_StaticEnergyChannel[i]].Rect, + CDraw.DrawTexture(_Statics[_StaticEnergyPlayer[i]].Texture, _Statics[_StaticEnergyPlayer[i]].Rect, new SColorF(1f, 1f, 1f, 1f), rect); } } @@ -363,18 +309,14 @@ namespace Vocaluxe.Screens foreach (CRecordDevice device in _Devices) { - if (device.PlayerChannel1 > 0) + for (int ch = 0; ch < (uint)device.Channels; ++ch) { - CConfig.Config.Record.MicConfig[device.PlayerChannel1 - 1].Channel = 1; - CConfig.Config.Record.MicConfig[device.PlayerChannel1 - 1].DeviceName = device.Name; - CConfig.Config.Record.MicConfig[device.PlayerChannel1 - 1].DeviceDriver = device.Driver; - } - - if (device.PlayerChannel2 > 0) - { - CConfig.Config.Record.MicConfig[device.PlayerChannel2 - 1].Channel = 2; - CConfig.Config.Record.MicConfig[device.PlayerChannel2 - 1].DeviceName = device.Name; - CConfig.Config.Record.MicConfig[device.PlayerChannel2 - 1].DeviceDriver = device.Driver; + if (device.PlayerChannel[ch] > 0) + { + CConfig.Config.Record.MicConfig[device.PlayerChannel[ch] - 1].Channel = ch+1; + CConfig.Config.Record.MicConfig[device.PlayerChannel[ch] - 1].DeviceName = device.Name; + CConfig.Config.Record.MicConfig[device.PlayerChannel[ch] - 1].DeviceDriver = device.Driver; + } } } CConfig.SaveConfig(); @@ -382,31 +324,62 @@ namespace Vocaluxe.Screens CRecord.Start(); } - private void _SetPlayerColors() - { - _Texts[_TextChannel1].Color = _SelectSlides[_SelectSlideRecordChannel1].Selection <= 0 - ? new SColorF(1, 1, 1, 1) : CThemes.GetPlayerColor(_SelectSlides[_SelectSlideRecordChannel1].Selection); - _Texts[_TextChannel2].Color = _SelectSlides[_SelectSlideRecordChannel2].Selection <= 0 - ? new SColorF(1, 1, 1, 1) : CThemes.GetPlayerColor(_SelectSlides[_SelectSlideRecordChannel2].Selection); - } - private void _SetMicConfig() { if (_DeviceNr < 0) return; CRecordDevice device = _Devices[_DeviceNr]; - device.PlayerChannel1 = _SelectSlides[_SelectSlideRecordChannel1].Selection; - device.PlayerChannel2 = _SelectSlides[_SelectSlideRecordChannel2].Selection; - _SetPlayerColors(); + + for (int ch = 0; ch < device.Channels; ++ch) + device.PlayerChannel[ch] = 0; + + for (int p = 0; p < CSettings.MaxNumPlayer; ++p) + { + int ch = _SelectSlides[_SelectSlideRecordPlayer[p]].Selection; + + if (ch > 0) + device.PlayerChannel[ch-1] = p+1; + + } + } + + private void _SelectSlideAction() + { + if (_SelectSlides[_SelectSlideRecordDevices].Selected) + _OnDeviceEvent(); + + for (int i = 0; i < _SelectSlideRecordPlayer.Length; ++i) + if (_SelectSlides[_SelectSlideRecordPlayer[i]].Selected) + _SetMicConfig(); + + if (_SelectSlides[_SelectSlideDelay].Selected) + _SaveDelayConfig(); } private void _UpdateChannels() { - _SelectSlides[_SelectSlideRecordChannel1].Selection = _Devices[_DeviceNr].PlayerChannel1; - _SelectSlides[_SelectSlideRecordChannel2].Selection = _Devices[_DeviceNr].PlayerChannel2; + int max = _Devices[_DeviceNr].Channels + 1; + + for (int p = 0; p < CSettings.MaxNumPlayer; ++p) + { + _SelectSlides[_SelectSlideRecordPlayer[p]].Clear(); + _SelectSlides[_SelectSlideRecordPlayer[p]].NumVisible = max; + _SelectSlides[_SelectSlideRecordPlayer[p]].AddValue(CLanguage.Translate("TR_CONFIG_OFF")); + } + + for (int i = 1; i <= _Devices[_DeviceNr].Channels; ++i) + { + for (int p = 0; p < CSettings.MaxNumPlayer; ++p) + _SelectSlides[_SelectSlideRecordPlayer[p]].AddValue(i.ToString()); + + int pc = _Devices[_DeviceNr].PlayerChannel[i-1]; + if (pc > 0) + { + _SelectSlides[_SelectSlideRecordPlayer[pc-1]].Selection = i; + } + } _SaveMicConfig(); - _SetPlayerColors(); } private bool _CheckMicConfig() @@ -420,20 +393,15 @@ namespace Vocaluxe.Screens foreach (CRecordDevice device in _Devices) { - if (device.PlayerChannel1 > 0) + for (int i = 0; i < device.Channels; ++i) { - if (isSet[device.PlayerChannel1 - 1]) - return false; + if (device.PlayerChannel[i] > 0) + { + if (isSet[device.PlayerChannel[i] - 1]) + return false; - isSet[device.PlayerChannel1 - 1] = true; - } - - if (device.PlayerChannel2 > 0) - { - if (isSet[device.PlayerChannel2 - 1]) - return false; - - isSet[device.PlayerChannel2 - 1] = true; + isSet[device.PlayerChannel[i] - 1] = true; + } } } return true; @@ -443,7 +411,7 @@ namespace Vocaluxe.Screens { _SaveMicConfig(); _DelayTest.Reset(); - _DelayTest.Start(new int[] {_SelectSlides[_SelectSlideRecordChannel1].Selection - 1, _SelectSlides[_SelectSlideRecordChannel2].Selection - 1}); + _DelayTest.Start(new int[] {0, 1, 2, 3, 4, 5}); } private void _GetFirstConfiguredRecordDevice(ref int device) From 139579a1cafd4360918c682ff2835e1c235f2be1 Mon Sep 17 00:00:00 2001 From: Jiiniasu Date: Sun, 6 Mar 2016 17:20:10 +0100 Subject: [PATCH 2/3] Up the version on ScreenOptionsRecord for the Ambient theme --- Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml b/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml index c7357bae..b847dca2 100644 --- a/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml +++ b/Output/Themes/Ambient/Screens/ScreenOptionsRecord.xml @@ -2,7 +2,7 @@ ScreenOptionsRecord - 4 + 5 From 3a6ed62282dc91e801d6839b8bfeefbae0723bf4 Mon Sep 17 00:00:00 2001 From: Jiiniasu Date: Sun, 6 Mar 2016 20:04:06 +0100 Subject: [PATCH 3/3] Edit IsMicConfig to fix "accidental" wiping of microphone config Previously Vocaluxe would autoassign player 1 and 2 if these players were both configured on channels higher than 2. Mashed together IsMicConfig() and IsMicConfig(int player) to handle both specific and any player microphone config check. --- Vocaluxe/Base/CConfig.cs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index b64dd215..67d6bcac 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -520,31 +520,27 @@ namespace Vocaluxe.Base return (1f / Config.Graphics.MaxFPS) * 1000f; } - /// - /// Checks, if there is a mic-configuration - /// - /// - public static bool IsMicConfig() - { - ReadOnlyCollection devices = CRecord.GetDevices(); - if (devices == null) - return false; - - return devices.Any(t => t.PlayerChannel[0] != 0 || t.PlayerChannel[1] != 0); - } - /// /// Checks, if there is a mic-configuration /// /// Player-Number /// - public static bool IsMicConfig(int player) + public static bool IsMicConfig(int player = 0) { ReadOnlyCollection devices = CRecord.GetDevices(); if (devices == null) return false; - return devices.Any(t => t.PlayerChannel.Contains(player)); + if (player > 0) + return devices.Any(t => t.PlayerChannel.Contains(player)); + + for (int p = 0; p < CSettings.MaxNumPlayer; ++p) + if (devices.Any(t => t.PlayerChannel.Contains(p+1))) + { + return true; + } + + return false; } public static int GetMaxNumMics()