fingerprint

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

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

Go to latest
Published: Aug 3, 2014 License: MIT Imports: 6 Imported by: 2

README

fingerprint GoDoc

Acoustic fingerprinting in Go.

License

MIT

Documentation

Overview

Package fingerprint provides functionality to calculate, compare and analyse acoustic fingerprints of raw audio data. According to Wikipedia, acoustic fingerprint is a condensed digital summary, deterministically generated from an audio signal, that can be used to identify an audio sample or quickly locate similar items in an audio database.

Installation

go get https://github.com/go-fingerprint/fingerprint

You should also install any package containing the implementation of any fingerprinting algoritms. Currently only bindings to chromaprint library are supported.

go get https://github.com/go-fingerprint/gochroma

Usage

reader, _ := os.Open("test.raw")
fpcalc := chromaprint.New(chromaprint.AlgorithmDefault)
defer fpcalc.Close()
fprint, _ := fpcalc.Fingerprint(
	fingerprint.RawInfo{
		Src: reader,
		Channels: 2,
		Rate: 44100,
		MaxSeconds: 120,
	})
// do anything with fingerprint...

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLength = errors.New(`fingerprint: unable to compare fingerprints with
	different length`)
)

ErrLength describes a error that occurs when trying to compare fingerprints with different length.

Functions

func Compare

func Compare(fprint1, fprint2 []int32) (float64, error)

Compare returns a number that indicates how two fingerprints are similar to each other as a value from 0 to 1. Usually two fingerprints can be considered identical when the score is greater or equal than 0.95.

func Distance

func Distance(fprint1, fprint2 []int32) ([]int32, error)

Distance returns slice of pairwisely XOR-ed fingerprints.

func ImageDistance

func ImageDistance(fprint1, fprint2 []int32) (im image.Image, err error)

ImageDistance returns black-and white image.Image with graphical representation of distance between fingerprints.

func ToImage

func ToImage(fprint []int32) (im image.Image)

ToImage returns black-and-white image.Image with graphical representation of fingerprint: each column represents 32-bit integer, where black and white pixels correspond to 1 and 0 respectively.

Types

type Calculator

type Calculator interface {
	Fingerprint(i RawInfo) (fprint string, err error)
	RawFingerprint(i RawInfo) (fprint []int32, err error)
}

Calculator is an interface type that can calculate acoustic fingerprints and return as raw int32 data or as base64-encoded string.

type RawInfo

type RawInfo struct {
	// Reader connected with the audio data stream
	Src io.Reader
	// Number of channels of audio stream
	Channels uint
	// Sampling rate of input audio data, e.g. 44100
	Rate uint
	// Maximum number of seconds that will be taken
	// from the audio stream
	MaxSeconds uint
}

A RawInfo holds information about raw audio data.

Jump to

Keyboard shortcuts

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