Giter VIP home page Giter VIP logo

panako's Introduction

Panako build status Panako JOSS DOI badge

Panako – Acoustic Fingerprinting

Panako is an acoustic fingerprinting system. The system is able to extract fingerprints from an audio stream, and either store those fingerprints in a database, or find a match between the extracted fingerprints and stored fingerprints. Several acoustic fingerprinting algorithms are implemented within Panako. The main algorithm, the Panako algorithm, has the feature that audio queries can be identified reliably and quickly even if they has been sped up, time stretched or pitch shifted with respect to the reference audio. The main focus of Panako is to serve as a demonstration of the Panako algorithm. Other acoustic fingerprinting schemes are implemented to serve as a baseline for comparison. More information can be found in the article about Panako.

Please be aware of the patents US7627477 B2 and US6990453 and perhaps others. They describe techniques used in some algorithms implemented within Panako. The patents limit the use of some algorithms under various conditions and for several regions. Please make sure to consult your intellectual property rights specialist if you are in doubt about these restrictions. If these restrictions apply, respect the patent holders rights. The first aim of Panako is to serve as a research platform to experiment with and improve fingerprinting algorithms.

This document covers installation, usage and configuration of Panako.

The Panako source code is licensed under the GNU Affero General Public License.

Overview

  1. Why Panako?
  2. Getting Started
  3. Usage
    1. Store Fingerprints
    2. Query for Matches
    3. Monitor Stream for Matches
    4. Print Storage Statistics
    5. Print Configuration
  1. Panako test run and output
  2. Further reading
  3. Panako and docker
  4. Evaluate Panako
  5. Contribute to Panako
  6. Credits
  7. Changelog

Why Panako?

Content based music search algorithms make it possible to identify a small audio fragment in a digital music archive with potentially millions of songs. Current search algorithms are able to respond quickly and reliably on an audio query, even if there is noise or other distortions present. During the last decades they have been used successfully as digital music archive management tools, music identification services for smartphones or for digital rights management.

General content based audio search scheme
Fig. General content based audio search scheme.

Most algorithms, as they are described in the literature, do not allow substantial changes in replay speed. The speed of the audio query needs to be the same as the reference audio for the current algorithms to work. This poses a problem, since changes in replay speed do occur commonly, they are either introduced by accident during an analog to digital conversion or are introduced deliberately.

Analogue physical media such as wax cylinders, wire recordings, magnetic tapes and grammophone records can be digitized at an incorrect or varying playback speed. Even when calibrated mechanical devices are used in a digitization process, the media could already have been recorded at an undesirable speed. To identify duplicates in a digitized archive, a music search algorithm should compensate for changes in replay speed

Next to accidental speed changes, deliberate speed manipulations are sometimes introduced during radio broadcasts: occasionally songs are played a bit faster to fit into a timeslot. During a DJ-set speed changes are almost always present. To correctly identify audio in these cases as well, a music search algorithm robust against pitch shifting, time stretching and speed changes is desired.

The Panako algorithm allows such changes while maintaining other desired features as scalability, robustness and reliability. Next to the panako algorithm there is also an implementation of the algorithm described in An Industrial-Strength Audio Search Algorithm (internally identified as Olaf). Also the algorithm in A Robust Audio Fingerprinter Based on Pitch Class Histograms – Applications for Ethnic Music Archives is available. To make comparisons between fingerprinting systems easy, researchers are kindly invited to contribute algorithms to the Panako project.

Alternative open source music identification systems are audfprint Matlab, audfprint Python, NeuralFP and echoprint. Alternative systems with similar features are described in US7627477 B2 and in Quad-based Audio Fingerprinting Robust To Time And Frequency Scaling by Reinhard Sonnleitner and Gerhard Widmer.

Getting started

The Panako repository is organized as follows:

  • src contains the Java source files.
  • lib contains some dependencies (JAR-files).
  • resources default configuration settings, script for evaluation and to analyze results and schemas to document Panako.

To compile Panako, a Java JDK 11 or later is required. See, for example the OpenJDK website", for installation instructions for your operating system.

Panako uses the Gradle build system. If Gradle is not present on your system it is automatically installed by the gradlew script. To build and install Panako, the following should get you started:

git clone --depth 1 https://github.com/JorenSix/Panako.git
cd Panako
./gradlew shadowJar #Builds the core Panako library
./gradlew install #Installs Panako in the ~/.panako directory
./gradlew javadoc #Creates the documentation in build/doc
#copy the panako startup script to your path:
sudo cp resources/defaults/panako /usr/local/bin 

The last command copies the startup script in resources/defaults/panako to a directory in your path. The script allows for easy access to Panako’s functionality. If this does not work for you, you can still call Panako using java -jar ~/.panako/panako.jar [..args].

Panako decodes audio using by calling ffmpeg, an utility for decoding and resampling audio.
The ffmpeg command needs to be on the systems path. On a Debian like system:

apt-get install ffmpeg

At this point it might be of interest to run the test to see if Panako is working correctly.

The current release does not support Apple M1 out of the box. Additional steps are needed to provide the Java lmdb bidge. This blogpost details how to get java lmdb working on Apple M1.

Panako Usage

Panako provides a command line interface, it can be called using panako subapplication [argument...]. For each task Panako has to perform, there is a subapplication. There are subapplications to store fingerprints, query audio fragments, monitor audio streams, and so on. Each subapplication has its own list of arguments, options, and output format that define the behavior of the subapplication. The screen capture below shows a typical interaction with Panako.

A typical interaction with Panako via the command line interface
Fig. A typical interaction with Panako via the command line interface. It shows how to store audio, perform a query and how to print database statistics.

To save some keystrokes the name of the subapplication can be shortened using a unique prefix. For example panako m file.mp3 is expanded to panako monitor file.mp3. Since both stats and store are valid subapplications the store call can be shortened to panako sto *.mp3, panako s *.mp3 gives an invalid application message. A trie is used to find a unique prefix.

What follows is a list of those subapplications, their arguments, and respective goal.

Store Fingerprints – panako store

The store instruction extracts fingerprints from audio tracks and stores those in the datastorage. The command expects a list of audio files, video files or a text file with a list of file names.

#Audio is converted automatically
panako store audio.mp3 audio.ogg audio.flac audio.wav 

#The first audio stream of video containers formats are used.
panako store audio.mpc audio.mp4 audio.acc audio.avi audio.ogv audio.wma 

