Permalink
Browse files

Initial version

  • Loading branch information...
lalinsky committed Jan 2, 2011
0 parents commit 073f57499ae95e17dd65f98922fe21e1a187782a
Showing with 1,125 additions and 0 deletions.
  1. +21 −0 .bzrignore
  2. +5 −0 AUTHORS
  3. +481 −0 COPYING
  4. 0 ChangeLog
  5. +3 −0 Makefile.am
  6. +1 −0 NEWS
  7. +21 −0 README
  8. +18 −0 autogen.sh
  9. +98 −0 configure.ac
  10. +59 −0 examples/gst-acoustid-query.py
  11. +15 −0 src/Makefile.am
  12. +319 −0 src/gstchromaprint.c
  13. +84 −0 src/gstchromaprint.h
@@ -0,0 +1,21 @@
+aclocal.m4
+autom4te.cache
+autoregen.sh
+config.*
+configure
+libtool
+INSTALL
+Makefile
+Makefile.in
+depcomp
+install-sh
+ltmain.sh
+missing
+stamp-*
+gst-chromaprint-*.tar.*
+*~
+*.la
+*.lo
+
+.deps
+.libs
@@ -0,0 +1,5 @@
+Milosz Derezynski
+Eric Buehl
+Sebastian Dröge <slomo@circular-chaos.org>
+Lukáš Lalinský <lalinsky@gmail.com>
+
481 COPYING

Large diffs are not rendered by default.

