dsp

package
v0.0.0-...-8b429ed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const FrameTypeMax = 6

Variables

This section is empty.

Functions

func CQString

func CQString(number int) string

CQString formats a CQ string with number

func Checksum16

func Checksum16(input string) string

Checksum16 computes a 16-bit CRC checksum and packs it into 3 characters

func Checksum16Valid

func Checksum16Valid(checksum, input string) bool

Checksum16Valid validates a 16-bit CRC checksum

func Checksum32

func Checksum32(input string) string

Checksum32 computes a 32-bit CRC checksum and packs it into 6 characters

func Checksum32Valid

func Checksum32Valid(checksum, input string) bool

Checksum32Valid validates a 32-bit CRC checksum

func ContainsLettersAndNumbers

func ContainsLettersAndNumbers(s string) bool

ContainsLettersAndNumbers checks if a string contains both letters and numbers (exported for testing)

func Deg2Grid

func Deg2Grid(dlong, dlat float32) string

Deg2Grid converts decimal degrees to Maidenhead grid square (matches C++ implementation)

func Escape

func Escape(text string) string

Escape escapes special characters in text

func FormatPWR

func FormatPWR(dbm int) string

FormatPWR formats power value in dBm for display

func FormatSNR

func FormatSNR(snr int) string

FormatSNR formats SNR value for display

func Grid2Deg

func Grid2Deg(grid string) (float32, float32)

Grid2Deg converts Maidenhead grid square to decimal degrees (matches C++ implementation)

func HBString

func HBString(number int) string

HBString formats a heartbeat string with number

func IsCommandAllowed

func IsCommandAllowed(cmd string) bool

IsCommandAllowed checks if a command is allowed

func IsCommandAutoreply

func IsCommandAutoreply(cmd string) bool

IsCommandAutoreply checks if a command should generate an automatic reply

func IsCommandBuffered

func IsCommandBuffered(cmd string) bool

IsCommandBuffered checks if a command should be buffered

func IsCommandChecksumed

func IsCommandChecksumed(cmd string) int

IsCommandChecksumed returns checksum type for command (0=none, 16=16bit, 32=32bit)

func IsGridSquare

func IsGridSquare(s string) bool

IsGridSquare checks if a string looks like a Maidenhead grid square (exported for testing)

func IsSNRCommand

func IsSNRCommand(cmd string) bool

IsSNRCommand checks if a command is SNR-related

func Lstrip

func Lstrip(str string) string

Lstrip removes leading whitespace

func Pack5bits

func Pack5bits(packed uint8) string

Pack5bits packs a 5-bit value (0-31) into a single character

func Pack6bits

func Pack6bits(packed uint8) string

Pack6bits packs a 6-bit value (0-40) into a single character

func Pack16bits

func Pack16bits(packed uint16) string

Pack16bits packs a 16-bit value into 3 base-41 characters

func Pack32bits

func Pack32bits(packed uint32) string

Pack32bits packs a 32-bit value into 6 base-41 characters

func Pack64bits

func Pack64bits(packed uint64) string

Pack64bits packs a 64-bit value into 12 base-41 characters

func Pack72bits

func Pack72bits(value uint64, rem uint8) string

Pack72bits packs 72 bits (64 + 8) into 12 base-64 characters

func PackGrid

func PackGrid(grid string) uint16

PackGrid packs a grid square into 16 bits using JS8 format

func PadMessage

func PadMessage(message string, fillChar byte) (string, error)

PadMessage pads a message to exactly 12 characters using a fill character

func ParseCallsigns

func ParseCallsigns(input string) []string

ParseCallsigns extracts callsigns from input text

func ParseGrids

func ParseGrids(input string) []string

ParseGrids extracts grid squares from input text

func PreprocessJS8Message

func PreprocessJS8Message(message string) string

PreprocessJS8Message preprocesses a message to make it compatible with JS8 encoding This handles common JS8 message formats and removes invalid characters

func Rstrip

func Rstrip(str string) string

Rstrip removes trailing whitespace

func StartsWithCQ

func StartsWithCQ(text string) bool

StartsWithCQ checks if text starts with CQ

func StartsWithHB

func StartsWithHB(text string) bool

StartsWithHB checks if text starts with HB (heartbeat)

