core

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 1 Imported by: 1 module, 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 core defines the data currency shared by every layer of the player: interleaved float32 PCM at a known frame format, frame-domain positions, and the Module contract that pre- and post-ring processing both satisfy.

Nothing in this package may import another molo package; every other package depends on core.

Index

Constants

This section is empty.

Variables

View Source
var CanonicalFormat = FrameFormat{Rate: 48000, Ch: 2, Fmt: F32}

CanonicalFormat is the one PCM layout the engine speaks end to end: every decoder output is normalized to it before the ring, the device is opened for it, and positions are counted in its frames. It lives here, in the only package every layer already depends on, so a rate change breaks compilation in one place instead of drifting silently between packages.

Functions

This section is empty.

Types

type DurationMode

type DurationMode uint8

DurationMode selects how much work a probe may do to learn a stream length.

const (
	// DurationUnknown opens as fast as possible and leaves the total unknown.
	DurationUnknown DurationMode = iota
	// DurationProbe reads the tail of the file, cheap.
	DurationProbe
	// DurationScan reads and decodes the whole file.
	DurationScan
)

type FrameFormat

type FrameFormat struct {
	Rate int
	Ch   int
	Fmt  SampleFormat
}

FrameFormat describes an interleaved PCM stream. Rate is in Hz and Ch is the interleaved channel count, so one frame holds Ch samples.

func (FrameFormat) BytesPerFrame

func (f FrameFormat) BytesPerFrame() int

BytesPerFrame is the size of one interleaved frame in bytes.

func (FrameFormat) Equal

func (f FrameFormat) Equal(o FrameFormat) bool

Equal reports whether two formats produce identical PCM layouts.

type Module

type Module interface {
	Name() string
	Configure(in FrameFormat) (out FrameFormat, err error)
	Process(buf []float32, frames int) error
	Reset() error
}

Module is one insertable stage of the pipeline. Pre-ring modules may allocate; post-ring modules are on the real-time path and must not.

type SampleFormat

type SampleFormat uint8

SampleFormat identifies how one PCM sample is encoded on the wire or in a device buffer. The engine itself works in F32 regardless of the source format; the others exist so factories can describe what they decode natively.

const (
	// F32 is 32-bit interleaved floating-point PCM, the engine's own currency.
	F32 SampleFormat = iota
	// S16 is 16-bit interleaved signed-integer PCM.
	S16
	// S32 is 32-bit interleaved signed-integer PCM.
	S32
)

type StreamInfo

type StreamInfo struct {
	Format      FrameFormat
	TotalFrames int64
	Bitrate     int

	// SourceSamples and SourceRate hold the exact length in the source domain,
	// so a source whose rate does not divide evenly into 48 kHz (44.1 kHz is
	// the common case) still reports a duration. Zero means unknown.
	SourceSamples int64
	SourceRate    int
}

StreamInfo describes a decoded stream. TotalFrames is in 48 kHz output frames and is -1 while unknown, which is the normal state right after Open.

func (StreamInfo) Duration

func (s StreamInfo) Duration() time.Duration

Duration converts the stream length to wall-clock time. The source domain is preferred when it is known: TotalFrames is the output frame count the delivery path clamps to and is -1 whenever the source rate does not divide exactly into 48 kHz, while SourceSamples is the exact source-domain length that survives that case. Unknown lengths and formats without a usable rate yield zero so callers can treat "no duration" as "not yet known" instead of an error.

Jump to

Keyboard shortcuts

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