Skip to content

Instantly share code, notes, and snippets.

View andreasjansson's full-sized avatar

Andreas Jansson andreasjansson

View GitHub Profile
function(x) {
k.indices <- grep('k', x)
M.indices <- grep('M', x)
G.indices <- grep('G', x)
nums <- as.numeric(gsub("[kMG]", "", x))
nums[k.indices] <- nums[k.indices] * 1000
nums[M.indices] <- nums[M.indices] * 1000000
nums[G.indices] <- nums[G.indices] * 1000000000
nums
}
$ soxi "Herbie Hancock/Thrust/01 Palm Grease.mp3"
Input File : 'Herbie Hancock/Thrust/01 Palm Grease.mp3'
Channels : 2
Sample Rate : 44100
Precision : 16-bit
Duration : 00:10:37.34 = 28106474 samples = 47800.1 CDDA sectors
File Size : 15.5M
Bit Rate : 195k
Sample Encoding: MPEG audio (layer I, II or III)
$ sox "Herbie Hancock/Thrust/01 Palm Grease.mp3" -n stats
Overall Left Right
DC offset -0.000033 -0.000033 0.000002
Min level -1.000000 -1.000000 -1.000000
Max level 1.000000 1.000000 1.000000
Pk lev dB 0.00 0.00 0.00
RMS lev dB -16.50 -16.64 -16.37
RMS Pk dB -10.17 -10.40 -10.17
RMS Tr dB -inf -inf -inf
Crest factor - 6.79 6.59
## zuse_z3
## Copyright (C) 2011 Andreas Jansson <[email protected]>
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or (at
## your option) any later version.
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
@andreasjansson
andreasjansson / gist:1418093
Created December 1, 2011 16:44
PHP callPrivate, callPrivateStatic
function callPrivate($object, $methodName /*, $arg1, $arg2, ... */)
{
if(!is_object($object))
throw new Exception('$object is not an object');
if(!method_exists($object, $methodName))
throw new Exception("\$object has no method $method");
$args = array_slice(func_get_args(), 2);
$method = new ReflectionMethod(get_class($object), $methodName);
@andreasjansson
andreasjansson / private.php
Created December 1, 2011 16:45
Call private and private static functions
<?php
function callPrivate($object, $methodName /*, $arg1, $arg2, ... */)
{
if(!is_object($object))
throw new Exception('$object is not an object');
if(!method_exists($object, $methodName))
throw new Exception("\$object has no method $method");
@andreasjansson
andreasjansson / wav_header.c
Created December 3, 2011 21:17
Infinite wav header
char header[] = {
0x52, 0x49, 0x46, 0x46, 0x24, 0x40, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6d, 0x74, 0x20,
0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00,
0x04, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0xff, 0xff, 0xff, 0xff
};
midi.set.tempo(105)
bs <- 0
as <- c(1, 5, 9, 13, 17)
us <- c(1, 9)
r <- function(x) {
x + rep((0:41) * 21, each = length(x))
}
library(rmidi)
library(magic)
midi.set.tempo(140)
ppq = midi.get.ppq()
an <- c(12, 0, 12, 11, 0,
11, 0, 11, 5, 0,
5, 0, 5, 8, 0,
8, 0, 8, 7, 0,
library(rmidi)
midi.set.tempo(105)
bs <- 0
as <- c(1, 5, 9, 13, 17)
us <- c(1, 9)
r <- function(x) {
x + rep((0:41) * 21, each = length(x))