Giter VIP home page Giter VIP logo

jorensix / olaf Goto Github PK

View Code? Open in Web Editor NEW
306.0 9.0 33.0 5.61 MB

Olaf: Overly Lightweight Acoustic Fingerprinting is a portable acoustic fingerprinting system.

License: GNU Affero General Public License v3.0

Makefile 0.98% Ruby 7.14% C 85.78% HTML 0.64% Zig 0.37% Dockerfile 0.13% C++ 1.39% R 0.41% TeX 1.79% Python 1.38%
music-information-retrieval audio-fingerprinting acoustic-fingerprinting wasm esp32

olaf's People

Contributors

danielskatz avatar jorensix avatar taf2 avatar toy avatar vagahbond 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

olaf's Issues

Missing file

Hi,

I'm trying to compile the web version but 'wasm/js/olaf_processor_edit.js' is missing.
And I'm getting this error in Chrome:
DOMException: Failed to construct 'AudioWorkletNode': AudioWorkletNode cannot be created: The node name 'olaf-processor' is not defined in AudioWorkletGlobalScope.

Can you please upload this file also to the repository ?

Thank you!

Success in adding track, but web build doesn't recognise track

Hi there! I am working on a proof of concept, and I have managed to correctly install Olaf and fingerprint a track. However, when I run the web build I can't get a successful response. I am running make web after adding the track and then running the server - are there any steps I am missing?

Additional: After testing olaf monitor test.mp3 it threw the following error:

