private bool UserKey(char key) { bool processed = false; if (key == _dlgAssigner.Key_BT) { key = MorseInfo.PROSIGN_BT; } else if (key == _dlgAssigner.Key_SK) { key = MorseInfo.PROSIGN_SK; } else if (key == _dlgAssigner.Key_AR) { key = MorseInfo.PROSIGN_AR; } if (key == '\b') { // backspace if (txtAnalysis.TextLength > 0) { if (txtAnalysis.Text[txtAnalysis.TextLength - 1] == '>' && txtAnalysis.TextLength > 3 && txtAnalysis.Text[txtAnalysis.TextLength - 4] == '<') { txtAnalysis.Select(txtAnalysis.TextLength - 4, 4); } else { txtAnalysis.Select(txtAnalysis.TextLength - 1, 1); } txtAnalysis.ReadOnly = false; txtAnalysis.SelectedText = ""; txtAnalysis.ReadOnly = true; } processed = true; } else if (key == '\u001b') { // esc processed = true; } else if (key == '\r') { // enter processed = true; } else { String expanded = MorseInfo.ExpandProsigns(key.ToString()).ToUpperInvariant(); txtAnalysis.AppendText(expanded); _recorded.Append(expanded); processed = true; } return(processed); }
public override string Str(ResultsFlags flags) { String ret = ""; if ((flags & ResultsFlags.Extra) != 0) { ret = MorseInfo.ExpandProsigns(_str); } ret = SpacesToUnderscores(ret); return(ret); }
private void MakeWaveform(object state) { BuildWaverformAsync buildInfo = (BuildWaverformAsync)state; List <Int16[]> soundsList = new List <short[]>(); _toneGenerator.Update(); foreach (Char c in buildInfo.Word) { String morse = MorseInfo.ToMorse(c); bool first = true; foreach (Char d in morse) { if (first) { first = false; } else { soundsList.Add(_toneGenerator.DotSpaceWaveform); } switch (d) { case '.': soundsList.Add(_toneGenerator.DotToneWaveform); break; case '-': soundsList.Add(_toneGenerator.DashToneWaveform); break; case ' ': soundsList.Add(_toneGenerator.WordSpaceWaveform); break; } } soundsList.Add(_toneGenerator.LetterSpaceWaveform); // Farnsworth timing if (_toneGenerator.FarnsworthWPM < _toneGenerator.WPM) { soundsList.Add(_toneGenerator.FarnsworthSpacingWaveform(c)); } } soundsList.Add(_toneGenerator.WordSpaceWaveform); WaveStream stream = new WaveStream(buildInfo.Word, soundsList, ToneGenerator.SAMPLES_PER_SECOND, _toneGenerator.SamplesPerCycle); buildInfo.SetWaveform(stream); buildInfo.Callback(); buildInfo.TriggerWaitHandle(); }
/// <summary> /// Creates a space waveform array based on the Farnsworth timing /// </summary> public Int16[] FarnsworthSpacingWaveform(Char c) { // Get the equivalent dots int elements = MorseInfo.ToElements(c); // Farnsworth timing stretches time between characters. // Character has already been sent WPM and now we have to // wait as if it were sent FarnsworthWPM float wpmTime = _msPerElement * elements; float farnsworthTime = _msPerFarnsworthElement * elements; float difference = farnsworthTime - wpmTime; return(CreateSpace(difference)); }
private void ShowStats(MorseCompareResults results) { int[] sent = new int[256]; int[] valid = new int[256]; int[] dropped = new int[256]; int[] extra = new int[256]; int totalValid = 0; foreach (char c in results.Sent) { sent[c]++; } foreach (MorseSubstring substring in results.SubStrings) { int[] counter = null; switch (substring.ResultInfo & ResultsFlags.All) { case ResultsFlags.Dropped: counter = dropped; break; case ResultsFlags.Extra: counter = extra; break; case ResultsFlags.Valid: counter = valid; totalValid += substring.Chars.Length; break; } if (counter != null) { foreach (char c in substring.Chars) { counter[c]++; } } } Write(String.Format("Sent {0} and {1} recorded valid: {2:0}%" + Environment.NewLine, results.Sent.Length, totalValid, 100 * (float)totalValid / (float)results.Sent.Length)); // Show characters sent Write(Environment.NewLine + "Characters sent:" + Environment.NewLine); foreach (char c in MorseInfo.PossibleCharacters) { if (sent[c] != 0) { Write(String.Format(" {0} {1}/{2} : {3},{4}" + Environment.NewLine, MorseInfo.ExpandProsigns(c), valid[c], sent[c], dropped[c], extra[c])); } } // Show extra characters received Write(Environment.NewLine + "Characters not sent:" + Environment.NewLine); foreach (char c in MorseInfo.PossibleCharacters) { if (sent[c] == 0 && extra[c] != 0) { Write(String.Format(" {0} {1}/{2} : {3},{4}" + Environment.NewLine, MorseInfo.ExpandProsigns(c), valid[c], sent[c], dropped[c], extra[c])); } } }