Posts

Midi musical intrument controllers and synthesizers with python and pygame

Image
Musical Instrument Digital Interface (Midi), is for letting digital musical instruments talk to each other in 'real time'. It came from the early 80s, and is still used today. The main idea is that rather than sending audio data, it sends small control messages. This is great for fast real time low bandwidth communication. I'm going to show in all the different ways midi can be used with python/pygame with three separate programs, and how to set up a virtual synth (I've included instructions for Win, Mac, and Linux). Full article is available for patrons first as an "early access" before it becomes available to all in a month:  https://www.patreon.com/posts/midi-music-pygame-python-43826303 You can support my pygame development and read my development log at: https://www.patreon.com/pygame

Finger painting with multi-touch in python using pygame 2

Image
pygame 2 has support for Multi-Touch. You know, where it can track multiple fingers. I've made an app and tutorial to show off the new Multi-Touch features. Finger Painting with Multi-Touch   Full article is available for patrons first as an "early access" before it becomes available to all in a month: https://www.patreon.com/posts/finger-painting-with-multi-touch-pygame2-43786073 You can support my pygame development and read my development log at: https://www.patreon.com/pygame

post modern C tooling - draft 6

Image
Contemporary C tooling for making higher quality C, faster or more safely. DRAFT 0 - 10/11/18,  DRAFT 1 - 9/16/19, 7:19 PM, I'm still working on this, but it's already useful and I'd like some feedback - so I decided to share it early. DRAFT 2 - 10/1/19, mostly additions to static analysis tools. DRAFT 3 - 10/4/19, updates on build systems, package management, and complexity analysis.  DRAFT 4 - 10/6/19, run time dynamic verification and instrumentation, sanitizers (asan/ubsan/etc), performance tools, static analyzers. DRAFT 5 - C interpreter(s).  DRAFT 6 - 11/6/19 , mention TermDebug vim,  more windows debugging tools, C drawing for intro. In 2001 or so people started using the phrase "Modern C++". So now that it's 2019, I guess we're in the post modern era? Anyway, this isn't a post about C++ code, but some of this information applies there too. No logo, but it's used everywhere. Welcome to the post modern era. S

Draft 3 of, ^Let's write a unit test!^

Image
So, I started writing this for people who want to 'contribute' to Community projects, and also Free Libre or Open source projects. Maybe you'd like to get involved, but are unsure of where to begin? Follow along with this tutorial, and peek at the end in the "what is a git for?" section for explanations of what some of the words mean. Draft 1, 2018/07/18 - initial draft. Draft 2, 2019/11/04 - two full unit test examples, assertions, making a pull request, use python 3 unittest substring search, "good first issue" is a thing now. Started "What is a git for? Jargon" section. Draft 3, 2020/12/12 - default branch name is main. What's first? A test is first. A unit test is a piece of code which tests one thing works well in isolation from other parts of software. In this guide, I'm going to explain how to write one using the standard python unittest module, for the pygame game library. You can apply this advice to most python pr

Using PostgreSQL as a cache?

In the article on his blog Peter asks " How much faster is Redis at storing a blob of JSON compared to PostgreSQL? ". Answer: 14x slower. Seems about right. Usually Redis is about 4x faster for a simple query like that compared to using PostgreSQL as a cache in my experience. It's why so many people use Redis as a cache. But I'd suggest PostgreSQL is good enough to act as a cache for many people. Django is pretty slow at fetching from PostgreSQL compared to other python options, so this could explain part of the 14x VS 4x difference. Note that Django should be adding an index because of ForeignKey. However it's possible it isn't being used, or the table may need to analyze stats again. Also note that Django does not support prepared statements built in, and when you don't use prepared statements you do not use the PostgreSQL query cache. Prepared statements can give a 50% speedup often, because they don't have to do the query parsing and do a n

Experiments with new low latency PyPy garbage collector in a thread.

Image
TLDR; less performance spikes, faster average performance, PyPy is a good Python for games and multimedia apps on desktop systems, running GC in a thread is a good idea for GIL releasing apps. In March 2018 at the PyPy winter sprint I spent some days working on improving pygame support on PyPy. Part of this was investigating pypy frame drop . In there I found PyPy had both lower average performance in this pygame-using-CPython-API benchmark, and had spikes which caused frame drops. Remember that in latency sensitive applications performance spikes are not allowed. Note that not very much of this code is pure python (where PyPy is fastest), so it's almost a worst case benchmark for PyPy performance. Thanks to Antonio, the PyPy team and their supporters — things have much improved since then. One improvement in particular is that PyPy now allows more control of when the Garbage Collection does its work. Read more about it in the blog post " PyPy for low latency systems &q