Rename CRecord methods (remove prefix)

Document IRecord
This commit is contained in:
Flamefire committed 2014-03-16 11:25:48 +01:00
1 parent e20bd6e90b
commit 12ba762cb9
15 files changed
+111 -48

No files matched your search

+3 -4
View File
@@ -291,7 +291,6 @@ namespace Vocaluxe.Base
#endregion Video #endregion Video
#region Record #region Record
MicConfig = new SMicConfig[CSettings.MaxNumPlayer];
for (int p = 1; p <= CSettings.MaxNumPlayer; p++) for (int p = 1; p <= CSettings.MaxNumPlayer; p++)
{ {
MicConfig[p - 1] = new SMicConfig(0); MicConfig[p - 1] = new SMicConfig(0);
@@ -627,7 +626,7 @@ namespace Vocaluxe.Base
/// <returns></returns> /// <returns></returns>
public static bool IsMicConfig() public static bool IsMicConfig()
{ {
ReadOnlyCollection<CRecordDevice> devices = CRecord.RecordGetDevices(); ReadOnlyCollection<CRecordDevice> devices = CRecord.GetDevices();
if (devices == null) if (devices == null)
return false; return false;
@@ -641,7 +640,7 @@ namespace Vocaluxe.Base
/// <returns></returns> /// <returns></returns>
public static bool IsMicConfig(int player) public static bool IsMicConfig(int player)
{ {
ReadOnlyCollection<CRecordDevice> devices = CRecord.RecordGetDevices(); ReadOnlyCollection<CRecordDevice> devices = CRecord.GetDevices();
if (devices == null) if (devices == null)
return false; return false;
@@ -668,7 +667,7 @@ namespace Vocaluxe.Base
{ {
//Look for (usb-)mic //Look for (usb-)mic
//SRecordDevice[] Devices = new SRecordDevice[CRecord.RecordGetDevices().Length]; //SRecordDevice[] Devices = new SRecordDevice[CRecord.RecordGetDevices().Length];
ReadOnlyCollection<CRecordDevice> devices = CRecord.RecordGetDevices(); ReadOnlyCollection<CRecordDevice> devices = CRecord.GetDevices();
if (devices == null) if (devices == null)
return false; return false;
+2 -2
View File
@@ -271,14 +271,14 @@ namespace Vocaluxe.Base
if (line == lines.Length - 1 && beat == lines[line].LastNoteBeat) if (line == lines.Length - 1 && beat == lines[line].LastNoteBeat)
Players[p].SongFinished = true; Players[p].SongFinished = true;
if (notes[note].PointsForBeat > 0 && (CRecord.RecordToneValid(p) if (notes[note].PointsForBeat > 0 && (CRecord.ToneValid(p)
#if DEBUG_HIT #if DEBUG_HIT
|| true || true
#endif #endif
)) ))
{ {
int tone = notes[note].Tone; int tone = notes[note].Tone;
int tonePlayer = CRecord.RecordGetTone(p); int tonePlayer = CRecord.GetTone(p);
while (tonePlayer - tone > 6) while (tonePlayer - tone > 6)
tonePlayer -= 12; tonePlayer -= 12;
+4 -4
View File
@@ -616,10 +616,10 @@ namespace Vocaluxe.Base
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2) if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL2)
{ {
debugOutput.Add(CRecord.RecordGetToneAbs(0).ToString(CLanguage.Translate("TR_DEBUG_TONE_ABS") + " P1: 00")); debugOutput.Add(CRecord.GetToneAbs(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.GetMaxVolume(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.GetToneAbs(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.GetMaxVolume(1).ToString(CLanguage.Translate("TR_DEBUG_MAX_VOLUME") + " P2: 0.000"));
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3) if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL3)
{ {
+1 -1
View File
@@ -626,7 +626,7 @@ namespace Vocaluxe.Base
{ {
public int GetToneAbs(int playerNr) public int GetToneAbs(int playerNr)
{ {
return CRecord.RecordGetToneAbs(playerNr); return CRecord.GetToneAbs(playerNr);
} }
} }
+12 -12
View File
@@ -10,7 +10,7 @@ namespace Vocaluxe.Base
{ {
private static IRecord _Record; private static IRecord _Record;
public static void RecordInit() public static void Init()
{ {
switch (CConfig.RecordLib) 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(); return _Record.Start();
} }
public static bool RecordStop() public static bool Stop()
{ {
return _Record.Stop(); return _Record.Stop();
} }
@@ -47,34 +47,34 @@ namespace Vocaluxe.Base
_Record.AnalyzeBuffer(player); _Record.AnalyzeBuffer(player);
} }
public static int RecordGetToneAbs(int player) public static int GetToneAbs(int player)
{ {
return _Record.GetToneAbs(player); return _Record.GetToneAbs(player);
} }
public static int RecordGetTone(int player) public static int GetTone(int player)
{ {
return _Record.GetTone(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); _Record.SetTone(player, tone);
} }
public static bool RecordToneValid(int player) public static bool ToneValid(int player)
{ {
return _Record.ToneValid(player); return _Record.ToneValid(player);
} }
public static float RecordGetMaxVolume(int player) public static float GetMaxVolume(int player)
{ {
return _Record.GetMaxVolume(player); return _Record.GetMaxVolume(player);
} }
public static int NumHalfTones(int player) public static int NumHalfTones(int player)
{ {
return _Record.NumHalfTones(player); return _Record.NumHalfTones();
} }
public static float[] ToneWeigth(int player) public static float[] ToneWeigth(int player)
@@ -82,7 +82,7 @@ namespace Vocaluxe.Base
return _Record.ToneWeigth(player); return _Record.ToneWeigth(player);
} }
public static ReadOnlyCollection<CRecordDevice> RecordGetDevices() public static ReadOnlyCollection<CRecordDevice> GetDevices()
{ {
ReadOnlyCollection<CRecordDevice> devices = _Record.RecordDevices(); ReadOnlyCollection<CRecordDevice> devices = _Record.RecordDevices();
-3
View File
@@ -1,8 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
namespace Vocaluxe namespace Vocaluxe
{ {
+3 -2
View File
@@ -5,8 +5,9 @@ namespace Vocaluxe.Lib.Sound.Record
{ {
class CBuffer : IDisposable class CBuffer : IDisposable
{ {
private const double _BaseToneFreq = 65.4064; //Half tones: C C♯ D Eb E F F♯ G G♯ A Bb B
public const int NumHalfTones = 17; 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 _AnalysisBufLen = 4096;
private const int _AnalysisByteBufLen = _AnalysisBufLen * 2; private const int _AnalysisByteBufLen = _AnalysisBufLen * 2;
+1 -1
View File
@@ -82,7 +82,7 @@ namespace Vocaluxe.Lib.Sound.Record
{ {
if (_DelaysChannel[i].Channel < 0 || _DelaysChannel[i].Finished) if (_DelaysChannel[i].Channel < 0 || _DelaysChannel[i].Finished)
continue; 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; Delays[i] = (int)_Timer.ElapsedMilliseconds;
_DelaysChannel[i].Finished = true; _DelaysChannel[i].Finished = true;
@@ -66,7 +66,7 @@ namespace Vocaluxe.Lib.Sound.Record.DirectSound
return true; return true;
} }
public void CloseAll() public void Close()
{ {
if (_Initialized) if (_Initialized)
{ {
@@ -173,7 +173,7 @@ namespace Vocaluxe.Lib.Sound.Record.DirectSound
return _Devices.AsReadOnly(); return _Devices.AsReadOnly();
} }
public int NumHalfTones(int player) public int NumHalfTones()
{ {
if (!_Initialized) if (!_Initialized)
return 0; return 0;
+68 -2
View File
@@ -61,21 +61,87 @@ namespace Vocaluxe.Lib.Sound.Record
interface IRecord interface IRecord
{ {
/// <summary>
/// Initializes recording
/// </summary>
/// <returns>True on success</returns>
bool Init(); 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(); bool Start();
/// <summary>
/// Stops recording on all devices
/// </summary>
/// <returns>True on success, false on error or not initialized</returns>
bool Stop(); bool Stop();
/// <summary>
/// Analyzes the buffer for the given player
/// </summary>
/// <param name="player"></param>
void AnalyzeBuffer(int player); 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); 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); 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); 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); 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); 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); 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(); ReadOnlyCollection<CRecordDevice> RecordDevices();
} }
} }
@@ -56,7 +56,7 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
try try
{ {
if (_Initialized) if (_Initialized)
CloseAll(); Close();
if (_ErrorCheck("Initialize", PortAudioSharp.PortAudio.Pa_Initialize())) if (_ErrorCheck("Initialize", PortAudioSharp.PortAudio.Pa_Initialize()))
return false; return false;
@@ -164,7 +164,7 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
/// <summary> /// <summary>
/// Stop all voice capturing streams and terminate PortAudio /// Stop all voice capturing streams and terminate PortAudio
/// </summary> /// </summary>
public void CloseAll() public void Close()
{ {
Stop(); Stop();
@@ -229,7 +229,7 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
return _Buffer[player].ToneValid; return _Buffer[player].ToneValid;
} }
public int NumHalfTones(int player) public int NumHalfTones()
{ {
if (!_Initialized) if (!_Initialized)
return 0; return 0;
+2 -2
View File
@@ -126,7 +126,7 @@ namespace Vocaluxe
// Init Record // Init Record
CLog.StartBenchmark(0, "Init Record"); CLog.StartBenchmark(0, "Init Record");
CRecord.RecordInit(); CRecord.Init();
CLog.StopBenchmark(0, "Init Record"); CLog.StopBenchmark(0, "Init Record");
Application.DoEvents(); Application.DoEvents();
@@ -243,7 +243,7 @@ namespace Vocaluxe
{ {
CVocaluxeServer.Close(); CVocaluxeServer.Close();
CController.Close(); CController.Close();
CRecord.RecordCloseAll(); CRecord.Close();
CSound.CloseAllStreams(); CSound.CloseAllStreams();
CVideo.CloseAll(); CVideo.CloseAll();
CDraw.Unload(); CDraw.Unload();
+2 -2
View File
@@ -555,7 +555,7 @@ namespace Vocaluxe.Screens
public override void OnShow() public override void OnShow()
{ {
base.OnShow(); base.OnShow();
CRecord.RecordStart(); CRecord.Start();
_NameSelections[_NameSelection].Init(); _NameSelections[_NameSelection].Init();
_LoadProfiles(); _LoadProfiles();
@@ -565,7 +565,7 @@ namespace Vocaluxe.Screens
public override void OnClose() public override void OnClose()
{ {
base.OnClose(); base.OnClose();
CRecord.RecordStop(); CRecord.Stop();
} }
public override bool Draw() public override bool Draw()
+6 -6
View File
@@ -228,7 +228,7 @@ namespace Vocaluxe.Screens
int player = _SelectSlides[_SelectSlideRecordChannel1].Selection; int player = _SelectSlides[_SelectSlideRecordChannel1].Selection;
if (player > 0) if (player > 0)
{ {
_ChannelEnergy[0] = CRecord.RecordGetMaxVolume(player - 1); _ChannelEnergy[0] = CRecord.GetMaxVolume(player - 1);
_Equalizers[_EqualizerChannel1].Update(CRecord.ToneWeigth(player - 1)); _Equalizers[_EqualizerChannel1].Update(CRecord.ToneWeigth(player - 1));
} }
else else
@@ -238,7 +238,7 @@ namespace Vocaluxe.Screens
player = _SelectSlides[_SelectSlideRecordChannel2].Selection; player = _SelectSlides[_SelectSlideRecordChannel2].Selection;
if (player > 0) if (player > 0)
{ {
_ChannelEnergy[1] = CRecord.RecordGetMaxVolume(player - 1); _ChannelEnergy[1] = CRecord.GetMaxVolume(player - 1);
_Equalizers[_EqualizerChannel2].Update(CRecord.ToneWeigth(player - 1)); _Equalizers[_EqualizerChannel2].Update(CRecord.ToneWeigth(player - 1));
} }
else else
@@ -266,7 +266,7 @@ namespace Vocaluxe.Screens
_DeviceNr = -1; _DeviceNr = -1;
_Devices = CRecord.RecordGetDevices(); _Devices = CRecord.GetDevices();
if (_Devices != null) if (_Devices != null)
{ {
_DeviceNr = 0; _DeviceNr = 0;
@@ -337,7 +337,7 @@ namespace Vocaluxe.Screens
public override void OnClose() public override void OnClose()
{ {
base.OnClose(); base.OnClose();
CRecord.RecordStop(); CRecord.Stop();
_DelayTest.Reset(); _DelayTest.Reset();
CBackgroundMusic.Disabled = false; CBackgroundMusic.Disabled = false;
@@ -363,7 +363,7 @@ namespace Vocaluxe.Screens
if (_Devices == null) if (_Devices == null)
return; return;
CRecord.RecordStop(); CRecord.Stop();
_SetMicConfig(); _SetMicConfig();
if (_CheckMicConfig()) if (_CheckMicConfig())
@@ -389,7 +389,7 @@ namespace Vocaluxe.Screens
} }
CConfig.SaveConfig(); CConfig.SaveConfig();
} }
CRecord.RecordStart(); CRecord.Start();
} }
private void _SetPlayerColors() private void _SetPlayerColors()
+2 -2
View File
@@ -556,7 +556,7 @@ namespace Vocaluxe.Screens
{ {
if (_CurrentStream > -1) if (_CurrentStream > -1)
CSound.FadeAndClose(_CurrentStream, 0f, 0.5f); CSound.FadeAndClose(_CurrentStream, 0f, 0.5f);
CRecord.RecordStop(); CRecord.Stop();
if (_CurrentVideo != -1) if (_CurrentVideo != -1)
{ {
CVideo.Close(_CurrentVideo); CVideo.Close(_CurrentVideo);
@@ -738,7 +738,7 @@ namespace Vocaluxe.Screens
{ {
_PrepareTimeLine(); _PrepareTimeLine();
CSound.Play(_CurrentStream); CSound.Play(_CurrentStream);
CRecord.RecordStart(); CRecord.Start();
if (_Webcam) if (_Webcam)
CWebcam.Start(); CWebcam.Start();
} }