This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Run this with python3 interactively like | |
#python3 -i sound_test.py | |
#In the python interactive console you can play with | |
#env, wave and rb to adjust envelope, waveform and reverb settings | |
import ctypes, sys, math, threading | |
PA = ctypes.CDLL('libpulse-simple.so') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5.QtGui import QTextOption, QFont | |
from PyQt5.QtCore import Qt | |
from PyQt5.QtWidgets import QApplication, QTableView, QTableWidget, QTableWidgetItem, QMainWindow, QGridLayout, QWidget, QPlainTextEdit | |
import re | |
monospace = QFont('DejaVu Sans Mono') | |
monospace.setStyleHint(QFont.Monospace) | |
print(monospace) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lowlevel_gl import * | |
# Test | |
#Kom ihåg error check för push/pop matrix | |
import threading | |
assert glfwInit() == 1 | |
w = glfwCreateWindow(640, 480, b"Hello World!", None, None) | |
assert w, 'Failed to create window' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy, subprocess, struct, sys | |
#pacmd load-module module-null-sink sink_name=Python_input | |
#pacmd update-sink-proplist Python_input device.description="Python sound processing input" | |
#Note - seems we can't have spaces in description so replace with _ or something for now | |
# - it might be a bash thing so it might work from subprocess.call, have not tested | |
#figure out what monitor-stream this is and put it down there where we pamon | |
#also remember to redirect the source application to this sink (for instance pavucontrol) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Processed events 34.68 K @ 69.26 K/s. | |
Processed events 52.52 K @ 31.35 K/s. | |
Processed events 64.64 K @ 23.5 K/s. | |
Processed events 83.74 K @ 38.16 K/s. | |
Deflated processed 7.0 MiB @ 3.01 MiB/s. | |
Inflated processed 30.04 MiB @ 12.9 MiB/s. | |
Processed events 107.22 K @ 43.06 K/s. | |
Processed events 151.13 K @ 87.78 K/s. | |
Processed events 176.55 K @ 50.83 K/s. | |
Processed events 202.01 K @ 50.93 K/s. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bz2, time, functools, xml.etree.ElementTree | |
#serial reading of XML inspired by http://boscoh.com/programming/reading-xml-serially.html | |
#note that you can do elem.clear for every element | |
def format_amount(amount, precision=2, unit='B', base=1024, unit_prefix='i'): | |
if amount < base ** 1: | |
return f'{amount}{unit}' | |
elif amount < base ** 2: | |
return f'{round(amount/(base**1), precision)} K{unit_prefix}{unit}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
___ _ _ _ _ ___ _ ___ _ _ _ | |
/ __| |___| |_| |_ ___ __| | | _ \___| |___ / __| (_)__| |___ _ _ | |
\__ \ / _ \ _| _/ -_) _` | | _/ _ \ / -_) \__ \ | / _` / -_) '_| | |
|___/_\___/\__|\__\___\__,_| |_| \___/_\___| |___/_|_\__,_\___|_| | |
by: Mikael Lövqvist @ LED Alert Hackerspace | |
.-----. outer diameter: 2 × pole_shroud_thickness + pole_diameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PIL.Image, our_png_save | |
im = PIL.Image.new('RGB', (256, 256)) | |
p = im.load() | |
for y in range(256): | |
for x in range(256): | |
p[x,y] = (x, y, (x * y) >> 8) | |
colors = set() | |
for y in range(256): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PIL.PngImagePlugin | |
#Import all the things unless they start with two underscores. "from stuff import *" will not import things beginning with one underscore | |
#And we need things like _MAGIC etc | |
locals().update({k: v for k, v in PIL.PngImagePlugin.__dict__.items() if not k.startswith('__')}) | |
#This function is taken from PIL.PngImagePlugin with a small change that is noted below | |
#In the bottom we register this modified function to be the PNG save function -devilholk | |
def overidden_save(im, fp, filename, chunk=putchunk): | |
# save an image to disk (called by the save method) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, collections | |
class max_stack_level: | |
active = collections.Counter() | |
def __init__(self, max): | |
self.max = max | |
def __enter__(self): | |
frame = sys._getframe(1) |