models

package
v0.0.0-...-57178c3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: ISC Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KindValue = map[string]LabelKind{
	"UNDEFINED":    0,
	"MOODS":        1,
	"INSTRUMENTS":  2,
	"GENRES":       3,
	"INSTRUCTIONS": 4,
}

KindValue maps types and enum ints

Functions

func GetKind

func GetKind(lk LabelKind) string

GetKind returns the label kind as lowercase string and plural

func Mapkey

func Mapkey(m map[string]LabelKind, value LabelKind) (key string, ok bool)

Mapkey get a key from value

func StandardOpener

func StandardOpener(opener int, windowSize int) int

StandardOpener specifies a standard window size

Types

type Account

type Account struct {
	AccountID    string    `json:"account_id" gorm:"primary_key;column:account_id"`
	Email        string    `json:"email"`
	Username     string    `json:"username"`
	Password     string    `json:"password,omitempty"` // must exist for bcrypt
	Verified     bool      `json:"-"`
	Temporary    bool      `json:"temp" gorm:"-"`
	Role         string    `json:"-"`
	Created      time.Time `json:"created"`
	Createz      string    `json:"createz"`
	Updated      time.Time `json:"updated"`
	Updatez      string    `json:"updatez"`
	LabelQuality float64   `json:"-"`
}

Account is a single user

func NewAccount

func NewAccount() *Account

NewAccount constructs an account

func (*Account) GenerateTemporary

func (acc *Account) GenerateTemporary()

GenerateTemporary generates a temporary account

func (*Account) SetUpdated

func (acc *Account) SetUpdated()

SetUpdated updates the time

type AccountQuality

type AccountQuality map[string]float64

AccountQuality maps a string to benchmark quality value

type Benchmark

type Benchmark map[string]RecordingLabelsTree

Benchmark represents a group of benchmarks by mapping a recording ID to an interval tree

type Clip

type Clip struct {
	ClipID      string           `json:"clip_id" gorm:"primary_key;column:clip_id"`
	AccountID   *string          `json:"account_id" gorm:"column:account_id"` // pointer to allow null
	RecordingID string           `json:"recording_id" gorm:"foreignkey:recording_id;association_foreignkey:recording_id;column:recording_id"`
	Opener      int              `json:"opener"`
	Closer      int              `json:"closer"`
	Duration    int              `json:"duration"`
	Created     time.Time        `json:"created"`
	Createz     string           `json:"createz"`
	Updated     time.Time        `json:"updated"`
	Updatez     string           `json:"updatez"`
	Labels      []RecordingLabel `json:"labels"`
	Windows     []ClipWindow     `json:"windows" gorm:"-"`
}

Clip object is a partial or complete section of a specific recording.

func NewClip

func NewClip() *Clip

NewClip returns a new Clip object

func NewClipFrom

func NewClipFrom(clip *Clip) *Clip

NewClipFrom returns a new Clip using inputs from another

func (*Clip) Clone

func (cl *Clip) Clone() *Clip

Clone makes a copy

type ClipSelection

type ClipSelection struct {
	Selection []*string `json:"-" gorm:"-"`
}

ClipSelection contains possible clip options

type ClipWindow

type ClipWindow struct {
	Opener int     `json:"opener"`
	Closer int     `json:"closer"`
	Labels []Label `json:"labels"`
}

ClipWindow describes a window of labels

type Label

type Label interface {
	GetValue() string
	GetKind() string
	TableName() (string, error)
	GetID() (string, string)
	GetFK() (string, string)
	GetLiteral() interface{}
	SetDisplay(string)
	SetKind(LabelKind)
	SetCreated()
	SetUpdated()
}

Label defines the generic label interface

type LabelKind

type LabelKind int32

LabelKind is a data type using int to fake an enum

const (
	UndefinedKind LabelKind = iota
	MoodKind
	InstrumentKind
	GenreKind
	InstructionKind
)

Constants define kind types

type Playlist

type Playlist struct {
	PlaylistID string           `json:"playlist_id" gorm:"primary_key;column:playlist_id"`
	TemplateID string           `json:"template_id" gorm:"column:template_id"`
	AccountID  string           `json:"-" gorm:"column:account_id"`
	Name       string           `json:"name"`
	Tagline    string           `json:"tagline"`
	Created    time.Time        `json:"-"`
	Createz    string           `json:"-"`
	Updated    time.Time        `json:"-"`
	Updatez    string           `json:"-"`
	Ready      bool             `json:"-"`
	Status     string           `json:"-"`
	Unique     bool             `json:"-"`
	Numbers    []PlaylistNumber `json:"numbers" gorm:"foreignkey:playlist_id;association_foreignkey:playlist_id"`
	Template   *Template        `json:"-" gorm:"-"`
	Set        map[string]int   `json:"-" gorm:"-"`
	TotalSet   int              `json:"-" gorm:"-"`
}

Playlist is a playlist

func NewPlaylist

func NewPlaylist() *Playlist

NewPlaylist returns a new Playlist object

func NewPlaylistFrom

func NewPlaylistFrom(pl *Playlist) *Playlist

NewPlaylistFrom returns a new Playlist using inputs from another

func NewPlaylistFromTemplate

func NewPlaylistFromTemplate(tpl *Template) *Playlist

NewPlaylistFromTemplate returns a new playlist based on a template

func (*Playlist) Clone

func (pl *Playlist) Clone() *Playlist

Clone makes a new copy

func (Playlist) GetError

func (pl Playlist) GetError() float64

GetError gets the error for simulated annealing

func (Playlist) Print

func (pl Playlist) Print(name string)

Print displays playlist error information

func (*Playlist) SetPlaylistNumber

func (pl *Playlist) SetPlaylistNumber(i int, clip *Clip) error

SetPlaylistNumber sets a playlist number

func (*Playlist) SetSources

func (pl *Playlist) SetSources(db *gorm.DB)

SetSources sets the source name and source id TODO: remove gorm dependency, break out setsources, no database stuff here

type PlaylistNumber

type PlaylistNumber struct {
	PlaylistID string `json:"-" gorm:"primary_key;column:playlist_id"`
	Name       string `json:"name" gorm:"-"`
	Artist     string `json:"artist" gorm:"-"`
	Number     int    `json:"number" gorm:"primary_key"`
	Duration   int    `json:"duration" gorm:"-"`
	Tagline    string `json:"tagline"`
	ClipID     string `json:"clip_id" gorm:"column:clip_id"`
	Clip       Clip   `json:"-" gorm:"foreignkey:clip_id;association_foreignkey:clip_id"`
}

PlaylistNumber is a track number in a playlist

func (*PlaylistNumber) GetError

func (pln *PlaylistNumber) GetError(tpln *TemplateNumber) float64

GetError gets the error

func (*PlaylistNumber) TableName

func (pln *PlaylistNumber) TableName() string

TableName sets the Gorm table name

type RecordingLabel

type RecordingLabel struct {
	ID          string    `json:"id" gorm:"primary_key" sql:"AUTO_INCREMENT"`
	Node        int       `json:"-" gorm:"column:node"`
	Opener      int       `json:"opener"`
	Closer      int       `json:"closer"`
	RecordingID string    `json:"recording_id" gorm:"column:recording_id"`
	AccountID   *string   `json:"account_id" gorm:"column:account_id"`
	Kind        LabelKind `json:"kind" gorm:"-"`
	Display     string    `json:"display" gorm:"-"`
	Value       string    `json:"value"`
	Present     string    `json:"present"`
	Created     time.Time `json:"created"`
	Createz     string    `json:"createz"`
	Updated     time.Time `json:"updated"`
	Updatez     string    `json:"updatez"`
}

RecordingLabel describes a section of a clip.

func NewRecordingLabel

func NewRecordingLabel() *RecordingLabel

NewRecordingLabel returns a new RecordingLabel object

func NewRecordingLabelFrom

func NewRecordingLabelFrom(lbl *RecordingLabel) *RecordingLabel

NewRecordingLabelFrom returns a new RecordingLabel using inputs from another

func (*RecordingLabel) GetFK

func (lbl *RecordingLabel) GetFK() (string, string)

GetFK gets the label association

func (*RecordingLabel) GetID

func (lbl *RecordingLabel) GetID() (string, string)

GetID gets the label id

func (*RecordingLabel) GetKind

func (lbl *RecordingLabel) GetKind() string

GetKind gets the label kind as string

func (*RecordingLabel) GetLiteral

func (lbl *RecordingLabel) GetLiteral() interface{}

GetLiteral retrieves the literal

func (*RecordingLabel) GetValue

func (lbl *RecordingLabel) GetValue() string

GetValue gets the label value

func (*RecordingLabel) Limits

func (lbl *RecordingLabel) Limits() (float64, float64)

Limits returns limits for an interval tree

func (*RecordingLabel) SetCreated

func (lbl *RecordingLabel) SetCreated()

SetCreated sets the created time

func (*RecordingLabel) SetDisplay

func (lbl *RecordingLabel) SetDisplay(disp string)

SetDisplay changes the label display

func (*RecordingLabel) SetKind

func (lbl *RecordingLabel) SetKind(kind LabelKind)

SetKind sets the label kind

func (*RecordingLabel) SetUpdated

func (lbl *RecordingLabel) SetUpdated()

SetUpdated sets the created time

func (*RecordingLabel) TableName

func (lbl *RecordingLabel) TableName() (string, error)

TableName sets the Gorm table name

type RecordingLabelsTree

type RecordingLabelsTree struct {
	Recordings []intree.Bounds
	Tree       *intree.INTree
	MinOpener  int
	MaxCloser  int
}

RecordingLabelsTree represents a group of recording labels for a single recording using an interval tree

type SelectionRetriever

type SelectionRetriever func(labels []TemplateLabel) []*string

SelectionRetriever defines a function that takes labels and returns matching clips

type Spectrogram

type Spectrogram struct {
	RecordingID string `gorm:"primary_key;column:recording_id"`
	Filepath    string `gorm:"column:filepath"`
	Opener      int    `gorm:"column:offset"`
}

Spectrogram represents an image spectrogram

type StepErr

type StepErr struct {
	Desc string
}

StepErr is an error

func (StepErr) Error

func (e StepErr) Error() string

type Template

type Template struct {
	TemplateID string           `json:"template_id" gorm:"primary_key;column:template_id"`
	AccountID  string           `json:"account_id" gorm:"column:account_id"`
	Name       string           `json:"name"`
	Tagline    string           `json:"tagline"`
	Created    time.Time        `json:"created"`
	Createz    string           `json:"createz"`
	Updated    time.Time        `json:"updated"`
	Updatez    string           `json:"updatez"`
	Numbers    []TemplateNumber `json:"numbers" sql:"foreignkey:template_id;association_foreignkey:template_id"`
	Deprecated bool             `json:"-"`
}

Template is a template for a playlist

func NewTemplate

func NewTemplate() *Template

NewTemplate returns a new Template object

func (*Template) SetLabels

func (tpl *Template) SetLabels(lbls interface{})

SetLabels sets the labels

func (*Template) SetSelection

func (tpl *Template) SetSelection(selFunc SelectionRetriever)

SetSelection sets each template number's possible clips

type TemplateLabel

type TemplateLabel struct {
	ID         string    `json:"id" gorm:"primary_key;column:id"`
	TemplateID string    `json:"template_id" gorm:"column:template_id"`
	Number     int       `json:"number"`
	Kind       LabelKind `json:"kind" gorm:"-"`
	Display    string    `json:"display" gorm:"-"`
	Value      string    `json:"value"`
	Created    time.Time `json:"created"`
	Createz    string    `json:"createz"`
	Updated    time.Time `json:"updated"`
	Updatez    string    `json:"updatez"`
}

TemplateLabel is a label for a template

func (*TemplateLabel) GetFK

func (lbl *TemplateLabel) GetFK() (string, string)

GetFK gets the label association

func (*TemplateLabel) GetID

func (lbl *TemplateLabel) GetID() (string, string)

GetID gets the label id

func (*TemplateLabel) GetKind

func (lbl *TemplateLabel) GetKind() string

GetKind gets the label kind as string

func (*TemplateLabel) GetLiteral

func (lbl *TemplateLabel) GetLiteral() interface{}

GetLiteral retrieves the literal

func (*TemplateLabel) GetValue

func (lbl *TemplateLabel) GetValue() string

GetValue returns the template label value

func (*TemplateLabel) SetCreated

func (lbl *TemplateLabel) SetCreated()

SetCreated sets the created time

func (*TemplateLabel) SetDisplay

func (lbl *TemplateLabel) SetDisplay(disp string)

SetDisplay changes the label display

func (*TemplateLabel) SetKind

func (lbl *TemplateLabel) SetKind(kind LabelKind)

SetKind sets the label kind

func (*TemplateLabel) SetUpdated

func (lbl *TemplateLabel) SetUpdated()

SetUpdated sets the created time

func (*TemplateLabel) TableName

func (lbl *TemplateLabel) TableName() (string, error)

TableName sets the Gorm table name

type TemplateNumber

type TemplateNumber struct {
	TemplateID string          `json:"template_id" gorm:"primary_key"`
	Number     int             `json:"number" gorm:"primary_key"`
	Duration   int             `json:"duration"`
	Tagline    string          `json:"tagline"`
	Created    time.Time       `json:"created"`
	Createz    string          `json:"createz"`
	Updated    time.Time       `json:"updated"`
	Updatez    string          `json:"updatez"`
	Labels     []TemplateLabel `json:"labels"`
	ClipSelection
}

TemplateNumber is a track number in a template

func (*TemplateNumber) SelectRandomClip

func (tpn *TemplateNumber) SelectRandomClip() *string

SelectRandomClip returns a random clip from the possible selections

func (*TemplateNumber) TableName

func (tpn *TemplateNumber) TableName() string

TableName sets the Gorm table name

type Templates

type Templates []*Template

Templates is a slice of template pointers

func (Templates) First

func (tpls Templates) First() (*Template, error)

First returns the first template in a list of them

Jump to

Keyboard shortcuts

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