Skip to content

Instantly share code, notes, and snippets.

View AndreasMattsson's full-sized avatar

Andreas Mattsson AndreasMattsson

View GitHub Profile
@Alexis-D
Alexis-D / consumer.c
Created February 11, 2012 15:51
Producer / Consumer / Conditions variables / pthreads
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define BUF_SIZE 5
// the buffer works like a stack for
// the sake of simplicity, if needed
// we may implement a queue
@jl2
jl2 / readaudio.c
Created January 26, 2012 06:33
Use ffmpeg's libavcodec and libavformat to decode an audio file into an output buffer.
/*
readmp3.c
Copyright (c) 2012, Jeremiah LaRocco [email protected]
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@kbarros
kbarros / FFTW3Library.java
Created December 4, 2011 00:30
Automatically generated Java FFTW wrapper
//
// Java wrapper for FFTW3 using Java Native Access (JNA)
// Author: Kipton Barros
//
package fftw3;
// This file was automatically generated with JNAerator the command:
// java -jar jnaerator-0.9.7.jar -library FFTW3 /usr/local/include/fftw3.h -o . -v -noJar -noComp -noPrimitiveArrays -noMangling -structsInLibrary -runtime JNA -sizeAsLong -Dfftw_complex=double -Dfftwf_complex=float
// I made some small manual modifications, essentially to remove unneeded JNAerator dependencies
@granoeste
granoeste / gist:870440
Created March 15, 2011 07:57
[Android] Modify contrast using a ColorMatrix
ColorMatrixColorFilter setContrast(float contrast) {
float scale = contrast + 1.f;
float translate = (-.5f * scale + .5f) * 255.f;
float[] array = new float[] {
scale, 0, 0, 0, translate,
0, scale, 0, 0, translate,
0, 0, scale, 0, translate,
0, 0, 0, 1, 0};
ColorMatrix matrix = new ColorMatrix(array);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
@dweekly
dweekly / mp3acm.c
Created October 19, 2010 00:45
Windows Snippet To Use Built-in ACM MP3 Decoder
#include <windows.h>
#include <stdio.h>
#include <assert.h>
#include <mmreg.h>
#include <msacm.h>
#define MP3_BLOCK_SIZE 522
#define SOURCE_MP3 "C:\\audiograbber\\At The Club Last Night\\At_The_Club_Last_Night_-_Haven't_You_Heard.mp3"
#define OUTPUT_PCM_FILE "c:\\dump.pcm"