Can the NN cope with monitoring the mic for a clap/whistle or two so one can have clap/whistle to stop/pause/play audio recording/playing?

Lang=C: http://befinitiv.wordpress.com/2012/04/01/control-your-home-devices-by-whistling/

There is also the attached python script off the internet.

If so I will add getting one of these apps working, on to my todo list. Which one? C or Python?
#!/usr/bin/python
# -*- coding: utf-8 -*-

# PUBLIC DOMAIN

#2012-09-07  Alexander Ross  <sourcecode1[AT anti spam]aross.me>
# * Added support for MOC.


import gtk, gst, dbus

prev = False

# Receiving informations about the intensity of the sound
def playerbinMessage(bus, message):
	if message.type == gst.MESSAGE_ELEMENT:
		struct = message.structure
		
		if struct.get_name() == 'level':
			# If we receive 2 signals for 1 clap
			global prev
			
			if prev:
				prev = False
			
			# Intensity of the sound
			elif struct['peak'][0] > -16:
				# Play/pause
				
				inst = None
				
				if 'org.bansheeproject.Banshee' in dbus.SessionBus().list_names():
					dbus.SessionBus().get_object('org.bansheeproject.Banshee', '/org/bansheeproject/Banshee/PlayerEngine').TogglePlaying()
				
				elif 'org.mpris.Totem' in dbus.SessionBus().list_names():
					inst = dbus.Interface(dbus.SessionBus().get_object('org.mpris.Totem', '/Player'), dbus_interface='org.freedesktop.MediaPlayer')
				
				elif 'org.mpris.clementine' in dbus.SessionBus().list_names():
					inst = dbus.Interface(dbus.SessionBus().get_object('org.mpris.clementine', '/Player'), dbus_interface='org.freedesktop.MediaPlayer')
				
				elif 'org.mpris.xmms2 ' in dbus.SessionBus().list_names():
					inst = dbus.Interface(dbus.SessionBus().get_object('org.mpris.xmms2', '/Player'), dbus_interface='org.freedesktop.MediaPlayer')
				
				elif 'org.mpris.audacious' in dbus.SessionBus().list_names():
					inst = dbus.Interface(dbus.SessionBus().get_object('org.mpris.audacious', '/Player'), dbus_interface='org.freedesktop.MediaPlayer')
				
				elif 'org.gnome.Muine' in dbus.SessionBus().list_names():
					inst = dbus.Interface(dbus.SessionBus().get_object('org.gnome.Muine', '/Player'), dbus_interface='org.freedesktop.MediaPlayer')
				
				elif 'org.kde.amarok' in dbus.SessionBus().list_names():
					inst = dbus.Interface(dbus.SessionBus().get_object('org.kde.amarok', '/Player'), dbus_interface='org.freedesktop.MediaPlayer')
						
				elif 'org.gnome.Rhythmbox' in dbus.SessionBus().list_names():
					dbus.Interface(dbus.SessionBus().get_object('org.gnome.Rhythmbox', '/org/gnome/Rhythmbox/Player'), dbus_interface='org.gnome.Rhythmbox.Player').playPause(True)
				
				if inst:
					if inst.GetStatus()[0] == 0:
						inst.Pause()
					
					else:
						inst.Play()
				
				from subprocess import call
				call(["mocp", "--toggle-pause"])
				
				prev = True

# Listening
pipeline = gst.parse_launch('pulsesrc ! level ! audioconvert ! vorbisenc ! oggmux ! filesink location=/dev/null')

bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect('message', playerbinMessage)

pipeline.set_state(gst.STATE_PLAYING)

gtk.main()
_______________________________________________
Qi Hardware Discussion List
Mail to list (members only): [email protected]
Subscribe or Unsubscribe: 
http://lists.en.qi-hardware.com/mailman/listinfo/discussion

Reply via email to