#Glob characters can be practical
panako store */*.mp3

#A text file with audio files can be used as well
#The following searches for all mp3's (recursively) and
#stores them in a text file
find . -name '*.mp3' > list.txt
#Iterate the list
panako store list.txt

Remove fingerprints – panako delete

This application removes fingerprints from the index. It essentially reverses the store operation. The operation can be checked with panako stats

panako delete test.mp3

The default key-value-store is backed by some kind of B-tree structure. Removing many elements from such structure might leave the tree in an unbalanced state, which results in worse performance. I am not sure about the performance implications of deletion for LMDB but it might be of interest to either rebuild the index or avoid deletion as much as possible.

Query for Matches – panako query

The query command extracts fingerprints from an audio frament and tries to match the fingerprints with the database.

panako query short_audio.mp3

Monitor Stream for Matches – panako monitor

The query command extracts fingerprints from a short audio frament and tries to match the fingerprints with the database. The incoming audio is, by default, chopped in parts of 25s with an overlap of 5s. So every 25-5=20s the database is queried and a result is printed to the command line.

panako monitor [short_audio.mp3]

If no audio file is given, the default microphone is used as input.

Print Storage Statistics – panako stats

The stats command prints statistics about the stored fingerprints and the number of audio fragments. If an integer argument is given it keeps printing the stats every x seconds.

panako stats # print stats once
panako stats 20 # print stats every 20s 

Print Configuration – panako config

The config subapplication prints the configuration currently in use.

panako config

To override configuration values there are two options. The first option is to create a configuration file, by default at the following location: ~./panako/config.properties. The configuration file is a properties text file. An commented configuration file should be included in the doc directory at doc/config.properties.

The second option to override configuration values is by adding them to the arguments of the command line call as follows:

panako subapplication CONFIG_KEY=value

For example, if you do not want to check for duplicate files while building a fingerprint database the following can be done:

panako store file.mp3 CHECK_FOR_DUPLICATES=FALSE

The configuration values provided as a command line argument have priority over the ones in the configuration file. If there is no value configured a default is used automatically. To find out which configuration options are available and their respective functions, consult the documented example configuration file doc/config.properties..

Resolve an identifier for a filename – panako resolve

This application simply returns the identifier that is used internally for a filename. The following call returns for example 54657653:

panako resolve test.mp3

The internal identifiers are currently defined using integers.

Prints how similar two audio files are – panako same

This application checks the similarity of two files. The percentage returned indicates the percentage of seconds for which fingerprints match between the first and second file. So 100% that matches are found in every second. A result of 30% still means that much of the audio matches.

panako same first.mp3 second.mp3

Note that this operation is performed in memory. Nothing changes on disk.

Testing Panako

There is a script provided to quickly test Panako with a small dataset. Note that you might need a new shell environment to use panako. To download the dataset you also need SoX and wget on your system.

The test first downloads a set of songs from Jamendo, a website with creative commons licensed music. Then it selects a random part of each downloaded song to use as a query. The query is modified by running an audio compressor followed by a random speed-up between 93% and 107%. Then Panako tries to match each query to the reference items.

#brew install sox wget
#apt-get install sox wget
panako -v #prints version
panako stats #db info
cd resources/scripts/create_test_dataset
ruby create_dataset.rb #make sure SoX is installed
panako store STRATEGY=panako dataset/reference_items/*
panako query STRATEGY=panako dataset/queries/*

The output after running the store command should be similar to the following. The last column represents how many seconds of audio can be processed in a single second. On the device that ran the command about 80 seconds are processed in a single second.

Index;Audiofile;Audio duration;Processing time;Audio duration/processing time
1/5;1009601.wav;00:00:32;674.00 ms;47.12
2/5;406015.wav;00:03:21;2.53 s;79.50
3/5;557132.wav;00:04:24;3.25 s;81.18
4/5;566726.wav;00:03:17;2.43 s;81.10
5/5;946523.wav;00:04:39;3.55 s;78.5

After running the query command the following should appear.

Index; Total ; Query path;Query start (s);Query stop (s); Match path;Match id; Match start (s); Match stop (s); Match score; Time factor (%); Frequency factor(%); Seconds with match (%)
1 ; 5 ; queries/1009601_17_100.wav ; 1.269 ; 12.925 ; reference_items/1009601.wav ; 1009601 ; 18.269 ; 29.925 ; 193 ; 1.001 % ; 1.000 %; 1.00
4 ; 5 ; queries/566726_129_101.wav ; 0.885 ; 8.381 ; reference_items/566726.wav ; 566726 ; 129.893 ; 137.437 ; 127 ; 1.006 % ; 1.016 %; 1.00
5 ; 5 ; queries/946523_208_103.wav ; 0.941 ; 11.909 ; reference_items/946523.wav ; 946523 ; 208.949 ; 220.245 ; 70 ; 1.031 % ; 1.016 %; 0.83
3 ; 5 ; queries/557132_97_104.wav ; 0.925 ; 12.405 ; reference_items/557132.wav ; 557132 ; 97.933 ; 109.869 ; 173 ; 1.040 % ; 1.042 %; 1.00
2 ; 5 ; queries/406015_182_97.wav ; 0.917 ; 9.109 ; reference_items/406015.wav ; 406015 ; 182.917 ; 190.853 ; 101 ; 0.972 % ; 0.976 %; 1.00

To interpret the results, it helps to explain the output:

  • Index The index in the list of queries, note that the results might be out of order due to the multi-threaded nature of Panako.
  • Total The total number of queries being handled.
  • Query path The path of the query file
  • Query start (s) The matching part of the query with the reference starts at this point in the query. It is expressed in seconds.
  • Query stop (s) The matching part of the query with the reference stops at this point in the query. It is expressed in seconds.
  • Match path The path of the matching file.
  • Match id The internal identifier of the matching file. If the filename contains only digits then it equals the file name (as is the case here). Otherwise it is a hash of the filename.
  • Match start (s) The matching part of the query with the reference starts at this point in the reference. It is expressed in seconds.
  • Match stop (s) The matching part of the query with the reference stops at this point in the reference. It is expressed in seconds.
  • Match score The number of matching fingerprints between query and reference. The number of fingerprints per second can be calculated by dividing by the match duration.
  • Time factor (%) How much faster the query is with respect to the reference.
  • Frequency factor(%) How much higher in pitch the query is with respect to the reference. If the query is sped up the time factor is expected to be nearly equal to the frequency factor.
  • Seconds with match (%) The number of seconds for which matches are found. If in each matching second a match is found, then this number is 1. A low ratio might indicate a false positive.

For the test queries the start of the match is encoded into the filename. Likewise for the speed-up factor and matching identifier. For example queries/557132_97_104.wav expects to match the file with identifier 557132 starting from second 97 at a speed up of 104%. When looking at the result this closely matches what is reported.

See below for a full evaluation of Panako. The evaluation tests retrieval rates for various factors of pitch-shifting, time-stretching, speed-up and some audio effects.

Benchmarking Panako

To get an idea on the speed and scalability of panako, there is a benchmark script and some more information on benchmarking panako and how to run the benchmark yourself.

Panako and Docker

Panako can also be ran in a containerized environment. A Dockerfile is provided which should both work on x86_64 as aarch64. To build the container and run commands the following should get you started. Note that the database with fingerprints is located on the host at ~/.panako/docker:

To access audio files relative paths are given with respect to the current directory on the host. Watch out with absolute (host) paths, these will not work correctly.

docker build -t panako:2.1 resources/scripts/
mkdir -p $HOME/.panako/docker
wget "https://filesamples.com/samples/audio/mp3/sample3.mp3"
#Store and test if it is added to the database
docker run -v $HOME/.panako/docker:/root/.panako/dbs -v $PWD:/root/audio panako:2.1 panako store sample3.mp3
docker run -v $HOME/.panako/docker:/root/.panako/dbs panako:2.1 panako stats
#change the algorithm to panako
docker run -v $HOME/.panako/docker:/root/.panako/dbs -v $PWD:/root/audio panako:2.1 panako store STRATEGY=panako sample3.mp3
docker run -v $HOME/.panako/docker:/root/.panako/dbs -v $PWD:/root/audio panako:2.1 panako query STRATEGY=panako sample3.mp3

Further Reading

Some relevant reading material about acoustic fingerprinting. The order gives an idea of relevance to the Panako project.

  1. Six, Joren and Leman, Marc Panako – A Scalable Acoustic Fingerprinting System Handling Time-Scale and Pitch Modification (2014)
  2. Wang, Avery L. An Industrial-Strength Audio Search Algorithm (2003)
  3. Cano, Pedro and Batlle, Eloi and Kalker, Ton and Haitsma, Jaap A Review of Audio Fingerprinting (2005)
  4. Six, Joren and Cornelis, Olmo A Robust Audio Fingerprinter Based on Pitch Class Histograms – Applications for Ethnic Music Archives (2012)
  5. Arzt, Andreas and Bock, Sebastian and Widmer, Gerhard Fast Identification of Piece and Score Position via Symbolic Fingerprinting (2012)
  6. Fenet, Sebastien and Richard, Gael and Grenier, Yves A Scalable Audio Fingerprint Method with Robustness to Pitch-Shifting (2011)
  7. Ellis, Dan and Whitman, Brian and Porter, Alastair Echoprint – An Open Music Identification Service (2011)
  8. Sonnleitner, Reinhard and Widmer, Gerhard Quad-based Audio Fingerprinting Robust To Time And Frequency Scaling (2014)
  9. Sonnleitner, Reinhard and Widmer, Gerhard Robust Quad-Based Audio Fingerprinting (2015)
  10. S. Chang et al., “Neural Audio Fingerprint for High-Specific Audio Retrieval Based on Contrastive Learning” (2021) – ICASSP 2021.

Contribute to Panako

There are several ways to contribute to Panako. The first is to use Panako and report issues or feature requests using the Github Issue tracker. Bug reports are greatly appreciated, but keep in mind the note below on responsiveness.

Another way to contribute is to dive into the code, fork and improve Panako yourself. Merge requests with additional documentation, bug fixes or new features will be handled and end up in the main branch if correctness, maintainability and simplicity are kept in check. However, keep in mind the note below:

My time to spend on Panako is limited and goes in activity bursts. If an issue is raised it might take a couple of months before I am able to spend time on it during the next burst of activity. A period of relative silence does not mean your feedback is not greatly valued!

Credits

The Panako software was developed at IPEM, Ghent University by Joren Six.

Some parts of Panako were inspired by the Robust Landmark-Based Audio Fingerprinting Matlab implementation by Dan Ellis.

Panako includes parts or depends on the following projects:

  • A trie by Marcus McCurdyBSD licensed. For autocompletion.
  • The Gaborator, ‘a C++ library that generates constant-Q spectrograms for visualization and analysis of audio signals’ – AGPLv3 licensed but with commercial licenses available!
  • JGaborator a JNI bridge to The Gaborator by Joren Six – AGPL licensed.
  • LMDB (The OpenLDAP Public License) and lmdbjava (Apache License, Version 2.0). LMDB is used as key-value-store.

If you use Panako for research purposes, please cite the following works:

@inproceedings{six2014panako,
  author      = {Joren Six and Marc Leman},
  title       = {{Panako - A Scalable Acoustic Fingerprinting System Handling Time-Scale and Pitch Modification}},
  booktitle   = {{Proceedings of the 15th ISMIR Conference (ISMIR 2014)}}, 
  year        =  2014
}
@inproceedings{six2021panako,
  title={Panako 2.0-Updates for an acoustic fingerprinting system},
  author={Six, Joren},
  booktitle={Demo / late-breaking abstracts of 22st International Society for Music Information Retrieval Conference, ISMIR},
  year={2021}
}

Evaluate Panako

The directory resources/scripts/evaluation contains scripts to reproduce the result found in the
Panako ISMIR 2021 abstract. The script follows this procedure:

  1. The fingerprints are extracted and stored for each file in the data set.o download an openly available dataset
  2. Query files are created from the Jamendo data set.
  3. Panako is queried for each query file, results are logged
  4. Results are parsed.

To run the evaluation scripts, a UNIX like system with following additional utilities is required.
Evidently the Panako software should also be installed. Please see above to install Panako. Download Free Music Archive

  • Ruby: The ruby programming language runtime environment.
  • SoX, including support for MP3 and GSM encoding.
  • GNUPlot: for plotting the results

If all requirements are met, running the evaluation is done using ruby evaluation.rb fma_small

Limitations

Panako has a couple of limitations:

  • Multiple writes the key-value store does not allow writes from multiple threads. These are effectively done on a single thread. To build a reference database quickly it is advised to use the cache feature of Panako.
  • Windows support Currently Panako does not support Windows. The key-value store used has spotty Windows support. The way in which audio is decoded using ffmpeg is also problematic on Windows. However, WSL offers a way in which to run Panako on Windows. WSL enables you to use Linux tools, like Bash or Grep […], with no need to dual-boot.’ With this option in mind, pure Windows support is not a priority. Another option to run Panako on windows is to use Docker on Windows

Changelog

Version 1.5
2016-12-08

Improvements to SyncSink. The cross correlation now behaves well also in edge cases. The Sync code has been simplified to allow maintenance. Included unit tests. Updated to TarsosDSP version 2.4.

Version 1.6
2017-03-17

This release adds a simplified version of chromaprint and an implementation of ‘A Highly Robust Audio Fingerprinting System’ by Haitsma and Kalker

Version 2.0
2021-04-27

A major overhaul of Panako. The main aim of this release is to ensure the longevity and maintainability of Panako. The featureset has been reduced to focus on core functionality. The version bump is also explained by the use of lambdas and the need for a newer JRE (8+). A list of changes:

  • The number of dependencies has been drastically cut by removing support for multiple key-value stores.
  • The key-value store has been changed to a faster and simpler system (from MapDB to LMDB).
  • The SyncSink functionality has been moved to another project (with Panako as dependency).
  • The main algorithms have been replaced with simpler and better working versions:
    • Olaf is a new implementation of the classic Shazam algorithm.
    • The algoritm described in the Panako paper was also replaced. The core ideas are still the same. The main change is the use of a Gabor transform to go from time domain to the spectral domain (previously a constant-q transform was used). The gabor transform is implemented by JGaborator which in turn relies on The Gaborator C++ library via JNI.
  • Folder structure has been simplified.
  • The UI, which was mainly used for debugging, has been removed.
  • A new set of helper scripts are added in the scripts directory. They help with evaluation, parsing results, checking results, building panako, creating documentation,…
  • Changed the default panako location to ~/.panako, so users can install and use panako more easily (withouth need for sudo rights)
Version 2.1
2022-05

Changed the build system to Gradle, mainly to make upgrading dependencies more straightforward. The folder structure has been changed accordingly. The default JDK target has been changed to Java SE 17 (LTS). Panako now also supports Apple M1 targets.

panako's People

Contributors

jorensix avatar simran-b avatar wardva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

panako's Issues

create_dataset.rb doesn't work with Ruby 3.2.x

I tried to run the script resources/scripts/create_test_dataset/create_dataset.rb with Ruby 3.2.2, but it failed:

> ruby create_dataset.rb 
create_dataset.rb:79:in `<main>': undefined method `exists?' for File:Class (NoMethodError)

FileUtils.mkdir_p(QUERY_FOLDER) unless File.exists? QUERY_FOLDER
                                           ^^^^^^^^
Did you mean?  exist?

This is because using exists? is deprecated since Ruby 2.1 and was removed in 3.2: https://stackoverflow.com/a/75353113
After downgrading the version to Ruby 3.1.4 it works.

Monitor matched length

First of all, thanks for amazing piece of code. Exploring monitor sub-application for fingerprint matching and it looks great to find occurrence of the fingerprint into reference file and we get results like this

_Query;Query start (s);Query stop (s); Match Identifier;Match description; Match start (s); Match score; Time factor (%); Frequency factor(%)
p1-1568098567-0156.ts;-5;10;1691754436;-Kissan-Roll.aac;7;9;100%;100%
While Match start gives start offset of the matching , is it possible to get Match Stop in similar way, if yes then we can easily calculate the occurrence as well as match length ?

I understand that SYNC can be used to calculate the offset but sync is complex/resource consuming process and if we may introduce Match Stop with Monitor then it will be great tool.

Please suggest way forward.

Mac M1 Docker image fails to build, Native build does not process anything.

docker build -t panako:2.1 resources/scripts/

 => [internal] load build definition from Dockerfile                                                                                                              0.0s
 => => transferring dockerfile: 1.44kB                                                                                                                            0.0s
 => [internal] load .dockerignore                                                                                                                                 0.0s
 => => transferring context: 2B                                                                                                                                   0.0s
 => [internal] load metadata for docker.io/library/debian:bullseye                                                                                                1.9s
 => [auth] library/debian:pull token for registry-1.docker.io                                                                                                     0.0s
 => [ 1/26] FROM docker.io/library/debian:bullseye@sha256:1beb7cf458bdfe71b5220cb2069eb45e3fc7eb77a1ccfb169eaebf5f6c4809ab                                       12.0s
 => => resolve docker.io/library/debian:bullseye@sha256:1beb7cf458bdfe71b5220cb2069eb45e3fc7eb77a1ccfb169eaebf5f6c4809ab                                          0.0s
 => => sha256:1beb7cf458bdfe71b5220cb2069eb45e3fc7eb77a1ccfb169eaebf5f6c4809ab 1.85kB / 1.85kB                                                                    0.0s
 => => sha256:42336fd1e6984b68afbf5c44d2583e8eaba3b96ab4ecb89ac5f8cd9775f96f7f 529B / 529B                                                                        0.0s
 => => sha256:4c26a989498112aa2445f8b49116e71205127a096c51316cb029c48a178286bc 1.48kB / 1.48kB                                                                    0.0s
 => => sha256:e837d9f05c625de5b814b851adbc03559ba02ea7078f57c81a01e18fc65bf42b 53.70MB / 53.70MB                                                                 10.3s
 => => extracting sha256:e837d9f05c625de5b814b851adbc03559ba02ea7078f57c81a01e18fc65bf42b                                                                         1.6s
 => [ 2/26] RUN apt-get update                                                                                                                                    4.0s
 => [ 3/26] RUN apt-get install -y --no-install-recommends git default-jdk ffmpeg                                                                                71.8s
 => [ 4/26] RUN apt-get install -y --no-install-recommends make gcc g++ libc-dev                                                                                 15.7s
 => [ 5/26] RUN git clone --depth 1 https://git.openldap.org/openldap/openldap.git                                                                               13.6s
 => [ 6/26] WORKDIR /openldap/libraries/liblmdb                                                                                                                   0.0s
 => [ 7/26] RUN make                                                                                                                                              3.1s
 => [ 8/26] RUN mv liblmdb.so /lib/                                                                                                                               0.1s
 => [ 9/26] RUN git clone --depth 1 https://github.com/JorenSix/JGaborator                                                                                        1.6s
 => [10/26] WORKDIR /JGaborator/gaborator/                                                                                                                        0.0s
 => ERROR [11/26] RUN make                                                                                                                                        0.3s
------
 > [11/26] RUN make:
0.263 echo /usr/lib/jvm/default-java
0.264 /usr/lib/jvm/default-java
0.264 ruby precompile_for_targets.rb
0.264 make: ruby: No such file or directory
0.264 make: *** [Makefile:6: all] Error 127
------
Dockerfile:26
--------------------
  24 |     WORKDIR /JGaborator/gaborator/
  25 |     ENV JAVA_HOME=/usr/lib/jvm/default-java
  26 | >>> RUN make
  27 |     RUN cp ../build/precompiled/libjgaborator.so /lib/
  28 |
--------------------
ERROR: failed to solve: process "/bin/sh -c make" did not complete successfully: exit code: 2```

gradle test fails due to wrong DATASET_URL

TestData.java
private static final String DATASET_URL = "https://panako.be/releases/Panako-test-dataset/"

it should be:
private static final String DATASET_URL = "https://0110.be/releases/Panako/Panako-test-dataset/"

However, the main problem is having a dependency on a remote web server which makes a test not repeatable (The R in F.I.R.S.T) under certain conditions.
As Robert Martin writes in Clean Code:

Tests should be repeatable in any environment [...] and on your laptop while riding home on the train without network

Caching partially solves this problem, I would add the required files in the repo since the build fails without working tests.

PanakoStrategy query logic Line 280 - printMap overwrites frequency and time values?

Possible minor refactoring to improve the recognition rate.

Issue
Initial testing against a set of audio tracks shows a fingerprint pattern (hash, f1, t1) will sometimes be repeated, but more often the hash is repeated and the f1/t1 is different.

In the current application logic, the use of a HashMap for the printMap means the f1/t1 information is sometimes lost resulting in a slightly less accurate recognition.

//query
for(PanakoFingerprint print : prints) {
	long hash = print.hash();
	db.addToQueryQueue(hash);
	printMap.put(hash, print);
}
...
hit.queryTime = printMap.get(fingerprintHash).t1;
hit.queryF1 = printMap.get(fingerprintHash).f1;

Suggestion
Pass the entire fingerprint to the db queue, extend the PanakoHit class to support queryTime and queryF1, set them when processing the db queue and do anyway with the printMap.

//query
for(PanakoFingerprint print : prints) {
	db.addToQueryQueue(print);
}
...
hit.queryTime = dbHit.queryT1;
hit.queryF1 = dbHit.queryF1;

Could not create a lock file for the database.

Hey there,

I'm currently having trouble to get panako running. I'm getting the following error message when trying to store a first fingerprint of some random mp3:

Could not create a lock file for the database.
Please make sure that '/opt/panako/dbs/nfft_panako_db.lck' is writable.

I tested this in two different environments. The first one was my local installation on Mac OS. The second one was an Ubuntu based Docker container. I was able to run panako -v or panako config via the "java -jar /opt/panako/panako.jar" way you described. However I'm currently out of ideas what I still need to set up to make things working?

BTW: When I look into the /opt/panako directory I cannot see any folder named dbs.

Looking forward to hearing from you.

Cheers,
Julian

Small issues with performance script docs

This is regarding https://github.com/JorenSix/Panako/blob/master/resources/scripts/benchmark/benchmark.textile Thank you for adding the script and its description. A couple of minor points:

  • Typo in "The FMA medium set contains 25, tracks of 30s spread over 16 unbalanced genres (22 GiB)". "25," tracks seems wrong.
  • You show two figures, one for Panako and one for Olaf, but don't describe them at all. Just seeing this one page, it's not easily understandable what Olaf refers to. You might want to add an explanatory sentence, very briefly describing the two graphs and what they show.
  • The page describing the benchmark should probably link to the script, instead of just mentioning that it's there.
  • The benchmark page does not seem to be linked to (or did I miss it?). A link from the README seems appropriate.

panako store process hangs indefinitely

When storing a large file (over 2 hours). With AVAILABLE_PROCESSORS=0
It looks like the java process goes to sleep midway through.
Running strace on the PID gives this message:

futex(0x7fe0b8229078, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY

Is this a thread deadlocking issue?

Building Panako from Dockerfile fails

Hi,

I think there's a problem with the code since building from Dockerfile fails. Could you help me with this?

> Task :compileJava FAILED
/Panako/src/main/java/be/panako/strategy/olaf/OlafStrategy.java:76: error: cannot find symbol
                        db = OlafStorageBtree.getInstance();
                             ^
  symbol:   variable OlafStorageBtree
  location: class OlafStrategy
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 21s
1 actionable task: 1 executed
Removing intermediate container 22d2644d2150
The command '/bin/sh -c ./gradlew shadowJar' returned a non-zero code: 1

A couple of issues on Windows

Hi,

First of all my java knowledge is non-existent so apologies for any blatant mistakes!

I am trying to use Panako on a Windows machine as the subject says. Because I don't have a java setup on Windows I thought I'd compile it on a linux vm (ubuntu based) and then send the .jar file over to Windows and try it there. Also I have populated a db from the linux vm and brought that over as well.

When I try to run the jar file on Windows I get the following output:

java -jar panako.jar query ..\sos-10.wav

Apr 12, 2018 1:21:03 PM be.tarsos.dsp.io.PipeDecoder <init>
INFO: found ffmpeg on the path (C:/u-blox/gallery/oracle/java/win_64/jdk1.8.0_102/bin;C:\CEVA-ToolBox\V10\CEVA-XC;C:\CEVA-ToolBox\V10\license;C:\CEVA-ToolBox\V1
0\Common;C:\u-blox\depot\\3.1;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\W
bem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Managemen
t Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;
C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Graphviz 2.28\bin;C:\Pr
ogram Files\Microsoft Windows Performance Toolkit\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\12
0\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\dotnet\;C:\u-blox\Programs\MATLAB\R2017b\runtime\win64;C:\u-blox\Programs\M
ATLAB\R2017b\bin;C:\Program Files (x86)\GitExtensions\;C:\Program Files\TortoiseSVN\bin). Will use ffmpeg for decoding media files.
Apr 12, 2018 1:21:03 PM be.panako.cli.Panako actuallyReallyStartApplication
INFO: Starting Panako application query with 1 arguments
Query;Query start (s);Query stop (s); Match Identifier;Match description; Match start (s); Match score; Time factor (%); Frequency factor(%)
Apr 12, 2018 1:21:03 PM be.tarsos.dsp.io.PipeDecoder getDecodedStream
INFO: Starting piped decoding process for C:\Users\gnak\Desktop\leenueks_shared\panako\..\sos-10.wav
Apr 12, 2018 1:21:03 PM be.tarsos.dsp.io.PipeDecoder getDecodedStream
INFO:  with command: ffmpeg -ss 0.0   -i "C:\Users\gnak\Desktop\leenueks_shared\panako\..\sos-10.wav" -vn -ar 8000 -ac 1 -sample_fmt s16 -f s16le pipe:1
Apr 12, 2018 1:21:03 PM be.tarsos.dsp.io.PipeDecoder getDecodedStream
WARNING: IO exception while decoding audio via sub process.Cannot run program "/bin/bash": CreateProcess error=2, The system cannot find the file specified
java.io.IOException: Cannot run program "/bin/bash": CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        at be.tarsos.dsp.io.PipeDecoder.getDecodedStream(PipeDecoder.java:175)
        at be.tarsos.dsp.io.PipedAudioStream.getMonoStream(PipedAudioStream.java:91)
        at be.tarsos.dsp.io.PipedAudioStream.getMonoStream(PipedAudioStream.java:73)
        at be.tarsos.dsp.io.jvm.AudioDispatcherFactory.fromPipe(AudioDispatcherFactory.java:187)
        at be.tarsos.dsp.io.jvm.AudioDispatcherFactory.fromPipe(AudioDispatcherFactory.java:163)
        at be.panako.strategy.nfft.NFFTStrategy.query(Unknown Source)
        at be.panako.cli.Query$QueryTask.run(Unknown Source)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
        at java.lang.ProcessImpl.start(ProcessImpl.java:137)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        ... 12 more

My java version on windows is "1.8.0_102" and on linux "1.8.0_162". Also for the record this runs fine on linux. Because I found some multi-platform support in the source code and libraries I thought it might work

Any ideas?

Thanks,
George

PanakoStrategy Query Logic - maxListSize @ 250 needs an override

Possible minor refactoring to improve the recognition rate.

Testing Results
Running the query algorithm using a high-powered system found that taking half the query matches as the firstHits and lastHits (see below) results in a slightly better recognition rate.

Suggestion
Add maxListSize to config.properties, maybe with a switch to allow the query algorithm to take half the query matches each time.

if(!overrideMaxListSize) {
  //view the first and last hits (max 250)
  int maxListSize = 250;
  firstHits = queryMatches.subList(0, Math.min(maxListSize,Math.max(minimumUnfilteredHits,queryMatches.size()/5)));
  lastHits  = queryMatches.subList(queryMatches.size()-Math.min(maxListSize, Math.max(minimumUnfilteredHits,queryMatches.size()/5)), queryMatches.size());
}
else { // Taking half and half seems to achieve a better recognition rate
  var numQueryMatches = queryMatches.size();
  var numQueryMatchesEvened = numQueryMatches % 2 == 0 ? numQueryMatches : numQueryMatches - 1;
  var batchSize = numQueryMatchesEvened / 2;
  firstHits = queryMatches.subList(0, batchSize - 1);
  lastHits = queryMatches.subList(numQueryMatchesEvened - batchSize , numQueryMatches - 1);	
}

PanakoStrategy Query logic - mostCommonDeltaTforHitList selects most common delta time by position in HashMap

Possible minor refactoring to improve the recognition rate.

Observation
A test against a set of audio tracks found that the PanakoStrategy.mostCommonDeltaTforHitList method will return the most common delta dependent on the number of occurrences. However, when more than one delta time has the same number of occurrences, the delta time returned is dependent on where it is stored in the HashMap, rather than a mathematical decision.

For example, for delta times x, y and z:
x with 1 occurrence
y with 2 occurrences
z with 3 occurrences

z is returned, but if x, y, and z delta times all have the same number of occurrences, which one is returned is dependent on chance - their position in the HashMap.

Suggestion
I don't know what mathematical decision is most suitable, but I tried taking the lowest delta time and this improved the recognition rate of the query. This is my quickly written alternative implementation of mostCommonDeltaTforHitList:

var timeDeltas = new ArrayList<TimeDeltaInfo>();

for(var queryMatch : queryMatches) {

  var foundTimeDelta = false;
  for(var timeDelta : timeDeltas) {
	  if(timeDelta.timeDelta == queryMatch.getTimeDelta()) {
		  timeDelta.count ++;
		  foundTimeDelta = true;
		  break;
	  }
  }
  if(!foundTimeDelta) {
	  timeDeltas.add(new TimeDeltaInfo(queryMatch.getTimeDelta()));
  }
}

// Get the time deltas with the highest number of occurrences at the top
timeDeltas.sort((a, b) -> b.count - a.count);

// Don't know what to do if we have no time deltas, so just return zero for now
if(timeDeltas.size() == 0) {
  return 0;
}

var topTimeDelta = timeDeltas.get(0);
var topTimeDeltas = new ArrayList<TimeDeltaInfo>();
topTimeDeltas.add(topTimeDelta);

for(var i = 1; i < timeDeltas.size(); i++) {
  if(timeDeltas.get(i).count == topTimeDelta.count) {
	  topTimeDeltas.add(timeDeltas.get(i));
  }
}

// Get the smallest time delta as it seems to work better than taking the average or the largest time delta.
topTimeDeltas.sort((a, b) -> a.timeDelta - b.timeDelta);

return topTimeDeltas.get(0).timeDelta;	

javadoc warnings

Somewhat cosmetic: When creating docs, javadoc warns about a number of missing @param and @return tags:

/Users/hendrik/Projects/Panako/src/main/java/be/panako/cli/Application.java:191: warning: no @param for defaultValue
        protected int getIntegerOption(String option,int defaultValue, String... arguments){
                      ^
/Users/hendrik/Projects/Panako/src/main/java/be/panako/strategy/olaf/OlafEventPoint.java:70: warning: no @param for m
        public OlafEventPoint(final int t, final int f, final float m){
               ^
/Users/hendrik/Projects/Panako/src/main/java/be/panako/strategy/QueryResult.java:82: warning: no @param for queryPath
        public QueryResult(String queryPath,
               ^
/Users/hendrik/Projects/Panako/src/main/java/be/panako/strategy/QueryResult.java:82: warning: no @param for refPath
        public QueryResult(String queryPath,
               ^
/Users/hendrik/Projects/Panako/src/main/java/be/panako/strategy/QueryResult.java:82: warning: no @param for refStop
        public QueryResult(String queryPath,
               ^
/Users/hendrik/Projects/Panako/src/main/java/be/panako/strategy/QueryResult.java:82: warning: no @param for percentOfSecondsWithMatches
        public QueryResult(String queryPath,
               ^
/Users/hendrik/Projects/Panako/src/main/java/be/panako/util/Hamming.java:59: warning: no @param for x
            public static int d(long x, long y) {
                              ^
/Users/hendrik/Projects/Panako/src/main/java/be/panako/util/Hamming.java:59: warning: no @param for y
            public static int d(long x, long y) {
                              ^
/Users/hendrik/Projects/Panako/src/main/java/be/panako/util/Hamming.java:59: warning: no @return
            public static int d(long x, long y) {

PanakoStrategy Query Logic - allow duplicate fingerprint hash?

Possible minor refactoring to improve the recognition rate.

Testing Result
Playing around with whether a duplicate fingerprint hash is processed produced an unexpected improvement in the recognition rate when duplicate fingerprints are not considered. However, this might not suit all use cases for the query algorithm.

Suggestion
Add a boolean flag to allow duplicate fingerprints or not. See pseudocode below:

//query
for(PanakoFingerprint print : prints) {
	long hash = print.hash();
        hashNotADuplicate = // add duplicate logic  
        if(allowDuplicates || hashNotADuplicate) {
	    db.addToQueryQueue(hash);
        }
	printMap.put(hash, print);
}

Should the DB Index be in RAM? Big collection - multiple indexes?

I am trying to index a very large collection of audio programmes (90000 items, ca. 1/2 hr per programme)
This collection has grown over 20 years - and my intention is to weed out the many duplicates.

I have started indexing using the standard settings. olaf db and cache are at ca. 10GB each for 4500 files analysed so far.
This suggests and overall index size of 200GB each.... (I know reducing the sample rate would reduce the index size).

I have 16GB RAM on the current server, with the same again as swap. The server has about 2TB free space left.

My question concerns querying/building the index. I can imagine it should/must be in RAM - is this correct?

If this is the case I was thinking of breaking the index to ca. 10GB fragments. i.e. scan to an index size of ca. 10GB then
stop and restart with a fresh index for the next load of files (e.g. at the current rate scan 4500 files for each index). I would slightly change the config before continuing each run of panako to make this happen.
This has the "advantage" also of being runnable on multiple machines (all accessing the same directory but different selections of files). The disadvantage would be having to query against 20 or so indexes (though this can be automated using bash).

Would this approach make sense? Or I my assumptions about RAM and the index incorrect - and an index file of 200GB is fine?

Thanks for any insights

I succeed store sound track into dbs, but can't query matching music

I have already installed Panako on my Mac OSx, and succeed stored some sound tracks for testing.
panako stats
Number of audio objects: 4
Number of fingerprints: 296
Number of seconds: 58.0
Number of fingerprints/second: 5.103448275862069

But, when I make a query testing. It's only the totally same with original sound can be matched. Beyond that, any cutting fragment sound from original sound cannot be matched.

panako query ser.m4a
Query;Query start (s);Query stop (s); Match Identifier;Match description; Match start (s); Match score; Time factor (%); Frequency factor(%)
/Users/rex/Desktop/ser.m4a;0;2;null;null;-1;-1;-1%;-1%

And I use panako browse, I can get the fragment is matching. How can I use this, thanks a lot
image

Main thread hangs in java.io.FileInputStream.readBytes

Panako can succesfully store all my MP3 collection, except a few MP3 files (that are perfectly playable) that makes it hang forever.
Here one of the MP3 files in question : https://mega.nz/file/pKFVDAyb#vtjUcy2UfDPt5SJMl7HFTRsnZxFC3vRG_Cqyo0w8fGE

[0] % panako store "Blondie - Maria.mp3"
Audiofile;Audio duration;Fingerprinting duration;ratio

I've extracted the main thread stacktrace with Mission Control:

main [1] (RUNNABLE)
   java.io.FileInputStream.readBytes line: not available [native method]
   java.io.FileInputStream.read line: 276 
   java.io.BufferedInputStream.read1 line: 282 
   java.io.BufferedInputStream.read line: 343 
   java.io.BufferedInputStream.fill line: 244 
   java.io.BufferedInputStream.read1 line: 284 
   java.io.BufferedInputStream.read line: 343 
   be.tarsos.dsp.io.UniversalAudioInputStream.read line: 54 
   be.tarsos.dsp.AudioDispatcher.readNextAudioBlock line: 399 
   be.tarsos.dsp.AudioDispatcher.run line: 286 
   be.panako.strategy.olaf.OlafStrategy.toFingerprints line: 212 
   be.panako.strategy.olaf.OlafStrategy.toFingerprints line: 167 
   be.panako.strategy.olaf.OlafStrategy.store line: 97 
   be.panako.cli.Store$StoreTask.run line: 128 
   be.panako.cli.Store.run line: 74 
   be.panako.cli.Panako.actuallyReallyStartApplication line: 234 
   be.panako.cli.Panako.actuallyStartApplication line: 213 
   be.panako.cli.Panako.startApplication line: 155 
   be.panako.cli.Panako.main line: 329 

The same freeze (in java.io.FileInputStream.readBytes) is happening with panako print "Blondie - Maria.mp3".

Some informations about my machine:

salomonbrys@Salomons-MacBook-Pro ‹ master › : ~/Code/clones/Panako
[0] % uname -a
Darwin Salomons-MacBook-Pro.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct  9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64 x86_64 i386 Darwin

salomonbrys@Salomons-MacBook-Pro ‹ master › : ~/Code/clones/Panako
[0] % git show-ref HEAD
c2cd1cfe2305d1c933e7753a6823d2df4fb0c469 refs/remotes/origin/HEAD

salomonbrys@Salomons-MacBook-Pro ‹ master › : ~/Code/clones/Panako
[0] % java -version
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)

Sync Match Duration

Hi All,

I have tried panako for sync and its working find. I am facing an issue its not giving matched duration.
So is there is any way that I can get duration of matched content.
I am using NFFT recognition with sync process.

A fatal error has been detected by the Java Runtime Environment

java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~20.04-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
panako --version
Panako Acoustic Fingerprinting, by user
  Built on: June 14 2021
  Version: 2.0-20210614
uname -a
Linux box 5.4.0-74-generic #83-Ubuntu SMP Sat May 8 02:35:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

I am trying to import a couple hundred mp3s into the database and after 70 or so I get this error. Then it keeps happening every 5 or so mp3s. The mp3 files are fine and not corrupt. My RAM is only 20% utilized and swap is 1% when importing. CPU hits 99-100% on all cores while importing but system doesn't freeze or seem to slow. I also tried Java 11, same crash. Any ideas?

panako store list.txt
78/822;Track91.mp3;00:03:11;15.96 s;11.99
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fdbfa9086a0, pid=17201, tid=0x00007fdbdda96700
#
# JRE version: OpenJDK Runtime Environment (8.0_292-b10) (build 1.8.0_292-8u292-b10-0ubuntu1~20.04-b10)
# Java VM: OpenJDK 64-Bit Server VM (25.292-b10 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V  [libjvm.so+0x7146a0]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/vghugyfjhf/Desktop/test/hs_err_pid17201.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#
/usr/local/bin/panako: line 32: 17201 Aborted                 (core dumped) java $PANAKO_JVM_OPTS -Djava.util.logging.config.file=$LOG_CONFIGURATION -jar $PANAKO_JAR "$@" 2>> $PANAKO_STD_ERROR

Fingerprint matching and DB init

  1. I'm testing Panako from a docker image with this config NFFT_MAPDB_DATABASE=/opt/panako/dbs/nfft_panako_db
    There's no such db file

  2. Is it possible to sort a list of fingerprints by similarity rather than just look for an exact match?

Unbale to build Panako library: Compile error

After running ant in the Panako/build directory this is what occurs

Buildfile: /root/Panako/build/build.xml

compile:
[javac] Compiling 87 source files to /root/Panako/bin
[javac] /root/Panako/src/be/panako/util/StopWatch.java:142: error: unmappable character for >encoding ASCII
[javac] formatString = "%.2f ??s";
[javac] ^
[javac] /root/Panako/src/be/panako/util/StopWatch.java:142: error: unmappable character for >encoding ASCII
[javac] formatString = "%.2f ??s";
[javac] ^
[javac] 2 errors

BUILD FAILED

Can you give more information about settings for strategy NFFT?

Hello,
Can you give more information about settings for strategy NFFT?
I try use panako for detecting patterns in phone calls. For detecting answering machines by audio records.
And I cannot found any addityonal information about this parametrs.

Now I try found best settings for my task using algorithm Simulated annealing.

	/**
	 * The name of the MapDB database location.
	 */
	NFFT_MAPDB_DATABASE("/opt/panako/dbs/nfft_panako_db"),
	/**
	 * The sample rate of the input signal
	 */
	NFFT_SAMPLE_RATE(8000),	
	/**
	 * The size of the audio block and consequently the size (in samples) of the FFT.
	 */
	NFFT_SIZE(512),
	/**
	 * The size of the audio block step size (in samples).
	 */
	NFFT_STEP_SIZE(256),
	
	/**
	 * Allows only  a limited amount of event points each frame.
	 * Especially useful for percussive onsets.
	 */
	NFFT_EVENT_POINTS_MAX_PER_FFT_FRAME(3),

	/**
	 * Minium euclidean distance between event points. 
	 * The value is expressed in milliseconds cents
	 */
	NFFT_EVENT_POINT_MIN_DISTANCE(600),
	/**
	 * The maximum number of fingerpints per event points (fan-out).
	 */
	NFFT_MAX_FINGERPRINTS_PER_EVENT_POINT(2),
	
	
	/**
	 * The size of the Min filter halve of the MIN/MAX filter for 
	 * spectral peak detection, it should be odd.
	 */
	NFFT_MIN_FILTER_WINDOW_SIZE(7),
	/**
	 * The size of the MAX filter halve of the MIN/MAX filter for 
	 * spectral peak detection, it should be odd.
	 */
	 NFFT_MAX_FILTER_WINDOW_SIZE(15),
	 
	 /**
	 * Use a hash based on refined pitch estimates using the phase
	 * or not.
	 */
	NFFT_USE_PHASE_REFINED_HASH("FALSE"),

