data

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package data contains structs and methods common for listening test datasets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CorrelationRow added in v0.2.0

type CorrelationRow []CorrelationScore

CorrelationRow is correlations between a single score type and all score types.

func (CorrelationRow) Len added in v0.2.0

func (c CorrelationRow) Len() int

func (CorrelationRow) Less added in v0.2.0

func (c CorrelationRow) Less(i, j int) bool

func (CorrelationRow) Swap added in v0.2.0

func (c CorrelationRow) Swap(i, j int)

type CorrelationScore

type CorrelationScore struct {
	ScoreTypeA ScoreType
	ScoreTypeB ScoreType
	Score      float64
}

CorrelationScore contains the scorrelation score between two score types.

type CorrelationTable

type CorrelationTable []CorrelationRow

CorrelationTable contains the pairwise correlations between a set of score types.

func (CorrelationTable) String

func (c CorrelationTable) String() string

type Distortion

type Distortion struct {
	Name   string
	Path   string
	Scores map[ScoreType]float64
}

Distortion contains data for a distortion of a reference.

func (*Distortion) Load

func (d *Distortion) Load(dir string) (*audio.Audio, error)

Load returns the audio for this distortion.

type JNDAccuracyScore added in v0.2.0

type JNDAccuracyScore struct {
	ScoreType ScoreType
	Threshold float64
	Accuracy  float64
}

JNDAccuracyScore contains the accuracy for a metric when used to predict audible differences, and the threshold when that accuracy was achieved.

type JNDAccuracyScores added in v0.2.0

type JNDAccuracyScores []JNDAccuracyScore

JNDAccuracyScores contains the accuracy scores for multiple score types.

func (JNDAccuracyScores) Len added in v0.2.0

func (a JNDAccuracyScores) Len() int

func (JNDAccuracyScores) Less added in v0.2.0

func (a JNDAccuracyScores) Less(i, j int) bool

func (JNDAccuracyScores) String added in v0.2.0

func (a JNDAccuracyScores) String() string

func (JNDAccuracyScores) Swap added in v0.2.0

func (a JNDAccuracyScores) Swap(i, j int)

type MSEScore added in v0.2.0

type MSEScore struct {
	Decimals  int
	ScoreType ScoreType
	MSE       float64
	MinScore  float64
	MaxScore  float64
	MeanScore float64
}

MSEScore is MSE for a score type across a set of studies.

type MSEScores added in v0.2.0

type MSEScores []MSEScore

MSEScores contains the MSE for multiple score types.

func (MSEScores) Len added in v0.2.0

func (m MSEScores) Len() int

func (MSEScores) Less added in v0.2.0

func (m MSEScores) Less(i, j int) bool

func (MSEScores) String added in v0.2.0

func (m MSEScores) String() string

func (MSEScores) Swap added in v0.2.0

func (m MSEScores) Swap(i, j int)

type Measurement

type Measurement func(reference, distortion *audio.Audio) (float64, error)

Measurement returns distance between sounds.

type Reference

type Reference struct {
	Name        string
	Path        string
	Distortions []*Distortion
}

Reference contains data for a reference.

func (*Reference) Load

func (r *Reference) Load(dir string) (*audio.Audio, error)

Load returns the audio for this reference.

type ReferenceBundle added in v0.2.0

type ReferenceBundle struct {
	Dir        string
	References []*Reference
	ScoreTypes map[ScoreType]int
}

ReferenceBundle is a plain data type containing a bunch of references, typicall the content of a study.

func (*ReferenceBundle) Add added in v0.2.0

func (r *ReferenceBundle) Add(ref *Reference)

Add adds a reference to a bundle.

func (*ReferenceBundle) Calculate added in v0.2.0

func (r *ReferenceBundle) Calculate(measurements map[ScoreType]Measurement, pool *worker.Pool[any], force bool) error

Calculate computes measurements and populates the scores of the distortions.

func (*ReferenceBundle) Correlate added in v0.2.0

func (r *ReferenceBundle) Correlate() (CorrelationTable, error)

Correlate returns a table of all scores in the bundle Spearman correlated to each other.

func (*ReferenceBundle) Correlation added in v0.2.0

func (r *ReferenceBundle) Correlation(typeA, typeB ScoreType) (float64, error)

Correlation returns the Spearman correlation between score type A and B.

func (*ReferenceBundle) IsJND added in v0.2.0

func (r *ReferenceBundle) IsJND() bool

IsJND returns if this bundle is one with just-noticeable-difference evaluations, and only those.

