diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs
index 33f51fac..60731994 100644
--- a/Vocaluxe/Base/CConfig.cs
+++ b/Vocaluxe/Base/CConfig.cs
@@ -291,7 +291,6 @@ namespace Vocaluxe.Base
#endregion Video
#region Record
- MicConfig = new SMicConfig[CSettings.MaxNumPlayer];
for (int p = 1; p <= CSettings.MaxNumPlayer; p++)
{
MicConfig[p - 1] = new SMicConfig(0);
@@ -627,7 +626,7 @@ namespace Vocaluxe.Base
///
public static bool IsMicConfig()
{
- ReadOnlyCollection devices = CRecord.RecordGetDevices();
+ ReadOnlyCollection devices = CRecord.GetDevices();
if (devices == null)
return false;
@@ -641,7 +640,7 @@ namespace Vocaluxe.Base
///
public static bool IsMicConfig(int player)
{
- ReadOnlyCollection devices = CRecord.RecordGetDevices();
+ ReadOnlyCollection devices = CRecord.GetDevices();
if (devices == null)
return false;
@@ -668,7 +667,7 @@ namespace Vocaluxe.Base
{
//Look for (usb-)mic
//SRecordDevice[] Devices = new SRecordDevice[CRecord.RecordGetDevices().Length];
- ReadOnlyCollection devices = CRecord.RecordGetDevices();
+ ReadOnlyCollection devices = CRecord.GetDevices();
if (devices == null)
return false;
diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs
index 27c77ecb..46df686f 100644
--- a/Vocaluxe/Base/CGame.cs
+++ b/Vocaluxe/Base/CGame.cs
@@ -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 && (CRecord.RecordToneValid(p)
+ if (notes[note].PointsForBeat > 0 && (CRecord.ToneValid(p)
#if DEBUG_HIT
|| true
#endif
))
{
int tone = notes[note].Tone;
- int tonePlayer = CRecord.RecordGetTone(p);
+ int tonePlayer = CRecord.GetTone(p);
while (tonePlayer - tone > 6)
tonePlayer -= 12;
diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs
index d5e50d25..9befefb8 100644
--- a/Vocaluxe/Base/CGraphics.cs
+++ b/Vocaluxe/Base/CGraphics.cs
@@ -616,10 +616,10 @@ namespace Vocaluxe.Base
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2)
{
- 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"));
+ debugOutput.Add(CRecord.GetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00"));
+ debugOutput.Add(CRecord.GetMaxVolume(0).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P1: 0.000"));
+ debugOutput.Add(CRecord.GetToneAbs(1).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P2: 00"));
+ debugOutput.Add(CRecord.GetMaxVolume(1).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P2: 0.000"));
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3)
{
diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs
index 70798269..c0c44c4b 100644
--- a/Vocaluxe/Base/CMain.cs
+++ b/Vocaluxe/Base/CMain.cs
@@ -626,7 +626,7 @@ namespace Vocaluxe.Base
{
public int GetToneAbs(int playerNr)
{
- return CRecord.RecordGetToneAbs(playerNr);
+ return CRecord.GetToneAbs(playerNr);
}
}
diff --git a/Vocaluxe/Base/CRecord.cs b/Vocaluxe/Base/CRecord.cs
index 5493fd58..cbebccea 100644
--- a/Vocaluxe/Base/CRecord.cs
+++ b/Vocaluxe/Base/CRecord.cs
@@ -10,7 +10,7 @@ namespace Vocaluxe.Base
{
private static IRecord _Record;
- public static void RecordInit()
+ public static void Init()
{
switch (CConfig.RecordLib)
{
@@ -27,17 +27,17 @@ namespace Vocaluxe.Base
}
}
- public static void RecordCloseAll()
+ public static void Close()
{
- _Record.CloseAll();
+ _Record.Close();
}
- public static bool RecordStart()
+ public static bool Start()
{
return _Record.Start();
}
- public static bool RecordStop()
+ public static bool Stop()
{
return _Record.Stop();
}
@@ -47,34 +47,34 @@ namespace Vocaluxe.Base
_Record.AnalyzeBuffer(player);
}
- public static int RecordGetToneAbs(int player)
+ public static int GetToneAbs(int player)
{
return _Record.GetToneAbs(player);
}
- public static int RecordGetTone(int player)
+ public static int GetTone(int player)
{
return _Record.GetTone(player);
}
- public static void RecordSetTone(int player, int tone)
+ public static void SetTone(int player, int tone)
{
_Record.SetTone(player, tone);
}
- public static bool RecordToneValid(int player)
+ public static bool ToneValid(int player)
{
return _Record.ToneValid(player);
}
- public static float RecordGetMaxVolume(int player)
+ public static float GetMaxVolume(int player)
{
return _Record.GetMaxVolume(player);
}
public static int NumHalfTones(int player)
{
- return _Record.NumHalfTones(player);
+ return _Record.NumHalfTones();
}
public static float[] ToneWeigth(int player)
@@ -82,7 +82,7 @@ namespace Vocaluxe.Base
return _Record.ToneWeigth(player);
}
- public static ReadOnlyCollection RecordGetDevices()
+ public static ReadOnlyCollection GetDevices()
{
ReadOnlyCollection devices = _Record.RecordDevices();
diff --git a/Vocaluxe/COSFunctions.cs b/Vocaluxe/COSFunctions.cs
index c72b6c46..472956c6 100644
--- a/Vocaluxe/COSFunctions.cs
+++ b/Vocaluxe/COSFunctions.cs
@@ -1,8 +1,5 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
namespace Vocaluxe
{
diff --git a/Vocaluxe/Lib/Sound/Record/CBuffer.cs b/Vocaluxe/Lib/Sound/Record/CBuffer.cs
index cbf72706..3ead34bc 100644
--- a/Vocaluxe/Lib/Sound/Record/CBuffer.cs
+++ b/Vocaluxe/Lib/Sound/Record/CBuffer.cs
@@ -5,8 +5,9 @@ namespace Vocaluxe.Lib.Sound.Record
{
class CBuffer : IDisposable
{
- private const double _BaseToneFreq = 65.4064;
- public const int NumHalfTones = 17;
+ //Half tones: C C♯ D Eb E F F♯ G G♯ A Bb B
+ private const double _BaseToneFreq = 65.4064; // lowest (half-)tone to analyze (C2 = 65.4064 Hz)
+ public const int NumHalfTones = 17; //Number of halftone to analyze C2-E3 (TODO: use more/full octaves?)
private const int _AnalysisBufLen = 4096;
private const int _AnalysisByteBufLen = _AnalysisBufLen * 2;
diff --git a/Vocaluxe/Lib/Sound/Record/CDelayTest.cs b/Vocaluxe/Lib/Sound/Record/CDelayTest.cs
index 711484d3..a9974c40 100644
--- a/Vocaluxe/Lib/Sound/Record/CDelayTest.cs
+++ b/Vocaluxe/Lib/Sound/Record/CDelayTest.cs
@@ -82,7 +82,7 @@ namespace Vocaluxe.Lib.Sound.Record
{
if (_DelaysChannel[i].Channel < 0 || _DelaysChannel[i].Finished)
continue;
- if (CRecord.RecordGetMaxVolume(_DelaysChannel[i].Channel) > 0.1f && CRecord.RecordGetTone(_DelaysChannel[i].Channel) == 9)
+ if (CRecord.GetMaxVolume(_DelaysChannel[i].Channel) > 0.1f && CRecord.GetTone(_DelaysChannel[i].Channel) == 9)
{
Delays[i] = (int)_Timer.ElapsedMilliseconds;
_DelaysChannel[i].Finished = true;
diff --git a/Vocaluxe/Lib/Sound/Record/DirectSound/CDirectSoundRecord.cs b/Vocaluxe/Lib/Sound/Record/DirectSound/CDirectSoundRecord.cs
index 5707db98..84e54518 100644
--- a/Vocaluxe/Lib/Sound/Record/DirectSound/CDirectSoundRecord.cs
+++ b/Vocaluxe/Lib/Sound/Record/DirectSound/CDirectSoundRecord.cs
@@ -66,7 +66,7 @@ namespace Vocaluxe.Lib.Sound.Record.DirectSound
return true;
}
- public void CloseAll()
+ public void Close()
{
if (_Initialized)
{
@@ -173,7 +173,7 @@ namespace Vocaluxe.Lib.Sound.Record.DirectSound
return _Devices.AsReadOnly();
}
- public int NumHalfTones(int player)
+ public int NumHalfTones()
{
if (!_Initialized)
return 0;
diff --git a/Vocaluxe/Lib/Sound/Record/IRecord.cs b/Vocaluxe/Lib/Sound/Record/IRecord.cs
index 6812e7c0..04899008 100644
--- a/Vocaluxe/Lib/Sound/Record/IRecord.cs
+++ b/Vocaluxe/Lib/Sound/Record/IRecord.cs
@@ -61,21 +61,87 @@ namespace Vocaluxe.Lib.Sound.Record
interface IRecord
{
+ ///
+ /// Initializes recording
+ ///
+ /// True on success
bool Init();
- void CloseAll();
+ ///
+ /// Closes recording. You must not use it before calling Init again
+ ///
+ void Close();
+
+ ///
+ /// Starts recording on all enabled devices (PlayerChannelX set)
+ ///
+ /// True on success, false on error or not initialized
bool Start();
+
+ ///
+ /// Stops recording on all devices
+ ///
+ /// True on success, false on error or not initialized
bool Stop();
+
+ ///
+ /// Analyzes the buffer for the given player
+ ///
+ ///
void AnalyzeBuffer(int player);
+ ///
+ /// Get the current raw tone value for a player
+ ///
+ /// 0-based player index
+ /// Tone between 0 and NumHalftones-1
int GetToneAbs(int player);
+
+ ///
+ /// Get the current tone value for a player
+ ///
+ /// 0-based player index
+ /// Tone between 0 and 11 (one octave)
int GetTone(int player);
+
+ ///
+ /// DEBUG ONLY: Sets a tone for a player
+ ///
+ /// 0-based player index
+ /// Raw tone value between 0 and NumHalfTones-1
void SetTone(int player, int tone);
+
+ ///
+ /// Get the current maximum input volume (normalized) for a player
+ ///
+ /// 0-based player index
+ /// Maximum volume between 0 and 1
float GetMaxVolume(int player);
+
+ ///
+ /// Returns whether the current tone is valid. That includes, if maximum volume is higher than the threshold
+ ///
+ /// 0-based player index
+ /// True if tone is detected and volume higher than threshold
bool ToneValid(int player);
- int NumHalfTones(int player);
+
+ ///
+ /// Returns the number of half tones used for the raw tone detection
+ ///
+ /// number of half tones used for the raw tone detection
+ int NumHalfTones();
+
+ ///
+ /// Returns the tone weights for a player as an array of normalized values for each halftone
+ ///
+ /// 0-based player index
+ /// Array of values (0-1) with one entry per halftone
float[] ToneWeigth(int player);
+ ///
+ /// Readonly list of all detected record devices. Modifying the devices should not be done when record is running.
+ ///
+ /// Readonly list of all detected record devices
ReadOnlyCollection RecordDevices();
}
}
\ No newline at end of file
diff --git a/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs b/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs
index 156b0938..8c9e8dec 100644
--- a/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs
+++ b/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs
@@ -56,7 +56,7 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
try
{
if (_Initialized)
- CloseAll();
+ Close();
if (_ErrorCheck("Initialize", PortAudioSharp.PortAudio.Pa_Initialize()))
return false;
@@ -164,7 +164,7 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
///
/// Stop all voice capturing streams and terminate PortAudio
///
- public void CloseAll()
+ public void Close()
{
Stop();
@@ -229,7 +229,7 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
return _Buffer[player].ToneValid;
}
- public int NumHalfTones(int player)
+ public int NumHalfTones()
{
if (!_Initialized)
return 0;
diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs
index 526cf20a..6676cd78 100644
--- a/Vocaluxe/Program.cs
+++ b/Vocaluxe/Program.cs
@@ -126,7 +126,7 @@ namespace Vocaluxe
// Init Record
CLog.StartBenchmark(0, "Init Record");
- CRecord.RecordInit();
+ CRecord.Init();
CLog.StopBenchmark(0, "Init Record");
Application.DoEvents();
@@ -243,7 +243,7 @@ namespace Vocaluxe
{
CVocaluxeServer.Close();
CController.Close();
- CRecord.RecordCloseAll();
+ CRecord.Close();
CSound.CloseAllStreams();
CVideo.CloseAll();
CDraw.Unload();
diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs
index dc5165ce..f3789e5c 100644
--- a/Vocaluxe/Screens/CScreenNames.cs
+++ b/Vocaluxe/Screens/CScreenNames.cs
@@ -555,7 +555,7 @@ namespace Vocaluxe.Screens
public override void OnShow()
{
base.OnShow();
- CRecord.RecordStart();
+ CRecord.Start();
_NameSelections[_NameSelection].Init();
_LoadProfiles();
@@ -565,7 +565,7 @@ namespace Vocaluxe.Screens
public override void OnClose()
{
base.OnClose();
- CRecord.RecordStop();
+ CRecord.Stop();
}
public override bool Draw()
diff --git a/Vocaluxe/Screens/CScreenOptionsRecord.cs b/Vocaluxe/Screens/CScreenOptionsRecord.cs
index 7eead339..1a7941c8 100644
--- a/Vocaluxe/Screens/CScreenOptionsRecord.cs
+++ b/Vocaluxe/Screens/CScreenOptionsRecord.cs
@@ -228,7 +228,7 @@ namespace Vocaluxe.Screens
int player = _SelectSlides[_SelectSlideRecordChannel1].Selection;
if (player > 0)
{
- _ChannelEnergy[0] = CRecord.RecordGetMaxVolume(player - 1);
+ _ChannelEnergy[0] = CRecord.GetMaxVolume(player - 1);
_Equalizers[_EqualizerChannel1].Update(CRecord.ToneWeigth(player - 1));
}
else
@@ -238,7 +238,7 @@ namespace Vocaluxe.Screens
player = _SelectSlides[_SelectSlideRecordChannel2].Selection;
if (player > 0)
{
- _ChannelEnergy[1] = CRecord.RecordGetMaxVolume(player - 1);
+ _ChannelEnergy[1] = CRecord.GetMaxVolume(player - 1);
_Equalizers[_EqualizerChannel2].Update(CRecord.ToneWeigth(player - 1));
}
else
@@ -266,7 +266,7 @@ namespace Vocaluxe.Screens
_DeviceNr = -1;
- _Devices = CRecord.RecordGetDevices();
+ _Devices = CRecord.GetDevices();
if (_Devices != null)
{
_DeviceNr = 0;
@@ -337,7 +337,7 @@ namespace Vocaluxe.Screens
public override void OnClose()
{
base.OnClose();
- CRecord.RecordStop();
+ CRecord.Stop();
_DelayTest.Reset();
CBackgroundMusic.Disabled = false;
@@ -363,7 +363,7 @@ namespace Vocaluxe.Screens
if (_Devices == null)
return;
- CRecord.RecordStop();
+ CRecord.Stop();
_SetMicConfig();
if (_CheckMicConfig())
@@ -389,7 +389,7 @@ namespace Vocaluxe.Screens
}
CConfig.SaveConfig();
}
- CRecord.RecordStart();
+ CRecord.Start();
}
private void _SetPlayerColors()
diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs
index 20fff366..9b58c99a 100644
--- a/Vocaluxe/Screens/CScreenSing.cs
+++ b/Vocaluxe/Screens/CScreenSing.cs
@@ -556,7 +556,7 @@ namespace Vocaluxe.Screens
{
if (_CurrentStream > -1)
CSound.FadeAndClose(_CurrentStream, 0f, 0.5f);
- CRecord.RecordStop();
+ CRecord.Stop();
if (_CurrentVideo != -1)
{
CVideo.Close(_CurrentVideo);
@@ -738,7 +738,7 @@ namespace Vocaluxe.Screens
{
_PrepareTimeLine();
CSound.Play(_CurrentStream);
- CRecord.RecordStart();
+ CRecord.Start();
if (_Webcam)
CWebcam.Start();
}