Skip to content

Instantly share code, notes, and snippets.

@virtuald
virtuald / bpmdetect.py
Last active December 13, 2023 17:43
GStreamer BPM Detector frontend
#!/usr/bin/env python
'''
Simple program that uses the 'bpmdetect' GStreamer plugin to detect
the BPM of a song, and outputs that to console.
Requires GStreamer 1.x, PyGObject 1.x, and gst-plugins-bad
Copyright (C) 2015 Dustin Spicuzza
This program is free software; you can redistribute it and/or modify
@virtuald
virtuald / devices.py
Created August 16, 2015 03:19
Enumerate all Windows audio devices using python+ctypes
import ctypes.wintypes
import ctypes as C
_dsound_dll = C.windll.LoadLibrary("dsound.dll")
_DirectSoundEnumerateW = _dsound_dll.DirectSoundEnumerateW
_LPDSENUMCALLBACK = C.WINFUNCTYPE(C.wintypes.BOOL,
C.wintypes.LPVOID,
C.wintypes.LPCWSTR,
#
# Playbin bug: Play 2 flac files (presumably of any length), and play
# 2 mp3 files, using gapless playback, and weirdness happens
#
# On GST 1.4.5, track4.mp3 stalls for ~10s or so without playing, but
# there is no audio for track3 or track4. Other tests I've conducted
# track3 does have audio, but there is still a pause.
#
# On GST 1.5.2, there is no volume for track3 or track4.mp3, but no
# stall occurs. Seems like a bug.
@virtuald
virtuald / debug.log
Last active August 29, 2015 14:22
GStreamer deadlock
0:00:00.000044940 24400 0xd5e720 INFO GST_INIT gst.c:499:init_pre: Initializing GStreamer Core Library version 1.4.5
0:00:00.000090481 24400 0xd5e720 INFO GST_INIT gst.c:500:init_pre: Using library installed in /usr/lib64
0:00:00.000100859 24400 0xd5e720 INFO GST_INIT gst.c:511:init_pre: Linux localhost.localdomain 3.19.3-200.fc21.x86_64 #1 SMP Thu Mar 26 21:39:42 UTC 2015 x86_64
0:00:00.000254496 24400 0xd5e720 INFO GST_INIT gstmessage.c:119:_priv_gst_message_initialize: init messages
0:00:00.000601084 24400 0xd5e720 INFO GST_INIT gstcontext.c:77:_priv_gst_context_initialize: init contexts
0:00:00.000787706 24400 0xd5e720 INFO GST_PLUGIN_LOADING gstplugin.c:317:_priv_gst_plugin_initialize: registering 0 static plugins
0:00:00.000865813 24400 0xd5e720 INFO GST_PLUGIN_LOADING gstplugin.c:225:gst_plugin_register_static: registered static plugin "staticelements"
0:00:00.000876420 24400
@virtuald
virtuald / index.html
Created April 28, 2015 04:35
Concept for jQuery extensions for pynetworktables2js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<!-- This starts the NetworkTables websocket, it can be accessed from multiple
pages simultaneously -->
<script src="/networktables/networktables.js"></script>
@virtuald
virtuald / README.md
Last active March 24, 2016 04:38
FRC mjpg-streamer scripts

NOTE: These scripts are obsolete, you should use the mjpg-streamer.ipk file published at https://github.com/robotpy/roborio-packages instead.


mjpg-streamer scripts for RoboRIO

This was very quickly put together... so not quite as polished as I would normally like. :)

We used these scripts to run two camera servers on our roboRIO. Very little CPU usage as far as we can see. Only tested with the Microsoft LifeCam 3000 cameras.

@virtuald
virtuald / robot.py
Created February 15, 2015 00:50
Command sample that works
import wpilib
from wpilib.buttons import JoystickButton
from wpilib.command import Command, CommandGroup, Scheduler
class DoTheThing(Command):
def __init__(self, robot):
super().__init__()
self.robot = robot
@virtuald
virtuald / sshpass.py
Created December 20, 2014 19:49
Simple python wrapper to give SSH a password for automation purposes (with output capture)
#!/usr/bin/env python3
import os
import sys
_b = sys.version_info[0] < 3 and (lambda x:x) or (lambda x:x.encode('utf-8'))
def ssh_exec_pass(password, args, capture_output=False):
'''
Wrapper around openssh that allows you to send a password to
#!/usr/bin/env python
from tornado import gen
from tornado.ioloop import IOLoop
@gen.coroutine
def exception_gets_lost():
print 'got here'
#!/usr/bin/env python
from tornado import gen
from tornado.ioloop import IOLoop
from tornado import stack_context
import traceback
def broken(arg1, callback):