wavparse

package
v0.0.0-...-bd873f3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package wavparse provides Uniden Bearcat Scanner WAV file parsing. Portions from https://github.com/go-audio/wav

Index

Constants

This section is empty.

Variables

View Source
var ErrHeaderParsing = fmt.Errorf("file is invalid or empty when trying to parse riff headers")

ErrHeaderParsing is returned when RIFF headers can't be decoded due to a malformed file.

View Source
var ErrNilChunk = errors.New("can't decode a nil chunk")

ErrNilChunk is returned when a RIFF chunk is nil.

View Source
var ErrNotUNIDChunk = errors.New("was given something other than a unid riff chunk")

ErrNotUNIDChunk is returned when the chunk given to the UNID decode function is not actually a UNID chunk.

Functions

This section is empty.

Types

type ChannelInfo

type ChannelInfo struct {
	Name            string      `csv:"Channel_Name" json:",omitempty" validate:"omitempty,printascii"`
	Avoid           bool        `csv:"Channel_Avoid"`
	TGIDFrequency   string      `csv:"Channel_TGIDFrequency" json:",omitempty" validate:"omitempty,printascii"`
	Mode            string      `csv:"Channel_Mode" json:",omitempty" validate:"omitempty,printascii"`
	ToneCode        string      `csv:"Channel_ToneCode" json:",omitempty" validate:"omitempty,printascii"`
	ServiceType     ServiceType `csv:"Channel_ServiceType"`
	Attenuator      string      `csv:"Channel_Attenuator"` // Conventional systems only
	DelayValue      string      `csv:"Channel_DelayValue" json:",omitempty" validate:"omitempty,printascii"`
	VolumeOffset    string      `csv:"Channel_VolumeOffset" json:",omitempty" validate:"omitempty,printascii"`
	AlertToneType   string      `csv:"Channel_AlertToneType" json:",omitempty" validate:"omitempty,printascii"`
	AlertToneVolume string      `csv:"Channel_AlertToneVolume" json:",omitempty" validate:"omitempty,printascii"`
	AlertLightColor string      `csv:"Channel_AlertLightColor" json:",omitempty" validate:"omitempty,printascii"`
	AlertLightType  string      `csv:"Channel_AlertLightType" json:",omitempty" validate:"omitempty,printascii"`
	NumberTag       string      `csv:"Channel_NumberTag" json:",omitempty" validate:"omitempty,printascii"`
	Priority        string      `csv:"Channel_Priority" json:",omitempty" validate:"omitempty,printascii"`
}

func (*ChannelInfo) UnmarshalBinary

func (c *ChannelInfo) UnmarshalBinary(data []byte) error

type DepartmentInfo

type DepartmentInfo struct {
	Name      string  `csv:"Department_Name" json:",omitempty" validate:"omitempty,printascii"`
	Avoid     bool    `csv:"Department_Avoid"`
	Latitude  float64 `csv:"Department_Latitude" validate:"latitude"`
	Longitude float64 `csv:"Department_Longitude" validate:"longitude"`
	Range     float64 `csv:"Department_Range"`
	Shape     string  `csv:"Department_Shape" json:",omitempty" validate:"omitempty,printascii"`
	NumberTag string  `csv:"Department_NumberTag" json:",omitempty" validate:"omitempty,printascii"`
}

func (*DepartmentInfo) UnmarshalBinary

func (d *DepartmentInfo) UnmarshalBinary(data []byte) error

type FavoriteInfo

type FavoriteInfo struct {
	Name            string `csv:"Favorite_Name" json:",omitempty" validate:"omitempty,printascii"`
	File            string `csv:"Favorite_File" json:",omitempty" validate:"omitempty,printascii"`
	LocationControl bool   `csv:"Favorite_LocationControl"`
	Monitor         bool   `csv:"Favorite_Monitor"`
	QuickKey        string `csv:"Favorite_QuickKey" json:",omitempty" validate:"omitempty,printascii"`
	NumberTag       string `csv:"Favorite_NumberTag" json:",omitempty" validate:"omitempty,printascii"`
	ConfigKey0      string `csv:"Favorite_ConfigKey0" json:",omitempty" validate:"omitempty,printascii"`
	ConfigKey1      string `csv:"Favorite_ConfigKey1" json:",omitempty" validate:"omitempty,printascii"`
	ConfigKey2      string `csv:"Favorite_ConfigKey2" json:",omitempty" validate:"omitempty,printascii"`
	ConfigKey3      string `csv:"Favorite_ConfigKey3" json:",omitempty" validate:"omitempty,printascii"`
	ConfigKey4      string `csv:"Favorite_ConfigKey4" json:",omitempty" validate:"omitempty,printascii"`
	ConfigKey5      string `csv:"Favorite_ConfigKey5" json:",omitempty" validate:"omitempty,printascii"`
	ConfigKey6      string `csv:"Favorite_ConfigKey6" json:",omitempty" validate:"omitempty,printascii"`
	ConfigKey7      string `csv:"Favorite_ConfigKey7" json:",omitempty" validate:"omitempty,printascii"`
	ConfigKey8      string `csv:"Favorite_ConfigKey8" json:",omitempty" validate:"omitempty,printascii"`
	ConfigKey9      string `csv:"Favorite_ConfigKey9" json:",omitempty" validate:"omitempty,printascii"`
}

