bpm

package module
v0.0.0-...-ff5abaa Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: GPL-2.0 Imports: 2 Imported by: 1

README

bpm

GoDoc

Library and tool for dealing with beats per second detection in Go

This is a direct port of Mark Hills bpm-tools.

For that reason, it is also under the same licence as that utility, ( GPLv2 ).

You can use this version as a libary too, In testing you may find it produces slightly different results than bpm-tools. This is because both tools use a random float on mid point selection, Ideally it would use a static one, but I won't replicate drand exactly to just get 1:1 matching with the offical tools.

Usage of the command line util

You need to feed the command line utility PCM 32 bit little edian floats (mono), there are two easy ways to do this:

Sox:

sox "$FILE" -r 44100 -e float -c 1 -t raw - | ./cmd /dev/stdin

ffmpeg:

ffmpeg -v quiet -i 1479012090.ts -f f32le -ac 1 -c:a pcm_f32le -ar 44100 pipe:1 | ./cmd /dev/stdin

You can also ask for a "snapshot" per second of the BPM calculated, using progressive mode:

$ ffmpeg -v quiet -i 1479012090.ts -f f32le -ac 1 -c:a pcm_f32le -ar 44100 pipe:1 | ./cmd -progressive=true /dev/stdin
179.020979
193.086109
191.044776

The first value is the BPM for the first 10 seconds, the 2nd for 10-20 seconds, 3rd is the 20-30th (and more until you stop giving it data)

Documentation

Index

Constants

View Source
const (
	RATE     = 44100
	INTERVAL = 128
)

Variables

This section is empty.

Functions

func ProgressivelyReadFloatArray

func ProgressivelyReadFloatArray(in chan float32, out chan float32)

ProgressivelyReadFloatArray takes a channel of pcm_s16le samples and processes it give back samples for that can be used for ScanForBpm

func ReadFloatArray

func ReadFloatArray(samples []float32) []float32

ReadFloatArray takes a pcm_s16le file and processes it into an array that can be used by ScanForBpm

func ScanForBpm

func ScanForBpm(nrg []float32, slowest, fastest float64, steps, samples int) float64

ScanForBpm Scan a range of BPM values for the one with the minimum autodifference, needs to be fed a sampled input, you can use ReadFloatArray to do that.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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