Documentation
¶
Index ¶
- Constants
- type Cent
- type EventPoint
- type EventPointProcessor
- func (e *EventPointProcessor) GetEventPoints() []EventPoint
- func (e *EventPointProcessor) GetFingerprints() []Fingerprint
- func (e *EventPointProcessor) GetLatency() int64
- func (e *EventPointProcessor) GetMagnitudes() []float32
- func (e *EventPointProcessor) Process(source audio.Source) error
- func (e *EventPointProcessor) ProcessBlockChannel(channel chan []float32) error
- func (e *EventPointProcessor) ProcessingFinished()
- type Fingerprint
- func (f *Fingerprint) CompactHash() uint32
- func (f *Fingerprint) Equals(other *Fingerprint) bool
- func (f *Fingerprint) F1() uint32
- func (f *Fingerprint) GetHash(hashType FingerprintHashType) uint64
- func (f *Fingerprint) Hash() uint64
- func (f *Fingerprint) RobustHash() uint32
- func (f *Fingerprint) String() string
- func (f *Fingerprint) T1() uint32
- type FingerprintHashType
- type Hertz
- type Instance
- func (i *Instance) BinToHertz(bin uint32) Hertz
- func (i *Instance) BlockToDuration(t uint32, latency time.Duration) time.Duration
- func (i *Instance) GetEventPointProcessor() (*EventPointProcessor, error)
- func (i *Instance) GetStrategy(store Store, resamplerQuality ...filter.ResampleQuality) *Strategy
- func (i *Instance) GetTransformBandsPerOctave() int
- func (i *Instance) GetTransformMaximumFrequency() Hertz
- func (i *Instance) GetTransformMinimumFrequency() Hertz
- func (i *Instance) GetTransformReferenceFrequency() Hertz
- func (i *Instance) GetTransformTimeResolutionInSamples() int
- type MatchedRecord
- type Octave
- type QueryResult
- type ResourceId
- type Store
- type StoreRecord
- type Strategy
- func (s *Strategy) BlockChannelToFingerprints(channel chan []float32) []Fingerprint
- func (s *Strategy) QueryFingerprints(prints []Fingerprint) []QueryResult
- func (s *Strategy) QueryFingerprintsAsync(prints []Fingerprint, callback func(queryResults []QueryResult))
- func (s *Strategy) QueryStoreRecords(records []StoreRecord) (queryResults []QueryResult)
- func (s *Strategy) SourceToFingerprints(source audio.Source) []Fingerprint
- func (s *Strategy) StoreFingerprints(resourceId ResourceId, prints []Fingerprint)
- func (s *Strategy) StoreSource(resourceId ResourceId, source audio.Source) time.Duration
Constants ¶
const ( //Hash An uint64. Space is not fully used. Hash = FingerprintHashType(iota) //CompactHash An uint32. Slightly changed fingerprint with f1Range as 6-bit instead of 8-bit, so it fits into 32-bit values CompactHash //RobustHash An uint32. Uses Morton2D functions. Experimental. RobustHash )
const CentsPerOctave = 1200
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cent ¶
type Cent int64
Cent Twelve-tone equal temperament divides the Octave into 12 semitones of 100 Cent each.
type EventPoint ¶
type EventPoint struct { // Time The time expressed using an analysis frame index. Time uint32 // Frequency The frequency expressed using the bin number Instance.TransformBands in the constant Q transform (Cent). Frequency uint32 // Magnitude The energy value of the element. Magnitude float32 }
func (*EventPoint) DeltaTime ¶
func (p *EventPoint) DeltaTime(point *EventPoint) int64
type EventPointProcessor ¶
func NewEventPointProcessor ¶
func NewEventPointProcessor(instance *Instance) (*EventPointProcessor, error)
func (*EventPointProcessor) GetEventPoints ¶
func (e *EventPointProcessor) GetEventPoints() []EventPoint
func (*EventPointProcessor) GetFingerprints ¶
func (e *EventPointProcessor) GetFingerprints() []Fingerprint
func (*EventPointProcessor) GetLatency ¶
func (e *EventPointProcessor) GetLatency() int64
func (*EventPointProcessor) GetMagnitudes ¶
func (e *EventPointProcessor) GetMagnitudes() []float32
func (*EventPointProcessor) Process ¶
func (e *EventPointProcessor) Process(source audio.Source) error
func (*EventPointProcessor) ProcessBlockChannel ¶
func (e *EventPointProcessor) ProcessBlockChannel(channel chan []float32) error
func (*EventPointProcessor) ProcessingFinished ¶
func (e *EventPointProcessor) ProcessingFinished()
type Fingerprint ¶
type Fingerprint struct {
// contains filtered or unexported fields
}
Fingerprint A fingerprint connects three event points in a spectrogram. The points are defined by a time and frequency pair, both encoded with an integer. The frequency is defined by the bin index in the spectrogram. The time is defined as the index of the block processed.
func NewFingerprint ¶
func NewFingerprint(p1, p2, p3 *EventPoint) Fingerprint
func (*Fingerprint) CompactHash ¶
func (f *Fingerprint) CompactHash() uint32
CompactHash Slightly changed fingerprint with f1Range as 6-bit instead of 8-bit, so it fits into 32-bit values
func (*Fingerprint) Equals ¶
func (f *Fingerprint) Equals(other *Fingerprint) bool
func (*Fingerprint) F1 ¶
func (f *Fingerprint) F1() uint32
func (*Fingerprint) GetHash ¶
func (f *Fingerprint) GetHash(hashType FingerprintHashType) uint64
func (*Fingerprint) Hash ¶
func (f *Fingerprint) Hash() uint64
func (*Fingerprint) RobustHash ¶
func (f *Fingerprint) RobustHash() uint32
func (*Fingerprint) String ¶
func (f *Fingerprint) String() string
func (*Fingerprint) T1 ¶
func (f *Fingerprint) T1() uint32
type FingerprintHashType ¶
type FingerprintHashType int
type Instance ¶
type Instance struct { //BlockSize size of audio blocks and buffers, in number of samples per channel, passed to lower backends. Needs to be a power of two. BlockSize int //SampleRate in Hertz. sample rate of audio that the processor and fingerprinter require/resample to. SampleRate Hertz //TransformMinimumFrequency in Hertz. Acts as base for all others frequencies with octave offsets TransformMinimumFrequency Hertz //TransformReferenceFrequencyOffset in octaves above TransformMinimumFrequency. Determines bin centers TransformReferenceFrequencyOffset Octave //TransformMaximumFrequencyOffset in octaves above TransformMinimumFrequency. TransformMaximumFrequencyOffset Octave //TransformBands in absolute band count. Do not change away from 512 unless you know what you are doing. Total amount of bins for all octaves from min to TransformMaximumFrequencyOctaves TransformBands int //TransformTimeResolution in absolute values. Time resolution of fingerprints/matches TransformTimeResolution time.Duration //QueryRange in absolute time bins / hash units(???) range. When searching for hash matches, use query hash value +- QueryRange value QueryRange int //QueryMinimumHitsBeforeFiltering and QueryMinimumHitsAfterFiltering probably require adjustment if any of TransformTimeResolution, QueryRange are changed //QueryMinimumHitsBeforeFiltering in count per resourceId. Minimum amount of hits for a match to be considered for further filtering. QueryMinimumHitsBeforeFiltering int //QueryMinimumHitsAfterFiltering in count per resourceId. Minimum amount of hits for a match to be considered after basic filtering. QueryMinimumHitsAfterFiltering int //QueryTimeRatioFactor in ratio factor. Any match with its time ratio below or above 1 +- this value will not be considered QueryTimeRatioFactor float64 //QueryFrequencyRatioFactor in ratio factor. Any match with its frequency ratio below or above 1 +- this value will not be considered //TODO: maybe change this to work on Octave or Cent? QueryFrequencyRatioFactor float64 //QueryDurationPercentageMinimum in absolute percentage. Any match with its duration % ratio below this value will not be considered QueryDurationPercentageMinimum float64 //QueryDurationMinimum in absolute value. Any match with its absolute duration below this value will not be considered QueryDurationMinimum time.Duration QueryMaximumHitListSize int QueryHitListDivisor int QueryHitListDeltaTimeDepth int //PointFilterMaximumTimeFilterSize in samples from SampleRate. Must be odd PointFilterMaximumTimeFilterSize int //PointFilterMaximumTimeFilterSize in Cent units(???) PointFilterMaximumFrequencyFilterSize int //PointFilterMinimumTimeDistance in TransformTimeResolution units. EventPoint pairings below this time distance will not be considered PointFilterMinimumTimeDistance int //PointFilterMaximumTimeDistance in TransformTimeResolution units. EventPoint pairings above this time distance will not be considered PointFilterMaximumTimeDistance int //PointFilterMinimumFrequencyDistance in Cent. EventPoint pairings below this frequency distance will not be considered PointFilterMinimumFrequencyDistance Cent //PointFilterMaximumFrequencyDistance in Cent. EventPoint pairings above this frequency distance will not be considered PointFilterMaximumFrequencyDistance Cent //Other options //HashType select whether to use Fingerprint.Hash, Fingerprint.RobustHash or Fingerprint.CompactHash method when creating StoreRecord HashType FingerprintHashType }
func NewDefaultInstance ¶
func NewDefaultInstance() *Instance
func NewDefaultPackedInstance ¶
func NewDefaultPackedInstance() *Instance
func (*Instance) BinToHertz ¶
func (*Instance) BlockToDuration ¶
func (*Instance) GetEventPointProcessor ¶
func (i *Instance) GetEventPointProcessor() (*EventPointProcessor, error)
func (*Instance) GetStrategy ¶
func (i *Instance) GetStrategy(store Store, resamplerQuality ...filter.ResampleQuality) *Strategy
func (*Instance) GetTransformBandsPerOctave ¶
func (*Instance) GetTransformMaximumFrequency ¶
func (*Instance) GetTransformMinimumFrequency ¶
func (*Instance) GetTransformReferenceFrequency ¶
func (*Instance) GetTransformTimeResolutionInSamples ¶
type MatchedRecord ¶
type MatchedRecord struct { Query StoreRecord Match StoreRecord }
func (*MatchedRecord) DeltaTime ¶
func (r *MatchedRecord) DeltaTime() int64
type Octave ¶
type Octave int
Octave The interval between one musical pitch and another with double its frequency
type QueryResult ¶
type ResourceId ¶
type ResourceId uint64
type Store ¶
type Store interface { GetPanakoMatch(record StoreRecord, lookupRange int) chan *MatchedRecord GetPanakoMatches(records []StoreRecord, lookupRange int) chan *MatchedRecord //GetPanakoRecords optional to implement GetPanakoRecords(resourceId ResourceId) []StoreRecord StorePanakoPrint(record StoreRecord) StorePanakoPrints(records []StoreRecord) }
type StoreRecord ¶
type StoreRecord struct { ResourceId ResourceId Hash uint64 Time uint32 Frequency uint32 }
func NewStoreRecordFromCompactPacked ¶
func NewStoreRecordFromCompactPacked(resourceId ResourceId, hash, packed uint32) StoreRecord
func NewStoreRecordFromPacked ¶
func NewStoreRecordFromPacked(resourceId ResourceId, hash, packed uint64) StoreRecord
func (*StoreRecord) GetCompactPackedPrint ¶
func (r *StoreRecord) GetCompactPackedPrint() (uint32, uint32)
GetCompactPackedPrint Only use this when the Strategy instance option Instance.HashType is CompactHash, and bounds range is known for Time (limited to 20-bit) and Frequency (limited to 12-bit) This lets most of the max range for Frequency, and several hours of uninterrupted timestamps for Time
func (*StoreRecord) GetPackedPrint ¶
func (r *StoreRecord) GetPackedPrint() (uint64, uint64)
type Strategy ¶
type Strategy struct {
// contains filtered or unexported fields
}
func NewStrategy ¶
func NewStrategy(instance *Instance, store Store, resamplerQuality ...filter.ResampleQuality) *Strategy
func (*Strategy) BlockChannelToFingerprints ¶
func (s *Strategy) BlockChannelToFingerprints(channel chan []float32) []Fingerprint
func (*Strategy) QueryFingerprints ¶
func (s *Strategy) QueryFingerprints(prints []Fingerprint) []QueryResult
func (*Strategy) QueryFingerprintsAsync ¶
func (s *Strategy) QueryFingerprintsAsync(prints []Fingerprint, callback func(queryResults []QueryResult))
func (*Strategy) QueryStoreRecords ¶
func (s *Strategy) QueryStoreRecords(records []StoreRecord) (queryResults []QueryResult)
func (*Strategy) SourceToFingerprints ¶
func (s *Strategy) SourceToFingerprints(source audio.Source) []Fingerprint
func (*Strategy) StoreFingerprints ¶
func (s *Strategy) StoreFingerprints(resourceId ResourceId, prints []Fingerprint)