func (*FavoriteInfo) UnmarshalBinary

func (f *FavoriteInfo) UnmarshalBinary(data []byte) error

type ListChunk

type ListChunk struct {
	System           string     `csv:"Public_System" json:",omitempty" validate:"omitempty,printascii"`           // IART
	Department       string     `csv:"Public_Department" json:",omitempty" validate:"omitempty,printascii"`       // IGNR
	Channel          string     `csv:"Public_Channel" json:",omitempty" validate:"omitempty,printascii"`          // INAM
	TGIDFreq         string     `csv:"Public_TGIDFreq" json:",omitempty" validate:"omitempty,printascii"`         // ICMT
	Product          string     `csv:"Public_Product" json:",omitempty" validate:"omitempty,printascii"`          // IPRD
	Unknown          string     `csv:"Public_Unknown" json:",omitempty" validate:"omitempty,printascii"`          // IKEY
	Timestamp        *time.Time `csv:"Public_Timestamp" json:",omitempty" validate:"omitempty,printascii"`        // ICRD
	Tone             string     `csv:"Public_Tone" json:",omitempty" validate:"omitempty,printascii"`             // ISRC
	UnitID           string     `csv:"Public_UnitID" json:",omitempty" validate:"omitempty,printascii"`           // ITCH
	FavoriteListName string     `csv:"Public_FavoriteListName" json:",omitempty" validate:"omitempty,printascii"` // ISBJ
	Reserved         string     `csv:"Public_Reserved" json:",omitempty" validate:"omitempty,printascii"`         // ICOP
}

type Metadata

type Metadata struct {
	TGID      string  `csv:"Metadata_TGID" json:",omitempty" validate:"omitempty,printascii"`
	Frequency float64 `csv:"Metadata_Frequency"`
	WACN      string  `csv:"Metadata_WACN" json:",omitempty" validate:"omitempty,hexadecimal"`
	NAC       string  `csv:"Metadata_NAC" json:",omitempty" validate:"omitempty,hexadecimal"`
	UnitID    string  `csv:"Metadata_UnitID" json:",omitempty" validate:"omitempty,hexadecimal"`

	RawTGID      string `csv:"Metadata_RawTGID" json:",omitempty" validate:"omitempty,printascii"`
	RawFrequency string `csv:"Metadata_RawFrequency" json:",omitempty" validate:"omitempty,printascii"`
	RawWACN      string `csv:"Metadata_RawWACN" json:",omitempty" validate:"omitempty,printascii"`
	RawNAC       string `csv:"Metadata_RawNAC" json:",omitempty" validate:"omitempty,printascii"`
	RawUnitID    string `csv:"Metadata_RawUnitID" json:",omitempty" validate:"omitempty,printascii"`

	FrequencyFmt string `csv:"Metadata_FrequencyFmt" json:",omitempty" validate:"omitempty,printascii"`
	WACNFmt      string `csv:"Metadata_WACNFmt" json:",omitempty" validate:"omitempty,printascii"`
	UnknownFmt   string `csv:"Metadata_UnknownFmt" json:",omitempty" validate:"omitempty,printascii"`
	NACFmt       string `csv:"Metadata_NACFmt" json:",omitempty" validate:"omitempty,printascii"`
}

func (*Metadata) UnmarshalBinary

func (t *Metadata) UnmarshalBinary(data []byte) error

type RawUnidenChunk

type RawUnidenChunk struct {
	// Start byte 600
	Favorite   [65]byte   // 0-65 	   / 600-665
	System     [65]byte   // 65-130 	 / 665-730
	Department [65]byte   // 130-195 	 / 730-795
	Channel    [65]byte   // 195-260 	 / 795-860
	Site       [65]byte   // 260-325 	 / 860-925
	Empty      [283]byte  // 325-608 	 / 925-1208
	Metadata   [216]byte  // 608-824 	 / 1208-1424
	Remainder  [1224]byte // 824-2048  / 1424-2648

}

type Recording

