Skip to content

Instantly share code, notes, and snippets.

View Jacajack's full-sized avatar
🦄

Jacek Wieczorek Jacajack

🦄
View GitHub Profile
@Jacajack
Jacajack / fmsynth2.c
Created January 9, 2019 00:21
FM synthesizer for aplay (rev. 2)
#include <stdio.h>
#include <math.h>
#include <time.h>
#define SAMPLE_RATE 8000.0
// Sample output
void outsample( float v )
{
// Clamp
@Jacajack
Jacajack / apdft.c
Created January 9, 2019 00:19
A utility to compute DFT of aplay data stream (WIP)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <complex.h>
#include <argp.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
@Jacajack
Jacajack / repeat.c
Last active December 20, 2018 00:11
Utility to repeat file contents
/*
A crude utility to repeat file contents n times.
As far as I know, there's no UNIX tool to that yet.
2018, Jacek Wieczorek
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@Jacajack
Jacajack / mkmif.c
Created December 4, 2018 22:48
(WIP) Utility to create *.mif (Memory Initialization) files for Quartus
/*
Utility to create *.mif (Memory Initialization File) for Quartus.
Usage:
cat file.bin | mkmif <WIDTH> <COUNT> > out.mif
by Jacek Wieczorek, 2018
*/
#include <stdio.h>
#include <stdlib.h>
@Jacajack
Jacajack / fmsynth.c
Last active December 1, 2018 01:14
🎶 FM synthesis example for use with aplay - simple electric piano sound 🎶
#include <stdio.h>
#include <math.h>
#include <time.h>
#define SAMPLE_RATE 8000.0
// Sample output
void outsample( float v )
{
// Clamp
@Jacajack
Jacajack / dcf.c
Last active November 18, 2018 20:23
DCF77 frame parser (optimized for size - 344b)
#include "dcf.h"
#include <time.h>
#include <inttypes.h>
// 8-bit BCD decoder
// Requires n > 0
static uint8_t dcf_decode_bcd( uint8_t *frame, uint8_t start, uint8_t n )
{
uint8_t val = 0;
uint8_t b = 1;
@Jacajack
Jacajack / dcf.c
Last active October 27, 2018 00:29
DCF77 frame parser
#include "dcf.h"
#include <time.h>
#include <inttypes.h>
// 8-bit BCD decoder
static inline int dcf_decode_bcd( uint8_t bits )
{
return ( bits & 0x0f ) + 10 * ( ( bits >> 4 ) & 0x0f );
}
@Jacajack
Jacajack / spotify-skipper.py
Last active September 30, 2018 17:36
Skips Spotify tracks played less than 2h ago
#!/usr/bin/env python3
import gi
gi.require_version( "Playerctl", "1.0" )
from gi.repository import Playerctl, GLib
import time, sys
player = Playerctl.Player()
@Jacajack
Jacajack / cuos.cpp
Created July 8, 2018 10:33
Commonly Used OpenGL Stuff (CUOS)
#include "cuos.hpp"
#include <libpng16/png.h>
#include <GL/glew.h>
#include <dirent.h>
#ifdef __cplusplus
#include <cstdio>
#include <cstdlib>
#include <vector>
@Jacajack
Jacajack / dungen.lua
Created March 8, 2018 21:03
Lua Love2D dungeon generator
function mkroom(x, y, w, h, id)
local room = {
x = x,
y = y,
w = w,
h = h,
adj = {},
id = id or 0
};