Oops, something went wrong.
No changes.
@@ -0,0 +1,3 @@
+SUBDIRS = src
+
+EXTRA_DIST = autogen.sh
1 NEWS
@@ -0,0 +1 @@
+Nothing much yet.
21 README
@@ -0,0 +1,21 @@
+WCHROMAPRINT GSTREAMER PLUG-IN
+------------------------------
+
+gst-chromaprint is a GStreamer plug-in for generating audio fingerprints using
+the Chromaprint library [1].
+
+The simplest way to use it is via the `gst-launch` application:
+
+$ gst-launch-0.10 -t filesrc location=/path/to/audio/file ! decodebin \
+ ! audioconvert ! chromaprint duration=60 ! fakesink sync=0 \
+ | grep 'chromaprint fingerprint'
+
+This command will decode an audio file and calculate its fingerprint.
+
+See the examples/ directory for a sample Python script that uses
+GStreamer to generate Chromaprint audio fingerprints and look them
+up in the Acoustid database [2].
+
+[1] http://wiki.acoustid.org/wiki/Chromaprint
+[2] http://acoustid.org/
+
@@ -0,0 +1,18 @@
+#!/bin/sh
+# you can either set the environment variables AUTOCONF, AUTOHEADER, AUTOMAKE,
+# ACLOCAL, AUTOPOINT and/or LIBTOOLIZE to the right versions, or leave them
+# unset and get the defaults
+
+autoreconf --verbose --force --install --make || {
+ echo 'autogen.sh failed';
+ exit 1;
+}
+
+./configure || {
+ echo 'configure failed';
+ exit 1;
+}
+
+echo
+echo "Now type 'make' to compile this module."
+echo
@@ -0,0 +1,98 @@
+dnl required version of autoconf
+AC_PREREQ([2.53])
+
+dnl TODO: fill in your package name and package version here
+AC_INIT([gst-chromaprint],[0.1.0])
+
+dnl required versions of gstreamer and plugins-base
+GST_REQUIRED=0.10.16
+GSTPB_REQUIRED=0.10.16
+
+AC_CONFIG_SRCDIR([src/gstchromaprint.c])
+AC_CONFIG_HEADERS([config.h])
+
+dnl required version of automake
+AM_INIT_AUTOMAKE([1.10])
+
+dnl enable mainainer mode by default
+AM_MAINTAINER_MODE([enable])
+
+dnl check for tools (compiler etc.)
+AC_PROG_CC
+
+dnl required version of libtool
+LT_PREREQ([2.2.6])
+LT_INIT
+
+dnl give error and exit if we don't have pkgconfig
+AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, [ ], [
+ AC_MSG_ERROR([You need to have pkg-config installed!])
+])
+
+dnl Check for the required version of GStreamer core (and gst-plugins-base)
+dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am
+dnl
+dnl If you need libraries from gst-plugins-base here, also add:
+dnl for libgstvideo-0.10: gstreamer-video-0.10 >= $GST_REQUIRED
+dnl for libgsttag-0.10: gstreamer-tag-0.10 >= $GST_REQUIRED
+dnl for libgstpbutils-0.10: gstreamer-pbutils-0.10 >= $GST_REQUIRED
+dnl for libgstfft-0.10: gstreamer-fft-0.10 >= $GST_REQUIRED
+dnl for libgstinterfaces-0.10: gstreamer-interfaces-0.10 >= $GST_REQUIRED
+dnl for libgstrtp-0.10: gstreamer-rtp-0.10 >= $GST_REQUIRED
+dnl for libgstrtsp-0.10: gstreamer-rtsp-0.10 >= $GST_REQUIRED
+dnl etc.
+PKG_CHECK_MODULES(GST, [
+ gstreamer-0.10 >= $GST_REQUIRED
+ gstreamer-audio-0.10 >= $GST_REQUIRED
+ gstreamer-base-0.10 >= $GST_REQUIRED
+ gstreamer-controller-0.10 >= $GST_REQUIRED
+], [
+ AC_SUBST(GST_CFLAGS)
+ AC_SUBST(GST_LIBS)
+], [
+ AC_MSG_ERROR([
+ You need to install or upgrade the GStreamer development
+ packages on your system. On debian-based systems these are
+ libgstreamer0.10-dev and libgstreamer-plugins-base0.10-dev.
+ on RPM-based systems gstreamer0.10-devel, libgstreamer0.10-devel
+ or similar. The minimum version required is $GST_REQUIRED.
+ ])
+])
+
+PKG_CHECK_MODULES(CHROMAPRINT, [
+ libchromaprint
+], [
+ AC_SUBST(GST_CFLAGS)
+ AC_SUBST(GST_LIBS)
+], [
+ AC_MSG_ERROR([
+ You need to install libchromaprint.
+ ])
+])
+
+dnl check if compiler understands -Wall (if yes, add -Wall to GST_CFLAGS)
+AC_MSG_CHECKING([to see if compiler understands -Wall])
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Wall"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ], [ ])], [
+ GST_CFLAGS="$GST_CFLAGS -Wall"
+ AC_MSG_RESULT([yes])
+], [
+ AC_MSG_RESULT([no])
+])
+
+dnl set the plugindir where plugins should be installed (for src/Makefile.am)
+if test "x${prefix}" = "x$HOME"; then
+ plugindir="$HOME/.gstreamer-0.10/plugins"
+else
+ plugindir="\$(libdir)/gstreamer-0.10"
+fi
+AC_SUBST(plugindir)
+
+dnl set proper LDFLAGS for plugins
+GST_PLUGIN_LDFLAGS='-module -avoid-version -export-symbols-regex [_]*\(gst_\|Gst\|GST_\).*'
+AC_SUBST(GST_PLUGIN_LDFLAGS)
+
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_OUTPUT
+
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+
+import sys
+import urllib, urllib2
+from xml.etree import ElementTree
+
+import gobject
+gobject.threads_init()
+
+import pygst
+pygst.require("0.10")
+import gst
+
+print "Decoding audio"
+
+bin = gst.parse_launch("filesrc name=source ! decodebin ! chromaprint name=chromaprint0 duration=60 ! fakesink sync=0 silent=TRUE")
+source = bin.get_by_name("source")
+source.set_property("location", sys.argv[1])
+
+mainloop = gobject.MainLoop()
+
+def on_eos(bus, msg):
+ mainloop.quit()
+
+bus = bin.get_bus()
+bus.add_signal_watch()
+bus.connect('message::eos', on_eos)
+
+bin.set_state(gst.STATE_PLAYING)
+mainloop.run()
+
+format = gst.Format(gst.FORMAT_TIME)
+length = bin.query_duration(format)[0] / gst.SECOND
+bin.set_state(gst.STATE_NULL)
+
+chromaprint = bin.get_by_name("chromaprint0")
+fingerprint = chromaprint.get_property("fingerprint")
+
+print "Looking up fingerprint"
+
+data = {}
+data['client'] = 'IUThVP5T'
+data['meta'] = '2'
+data['length'] = str(length)
+data['fingerprint'] = fingerprint
+resp = urllib2.urlopen('http://api.acoustid.org/lookup', urllib.urlencode(data))
+tree = ElementTree.parse(resp)
+results = tree.findall('results/result')
+if results:
+ print 'Found %s matching song(s):' % (len(results),)
+ for result in results:
+ print
+ print 'Score:', result.find('score').text
+ print 'ID:', result.find('id').text
+ for track in result.findall('tracks/track'):
+ print 'http://musicbrainz.org/track/%s.html' % track.find('id').text
+else:
+ print 'No matching songs found'
+
@@ -0,0 +1,15 @@
+# Note: plugindir is set in configure
+
+plugin_LTLIBRARIES = libgstchromaprint.la
+
+# sources used to compile this plug-in
+libgstchromaprint_la_SOURCES = gstchromaprint.c gstchromaprint.h
+
+# compiler and linker flags used to compile this plugin, set in configure.ac
+libgstchromaprint_la_CFLAGS = $(GST_CFLAGS) $(CHROMAPRINT_CFLAGS)
+libgstchromaprint_la_LIBADD = $(GST_LIBS) $(CHROMAPRINT_LIBS)
+libgstchromaprint_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstchromaprint_la_LIBTOOLFLAGS = --tag=disable-static
+
+# headers we need but don't want installed
+noinst_HEADERS = gstchromaprint.h
Oops, something went wrong.

0 comments on commit 073f574

Please sign in to comment.