type Recording struct {
	File     string            `json:",omitempty" validate:"omitempty,printascii"`
	Duration StopwatchDuration `json:",omitempty"`
	Public   *ListChunk        `csv:"-" json:",omitempty"`
	Private  *UnidenChunk      `csv:"-" json:",omitempty"`
}

func DecodeRecording

func DecodeRecording(path string) (*Recording, error)

DecodeRecording will decode the metadata in the WAV file at the given path.

type ServiceType

type ServiceType int

func (ServiceType) String

func (s ServiceType) String() string

type SiteInfo

type SiteInfo struct {
	Name             string  `csv:"Site_Name" json:",omitempty" validate:"omitempty,printascii"`
	Avoid            bool    `csv:"Site_Avoid"`
	Latitude         float64 `csv:"Site_Latitude" validate:"latitude"`
	Longitude        float64 `csv:"Site_Longitude" validate:"longitude"`
	Range            float64 `csv:"Site_Range"`
	Modulation       string  `csv:"Site_Modulation" json:",omitempty" validate:"omitempty,printascii"`
	MotorolaBandPlan string  `csv:"Site_MotorolaBandPlan" json:",omitempty" validate:"omitempty,printascii"`
	EDACS            string  `csv:"Site_EDACS" json:",omitempty" validate:"omitempty,printascii"`
	Shape            string  `csv:"Site_Shape" json:",omitempty" validate:"omitempty,printascii"`
	Attenuator       bool    `csv:"Site_Attenuator"`
}

func (*SiteInfo) UnmarshalBinary

func (s *SiteInfo) UnmarshalBinary(data []byte) error

type StopwatchDuration

type StopwatchDuration time.Duration

func (*StopwatchDuration) MarshalCSV

func (clock *StopwatchDuration) MarshalCSV() (string, error)

Convert the internal duration as CSV string.

func (*StopwatchDuration) MarshalJSON

func (clock *StopwatchDuration) MarshalJSON() ([]byte, error)

func (*StopwatchDuration) UnmarshalCSV

func (clock *StopwatchDuration) UnmarshalCSV(csv string) error

Convert the CSV string as internal duration.

type SystemInfo

type SystemInfo struct {
	Name                     string `csv:"System_Name" json:",omitempty" validate:"omitempty,printascii"`
	Avoid                    bool   `csv:"System_Avoid"`
	Blank                    string `csv:"System_Blank" json:",omitempty" validate:"omitempty,printascii"`
	Type                     string `csv:"System_Type" json:",omitempty" validate:"omitempty,printascii"`
	IDSearch                 string `csv:"System_IDSearch"`
	EmergencyAlertType       string `csv:"System_EmergencyAlertType" json:",omitempty" validate:"omitempty,printascii"`
	AlertVolume              string `csv:"System_AlertVolume" json:",omitempty" validate:"omitempty,printascii"`
	MotorolaStatusBit        string `csv:"System_MotorolaStatusBit" json:",omitempty" validate:"omitempty,printascii"`
	P25NAC                   string `csv:"System_P25NAC" json:",omitempty" validate:"omitempty,printascii"`
	QuickKey                 string `csv:"System_QuickKey" json:",omitempty" validate:"omitempty,printascii"`
	NumberTag                string `csv:"System_NumberTag" json:",omitempty" validate:"omitempty,printascii"`
	HoldTime                 string `csv:"System_HoldTime" json:",omitempty" validate:"omitempty,printascii"`
	AnalogAGC                string `csv:"System_AnalogAGC" json:",omitempty" validate:"omitempty,printascii"`
	DigitalAGC               string `csv:"System_DigitalAGC" json:",omitempty" validate:"omitempty,printascii"`
	EndCode                  string `csv:"System_EndCode" json:",omitempty" validate:"omitempty,printascii"`
	PriorityID               string `csv:"System_PriorityID" json:",omitempty" validate:"omitempty,printascii"`
	EmergencyAlertLightColor string `csv:"System_EmergencyAlertLightColor" json:",omitempty" validate:"omitempty,printascii"`
	EmergencyAlertCondition  string `csv:"System_EmergencyAlertCondition" json:",omitempty" validate:"omitempty,printascii"`
}

func (*SystemInfo) UnmarshalBinary

func (s *SystemInfo) UnmarshalBinary(data []byte) error

type UnidenChunk

type UnidenChunk struct {
	Favorite   FavoriteInfo   `csv:"-"`
	System     SystemInfo     `csv:"-"`
	Department DepartmentInfo `csv:"-"`
	Channel    ChannelInfo    `csv:"-"`
	Site       SiteInfo       `csv:"-"`
	Metadata   Metadata       `csv:"-"`
}

Jump to

Keyboard shortcuts

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