query index,total queries, query name, match name, match id, match count (#), q to ref time delta (s), ref start (s), ref stop (s), query time (s) Traceback (most recent call last): 8: from /usr/local/bin/olaf:372:in `<main>' 7: from /usr/local/bin/olaf:372:in `each_with_index' 6: from /usr/local/bin/olaf:372:in `each' 5: from /usr/local/bin/olaf:373:in `block in <main>' 4: from /usr/local/bin/olaf:80:in `monitor' 3: from /usr/local/bin/olaf:180:in `with_converted_audio_part' 2: from /usr/local/bin/olaf:84:in `block in monitor' 1: from /usr/local/bin/olaf:84:in `each' /usr/local/bin/olaf:91:in `block (2 levels) in monitor': undefined local variable or method `filename' for main:Object (NameError)

Could this be related to the issue I am having in failing to recognise tracks or is this another issue?

How to optimize config for a huge movie collection track ?

I rewrite the ruby layer to request only the C code, I use the default (stock) config to store cached acoustic fingerprint to a custom directory with a php CLI only script (only exec() line can interest you) :

(TMP operation on tmpfs RAM)

  foreach($audiocodecs as $i => $audiocodec) {
   $acoustic = "$ACOUSTICDIR/$videobase.$filesize.$i.csv.gz";
   if(file_exists($acoustic))
    continue;

   echo "$videofile\n";
   exec("ffmpeg -loglevel quiet -i \"$videofile\" -map 0:a:$i -ac 1 -ar 16000 -f f32le -acodec pcm_f32le \"$TMPRAW\"");

   echo "$acoustic\n";
   exec("Olaf/bin/olaf_c print \"$TMPRAW\" \"$videofile\" | gzip > \"$TMPGZ\" && mv \"$TMPGZ\" \"$acoustic\"", $output);

   unlink($TMPRAW);
  }

And to build the B+ tree I use a loop to load all ~1h40/2h (average movie duration) audio tracks :

  foreach($audiocodecs as $i => $audiocodec) {
   $acoustic = "$ACOUSTICDIR/$videobase.$filesize.$i.csv.gz";
   if(!file_exists($acoustic))
    continue;

   echo "$videofile\n";
   exec("gunzip -c \"$acoustic\"", $output);
   $content = "";
   foreach($output as $line)
    $content .= "1/1,$videobase.$i,$line\n";
   file_put_contents($TMPCSV, $content);
   echo "$acoustic\n";
   exec("Olaf/bin/olaf_c store_cached \"$TMPCSV\"");
  }

I can generate all my audio track fingerprint from movies, all gz are lightweight, but integration into B+ tree part is too slow and db become too huge. even on my i9 64GB DDR5 / PCIE SSD machine :(

How you can store 340 days of audio (around 800GB of mp3s) inside a 15GB database ? mine grow way faster than this with your default config https://github.com/JorenSix/Olaf/blob/master/src/olaf_config.c .... and I have about 4000 days (10 years !) of sound to index !!!!! game over lol But with an estimation based on your result, this must enter inside 150GB database, good for me, but this is not the case (I grow rapidly over multiples terabytes and show as a snail to rebuild the B+ tree from all lightweight fingerprints.csv.gz)

Units tests "error"?

Related to openjournals/joss-reviews#5459

I think it's normal, but when running the unit tests on Linux (Ubuntu 22.04 LTS) and macOS (Catalina):

git clone https://github.com/JorenSix/Olaf
cd Olaf
make && make install
ruby eval/olaf_functional_tests.rb

I get the following "error" at the very beginning:

Database Error: No such file or directory

But I guess this is normal as there is a "PASS" just after to make sure the Database is empty?

Otherwise all tests pass 👍

Question: JAVA and C FP extraction difference

Hi, @JorenSix .

I tryed to compare JAVA and C FP algorithmus ans found out aparts of code in C version:

    uint64_t m1LargerThanm2 = m1 > m2 ? 1 : 0;
    uint64_t m2LargerThanm3 = m2 > m3 ? 1 : 0;
    uint64_t m3LargerThanm1 = m3 > m1 ? 1 : 0;

    m1LargerThanm2 = 0;
    m2LargerThanm3 = 0;
    m3LargerThanm1 = 0;

So in C version mXLargerThenmY is zeroed, but in JAVA it's not. Why? A BUG or a feature?

Question: What is the minimun audio duration that Olaf can identify?

I saw that Fragmented by default use 5 seconds, I'll like to know if OLAF can detect different version of audio, with just 2 or 3 seconds of different between them?

We have some ads that are 20 second long, but inside only 3 seconds or less change, that is common case into retails that has different products ads where they use the same sound and speech just changing Product Brand or name.

Some way to tune, fragmented to can improve the version detection?

thanks!

Audio not matching

Hello Joren!
First of all, I want to thank you for publishing this project on Github!

Have the problem that an audio snippet is not recognized.

olaf store store.mp3
olaf query external-stream.mp3

Side note, in my case the monitor command throws an error, maybe this is related.

olaf monitor external-stream.mp3
$ olaf monitor external-stream.mp3
1/1_0s external-stream.mp3 matches trimmed.mov q_to_ref_time_delta: 0.00, q_time: 5.44, score: 146, match_id: 779030374, ref_start: 0.29, ref_stop: 5.44
1/1_0s external-stream.mp3 Proccessed 471 fp's from 7.0s in 0.004s (1962 times realtime)
1/1_0s external-stream.mp3 Audio file 151390292 not found or unreadable.
1/1_7s external-stream.mp3 Proccessed 502 fp's from 7.0s in 0.004s (1969 times realtime)
1/1_7s external-stream.mp3 Audio file 151390292 not found or unreadable.
1/1_14s external-stream.mp3 Proccessed 515 fp's from 7.0s in 0.003s (2020 times realtime)
1/1_14s external-stream.mp3 Audio file 151390292 not found or unreadable.
Traceback (most recent call last):
	9: from /usr/local/bin/olaf:460:in `<main>'
	8: from /usr/local/bin/olaf:460:in `each_with_index'
	7: from /usr/local/bin/olaf:460:in `each'
	6: from /usr/local/bin/olaf:461:in `block in <main>'
	5: from /usr/local/bin/olaf:84:in `monitor'
	4: from /usr/local/bin/olaf:189:in `with_converted_audio_part'
	3: from /usr/local/bin/olaf:88:in `block in monitor'
	2: from /usr/local/bin/olaf:88:in `each'
	1: from /usr/local/bin/olaf:95:in `block (2 levels) in monitor'
/usr/local/bin/olaf:95:in `basename': no implicit conversion of nil into String (TypeError)

Maybe you can help me with that.

Greetings Fred
Archive.zip

Understanding the Output from ESP32 Example

Im currently trying to run the ESP32 example.

Unfortunately im struggling to understand the Output. It does look like its not working properly but I dont know what the Problem is.

Here is the Output from the Arduino IDE:

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13924
ho 0 tail 12 room 4
load:0x40080400,len:3600
entry 0x400805f0
[OLAF] Free memory before init: 273124 bytes
No home directory found, will use './db' as db folderMem DB for '852601.wav', 193.761s duration, 13207 fingerprints, 666 identifier
[OLAF] Free after init: 150444 bytes
[OLAF] Initialized with 32091 audio samples. Sample sample: 0.036510
Event point index: 0 
[OLAF] processed audio block index: 0
Event point index: 0 
[OLAF] processed audio block index: 1
Event point index: 0 
[OLAF] processed audio block index: 2
Event point index: 0 
[OLAF] processed audio block index: 3
Event point index: 0 
[OLAF] processed audio block index: 4
Event point index: 0 
[OLAF] processed audio block index: 5
Event point index: 0 
[OLAF] processed audio block index: 6
Event point index: 0 
[OLAF] processed audio block index: 7
Event point index: 0 
[OLAF] processed audio block index: 8
Event point index: 0 
[OLAF] processed audio block index: 9
Event point index: 0 
[OLAF] processed audio block index: 10
Event point index: 0 
[OLAF] processed audio block index: 11
Event point index: 0 
[OLAF] processed audio block index: 12
Event point index: 0 
...

...
[OLAF] processed audio block index: 106
Event point index: 29 
[OLAF] processed audio block index: 107
Event point index: 30 
[OLAF] processed audio block index: 108
Event point index: 30 
[OLAF] processed audio block index: 109
Event point index: 31 
FP index: 6 
0, 0.00, 0.00, , 0, 0.00, 0.00
[OLAF] processed audio block index: 110
Event point index: 23 
[OLAF] processed audio block index: 111

Possible BUG: There is no boundaies control in olaf_fp_extractor.c

Hi, @JorenSix

There is no boundaries control for fp_extractor->fingerprints.fingerprints.
So, [fp_extractor->fingerprints.fingerprintIndex can be incremented and go out of initial allocated for fp_extractor->fingerprints.fingerprints memmory block. I causes memory corruption in other modules and unpredictable behaivior.
I fixed this with additional condition in for loops:
for(int k = j+1; k < eventPoints->eventPointIndex && fp_extractor->fingerprints.fingerprintIndex < fp_extractor->config->maxFingerprints; k++){
and
for(int j = i+1; j < eventPoints->eventPointIndex && fp_extractor->fingerprints.fingerprintIndex < fp_extractor->config->maxFingerprints; j++){

But I do not know how would this affect fingerprinting algotithmus.

ESP32 Example(s)

Hi,
The olaf_fp_ref_mem.h included in the zip file from here:
https://0110.be/files/attachments/475/ESP32-Olaf.zip

Has a number of nuls on line 7.
image

In addition to that the content is different from the same file in the arduino sketch folder for esp32_inmp441_olaf

Should the nuls be there?
What song does this file represent?

2nd set of questions -
When trying to compile the arduino sketch esp32_inmp441_olaf.ino

I found I had to copy the content of the files referenced in the esp32_inmp441_olaf folder. Despite that I have been unable to successfully link the code.

Are you able to provide guidance as to how to build your original hardware and ESP32 code that you used here:
https://0110.be/posts/Olaf_-_Acoustic_fingerprinting_on_the_ESP32_and_in_the_Browser
For example what ESP32 board did you use and what pins did you have the microphone connected to?

I believe that this is a very interesting project and would like to replicate it.

Sean

Typos in eval page

Related to: openjournals/joss-reviews#5459

Could you run a spell-checker on this page? There a few typos. For example:

The tests check __wether Olaf works__.The evaluation verifies __how well__ Olaf works. The benchmark checks __how fast__ Olaf works and how it deals with scalability and resources. There are a few evaluation and benchmarking scripts available for Olaf. This text describes each script

  • "whether"
  • missing space after first sentence

A script is provided to measure memory use while running a query. First a few tracks are added to the index, then memory use for a 20 second fragment is measured and

  • incomplete sentence

h2(#test). Testing Olaf - check __wether Olaf works__

  • "whether"

Clearer install

Related to openjournals/joss-reviews#5459

<pre>

You do it later on for the tests, but perhaps you could also give the full installation steps even if it's "obvious":

sudo apt-get install ffmpeg ruby
git clone https://github.com/JorenSix/Olaf
cd Olaf
make && make install

On a similar note, is it possible to make Olaf "apt-get install"-able? And such that dependencies are also installed. That would be nice for convenience.

recognize short audio signal with distinct tones

beeping.zip
I'm having a hard time recognizing my audio signal consistently. It is a short sequence of well defined tones (audio file in attachment).

Is the method in this library suited for this type of audio? if so, could you recommend olaf_config.c configuration to fingerprint and recognize this signal using ESP32? Furthermore, is it possible to recognize and distinguish between multiple such audio signals (different tone patterns) on the ESP?
thanks in advance

Question: is possible use external database?

From doc say:

On traditional computers fingerprints are stored in a high-performance key-value-store: LMDB. LMDB offers an a B+-tree based persistent storage ideal for small keys and values with low storage overhead.

Is possible hosting the DB into remote server and connect Olaf to them?

I saw into LMDB doc the warning:

Do not use LMDB databases on remote filesystems, even between processes on the same host. This breaks flock() on some OSes, possibly memory map sync, and certainly sync between programs on different hosts.

Event Point Extractor

src/olaf_ep_extractor.c:152

void rotate(Olaf_EP_Extractor * ep_extractor){

ep_extractor->maxes[i-1]=ep_extractor->maxes[i];
ep_extractor->mags[i-1]=ep_extractor->mags[i];

Is there a pointer to array row assignment or you meaned array row values assigment?

On performance / low memory

Related to: openjournals/joss-reviews#5459

Olaf/paper.md

Line 38 in 0173ff1

The portability and low memory[^1] usage of Olaf allows it to run on microcontrollers such as the ESP32 or similarly specced microcontrollers. This unique feature facilitates innovative IoT music recognition and music synchronization applications. Olaf also runs in the browser. A compilation emits a WebAssembly binary which, together with the Web Audio API, enables browser based acoustic fingerprinting applications.

  • Typo "...of Olaf allow it..."
  • I would bring the footnote content to the main text, and add a hyperlink to the script you mention.

Multithreaded queries problem

Hi, @JorenSix .

I tried to add multithreading and find out, that there is a problem with multithreading:

  • in unrestricted mode(new threads created as fast as it is possible) from 464 input files Olaf found only 26 in DB
  • with delay of 1-0.5 second there was a result as good as in serial mode(no threading at all)
  • with delay of 0.25 second or less results are degrading

Could you explain, is it 'by design' or is it a BUG also?

Missing square brackets around references.

Related to: openjournals/joss-reviews#5459

Olaf/paper.md

Line 34 in 0173ff1

@six2018dupapps and @six2023duplicates describe the applications of acoustic fingerprints for digital music archive management. These range from meta-data quality verification - through the identification of duplicates - to merging archives with potential duplicate material. A less straightforward application of Olaf is audio-to-audio alignment and synchronization [@six2015synchronizing;@six2017framework]. In that case the matching fingerprints are used to align e.g. multiple video recordings of the same event by aligning the audio attached to each video.

Olaf/paper.md

Line 40 in 0173ff1

Alternative systems with available implementations are by @neuralfp, Panako by @six2022panako, audfprint by @ellis2014labrosafp, PeakFP by @cortes2022baf, ChromaPrint by @chromaprint, SpectroMap by @spectromap and Dejavu by @dejavu. All have a different focus and trade-offs but none offer the portability to target browsers or have the low memory usage to target microcontrollers.

Running on Windows

Can Olaf be compiled and run on windows OS? If yes kindle post compile instructions

Segmentation fault on store action

Hi,

I have just installed Olaf in Debian Buster and I can't get it to work.
Whenever I try to add a reference track, either with
olaf store filename.mp3
or
olaf_c store filename.mp3

I get a Segmentation fault (core dumped).

Do you reckon what could be going on?

Thank you.

Missing/limited instructions for running tests

I think it would be helpful if users/contributors had instructions for running the automated tests locally when possible. The README makes reference to the scripts in the eval/ directory, but it's not clear how to use them, when contributors should execute certain tests, and so on.

Similarly, there appears to be a test target in the Makefile that claims to "build and test" olaf, but no test is actually executed. If this is intended to be part of the testing suite, it'd be a good idea to include that in the README as well.

Related to: openjournals/joss-reviews#5459

Small typos in README

Related to openjournals/joss-reviews#5459

The tests check __wether Olaf works__.The evaluation verifies __how well__ Olaf works. The benchmark checks __how fast__ Olaf works and how it deals with scalability.

  • "whether"
  • "...works. The..."

Zig allso supports WebAssembly as a target platform as an alterative to Emscripten. The @zig.build@ file includes a conditional to build the memory db for WASM. To get a WASM binary call the following:

  • "also"

Less interesting are the unit tests, these are mainly of interest for developing Olaf. The unit test can be compiled with `make test` and ran with `./bin/olaf_tests`.

  • fix code formatting

The audio_item can be:

  • add code formatting here and fix formatting in the list below

To query audio comming from the microphone there is the @olaf microphone@ command. It uses ffmpeg to access the default microphone. See "the ffmpeg input devices docs for your platform:" http://www.ffmpeg.org/ffmpeg-devices.html#Input-Devices

  • "coming"

cannot compile `olaf_mem`

Trying to run the example to generate header.h file, but i cannot compile olaf_mem

make mem in WSL returns:

make mem

gcc -c src/pffft.c                                       -Dmem -W -Wall -std=gnu11 -pedantic -O2 #pfft needs M_PI and other constants not in the ANSI c standard
gcc -c src/hash-table.c                  -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/queue.c                               -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf_deque.c                          -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf_max_filter_perceptual_van_herk.c  -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf.c                                        -Dmem -W -Wall -std=gnu11 -pedantic -O2
gcc -c src/olaf_db_mem.c                         -Dmem -W -Wall -std=c11 -pedantic -O2
src/olaf_db_mem.c: In function ‘olaf_db_find’:
src/olaf_db_mem.c:112:42: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
  112 |                 for(size_t i = index ; i >= 0  ;i--){
      |                                          ^~
gcc -c src/olaf_fp_db_writer_mem.c       -Dmem -W -Wall -std=c11 -pedantic -O2
src/olaf_fp_db_writer_mem.c: In function ‘olaf_fp_db_writer_destroy’:
src/olaf_fp_db_writer_mem.c:93:36: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   93 |                         printf("%llu,\n",db_writer->hashes[i]);
      |                                 ~~~^     ~~~~~~~~~~~~~~~~~~~~
      |                                    |                      |
      |                                    long long unsigned int uint64_t {aka long unsigned int}
      |                                 %lu
gcc -c src/olaf_fp_file_writer.c         -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf_fp_db_writer_cache.c -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf_runner.c                         -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf_stream_processor.c       -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf_ep_extractor.c           -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf_fp_extractor.c           -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf_reader_stream.c          -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf_fp_matcher.c             -Dmem -W -Wall -std=c11 -pedantic -O2
gcc -c src/olaf_config.c                         -Dmem -W -Wall -std=c11 -pedantic -O2
mkdir -p bin
gcc -o bin/olaf_mem *.o                         -lc -lm -ffast-math
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_new':
olaf_db_mem.c:(.text+0x0): multiple definition of `olaf_db_new'; olaf_db.o:olaf_db.c:(.text+0x50): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_store':
olaf_db_mem.c:(.text+0x70): multiple definition of `olaf_db_store'; olaf_db.o:olaf_db.c:(.text+0x7f0): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_find':
olaf_db_mem.c:(.text+0xc0): multiple definition of `olaf_db_find'; olaf_db.o:olaf_db.c:(.text+0x8e0): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_find_single':
olaf_db_mem.c:(.text+0x2b0): multiple definition of `olaf_db_find_single'; olaf_db.o:olaf_db.c:(.text+0xa50): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_destroy':
olaf_db_mem.c:(.text+0x2f0): multiple definition of `olaf_db_destroy'; olaf_db.o:olaf_db.c:(.text+0xe00): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_stats':
olaf_db_mem.c:(.text+0x300): multiple definition of `olaf_db_stats'; olaf_db.o:olaf_db.c:(.text+0xcc0): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_string_hash':
olaf_db_mem.c:(.text+0x320): multiple definition of `olaf_db_string_hash'; olaf_db.o:olaf_db.c:(.text+0x1b0): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_store_meta_data':
olaf_db_mem.c:(.text+0x330): multiple definition of `olaf_db_store_meta_data'; olaf_db.o:olaf_db.c:(.text+0x2f0): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_find_meta_data':
olaf_db_mem.c:(.text+0x400): multiple definition of `olaf_db_find_meta_data'; olaf_db.o:olaf_db.c:(.text+0x430): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_delete_meta_data':
olaf_db_mem.c:(.text+0x430): multiple definition of `olaf_db_delete_meta_data'; olaf_db.o:olaf_db.c:(.text+0x3b0): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_has_meta_data':
olaf_db_mem.c:(.text+0x440): multiple definition of `olaf_db_has_meta_data'; olaf_db.o:olaf_db.c:(.text+0x780): first defined here
/usr/bin/ld: olaf_db_mem.o: in function `olaf_db_stats_meta_data':
olaf_db_mem.c:(.text+0x450): multiple definition of `olaf_db_stats_meta_data'; olaf_db.o:olaf_db.c:(.text+0x520): first defined here
/usr/bin/ld: olaf_fp_db_writer_mem.o: in function `olaf_fp_db_writer_new':
olaf_fp_db_writer_mem.c:(.text+0x20): multiple definition of `olaf_fp_db_writer_new'; olaf_fp_db_writer.o:olaf_fp_db_writer.c:(.text+0x0): first defined here
/usr/bin/ld: olaf_fp_db_writer_mem.o: in function `olaf_fp_db_writer_store':
olaf_fp_db_writer_mem.c:(.text+0x60): multiple definition of `olaf_fp_db_writer_store'; olaf_fp_db_writer.o:olaf_fp_db_writer.c:(.text+0x40): first defined here
/usr/bin/ld: olaf_fp_db_writer_mem.o: in function `olaf_fp_db_writer_delete':
olaf_fp_db_writer_mem.c:(.text+0x140): multiple definition of `olaf_fp_db_writer_delete'; olaf_fp_db_writer.o:olaf_fp_db_writer.c:(.text+0x140): first defined here
/usr/bin/ld: olaf_fp_db_writer_mem.o: in function `olaf_fp_db_writer_destroy':
olaf_fp_db_writer_mem.c:(.text+0x150): multiple definition of `olaf_fp_db_writer_destroy'; olaf_fp_db_writer.o:olaf_fp_db_writer.c:(.text+0x240): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:95: mem] Error 1```

Automated test failures

I'm on an M1 Mac running Ventura. gcc is symlinked to clang on my system, which isn't unusual on macOS.

When I build the test binary using make test, and then run bin/olaf_tests, an assertion fails:

(array_size == 512), function olaf_max_filter, file olaf_max_filter_perceptual.c, line 43.

Further, when I run eval/olaf_functional_tests.rb I get the following output:

PASS: Test dataset check: If not found, download it first! call e.g. 'ruby eval/olaf_download_dataset.rb'
1/1 1051039.mp3 SKIP: already stored audio
PASS: Command : olaf store 'dataset/ref/1051039.mp3'
1/1 1071559.mp3 SKIP: already stored audio
PASS: Command : olaf store 'dataset/ref/1071559.mp3'
1/1 1075784.mp3 SKIP: already stored audio
PASS: Command : olaf store 'dataset/ref/1075784.mp3'
1/1 11266.mp3 SKIP: already stored audio
PASS: Command : olaf store 'dataset/ref/11266.mp3'
1/1 147199.mp3 SKIP: already stored audio
PASS: Command : olaf store 'dataset/ref/147199.mp3'
1/1 173050.mp3 SKIP: already stored audio
PASS: Command : olaf store 'dataset/ref/173050.mp3'
1/1 189211.mp3 SKIP: already stored audio
PASS: Command : olaf store 'dataset/ref/189211.mp3'
1/1 297888.mp3 SKIP: already stored audio
PASS: Command : olaf store 'dataset/ref/297888.mp3'
1/1 612409.mp3 SKIP: already stored audio
PASS: Command : olaf store 'dataset/ref/612409.mp3'
1/1 852601.mp3 SKIP: already stored audio
PASS: Command : olaf store 'dataset/ref/852601.mp3'
FAIL: Expected 10 stored, was 11
FAIL: Expected 10 stored, was 11

Related to: openjournals/joss-reviews#5459

undefined local variable or method `filename' when using monitor command

Olaf/olaf.rb

Line 91 in 0b08dd9

puts "#{index}, #{length}_#{start}s, #{File.basename audio_filename}, #{File.basename filename}, #{line}\n"

I get an error when I try to use the monitor command (maybe it should be an audio_filename instead of filename)

/tmp/Olaf # olaf monitor input.mp3
/usr/local/bin/olaf:91:in `block (2 levels) in monitor': undefined local variable or method `filename' for main:Object (NameError)
	from /usr/local/bin/olaf:84:in `each'
	from /usr/local/bin/olaf:84:in `block in monitor'
	from /usr/local/bin/olaf:180:in `with_converted_audio_part'
	from /usr/local/bin/olaf:80:in `monitor'
	from /usr/local/bin/olaf:373:in `block in <main>'
	from /usr/local/bin/olaf:372:in `each'
	from /usr/local/bin/olaf:372:in `each_with_index'
	from /usr/local/bin/olaf:372:in `<main>'

Delete fails with undefined local variable or method audio_identifer

For a freshly added file, I cannot delete it from the database.

$ olaf delete "test.mp3"
Traceback (most recent call last):
	6: from /usr/local/bin/olaf:340:in `<main>'
	5: from /usr/local/bin/olaf:340:in `each_with_index'
	4: from /usr/local/bin/olaf:340:in `each'
	3: from /usr/local/bin/olaf:341:in `block in <main>'
	2: from /usr/local/bin/olaf:299:in `delete'
	1: from /usr/local/bin/olaf:138:in `with_converted_audio'
/usr/local/bin/olaf:300:in `block in delete': undefined local variable or method `audio_identifer' for main:Object (NameError)
Did you mean?  audio_filename
ERROR: 1

Unfortunately, I do not speak ruby, but I also don't see any sign of the undefined variable, so I daresay the error is correct.

Generating fingerprints for ESP32

Hi,

I am developing an application which communicates with external device and it should be able to perform diagnostics on this device according to sound made by it. I found your project today and I thought it fits ideally in my needs, however I have some serious problems with running it.

I am using ESP32 as my platform with I2S microphone (it is already working), so I wanted to build OLAF Mem version. It succeeded, but calling ./olaf_mem store sample.mp3 wav 666 generates following output:

Stored 0 fp's from 16.8s in 0.108s (156 times realtime)

I think that Ruby script is responsible for generating fingerprints, however I don't know how to use it correctly. Of course both ruby and ffmpeg are in my PATH.

Are you able to help me with generating fingerprints?

Comparing short audio files

Hi,
I'm interested in finding near-duplicate audio files. My dataset is about 3000 thousands short audio files, between 0.5 seconds to 5 seconds. Unlike Shazam, both the "target" audio (i.e. the songs in Shazam's case) and the user input are short, and both might contain noise.

Can this library help?
If so, are there any recommendations for tuning parameters?

N.B - if a file is matched to multiple other files, it's fine - I have a less efficient algorithm that can verify which match is correct. In other words, I can handle some amount of false positives, but I don't want false negatives.

Understanding the Output

For testing I have "stored" an mp3 (compilation.mp3) made from several tracks against which I have run 3 queries.
Query 1 = .mp3 of one of the tracks (made from the original .flac used to make the compilation) so would expect a single match but got the following:
1/3 TestAll54sec.mp3 match id, match count (#), q to ref time delta (s), ref start (s), ref stop (s), query time (s)
1, 3, TestAll54sec.mp3, 2146557281, /home/apb/Olaf-master/Compilation.mp3, 55, -2594.35, 2637.10, 2648.18, 53.83
1, 3, TestAll54sec.mp3, 2146557281, /home/apb/Olaf-master/Compilation.mp3, 6, -2594.34, 2643.14, 2643.14, 48.80

Query 2 = a 15sec clip from the same track as query 1
2, 3, Test15sec.mp3, 2146557281, /home/apb/Olaf-master/Compilation.mp3, 332, -2608.95, 2609.14, 2623.73, 14.78

Query 3 = the original .flac file used to make the .mp3 for query 1
3, 3, TestAll54secFLAC.flac, 2146557281, /home/apb/Olaf-master/Compilation.mp3, 84, -2594.35, 2637.10, 2648.03, 53.68

Questions:

  1. What do match count (#), q to ref time delta (s), ref start (s), ref stop (s), query time (s) mean? other than -2594.35 which is the negative of the start time of the track in the compilation and 53.83 which seems to match the track length I'm not sure how to interpret the other numbers.
  2. Any thoughts as to why query 1 would return 2 matches?
  3. The only difference between this query and query 1 was the file used was the original .flac not an. mp3 made from the same file so shouldn't the results be the same?

Mention comparison to Panako

Related to: openjournals/joss-reviews#5459

Olaf/paper.md

Line 40 in 0173ff1

Alternative systems with available implementations are by @neuralfp, Panako by @six2022panako, audfprint by @ellis2014labrosafp, PeakFP by @cortes2022baf, ChromaPrint by @chromaprint, SpectroMap by @spectromap and Dejavu by @dejavu. All have a different focus and trade-offs but none offer the portability to target browsers or have the low memory usage to target microcontrollers.

  • could be interesting to mention and link to the Panako comparison you did

Segmentation fault on some WAV files (even after FFMPEG converts them to RAW)

OS: Debian 10 x64
gcc version 8.3.0 (Debian 8.3.0-6)

For some reason olaf_c goes to segmentation fault on some files.
It is simply reprodusable on store and on query mode.

query mode make output as:
...
start key: 4365488144 stop key: 4365488154 results 0
start key: 4365488144 stop key: 4365488154 results 0
Segmentation fault

GDB does not show paticular line, but shows :

Program received signal SIGSEGV, Segmentation fault.
0x0000555555565003 in olaf_reader_read ()
(gdb) backtrace
#0 0x0000555555565003 in olaf_reader_read ()
#1 0x000055555556542d in olaf_stream_processor_process ()
#2 0x000055555555674e in main ()
(gdb)

make web fails

Was just trying to compile this and ran into an error when I run make web

$ make web
emcc -o wasm/js/olaf.html  -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS="['_malloc','_free']" -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' src/olaf_wasm.c src/pffft.c src/olaf_ep_extractor.c src/olaf_fp_extractor.c src/olaf_fp_db_mem.c src/olaf_fp_db_writer_mem.c src/olaf_fp_matcher_fast.c src/olaf_config.c  -O3 -Wall -lm -lc -W -I.
src/olaf_wasm.c:125:8: error: initializing 'int' with an expression of incompatible type 'void'
                        int maxMatchScore = olaf_fp_matcher_match(state.fp_matcher,state.fingerprints);
                            ^               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
emcc: error: '/Users/chris/code/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -DEMSCRIPTEN -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=17 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=/Users/chris/code/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -O3 -Wall -W -I. src/olaf_wasm.c -c -o /var/folders/gb/dws9z6hs4f12k5m58zl7s1c40000gn/T/emscripten_temp_6q5sozgt/olaf_wasm_0.o' failed (1)
make: *** [web] Error 1
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I'm not too familiar with C these days. Any ideas?

Formatting

Related to openjournals/joss-reviews#5459

With respect to other audio search systems, Olaf stands out for three reasons. Olaf runs on embedded devices. Olaf is fast on traditional computers. Olaf runs in the browsers.

Perhaps you can write out the three reasons as a list so that it stands out?

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.