func (*ReferenceBundle) JNDAccuracy added in v0.2.0

func (r *ReferenceBundle) JNDAccuracy() (JNDAccuracyScores, error)

JNDAccuracy returns the accuracy of each score type when used to predict audible differences.

func (*ReferenceBundle) JNDAccuracyAndThreshold added in v0.2.0

func (r *ReferenceBundle) JNDAccuracyAndThreshold(scoreType ScoreType) (float64, float64, error)

JNDAccuracyAndThreshold returns the treshold for the score type that provides the highest accuracy at predicting the JND score (whether a human observer was able to detect the distortion), and the accuracy it provided.

func (*ReferenceBundle) SortedTypes added in v0.2.0

func (r *ReferenceBundle) SortedTypes() ScoreTypes

SortedTypes returns the score types of a bundle, alphabetically ordered.

type ReferenceBundles added in v0.2.0

type ReferenceBundles []*ReferenceBundle

ReferenceBundles is a slice of ReferenceBundle.

func OpenBundles added in v0.2.0

func OpenBundles(glob string) (ReferenceBundles, error)

OpenBundles is a shortcut to opening multiple bundles from a glob.

func (ReferenceBundles) Leaderboard added in v0.2.0

func (r ReferenceBundles) Leaderboard(decimals int) (MSEScores, error)

Leaderboard returns the sorted mean squared errors for each score type that is represented in all bundles.

func (ReferenceBundles) References added in v0.2.0

func (r ReferenceBundles) References() int

References returns the sum of the number of references in all the bundles.

func (ReferenceBundles) Report added in v0.2.0

func (r ReferenceBundles) Report() (string, error)

Report returns a Markdown report based on the bundles.

func (ReferenceBundles) Split added in v0.2.0

Split will split the bundle randomly in two parts, at the split provided.

type Row

type Row []string

Row is a row of table data.

type ScoreType

type ScoreType string

ScoreType represents a type of score, such as MOS or Zimtohrli.

const (
	// MOS is mean opinion score from human evaluators.
	MOS ScoreType = "MOS"
	// Zimtohrli is the Zimtohrli distance.
	Zimtohrli ScoreType = "Zimtohrli"
	// JND is 1 if the evaluator detected a difference and 0 if not.
	JND ScoreType = "JND"
	// ViSQOL is the ViSQOL MOS.
	ViSQOL = "ViSQOL"
)

func (ScoreType) Better added in v0.1.11

func (s ScoreType) Better() int

Better returns 1 if higher is better for the score type, or -1 if lower is better.

type ScoreTypes

type ScoreTypes []ScoreType

ScoreTypes is a slice of ScoreType.

func (ScoreTypes) Len

func (s ScoreTypes) Len() int

func (ScoreTypes) Less

func (s ScoreTypes) Less(i, j int) bool

func (ScoreTypes) Swap

func (s ScoreTypes) Swap(i, j int)

type Studies added in v0.2.0

type Studies []*Study

Studies is a slice of studies.

func OpenStudies added in v0.2.0

func OpenStudies(glob string) (Studies, error)

OpenStudies returns the studies contained in the directories defined by the glob.

func (Studies) Close added in v0.2.0

func (s Studies) Close() error

Close closes the studies.

func (Studies) ToBundles added in v0.2.0

func (s Studies) ToBundles() (ReferenceBundles, error)

ToBundles returns reference bundles with the content of the studies.

type Study

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

Study contains data from a study.

func OpenStudy

func OpenStudy(dir string) (*Study, error)

OpenStudy opens a study from a database directory. If the study doesn't exist, it will be created.

func (*Study) ClearScore added in v0.2.0

func (s *Study) ClearScore(name ScoreType) error

ClearScore deletes the named score type from all distortions in the study.

func (*Study) Close

func (s *Study) Close() error

Close closes the study.

func (*Study) Put

func (s *Study) Put(refs []*Reference) error

Put inserts some references into a study.

func (*Study) ToBundle added in v0.2.0

func (s *Study) ToBundle() (*ReferenceBundle, error)

ToBundle returns a reference bundle for this study.

func (*Study) ViewEachReference

func (s *Study) ViewEachReference(f func(*Reference) error) error

ViewEachReference returns each reference in the study.

type Table

type Table []Row

Table is table structured data that can render in straight columns in a terminal.

func (Table) String

func (t Table) String() string

String returns a string representation of the table with colSpacing blanks between columns.

Jump to

Keyboard shortcuts

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