Skip to content

🎡 A cross-platform C++ Shazam client that identifies music files and fetches song details from Shazam.

License

Notifications You must be signed in to change notification settings

BayernMuller/vibra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


vibra

What is vibra?

  • vibra is a C++ music file recognition tool that uses an unofficial Shazam API.
  • vibra analyzes music files and returns fingerprint data. It searches the Shazam database to identify the song.
  • The Shazam algorithm is based on:
  • I referenced the Rust implementation of the Shazam client code from SongRec.
  • I created this project for embedded devices such as Raspberry Pi or Jetson Nano, which are challenging to set up with Python or Rust environments.

Compatibility table

Platform Architecture Build Status
WebAssembly - βœ…
Linux x86_64 βœ…
Linux ARM64 βœ…
Windows x86_64 βœ…
macOS x86_64 βœ…
macOS ARM64 βœ…
Raspberry Pi 4 ARMv8-A βœ…
Raspberry Pi Zero ARMv6 βœ…

Build vibra

Requirements

  • vibra uses CMake for building. You need to install CMake to build vibra.
  • vibra utilizes C++11 features.
  • vibra depends on the following libraries or tools:
    • CMake: To build the project.
    • libcurl: To send HTTP requests to the Shazam API.
    • libfftw3: To calculate the Fast Fourier Transform.
    • (Optional) FFmpeg: To decode audio files other than WAV. (e.g., MP3, FLAC, etc.)
      • If you want to want recognize non-WAV files, you need to install FFmpeg on your system.

Install dependencies

  • Ubuntu
    • sudo apt-get install cmake libcurl4-openssl-dev libfftw3-dev
    • sudo apt-get install ffmpeg (Optional)

Build

  • Clone repository recursively to include submodules.

    • git clone --recursive https://github.com/bayernmuller/vibra.git
  • Run the following commands to build vibra:

    • mkdir build && cd build
    • cmake ..
    • make

Usage

Use --help option to see the help message.
vibra {COMMAND} [OPTIONS]

Options:

  Commands:
      -F, --fingerprint                     Generate a fingerprint
      -R, --recognize                       Recognize a song
      -h, --help                            Display this help menu
  Sources:
      File sources:
          -f, --file                            File path
      Raw PCM sources:
          -s, --seconds                         Chunk seconds
          -r, --rate                            Sample rate
          -c, --channels                        Channels
          -b, --bits                            Bits per sample
- recognizing song from wav file
vibra --recognize --file sample.wav > result.json

jq .track.title result.json
"Stairway To Heaven"
jq .track.subtitle result.json
"Led Zeppelin"
jq .track.share.href result.json
"https://www.shazam.com/track/5933917/stairway-to-heaven"
- recognizing song from microphone
  • You can use sox or FFmpeg to print raw PCM data from microphone.
sox -d -t raw -b 24 -e signed-integer -r 44100 -c 1 - 2>/dev/null
| vibra --recognize --seconds 5 --rate 44100 --channels 1 --bits 24 > result.json

jq .track.title result.json
"Bound 2"
jq .track.subtitle result.json
"Kanye West"
jq .track.sections[1].text result.json
[
  "B-B-B-Bound to fall in love",
  "Bound to fall in love",
  "(Uh-huh, honey)",
  ...
]
- recognizing non-WAV files
  • You need to install FFmpeg on your system to decode non-WAV media files.
  • Vibra will try to locate FFmpeg in your PATH environment variable. Alternatively, you can specify the FFmpeg path by setting the FFMPEG_PATH environment variable.
# Automatically find FFmpeg in PATH
vibra --recognize --file out.mp3

# Specify the FFmpeg path
export FFMPEG_PATH=/opt/homebrew/bin/ffmpeg
vibra --recognize --file out.mp3
  • You can see the sample shazam result json file in here

Performance comparison


lower is better

  • I compared the performance of vibra with the SongRec rust and python version on the Raspberry Pi 4.
  • vibra is about 2 times faster than the SongRec!

WebAssembly Version Support

Demo Video

  • Real time music tracker and lighting solution "Mooding", which uses vibra.
  • Click to view!

Mooding

License

  • vibra is licensed under the GPLv3 license. See LICENSE for more details.

About

🎡 A cross-platform C++ Shazam client that identifies music files and fetches song details from Shazam.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published