func Unescape

func Unescape(text string) string

Unescape unescapes special characters in text

func Unpack5bits

func Unpack5bits(value string) uint8

Unpack5bits extracts a 5-bit value from a character

func Unpack6bits

func Unpack6bits(value string) uint8

Unpack6bits extracts a 6-bit value from a character

func Unpack16bits

func Unpack16bits(value string) uint16

Unpack16bits extracts a 16-bit value from 3 base-41 characters

func Unpack32bits

func Unpack32bits(value string) uint32

Unpack32bits extracts a 32-bit value from 6 base-41 characters

func Unpack64bits

func Unpack64bits(value string) uint64

Unpack64bits extracts a 64-bit value from 12 base-41 characters

func Unpack72bits

func Unpack72bits(text string, pRem *uint8) uint64

Unpack72bits extracts 72 bits from 12 base-64 characters, returning first 64 bits and last 8 bits

func UnpackGrid

func UnpackGrid(packed uint16) string

UnpackGrid unpacks a 16-bit value into a grid square using JS8 format

func ValidateMessage

func ValidateMessage(message string) error

ValidateMessage checks if a message contains only valid JS8 characters

Types

type CppDSP

type CppDSP struct {
	// contains filtered or unexported fields
}

CppDSP represents the C++ DSP engine with real JS8Call algorithms

func NewCppDSP

func NewCppDSP() *CppDSP

NewCppDSP creates a new C++ DSP instance

func (*CppDSP) Close

func (d *CppDSP) Close()

Close cleans up the C++ DSP library

func (*CppDSP) DecodeBuffer

func (d *CppDSP) DecodeBuffer(audioData []int16, callback func(*DecodeResult)) (int, error)

DecodeBuffer decodes audio samples and calls the callback for each decoded message

func (*CppDSP) EncodeMessage

func (d *CppDSP) EncodeMessage(message string, mode JS8Mode) ([]int16, error)

EncodeMessage encodes a text message to audio samples using C++ DSP

func (*CppDSP) EstimateAudioDuration

func (d *CppDSP) EstimateAudioDuration(mode JS8Mode) time.Duration

EstimateAudioDuration estimates the duration of encoded audio for a given mode

func (*CppDSP) GetError

func (d *CppDSP) GetError() string

GetError returns the last error message from the C++ library

func (*CppDSP) GetJS8Alphabet

func (d *CppDSP) GetJS8Alphabet() string

GetJS8Alphabet returns the valid JS8 alphabet

func (*CppDSP) GetSampleRate

func (d *CppDSP) GetSampleRate() int

GetSampleRate returns the current sample rate

func (*CppDSP) GetStats

func (d *CppDSP) GetStats() (totalDecoded, totalErrors uint32, err error)

GetStats returns decoder statistics

func (*CppDSP) GetToneCount

func (d *CppDSP) GetToneCount(mode JS8Mode) int

GetToneCount returns the number of tones for a given mode

func (*CppDSP) Initialize

func (d *CppDSP) Initialize() error

Initialize initializes the C++ DSP library

func (*CppDSP) SetSampleRate

func (d *CppDSP) SetSampleRate(rate int)

SetSampleRate sets the audio sample rate

func (*CppDSP) ValidateJS8Message

func (d *CppDSP) ValidateJS8Message(message string) error

ValidateJS8Message validates that a message contains only valid JS8 characters

type DSP

type DSP struct {
	// contains filtered or unexported fields
}

DSP represents the pure Go JS8 DSP engine

func NewDSP

func NewDSP() *DSP

NewDSP creates a new pure Go DSP instance

func (*DSP) Close

func (d *DSP) Close()

Close cleans up the DSP library (pure Go - nothing to clean up)

func (*DSP) DecodeBuffer

func (d *DSP) DecodeBuffer(audioData []int16, callback func(*DecodeResult)) (int, error)

DecodeBuffer decodes audio samples and calls the callback for each decoded message Now uses gonum/fourier for signal detection

func (*DSP) EncodeMessage

func (d *DSP) EncodeMessage(message string, mode JS8Mode) ([]int16, error)

EncodeMessage encodes a text message to audio samples using pure Go

func (*DSP) EstimateAudioDuration

