Documentation
¶
Index ¶
- Constants
- func GetExtensionForMimeType(mimeType string) string
- func GetFfmpegFormatForMimeType(mimeType string) string
- func GetMimeTypeFromExtension(ext string) string
- type AcousticCorrelation
- type AcousticData
- type AddPlayLogRequest
- type AudioFile
- type AuthKey
- type Document
- type Fingerprint
- type FingerprintRequest
- type FingerprintResponse
- type FreqDist
- type GetManySongsRequest
- type GetManySongsResponse
- type JsonFsAttr
- type JsonFsLsResponse
- type MarkovMap
- type Meta
- type MultiValuedMap
- type PlayLogEntry
- type SearchIdsResponse
- type SearchResponse
- type Song
- type SongID
- type SongInfo
- type SongIntl
- type SongSet
- type SuggestRequest
- type SuggestResponse
- type Transition
- type UploadResponse
- type User
Constants ¶
const ( MIMETYPE_FLAC = "audio/x-flac" MIMETYPE_MP3 = "audio/mpeg" )
const MarkovGlobalKey = "@GLOBAL"
Variables ¶
This section is empty.
Functions ¶
func GetExtensionForMimeType ¶
Types ¶
type AcousticCorrelation ¶
type AcousticData ¶
type AcousticData struct {
Features []byte `json:"f"`
}
AcousticData stores acoustic analysis output (as a binary blob, which is definitely not optimal).
type AddPlayLogRequest ¶
type AddPlayLogRequest struct {
Songs []SongID `json:"songs"`
}
Add an entry to the playlog. Songs are in increasing time order (most recently played last).
type AudioFile ¶
type AudioFile struct { MD5 string `json:"md5"` MimeType string `json:"mime_type"` Size int64 `json:"size"` SampleRate int `json:"sample_rate"` BitRate int `json:"bitrate"` Channels int `json:"channels"` BitsPerSample int `json:"bits_per_sample"` Duration float64 `json:"duration"` SongId SongID }
AudioFile describes a single audio file that has been uploaded.
func GetBestAudioFile ¶
type AuthKey ¶
type AuthKey struct { KeyId string `json:"key_id"` Secret string `json:"secret"` User string `json:"user"` }
AuthKey stores credentials for a single API key.
type Fingerprint ¶
type Fingerprint struct { Code string `json:"code"` Version string `json:"version"` Ok bool `json:"ok"` Stamp int64 `json:"stamp"` }
Fingerprint holds the binary audio fingerprint data
type FingerprintRequest ¶
type FingerprintRequest struct {
Fingerprints []string `json:"fingerprints"`
}
type FingerprintResponse ¶
type FreqDist ¶
FreqDist contains a probability distribution for a specific N-gram in the Markov model. We store counters instead of probabilities so that we can update the map incrementally.
func NewFreqDist ¶
func NewFreqDist() *FreqDist
func (*FreqDist) MarshalJSON ¶
func (*FreqDist) UnmarshalJSON ¶
type GetManySongsRequest ¶
type GetManySongsRequest struct {
SongIds []SongID `json:"song_ids"`
}
type GetManySongsResponse ¶
type GetManySongsResponse struct {
Results []*Song `json:"results"`
}
type JsonFsAttr ¶
type JsonFsAttr struct { Name string `json:"name"` IsDir bool `json:"is_dir"` Audio *AudioFile `json:"audio"` Meta *Meta `json:"meta"` }
JsonFs data structures.
type JsonFsLsResponse ¶
type JsonFsLsResponse struct {
Results []*JsonFsAttr
}
type MarkovMap ¶
MarkovMap contains probability distributions for playlists. The input tuple size is 1, and it's hard-coded in the interface.
func NewMarkovMap ¶
func NewMarkovMap() *MarkovMap
func (*MarkovMap) GetRandomSong ¶
GetRandomSong returns a random song chosen amongst those that appear as seeds in the map (i.e. that have been listened to at least once, and have at least one transition).
func (*MarkovMap) Len ¶
Len returns the total number of transitions encoded in the map (useful for debugging purposes).
func (*MarkovMap) MarshalJSON ¶
MarshalJSON serializes the map to JSON (using a quite inefficient mechanism at the moment).
func (*MarkovMap) UnmarshalJSON ¶
UnmarshalJSON restores a MarkovMap from a JSON serialization.
func (*MarkovMap) Update ¶
func (m *MarkovMap) Update(in chan Transition)
type Meta ¶
type Meta struct { Artist string `json:"artist"` Title string `json:"title"` Album string `json:"album"` Genre string `json:"genre"` Year int `json:"year"` TrackNum int `json:"track_num"` }
Meta stores metadata about the song.
type MultiValuedMap ¶
MultiValuedMap is a map of attributes to multiple values.
func (MultiValuedMap) Add ¶
func (m MultiValuedMap) Add(key, value string)
Add an attribute/value pair to the document.
type PlayLogEntry ¶
type PlayLogEntry struct { // Username. User string // History of played songs, from oldest to most recent. Songs []SongID // Timestamp of this log entry. Timestamp int64 }
PlayLogEntry records a single 'play' action by a user.
type SearchIdsResponse ¶
type SearchIdsResponse struct {
Results []SongID `json:"results"`
}
type SearchResponse ¶
type SearchResponse struct {
Results []*Song `json:"results"`
}
type Song ¶
type Song struct { Id SongID `json:"id"` Files []*AudioFile `json:"files"` Meta Meta `json:"meta"` Info SongInfo `json:"info"` }
Song has the comprehensive song state. Multiple AudioFiles can actually correspond to the same song (different rip, multiple versions, etc). This object is not stored directly in the db.
func NewSong ¶
NewSong assembles a Song object from a single audio file. The song ID will be equal to the file's MD5 checksum. The song will be created in the 'incoming' state.
func (*Song) GetBestAudioFile ¶
GetBestAudioFile returns the 'best' audio file for this song.
func (*Song) GetBestAudioFileByType ¶
GetBestAudioFileByType returns the 'best' file with the given MIME type.
type SongID ¶
type SongID [16]byte
SongID is the primary key type (in-memory). It consists of a MD5 hash, related to the audio contents of the song. We use a binary in-memory representation to save space, but the type is serialized to a hex-encoded string in JSON encodings and in the public API in general.
var NilSongID SongID
func ParseSongID ¶
func ParseSongIDSlice ¶
func (SongID) MarshalJSON ¶
func (*SongID) UnmarshalJSON ¶
type SongInfo ¶
type SongInfo struct { State string `json:"state"` CreatedAt int64 `json:"created_at"` DuplicateOf SongID `json:"duplicate_of"` }
SongInfo contains the internal song state.
type SongIntl ¶
type SongIntl struct { Id SongID `json:"id"` Files []string `json:"files"` Meta Meta `json:"meta"` Info SongInfo `json:"info"` }
SongIntl is the on-database representation of the above structure, with the various fields wrapped.
type SongSet ¶
type SongSet map[SongID]struct{}
Set is a simple unordered collection of songs.
type SuggestRequest ¶
type SuggestResponse ¶
type Transition ¶
A transition from a song to another.
type UploadResponse ¶
type UploadResponse struct {
Ok bool `json:"ok"`
}
type User ¶
type User struct { Email string `json:"email"` Password string `json:"password"` CreatedAt int64 `json:"created_at"` InvitedBy string `json:"invited_by"` InvitesLeft int `json:"invites_left"` State string `json:"state"` AuthKeyIds []string `json:"auth_keys"` }
User holds user information.