Documentation ¶
Overview ¶
Package freq gives frequency types and operations.
Package freq supports various scale related representations, including intervals and Mels.
Index ¶
- Constants
- type I
- type Mel
- type T
- func (f T) Cycles(d time.Duration) (int, time.Duration)
- func (f T) Float64() float64
- func (s T) FreqOf(rps float64) T
- func (f T) FromSamplesPerCycle(spc float64) T
- func (f T) MarshalJSON() ([]byte, error)
- func (f T) Period() time.Duration
- func (f T) Phase(d time.Duration) float64
- func (f T) RadsPer(g T) float64
- func (f T) RadsPerAt(s T) float64
- func (f T) SamplesPerCycle(g T) float64
- func (f T) String() string
- func (f *T) UnmarshalJSON(b []byte) error
Constants ¶
const ( Octave = I(2) Semitone = I(1.059463094359) Cent = I(1.000577789507) )
const ( NanoHertz T = 1 MicroHertz = 1000 * NanoHertz MilliHertz = 1000 * MicroHertz Hertz = 1000 * MilliHertz KiloHertz = 1000 * Hertz MegaHertz = 1000 * KiloHertz GigaHertz = 1000 * MegaHertz )
Different levels of "ouch".
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type I ¶
type I float64
Type I represents a frequency interval.
type Mel ¶
type Mel int64
Mel is a unit of frequency in which a difference less than MelAudible is generally imperceivable (melodically). See https://en.wikipedia.org/wiki/Mel_scale
MelAudible is the smallest difference in frequency in Mels which is melodically audible. Smaller harmonic differences are audible due to beating.
type T ¶
type T int64
T represents a frequency.
func FromPeriod ¶
FromPeriod gives the frequency whose period is p.
func (T) Cycles ¶
Cycles gives the number of times a signal at frequency f cycles during d time and a remainder duration.
For example if f = 3 Hz and t=.5sec then f.Cycles() returns (1, .5sec - .33333 sec).
func (T) FreqOf ¶
FreqOf gives the frequency f' such that f' has r radians per sample at sample freq f.
func (T) FromSamplesPerCycle ¶
FromSamplesPerCycle returns the frequency g which has
f.SamplesCyclesPerCycle(g) ~= spc
where "~=" accounts for floating point rounding to the smallest frequency quantum (NanoHertz).
func (T) MarshalJSON ¶
func (T) Phase ¶
Phase gives the offet or phase in radians at time d, assuming a signal at frequency f starts at 0.
func (T) RadsPerAt ¶
RadsPerAt gives the radians per sample of a signal at frequency f sampled at frequency r.
func (T) SamplesPerCycle ¶
SamplesPerCycle returns the number of samples, as a float, at sample rate f which constitute one cycle of the frequency g.