spectrum

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package spectrum works out how loud each part of a song's sound is, moment by moment, for the apps' music visualizer. The apps can't hear what they play (an Apple TV has no way to), so the server listens once, with FFmpeg, and they draw from the levels in time with the music.

Index

Constants

View Source
const (
	// FPS is how many moments a second the levels describe.
	FPS = 20
	// Bands is how many parts of the sound each moment has, from the bass
	// (40 Hz) up to the treble (5 kHz), spaced the way ears hear them.
	Bands = 24
)

Variables

This section is empty.

Functions

func Analyze

func Analyze(r io.Reader) ([]byte, error)

Analyze reads 16-bit little-endian mono samples at 10240 a second and returns their levels.

Types

type Analyzer

type Analyzer struct {
	FFmpeg string
	Dir    string
	// Timeout is the longest one file may take; 0 means five minutes.
	Timeout time.Duration
	// contains filtered or unexported fields
}

Analyzer works out songs' levels and keeps them, so each file is listened to once per version of it.

func New

func New(ffmpeg, dir string) *Analyzer

func (*Analyzer) Levels

func (a *Analyzer) Levels(ctx context.Context, path string) ([]byte, error)

Levels returns the file's levels: Bands bytes for each moment, 0 for silence to 255 for as loud as that band gets in the song.

Jump to

Keyboard shortcuts

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