Rename CRecord methods (remove prefix)
Document IRecord
This commit is contained in:
1 parent
e20bd6e90b
commit
12ba762cb9
15 files changed
+111
-48
No files matched your search
@@ -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
|
||||
/// <returns></returns>
|
||||
public static bool IsMicConfig()
|
||||
{
|
||||
ReadOnlyCollection<CRecordDevice> devices = CRecord.RecordGetDevices();
|
||||
ReadOnlyCollection<CRecordDevice> devices = CRecord.GetDevices();
|
||||
if (devices == null)
|
||||
return false;
|
||||
|
||||
@@ -641,7 +640,7 @@ namespace Vocaluxe.Base
|
||||
/// <returns></returns>
|
||||
public static bool IsMicConfig(int player)
|
||||
{
|
||||
ReadOnlyCollection<CRecordDevice> devices = CRecord.RecordGetDevices();
|
||||
ReadOnlyCollection<CRecordDevice> 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<CRecordDevice> devices = CRecord.RecordGetDevices();
|
||||
ReadOnlyCollection<CRecordDevice> devices = CRecord.GetDevices();
|
||||
if (devices == null)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -626,7 +626,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
public int GetToneAbs(int playerNr)
|
||||
{
|
||||
return CRecord.RecordGetToneAbs(playerNr);
|
||||
return CRecord.GetToneAbs(playerNr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -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<CRecordDevice> RecordGetDevices()
|
||||
public static ReadOnlyCollection<CRecordDevice> GetDevices()
|
||||
{
|
||||
ReadOnlyCollection<CRecordDevice> devices = _Record.RecordDevices();
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Vocaluxe
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -61,21 +61,87 @@ namespace Vocaluxe.Lib.Sound.Record
|
||||
|
||||
interface IRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes recording
|
||||
/// </summary>
|
||||
/// <returns>True on success</returns>
|
||||
bool Init();
|
||||
void CloseAll();
|
||||
|
||||
/// <summary>
|
||||
/// Closes recording. You must not use it before calling Init again
|
||||
/// </summary>
|
||||
void Close();
|
||||
|
||||
/// <summary>
|
||||
/// Starts recording on all enabled devices (PlayerChannelX set)
|
||||
/// </summary>
|
||||
/// <returns>True on success, false on error or not initialized</returns>
|
||||
bool Start();
|
||||
|
||||
/// <summary>
|
||||
/// Stops recording on all devices
|
||||
/// </summary>
|
||||
/// <returns>True on success, false on error or not initialized</returns>
|
||||
bool Stop();
|
||||
|
||||
/// <summary>
|
||||
/// Analyzes the buffer for the given player
|
||||
/// </summary>
|
||||
/// <param name="player"></param>
|
||||
void AnalyzeBuffer(int player);
|
||||
|
||||
/// <summary>
|
||||
/// Get the current raw tone value for a player
|
||||
/// </summary>
|
||||
/// <param name="player">0-based player index</param>
|
||||
/// <returns>Tone between 0 and NumHalftones-1</returns>
|
||||
int GetToneAbs(int player);
|
||||
|
||||
/// <summary>
|
||||
/// Get the current tone value for a player
|
||||
/// </summary>
|
||||
/// <param name="player">0-based player index</param>
|
||||
/// <returns>Tone between 0 and 11 (one octave)</returns>
|
||||
int GetTone(int player);
|
||||
|
||||
/// <summary>
|
||||
/// DEBUG ONLY: Sets a tone for a player
|
||||
/// </summary>
|
||||
/// <param name="player">0-based player index</param>
|
||||
/// <param name="tone">Raw tone value between 0 and NumHalfTones-1</param>
|
||||
void SetTone(int player, int tone);
|
||||
|
||||
/// <summary>
|
||||
/// Get the current maximum input volume (normalized) for a player
|
||||
/// </summary>
|
||||
/// <param name="player">0-based player index</param>
|
||||
/// <returns>Maximum volume between 0 and 1</returns>
|
||||
float GetMaxVolume(int player);
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the current tone is valid. That includes, if maximum volume is higher than the threshold
|
||||
/// </summary>
|
||||
/// <param name="player">0-based player index</param>
|
||||
/// <returns>True if tone is detected and volume higher than threshold</returns>
|
||||
bool ToneValid(int player);
|
||||
int NumHalfTones(int player);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of half tones used for the raw tone detection
|
||||
/// </summary>
|
||||
/// <returns>number of half tones used for the raw tone detection</returns>
|
||||
int NumHalfTones();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the tone weights for a player as an array of normalized values for each halftone
|
||||
/// </summary>
|
||||
/// <param name="player">0-based player index</param>
|
||||
/// <returns>Array of values (0-1) with one entry per halftone</returns>
|
||||
float[] ToneWeigth(int player);
|
||||
|
||||
/// <summary>
|
||||
/// Readonly list of all detected record devices. Modifying the devices should not be done when record is running.
|
||||
/// </summary>
|
||||
/// <returns>Readonly list of all detected record devices</returns>
|
||||
ReadOnlyCollection<CRecordDevice> RecordDevices();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// Stop all voice capturing streams and terminate PortAudio
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
+2
-2
@@ -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();
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user