model

package
v0.0.0-...-50abb7e Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DownsampleRatio = 4

DownsampleRatio is the default down sample ratio (4)

View Source
const MaxFreq = 5000.0

MaxFreq is 5kHz

View Source
const SampleSize = 1024.0

SampleSize is the default sample size (1024)

View Source
const TableValueSize = 8

TableValueSize represents the TableValueSize when encoded in bytes

Variables

This section is empty.

Functions

func SongNameFromPath

func SongNameFromPath(path string) string

SongNameFromPath returns the song file name from the given path (removing the path and the extension)

Types

type AnchorKey

type AnchorKey struct {
	// Frequency of the anchor point for the given point's target zone
	AnchorFreq float64
	// Frequency of the given point
	PointFreq float64
	// Delta time between the anchor point and the given point
	DeltaT float64
}

AnchorKey represents a anchor key

func NewAnchorKey

func NewAnchorKey(anchor, point ConstellationPoint) *AnchorKey

NewAnchorKey creates a new anchor key from the given anchor and the given point

func (*AnchorKey) Encode

func (tk *AnchorKey) Encode() EncodedKey

Encode encodes the anchor key using: 9 bits for the “frequency of the anchor”: fa 9 bits for the ” frequency of the point”: fp 14 bits for the ”delta time between the anchor and the point”: dt The result is then dt | fa | fp XXX: this only works if frequencies are coded in 9 bits or less (if we used a 1024 samples FFT, it will be the case)

type ConstellationPoint

type ConstellationPoint struct {
	Time float64
	Freq float64
}

ConstellationPoint represents a point in the constellation map (time + frequency)

func (ConstellationPoint) String

func (cp ConstellationPoint) String() string

type EncodedKey

type EncodedKey uint32

EncodedKey represents an encoded key

func (EncodedKey) Bytes

func (ek EncodedKey) Bytes() []byte

Bytes encodes the key in bytes

type TableValue

type TableValue struct {
	// AnchorTimeMs is the time of the anchor in the related song in milliseconds
	AnchorTimeMs uint32
	// SongID is an ID representing the related song
	SongID uint32
}

TableValue represents a table value

func NewTableValue

func NewTableValue(song uint32, anchor ConstellationPoint) *TableValue

NewTableValue creates a new table value from the given song ID and anchor point

func ValuesFromBytes

func ValuesFromBytes(b []byte) ([]TableValue, error)

ValuesFromBytes decodes a list of table values from the given byte array

func (*TableValue) Bytes

func (tv *TableValue) Bytes() []byte

Bytes encodes the given table value in bytes

func (TableValue) String

func (tv TableValue) String() string

String returns a string representation of a TableValue

Jump to

Keyboard shortcuts

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