Skip to content

Instantly share code, notes, and snippets.

View agrathwohl's full-sized avatar
👨‍🌾

Andrew Grathwohl agrathwohl

👨‍🌾
View GitHub Profile
@ncblair
ncblair / prng_test.c
Last active June 15, 2023 15:50
Fast Real-Time Safe Pseudorandom Number Generator + Benchmark
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
// xorshift code taken from wikipedia
struct xorshift32_state {
uint32_t a;
};
@amishshah
amishshah / ogg-containers.md
Last active May 11, 2024 04:38
A guide to the Ogg container format for demuxing opus audio

You take a stream/buffer of binary data. The start of your data is a "Page", which has a header followed by data.

Header

You need to read the following data from the header (see https://xiph.org/ogg/doc/framing.html for more detail)

  • capture_pattern - bytes 0 to 3, must read OggS
  • stream_structure_version - byte 4, must be 0
  • header_type_flag - byte 5, a bitflag that tells you metadata about the page (is it a new packet? is a packet continued here? is it the first/last page of the stream?)
  • absolute granule position - bytes 6 to 13, not needed unless you want seeking
  • stream serial number - bytes 14 to 17, a serial number given to each stream contained in the Ogg file. This is important for playing Ogg files that contain other streams, such as video or cover art. You need to identify and only bother parsing the Opus stream.
@martinruenz
martinruenz / ffmpeg-snippets.md
Last active March 7, 2025 22:28
ffmpeg snippets / cheatsheet
@dpboard
dpboard / 1-SOXAGC.md
Last active November 16, 2023 08:47
Building an 'Automatic Gain Control' with SoX

Building an 'Automatic Gain Control' with SoX

SoX is a great tool for converting and processing audio. As an engineer working at a radio station I find it especially useful for processing audio files so the volume is even and smooth throughout. A recent use case was preparing news bulletins recorded by a non-technical journalist so they sounded clear and loud for an Amazon Alexa skill.

What is an AGC?

Automatic Gain Control (AGC) is an audio processing technique that is designed to smooth out volume differences between different parts of an audio programme. The majority of radio stations will have a device at their transmitter (for example, an Optimod) that does just that. Parts of the broadcast that are two quiet are boosted and parts that are too loud are atenuated.

For those familiar with audio [compressors

@chrisguttandin
chrisguttandin / post.md
Created May 31, 2017 16:27
What else can we do with the Web Audio API?

What else can we do with the Web Audio API?

Of course the Web Audio API is meant for synthesizing and processing audio data. It is tailored for that use case. But at least in our digital world audio data is just a series of numbers, which are typically somewhere between +1 and -1. So why can't we use the Web Audio API for general computations?

Almost a year ago I had the pleasure to give a talk at the Web Audio Conference in Atlanta. The conference featured a lot of great talks, which I really appreciated as an attendee. However, as a speaker it was tough to reduce my own talk until it was short enough to fit into the schedule. I had the feeling that I had to rush through my slides. Since then I planned to write down my findings in a more detailed way, but I never got around to it. Luckily I was asked to repeat my talk at our local Web Audio Meetup here in

var hypercore = require('hypercore')
var ram = require('random-access-memory')
var feed = hypercore(ram)
feed.append('hello world')
@j-keck
j-keck / nixos-as-bhyve-guest.md
Last active July 19, 2025 01:09
nixos as bhyve guest

create a vm

root@main:~ # vm create -t debian -s 100G nixos
root@main:~ # vm iso /stuff/downloads/nixos-graphical-18.03.132192.ce0d9d638de-x86_64-linux.iso 
root@main:~ # vm -f install nixos nixos-graphical-18.03.132192.ce0d9d638de-x86_64-linux.iso

boot the image

determine the 'init' executable path from '(cd0)/isolinux/isolinux.cfg'. look for a line which start's with: 'APPEND init=/nix/store/.....'

@sagivo
sagivo / gist:3a4b2f2c7ac6e1b5267c2f1f59ac6c6b
Last active January 16, 2026 13:02
webRTC stun / turn server list
to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice
stun:
stun.l.google.com:19302,
stun1.l.google.com:19302,
stun2.l.google.com:19302,
stun3.l.google.com:19302,
stun4.l.google.com:19302,
stun.ekiga.net,
stun.ideasip.com,
@slhck
slhck / shuffle-playlist.py
Created October 24, 2016 10:44
Shuffle playlists for SRC-HRC randomization without repeating SRCs
import random
from pprint import pprint
sources = 2
conditions = 2
subjects = 3
playlists = {}
for subject in range(1, subjects + 1):
@mondain
mondain / public-stun-list.txt
Last active January 18, 2026 12:15
Public STUN server list
23.21.150.121:3478
iphone-stun.strato-iphone.de:3478
numb.viagenie.ca:3478
s1.taraba.net:3478
s2.taraba.net:3478
stun.12connect.com:3478
stun.12voip.com:3478
stun.1und1.de:3478
stun.2talk.co.nz:3478
stun.2talk.com:3478