I am Magnus Lidström. I write code. Lots of it. Some of it ends up at soniccharge.com. Some of it ends up here. Most of it ends up in ~/Trash.

PikaScript

October 16, 2014comments
PikaScript is a small interpreting C-style scripting language implemented with modern C++ programming techniques (C++03). The source code for PikaScript is very compact. It's core is around 1000 lines of C++ plus an additional header file of 500 lines including doxygen comments. The optional standard library (written in PikaScript), providing utilities for strings, math, algorithms and objects (including a mark and swipe garbage collector) is around 300 lines of source code Despite it's small size the language is powerful enough to support sophisticated concepts such as higher order functions

Symbiosis

June 01, 2014comments
Symbiosis is a developer tool for adapting Mac OS X VST plug-ins to the Audio Unit (AU) standard. It essentially consists of a single C++ file that you can compile into your VST project to make the plug-in compatible with the Audio Unit protocol. Optionally, you may choose to use a pre-built "wrapper plug-in" for adapting your existing VST plug-in to the AU standard without even having to recompile any source code. How Does It Work? Although the VST and Audio Unit SDKs differ greatly in implementation, the purpose and functions of the two standards are virtually identical. Both protocols p

DOS-Like Wildcard Matching

June 01, 2014comments
Here is the tiniest recursive algorithm I could come up with to perform string matching with DOS-like wildcard support. Let me know if you find any simpler implementation. bool wildcardMatch(const char* p, const char* s) { while (*p != '\0') { if (*p == '*') { if (wildcardMatch(p + 1, s)) { return true; } } else if (*p == '?' || tolower(*p) == tolower(*s)) { ++p; } else { return false; } ++s; } return (*s == '\0'); } p is pattern to match (? matches any character, * matches a

Priyome Chess Computer

June 01, 2014comments
Priyome is a complete chess computer in single plain C source code file. It was written to be easily ported to other even more primitive languages. E.g. it uses only integers and does not require structures. The AI is implemented using standard chess computer techniques such as alpha beta pruning search with iterative deepening, quiescence optimization (only checking for captures beyond a specific depth) and a memory efficient solution for transposition table lookup. A B C D E F G H +-----------------+ 8 | r n b q k b n r | 8 7 | p p p p p p p p | 7 6 | . . . . | 6 5 | . . .