func (d *DSP) EstimateAudioDuration(mode JS8Mode) time.Duration

EstimateAudioDuration estimates the duration of encoded audio for a given mode

func (*DSP) GetError

func (d *DSP) GetError() string

GetError returns the last error message (pure Go - not needed)

func (*DSP) GetJS8Alphabet

func (d *DSP) GetJS8Alphabet() string

GetJS8Alphabet returns the valid JS8 alphabet

func (*DSP) GetSampleRate

func (d *DSP) GetSampleRate() int

GetSampleRate returns the current sample rate

func (*DSP) GetToneCount

func (d *DSP) GetToneCount(mode JS8Mode) int

GetToneCount returns the number of tones for a given mode

func (*DSP) Initialize

func (d *DSP) Initialize() error

Initialize initializes the DSP library (pure Go - always succeeds)

func (*DSP) SetSampleRate

func (d *DSP) SetSampleRate(rate int)

SetSampleRate sets the audio sample rate

func (*DSP) ValidateJS8Message

func (d *DSP) ValidateJS8Message(message string) error

ValidateJS8Message validates that a message contains only valid JS8 characters

type DSPEngine

type DSPEngine interface {
	Initialize() error
	Close()
	SetSampleRate(rate int)
	GetSampleRate() int
	DecodeBuffer(audioData []int16, callback func(*DecodeResult)) (int, error)
	EncodeMessage(message string, mode JS8Mode) ([]int16, error)
	GetError() string
	ValidateJS8Message(message string) error
	GetJS8Alphabet() string
	EstimateAudioDuration(mode JS8Mode) time.Duration
	GetToneCount(mode JS8Mode) int
}

DSPEngine defines the interface for JS8 DSP implementations

type DecodeResult

type DecodeResult struct {
	UTC       int     `json:"utc"`
	SNR       int     `json:"snr"`
	DT        float32 `json:"dt"`
	Frequency float32 `json:"frequency"`
	Message   string  `json:"message"`
	Type      int     `json:"type"`
	Quality   float32 `json:"quality"`
	Mode      int     `json:"mode"`
}

DecodeResult represents a decoded JS8 message

type FrameType

type FrameType uint8

JS8 Frame types

const (
	FrameUnknown          FrameType = 255 // Sentinel value
	FrameHeartbeat        FrameType = 0   // [000]
	FrameCompound         FrameType = 1   // [001]
	FrameCompoundDirected FrameType = 2   // [010]
	FrameDirected         FrameType = 3   // [011]
	FrameData             FrameType = 4   // [10X]
	FrameDataCompressed   FrameType = 6   // [11X]
)

func (FrameType) String

func (f FrameType) String() string

type JS8Encoder

type JS8Encoder struct{}

JS8Encoder represents a pure Go JS8 encoder

func NewJS8Encoder

func NewJS8Encoder() *JS8Encoder

NewJS8Encoder creates a new JS8 encoder

func (*JS8Encoder) EncodeMessage

func (e *JS8Encoder) EncodeMessage(message string, frameType int) ([]int, error)

EncodeMessage encodes a JS8 message to tone sequence

func (*JS8Encoder) EncodeToAudio

func (e *JS8Encoder) EncodeToAudio(message string, frameType int, sampleRate int) ([]int16, error)

EncodeToAudio is a convenience function that encodes message directly to audio

func (*JS8Encoder) GenerateAudio

func (e *JS8Encoder) GenerateAudio(tones []int, sampleRate int) []int16

GenerateAudio converts tone sequence to audio samples

type JS8Mode

type JS8Mode int

JS8Mode represents JS8 submodes

const (
	ModeNormal JS8Mode = 0
	ModeFast   JS8Mode = 1
	ModeTurbo  JS8Mode = 2
	ModeSlow   JS8Mode = 4
	ModeUltra  JS8Mode = 8
)

type TransmissionType

type TransmissionType uint8

JS8 transmission types

const (
	JS8Call      TransmissionType = 0 // Any other frame of the message
	JS8CallFirst TransmissionType = 1 // First frame of a message
	JS8CallLast  TransmissionType = 2 // Last frame of a message
	JS8CallData  TransmissionType = 4 // Flagged frame (no frame type header)
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL