lib

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

This package contains shared datatypes and functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(t *testing.T, srcPath string, destPath string)

CopyFile copies a file from a source to a destination

func HexToRgb

func HexToRgb(hex string) (int, int, int, error)

func RgbToHex

func RgbToHex(r, g, b int) (string, error)

func SaveJson

func SaveJson(t *testing.T, library Library, path string)

SaveJson saves a lib.Library struct to a json-formatted stub

Types

type HotCue

type HotCue struct {
	Name     string  // name of hot cue
	Offset   float64 // offset of hot cue in seconds
	Position int     // position of hot cue, 1-indexed
	Color    string  // color of hot cue button, hex code
}

HotCue is a saved hot cue for a song.

type Library

type Library struct {
	Songs     []Song     // slice of Song structs, unordered
	Playlists []Playlist // slice of Playlist structs, ordered by position
}

Library is the entire library of a DJ software.

func LoadJson

func LoadJson(t *testing.T, path string) Library

LoadJson loads a json-formatted lib.Library struct stub

func (*Library) CheckCorruptedSongs

func (l *Library) CheckCorruptedSongs()

CheckCorruptedSongs removes songs marked as corrupted from the Library

func (*Library) Load

func (library *Library) Load(path string)

Load loads a Library struct from a json file. Used for development purposes only.

func (*Library) Save

func (library *Library) Save(path string)

Save saves a Library struct to a json file. Used for development purposes only.

func (*Library) SortSongs

func (l *Library) SortSongs()

SortSongs sorts a Library's Songs based on id and sorts each Song's Cues and Loops by position, used because Library.Songs is order-agnostic

type Loop

type Loop struct {
	Name     string  // name of loop
	Start    float64 // start time of loop, seconds
	End      float64 // end time of loop, seconds
	Position int     // position of loop, 1-indexed
	Color    string  // color of loop button, hex code
}

Loop is a saved loop for a song.

type Marker

type Marker struct {
	StartPosition float64 // start position in seconds
	Bpm           float64 // beats per minute
	BeatNumber    int     // beat in measure to start on, 0-indexed, assumed 4/4
}

Marker is a marker in a beatgrid.

type Playlist

type Playlist struct {
	PlaylistID   int        // playlist id used by software
	Name         string     // name of playlist
	Songs        []int      // slice of song ids in order
	SubPlaylists []Playlist // slice of child playlists in order, can be recursive
}

Playlist is a set of ordered songs which can contain other playlists. A folder is just a Playlist with no songs that contains other playlists.

type Song

type Song struct {
	SongID       int      // song id used by software
	Title        string   // title
	Artist       string   // artist
	Composer     string   // composer
	Album        string   // album song is from
	Grouping     string   // grouping
	Genre        string   // genre
	Filetype     string   // filetype, abbreviated lowercase
	Size         int      // file size, bytes
	Length       float32  // song length, seconds
	TrackNumber  int      // number in album
	Year         int      // release year
	Bpm          float32  // beats per minute
	DateModified int      // date last modified, unix
	DateAdded    int      // date added to library, unix
	Bitrate      int      // bitrate, kbps
	SampleRate   float64  // sample rate, hz
	Comment      string   // comment
	PlayCount    int      // play count
	LastPlayed   int      // date last played, unix
	Rating       int      // rating in multiples of 20: 0*=0, 1*=20... 5*=100
	Path         string   // song absolute path
	Remixer      string   // remixer
	Key          int      // key in int representation of camelot, 0-indexed: 0=8B, 1=8A, 2=9B... 23=7A
	Label        string   // label
	Mix          string   // mix
	Color        string   // color, hex code
	Cue          float64  // cue location, seconds
	Grid         []Marker // slice of Marker structs, ordered by start position
	Cues         []HotCue // slice of Cue structs, unordered
	Loops        []Loop   // slice of Loop structs, unordered
	Corrupt      bool     // is the song file corrupted?
}

Song is the metadata, analysis data, and saved cues/loops for a song.

Jump to

Keyboard shortcuts

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