Not getting accurate matches with radio recordings

I'm having issues with matching. I'm using the default config. My use case includes recorded audio from FM radio stations. We know radio adds problems for audio fingerprinting and matching because of compression and distortion. However, the recordings are clear enough that I would expect at least a bit of a match. I've fingerprinted a few hundred studio WAV files into my database. Then I cut a song from a radio broadcast, the same song I have previously fingerprinted in my database with a studio WAV. I'm not getting matches and sometimes I see matches for different genres (E.g. A techno song matched to a hard rock song). To my ears the studio WAV I fingerprinted and the FM radio recording sound similar enough. Sure the radio has slight distortion and artifacts but there isn't a huge audible difference. I see a lot of settings in config.properties but I'm unsure what changes would help my situation. Any ideas? Thanks

Monitor is hanging on big files

Hello all,

I'm using "monitor" from Panako to analyse big files of music (1-2 hours).
But after 10 minutes the process is hanging and never ends, the processor doesn't seem to be used anymore at this stage.

No exception is raised nor logged in the log files (I set the log configuration to "ALL"), and the last window analysed seemed to be random, even though it is always around the 1600th window analysed and about 10 minutes of computation. Cutting the file in small segments of 15 minutes and running "monitor" on each one of them solves the issue, but this is not convenient.

