Created
May 15, 2016 12:47
-
-
Save yuka1984/de25c7396611186ea3a203ff5ad4a4dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class SpeakerTest | |
{ | |
private IVoiceCapture _capture; | |
private IVoiceSpeaker _speaker; | |
[SetUp] | |
public void Setup() | |
{ | |
// サンプルレート8000にて16bits/1channelで250msec毎にデータを受け取る。 | |
_capture = new VoiceCapture(8000, 250); | |
// サンプルレート8000にて16bits/1channelの音声データを再生する。 | |
_speaker = new VoiceSpeaker(8000); | |
} | |
[TearDown] | |
public void Tear() | |
{ | |
_capture.Dispose(); | |
} | |
[Test] | |
public void CaptureSpeakerTest() | |
{ | |
var _stopwatch = Stopwatch.StartNew(); | |
_capture.Subscribe(b => | |
{ | |
var time = _stopwatch.ElapsedMilliseconds; | |
var bs = string.Join("-", b.Select(x => x.ToString("x2"))); | |
Console.WriteLine(bs); | |
Debug.WriteLine($"{time} {b.Length} {bs}"); | |
}); | |
// キャプチャーしたデータを1000msecディレイして再生する。 | |
_capture.Delay(TimeSpan.FromMilliseconds(1000)).Subscribe(_speaker); | |
_capture.Start(); | |
Thread.Sleep(5000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment