Split CSound and CRecord

This commit is contained in:
Flamefire committed 2014-03-16 10:44:40 +01:00
1 parent 11815a4f89
commit e20bd6e90b
12 files changed
+147 -142

No files matched your search

+4 -4
View File
@@ -627,7 +627,7 @@ namespace Vocaluxe.Base
/// <returns></returns>
public static bool IsMicConfig()
{
ReadOnlyCollection<CRecordDevice> devices = CSound.RecordGetDevices();
ReadOnlyCollection<CRecordDevice> devices = CRecord.RecordGetDevices();
if (devices == null)
return false;
@@ -641,7 +641,7 @@ namespace Vocaluxe.Base
/// <returns></returns>
public static bool IsMicConfig(int player)
{
ReadOnlyCollection<CRecordDevice> devices = CSound.RecordGetDevices();
ReadOnlyCollection<CRecordDevice> devices = CRecord.RecordGetDevices();
if (devices == null)
return false;
@@ -667,8 +667,8 @@ namespace Vocaluxe.Base
public static bool AutoAssignMics()
{
//Look for (usb-)mic
//SRecordDevice[] Devices = new SRecordDevice[CSound.RecordGetDevices().Length];
ReadOnlyCollection<CRecordDevice> devices = CSound.RecordGetDevices();
//SRecordDevice[] Devices = new SRecordDevice[CRecord.RecordGetDevices().Length];
ReadOnlyCollection<CRecordDevice> devices = CRecord.RecordGetDevices();
if (devices == null)
return false;
+4 -4
View File
@@ -225,7 +225,7 @@ namespace Vocaluxe.Base
MidRecordedBeat = -0.5f + GetBeatFromTime(time, song.BPM, song.Gap + CConfig.MicDelay / 1000f);
for (int p = 0; p < _NumPlayer; p++)
CSound.AnalyzeBuffer(p);
CRecord.AnalyzeBuffer(p);
if (_LastEvalBeat >= RecordedBeat)
return;
@@ -271,14 +271,14 @@ namespace Vocaluxe.Base
if (line == lines.Length - 1 && beat == lines[line].LastNoteBeat)
Players[p].SongFinished = true;
if (notes[note].PointsForBeat > 0 && (CSound.RecordToneValid(p)
if (notes[note].PointsForBeat > 0 && (CRecord.RecordToneValid(p)
#if DEBUG_HIT
|| true
#endif
))
{
int tone = notes[note].Tone;
int tonePlayer = CSound.RecordGetTone(p);
int tonePlayer = CRecord.RecordGetTone(p);
while (tonePlayer - tone > 6)
tonePlayer -= 12;
@@ -296,7 +296,7 @@ namespace Vocaluxe.Base
if (hit)
{
// valid
//CSound.RecordSetTone(p, Tone);
//CRecord.RecordSetTone(p, Tone);
double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat /
song.Notes.GetVoice(Players[p].VoiceNr).Points;
if (notes[note].Type == ENoteType.Golden)
+4 -4
View File
@@ -616,10 +616,10 @@ namespace Vocaluxe.Base
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2)
{
debugOutput.Add(CSound.RecordGetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00"));
debugOutput.Add(CSound.RecordGetMaxVolume(0).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P1: 0.000"));
debugOutput.Add(CSound.RecordGetToneAbs(1).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P2: 00"));
debugOutput.Add(CSound.RecordGetMaxVolume(1).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P2: 0.000"));
debugOutput.Add(CRecord.RecordGetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00"));
debugOutput.Add(CRecord.RecordGetMaxVolume(0).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P1: 0.000"));
debugOutput.Add(CRecord.RecordGetToneAbs(1).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P2: 00"));
debugOutput.Add(CRecord.RecordGetMaxVolume(1).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P2: 0.000"));
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3)
{
+1 -1
View File
@@ -626,7 +626,7 @@ namespace Vocaluxe.Base
{
public int GetToneAbs(int playerNr)
{
return CSound.RecordGetToneAbs(playerNr);
return CRecord.RecordGetToneAbs(playerNr);
}
}
+115
View File
@@ -0,0 +1,115 @@
using System.Collections.ObjectModel;
using Vocaluxe.Lib.Sound.Record;
using Vocaluxe.Lib.Sound.Record.DirectSound;
using Vocaluxe.Lib.Sound.Record.PortAudio;
using VocaluxeLib;
namespace Vocaluxe.Base
{
class CRecord
{
private static IRecord _Record;
public static void RecordInit()
{
switch (CConfig.RecordLib)
{
#if WIN
case ERecordLib.DirectSound:
_Record = new CDirectSoundRecord();
break;
#endif
// case ERecordLib.PortAudio:
default:
_Record = new CPortAudioRecord();
break;
}
}
public static void RecordCloseAll()
{
_Record.CloseAll();
}
public static bool RecordStart()
{
return _Record.Start();
}
public static bool RecordStop()
{
return _Record.Stop();
}
public static void AnalyzeBuffer(int player)
{
_Record.AnalyzeBuffer(player);
}
public static int RecordGetToneAbs(int player)
{
return _Record.GetToneAbs(player);
}
public static int RecordGetTone(int player)
{
return _Record.GetTone(player);
}
public static void RecordSetTone(int player, int tone)
{
_Record.SetTone(player, tone);
}
public static bool RecordToneValid(int player)
{
return _Record.ToneValid(player);
}
public static float RecordGetMaxVolume(int player)
{
return _Record.GetMaxVolume(player);
}
public static int NumHalfTones(int player)
{
return _Record.NumHalfTones(player);
}
public static float[] ToneWeigth(int player)
{
return _Record.ToneWeigth(player);
}
public static ReadOnlyCollection<CRecordDevice> RecordGetDevices()
{
ReadOnlyCollection<CRecordDevice> devices = _Record.RecordDevices();
if (devices != null)
{
foreach (CRecordDevice device in devices)
{
device.PlayerChannel1 = _GetPlayerFromMicConfig(device.Name, device.Driver, 1);
device.PlayerChannel2 = _GetPlayerFromMicConfig(device.Name, device.Driver, 2);
}
return devices;
}
return null;
}
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].Channel == channel)
return p + 1;
}
return 0;
}
}
}
-111
View File
@@ -16,17 +16,12 @@
#endregion
using System;
using System.Collections.ObjectModel;
using System.IO;
using Vocaluxe.Lib.Sound;
using Vocaluxe.Lib.Sound.Playback;
using Vocaluxe.Lib.Sound.Playback.Gstreamer;
using Vocaluxe.Lib.Sound.Playback.GstreamerSharp;
using Vocaluxe.Lib.Sound.Playback.OpenAL;
using Vocaluxe.Lib.Sound.Playback.PortAudio;
using Vocaluxe.Lib.Sound.Record;
using Vocaluxe.Lib.Sound.Record.DirectSound;
using Vocaluxe.Lib.Sound.Record.PortAudio;
using VocaluxeLib;
namespace Vocaluxe.Base
@@ -211,111 +206,5 @@ namespace Vocaluxe.Base
return stream;
}
#endregion Sounds
#region Record
private static IRecord _Record;
public static void RecordInit()
{
switch (CConfig.RecordLib)
{
#if WIN
case ERecordLib.DirectSound:
_Record = new CDirectSoundRecord();
break;
#endif
// case ERecordLib.PortAudio:
default:
_Record = new CPortAudioRecord();
break;
}
}
public static void RecordCloseAll()
{
_Record.CloseAll();
}
public static bool RecordStart()
{
return _Record.Start();
}
public static bool RecordStop()
{
return _Record.Stop();
}
public static void AnalyzeBuffer(int player)
{
_Record.AnalyzeBuffer(player);
}
public static int RecordGetToneAbs(int player)
{
return _Record.GetToneAbs(player);
}
public static int RecordGetTone(int player)
{
return _Record.GetTone(player);
}
public static void RecordSetTone(int player, int tone)
{
_Record.SetTone(player, tone);
}
public static bool RecordToneValid(int player)
{
return _Record.ToneValid(player);
}
public static float RecordGetMaxVolume(int player)
{
return _Record.GetMaxVolume(player);
}
public static int NumHalfTones(int player)
{
return _Record.NumHalfTones(player);
}
public static float[] ToneWeigth(int player)
{
return _Record.ToneWeigth(player);
}
public static ReadOnlyCollection<CRecordDevice> RecordGetDevices()
{
ReadOnlyCollection<CRecordDevice> devices = _Record.RecordDevices();
if (devices != null)
{
foreach (CRecordDevice device in devices)
{
device.PlayerChannel1 = _GetPlayerFromMicConfig(device.Name, device.Driver, 1);
device.PlayerChannel2 = _GetPlayerFromMicConfig(device.Name, device.Driver, 2);
}
return devices;
}
return null;
}
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].Channel == channel)
return p + 1;
}
return 0;
}
#endregion Record
}
}
+1 -1
View File
@@ -82,7 +82,7 @@ namespace Vocaluxe.Lib.Sound.Record
{
if (_DelaysChannel[i].Channel < 0 || _DelaysChannel[i].Finished)
continue;
if (CSound.RecordGetMaxVolume(_DelaysChannel[i].Channel) > 0.1f && CSound.RecordGetTone(_DelaysChannel[i].Channel) == 9)
if (CRecord.RecordGetMaxVolume(_DelaysChannel[i].Channel) > 0.1f && CRecord.RecordGetTone(_DelaysChannel[i].Channel) == 9)
{
Delays[i] = (int)_Timer.ElapsedMilliseconds;
_DelaysChannel[i].Finished = true;
+2 -2
View File
@@ -126,7 +126,7 @@ namespace Vocaluxe
// Init Record
CLog.StartBenchmark(0, "Init Record");
CSound.RecordInit();
CRecord.RecordInit();
CLog.StopBenchmark(0, "Init Record");
Application.DoEvents();
@@ -243,7 +243,7 @@ namespace Vocaluxe
{
CVocaluxeServer.Close();
CController.Close();
CSound.RecordCloseAll();
CRecord.RecordCloseAll();
CSound.CloseAllStreams();
CVideo.CloseAll();
CDraw.Unload();
+4 -4
View File
@@ -546,8 +546,8 @@ namespace Vocaluxe.Screens
for (int i = 1; i <= CGame.NumPlayer; i++)
{
CSound.AnalyzeBuffer(i - 1);
_Equalizers["EqualizerPlayer" + i].Update(CSound.ToneWeigth(i - 1));
CRecord.AnalyzeBuffer(i - 1);
_Equalizers["EqualizerPlayer" + i].Update(CRecord.ToneWeigth(i - 1));
}
return true;
}
@@ -555,7 +555,7 @@ namespace Vocaluxe.Screens
public override void OnShow()
{
base.OnShow();
CSound.RecordStart();
CRecord.RecordStart();
_NameSelections[_NameSelection].Init();
_LoadProfiles();
@@ -565,7 +565,7 @@ namespace Vocaluxe.Screens
public override void OnClose()
{
base.OnClose();
CSound.RecordStop();
CRecord.RecordStop();
}
public override bool Draw()
+9 -9
View File
@@ -213,7 +213,7 @@ namespace Vocaluxe.Screens
public override bool UpdateGame()
{
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
CSound.AnalyzeBuffer(i);
CRecord.AnalyzeBuffer(i);
if (_DelayTest.Running)
{
@@ -228,8 +228,8 @@ namespace Vocaluxe.Screens
int player = _SelectSlides[_SelectSlideRecordChannel1].Selection;
if (player > 0)
{
_ChannelEnergy[0] = CSound.RecordGetMaxVolume(player - 1);
_Equalizers[_EqualizerChannel1].Update(CSound.ToneWeigth(player - 1));
_ChannelEnergy[0] = CRecord.RecordGetMaxVolume(player - 1);
_Equalizers[_EqualizerChannel1].Update(CRecord.ToneWeigth(player - 1));
}
else
_Equalizers[_EqualizerChannel1].Reset();
@@ -238,8 +238,8 @@ namespace Vocaluxe.Screens
player = _SelectSlides[_SelectSlideRecordChannel2].Selection;
if (player > 0)
{
_ChannelEnergy[1] = CSound.RecordGetMaxVolume(player - 1);
_Equalizers[_EqualizerChannel2].Update(CSound.ToneWeigth(player - 1));
_ChannelEnergy[1] = CRecord.RecordGetMaxVolume(player - 1);
_Equalizers[_EqualizerChannel2].Update(CRecord.ToneWeigth(player - 1));
}
else
_Equalizers[_EqualizerChannel2].Reset();
@@ -266,7 +266,7 @@ namespace Vocaluxe.Screens
_DeviceNr = -1;
_Devices = CSound.RecordGetDevices();
_Devices = CRecord.RecordGetDevices();
if (_Devices != null)
{
_DeviceNr = 0;
@@ -337,7 +337,7 @@ namespace Vocaluxe.Screens
public override void OnClose()
{
base.OnClose();
CSound.RecordStop();
CRecord.RecordStop();
_DelayTest.Reset();
CBackgroundMusic.Disabled = false;
@@ -363,7 +363,7 @@ namespace Vocaluxe.Screens
if (_Devices == null)
return;
CSound.RecordStop();
CRecord.RecordStop();
_SetMicConfig();
if (_CheckMicConfig())
@@ -389,7 +389,7 @@ namespace Vocaluxe.Screens
}
CConfig.SaveConfig();
}
CSound.RecordStart();
CRecord.RecordStart();
}
private void _SetPlayerColors()
+2 -2
View File
@@ -556,7 +556,7 @@ namespace Vocaluxe.Screens
{
if (_CurrentStream > -1)
CSound.FadeAndClose(_CurrentStream, 0f, 0.5f);
CSound.RecordStop();
CRecord.RecordStop();
if (_CurrentVideo != -1)
{
CVideo.Close(_CurrentVideo);
@@ -738,7 +738,7 @@ namespace Vocaluxe.Screens
{
_PrepareTimeLine();
CSound.Play(_CurrentStream);
CSound.RecordStart();
CRecord.RecordStart();
if (_Webcam)
CWebcam.Start();
}
+1
View File
@@ -216,6 +216,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Base\CBackgroundMusic.cs" />
<Compile Include="Base\CRecord.cs" />
<Compile Include="COSFunctions.cs" />
<Compile Include="Lib\Sound\Playback\GstreamerSharp\CGstreamerSharpAudioStream.cs" />
<Compile Include="Lib\Sound\Playback\OpenAL\COpenAlStream.cs" />