I'm using a custom configuration with Panako from @werthen's master thesis: https://lib.ugent.be/fulltxt/RUG01/002/494/859/RUG01-002494859_2018_0001_AC.pdf
I tried to find and increase the settings linked to stop conditions with no success so far. Here's the configuration I'm currently using:

STRATEGY=NCTEQ
MONITOR_STEP_SIZE=15
MONITOR_OVERLAP=14
NFFT_SIZE=512
NFFT_MIN_FILTER_WINDOW_SIZE=7
NFFT_USE_PHASE_REFINED_HASH=FALSE
NFFT_MAPDB_DATABASE=/home/mickael/Documents/programming/Panako/dbs/nfft_panako_db
NFFT_EVENT_POINTS_MAX_PER_FFT_FRAME=100
NFFT_STEP_SIZE=256
NFFT_MAX_FINGERPRINTS_PER_EVENT_POINT=100
NFFT_EVENT_POINT_MIN_DISTANCE=300
NFFT_SAMPLE_RATE=8000
NFFT_MAX_FILTER_WINDOW_SIZE=15
HTTP_SERVER_PORT=8080
META_DATA_COMMAND=/opt/panako/extract_metadata.sh
DECODER_PIPE_LOG_FILE=decoder_log.txt
SYNC_MIN_ALIGNED_MATCHES=7
CHECK_DUPLICATE_FILE_NAMES=TRUE
DECODER_PIPE_ENVIRONMENT=/bin/bash
AVAILABLE_PROCESSORS=0
SYNC_MARKER_TIME_ERROR_ALLOWED=10
PCH_SAMPLE_RATE=22050
DECODER_PIPE_BUFFER_SIZE=44100
PCH_SIZE=2048
DECODER_PIPE_ENVIRONMENT_ARG=-c
DECODER=PIPE
MAX_FILE_SIZE=2097152000
PCH_OVERLAP=1024
DECODER_PIPE_COMMAND=ffmpeg -ss %input_seeking% %number_of_seconds% -i "%resource%" -vn -ar %sample_rate% -ac %channels% -sample_fmt s16 -f s16le pipe:1
PCH_FILES=/home/mickael/Documents/programming/Panako/dbs/pch
SYNC_MARKER_LOUDNESS_DELTA=17
META_DATA_DIRECTORY=/opt/panako/metadata
SYNC_MARKER_MAX_TIMESTAMP=3
NCTEQ_MAPDB_DATABASE=/home/mickael/Documents/programming/Panako/dbs/cteq_panako_db_2
NCTEQ_SAMPLE_RATE=44100
NCTEQ_STEP_SIZE=1536
NCTEQ_MIN_FREQ=3700
NCTEQ_MAX_FREQ=12200
NCTEQ_BINS_PER_OCTAVE=36
NCTEQ_EVENT_POINTS_PER_SECOND_FOR_QUERY=400
NCTEQ_EVENT_POINTS_PER_SECOND_FOR_STORAGE=200
NCTEQ_EVENT_POINT_FREQUENCY_DELTA_MAX=1066
NCTEQ_EVENT_POINT_BRANCHING_FOR_STORAGE=200
NCTEQ_EVENT_POINT_BRANCHING_FOR_QUERY=600
NCTEQ_MAX_HASH_COLLISIONS=10000
NCTEQ_MINIMUM_MATCHES_THRESHOLD=0
NCTEQ_MINIMUM_ALIGNED_MATCHES_THRESHOLD=0

