fix: bug when autocall for cw keyer is on which was
autocalling no matter which macro now only on CQ fix: ESC stop transmission but also autocall
This commit is contained in:
@@ -17,6 +17,10 @@ func charToMorse() map[byte]string {
|
||||
|
||||
// keyMessage synthesizes a clean keyed tone for msg at the given WPM/pitch.
|
||||
func keyMessage(msg string, fs, wpm int, pitch float64) []int16 {
|
||||
return keyMessageAmp(msg, fs, wpm, pitch, 9000)
|
||||
}
|
||||
|
||||
func keyMessageAmp(msg string, fs, wpm int, pitch, amp float64) []int16 {
|
||||
dot := fs * 1200 / (wpm * 1000) // samples per dot
|
||||
c2m := charToMorse()
|
||||
var out []int16
|
||||
@@ -25,7 +29,7 @@ func keyMessage(msg string, fs, wpm int, pitch float64) []int16 {
|
||||
|
||||
tone := func(n int) {
|
||||
for i := 0; i < n; i++ {
|
||||
out = append(out, int16(9000*math.Sin(phase)))
|
||||
out = append(out, int16(amp*math.Sin(phase)))
|
||||
phase += dphi
|
||||
}
|
||||
}
|
||||
@@ -79,6 +83,41 @@ func TestDecodeCleanSignal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeWithQRM(t *testing.T) {
|
||||
const fs = 16000
|
||||
// Target at 700 Hz; a strong interfering keyed signal at 950 Hz, slightly
|
||||
// quieter, sending different text. The pitch lock should hold on the target.
|
||||
target := keyMessageAmp("PARIS PARIS PARIS", fs, 20, 700, 9000)
|
||||
qrm := keyMessageAmp("BK DE QRZ QRZ TEST", fs, 26, 950, 6500)
|
||||
mix := make([]int16, len(target))
|
||||
for i := range target {
|
||||
v := int(target[i])
|
||||
if i < len(qrm) {
|
||||
v += int(qrm[i])
|
||||
}
|
||||
if v > 32767 {
|
||||
v = 32767
|
||||
} else if v < -32768 {
|
||||
v = -32768
|
||||
}
|
||||
mix[i] = int16(v)
|
||||
}
|
||||
|
||||
var sb strings.Builder
|
||||
d := New(fs, func(s string) { sb.WriteString(s) }, nil)
|
||||
for i := 0; i < len(mix); i += 256 {
|
||||
end := i + 256
|
||||
if end > len(mix) {
|
||||
end = len(mix)
|
||||
}
|
||||
d.Process(mix[i:end])
|
||||
}
|
||||
got := strings.ToUpper(sb.String())
|
||||
if !strings.Contains(got, "PARIS") {
|
||||
t.Fatalf("with QRM, decoded %q, want it to contain PARIS", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeNumbersAndProsign(t *testing.T) {
|
||||
const fs = 16000
|
||||
var sb strings.Builder
|
||||
|
||||
Reference in New Issue
Block a user