Am I missing a setting stopping the computation somehow? I increased NCTEQ_MAX_HASH_COLLISIONS, SYNC_MARKER_MAX_TIMESTAMP, and SYNC_MARKER_TIME_ERROR_ALLOWED with no impact on the issue. But it's hard to find the correct configuration as I didn't find any description of those settings.

PanakoStrategy.java typo Line 372?

In PanakoStrategy.java line 372 reads:

timeFactor < Config.getFloat(Key.PANAKO_MAX_FREQ_FACTOR)

Should read:

frequencyFactor < Config.getFloat(Key.PANAKO_MAX_FREQ_FACTOR)

Panako doesn't recognize pitch and speed differences

I tried Panako to compare 2 audios which are

  1. different with pitch (I used ([https://vocalremover.org]) to change pitch), but Panako didn't recognize it.
  2. different with speed (I used [https://vocalremover.org] to change speed), but they haven't recognized as well.

I think the problem here can be peak picking algorithm. Because when I print triplets, all peaks are different in some examples with frequency and in some examples with time. What can be a problem?. Because the paper which describes Panako assures that type of differences are catchable.

Run on Windows

I am trying to run Panako on windows 10. So far I managed to compile using ant. Using store parameter with input mp3 from file.txt gives following output only

java -server -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -Xms256m -Xmx256m -Djava.util.logging.config.file=logging.properties -jar panako-2.0.jar store list.txt
Audiofile;Audio duration;Fingerprinting duration;ratio

stats command

java -server -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -Xms256m -Xmx256m -Djava.util.logging.config.file=logging.properties -jar panako-2.0.jar stats
Exception in thread "main" java.lang.IllegalArgumentException: Unknown result code 112
at org.lmdbjava.ResultCodeMapper.checkRc(ResultCodeMapper.java:111)
at org.lmdbjava.Env$Builder.open(Env.java:495)
at org.lmdbjava.Env$Builder.open(Env.java:512)
at be.panako.strategy.olaf.storage.OlafStorageKV.(Unknown Source)
at be.panako.strategy.olaf.storage.OlafStorageKV.getInstance(Unknown Source)
at be.panako.strategy.olaf.OlafStrategy.printStorageStatistics(Unknown Source)
at be.panako.cli.Stats.run(Unknown Source)
at be.panako.cli.Panako.actuallyReallyStartApplication(Unknown Source)
at be.panako.cli.Panako.actuallyStartApplication(Unknown Source)
at be.panako.cli.Panako.startApplication(Unknown Source)
at be.panako.cli.Panako.main(Unknown Source)

Can anyone help me to get it running in windows environment?

Multiple Store

I was wondering if we may create multiple named store with panako. Basically multiple buckets possibility under single store which can be accessed by name with the store command.

Simple "how similar are two mp3 files" example

I was giving this software a shot, but I may have missed something. (It keeps trying to store files in a database in a directory that isn't writable. Does it need the datastore for the fingerprints to work?)

I was trying to make the simplest possible "hello world" Java example that would take in two mp3 files, and spit out "95% chance these are the same song". To do that, I think I create a new strategy (I choose which one), then pass it the path to the mp3, but I'm not sure if it needs to be uncompressed to a wav first.

Which strategy is the current best? (Reasonably fast, robust, good chance of accurate results)

This project seems to be the most advanced I've found for "are these two mp3s duplicates?" in Java.

./gradlew javadoc fails

> aren't properly encoded as &gt;. This leads to a failure, at least when using Java 11.

$ ./gradlew javadoc

> Task :javadoc
/Panako/src/main/java/be/panako/util/Key.java:113: error: bad use of '>'
         * So use a large number (> 50) to return all results
                                  ^
/Panako/src/main/java/be/panako/util/StopWatch.java:161: error: bad use of '>'
         * Return a formatted string for a time duration in seconds so from 61s => 1m:1s
                                                                                 ^
2 errors

> Task :javadoc FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':javadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/Panako/build/tmp/javadoc/javadoc.options'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
2 actionable tasks: 1 executed, 1 up-to-date

Some files can't be stored

When I call 'panako store file.mp3' on some files, it's stuck in infinite loop.

From my brief debugging, it seems that AudioDispatcher in TarsosDSP library always returns positive number from this.readNextAudioBlock();

I don't know why it happens only to some files, though :( Any idea?

Not working on Debian buster

Hi Joren,
First of all, thanks for this amazing work.

I wanted to ask you if you could help me making panako work in debian buster. I've make it work on ubuntu:20.04 flawlessly but it fails on debian when running panako store test/be/panako/tests/res/11266.mp3 STRATEGY=PANAKO.

The error I get is that the execution hangs. If I call the .jar file directly I obtain the following output:

java -jar build/panako-2.0.jar store test/be/panako/tests/res/11266.mp3 STRATEGY=PANAKO
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Mar 29, 2022 4:44:08 PM be.tarsos.dsp.io.PipeDecoder <init>
INFO: found ffmpeg on the path (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin). Will use ffmpeg for decoding media files.
Mar 29, 2022 4:44:08 PM be.panako.cli.Panako actuallyReallyStartApplication
INFO: Starting Panako application store with 1 arguments
Audiofile;Audio duration;Fingerprinting duration;ratio
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.lmdbjava.ByteBufferProxy$AbstractByteBufferProxy (file:/panako/build/panako-2.0.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of org.lmdbjava.ByteBufferProxy$AbstractByteBufferProxy
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Mar 29, 2022 4:44:08 PM be.tarsos.dsp.io.PipeDecoder getDecodedStream
INFO: Starting piped decoding process for /panako/test/be/panako/tests/res/11266.mp3
Mar 29, 2022 4:44:08 PM be.tarsos.dsp.io.PipeDecoder getDecodedStream
INFO:  with command: ffmpeg -hide_banner -loglevel panic -ss 0.0   -i "/panako/test/be/panako/tests/res/11266.mp3" -vn -ar 16000 -ac 1 -f s16le -acodec pcm_s16le pipe:1
Could not load jgaborator JNI library. Will attempt to use a version packed in the JAR archive
  info : no jgaborator in java.library.path: [/usr/java/packages/lib, /usr/lib/x86_64-linux-gnu/jni, /lib/x86_64-linux-gnu, /usr/lib/x86_64-linux-gnu, /usr/lib/jni, /lib, /usr/lib]

Here is the Dockerfile for reproducibility:

FROM debian:buster #if we change it to FROM ubuntu:20.04 it works
RUN apt-get update && apt-get install -y --no-install-recommends git default-jdk ant ffmpeg
RUN git clone https://github.com/JorenSix/Panako.git /panako
ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
WORKDIR /panako/build
RUN ant && ant install && ant doc
RUN cp panako /usr/local/bin
RUN cp config.properties ~/.panako/
CMD panako store /panako/test/be/panako/tests/res/11266.mp3 STRATEGY=PANAKO

Thanks in advance!

Improvement to Sync and SyncSink

I have been exploring using audio fingerprinting to determine sync offsets in media files. So far Panako has been extremely accurate in certain cases. If I have 2 files that are identical, but one has 160ms of silence at the beginning of the file, Panako reports this as a 160ms offset. Perfect! If I have a second set of files the the same 160ms offset at the beginning and an edit in the middle that adds 250ms of silence, bringing the total offset by the end to 410ms, Panako reports this as a single offset value of 410ms.

If Panako could report a more verbose analysis, I could potentially use ffmpeg to realign the test file to the reference.

A real world example would be the reference file as an audio stream for episodic content and the test file being Dubbed in spanish. This would contain the same music and effects and should match a fingerprint for the music.

Path to docs in README wrong

The readme says the docs are in doc, but in fact they are in build/docs

./gradlew javadoc #Creates the documentation in doc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.