Skip to content

Instantly share code, notes, and snippets.

View VioletGiraffe's full-sized avatar

Violet Giraffe VioletGiraffe

View GitHub Profile
/* fix_fft.c - Fixed-point in-place Fast Fourier Transform */
/*
All data are fixed-point short integers, in which -32768
to +32768 represent -1.0 to +1.0 respectively. Integer
arithmetic is used for speed, instead of the more natural
floating-point.
For the forward FFT (time -> freq), fixed scaling is
performed to prevent arithmetic overflow, and to map a 0dB
sine/cosine wave (i.e. amplitude = 32767) to two -6dB freq
@holms
holms / gist:5005629
Last active September 16, 2024 22:52
midnight commander dark color theme
Edit mc’s ini file (either ~/.mc/ini or ~/.config/mc/ini) and look for the line [Colors]. Then, change the line base_color to this:
[Colors]
base_color=linux:normal=white,black:marked=yellow,black:input=,green:menu=black:menusel=white:menuhot=red,:menuhotsel=black,red:dfocus=white,black:dhotnormal=white,black:dhotfocus=white,black:executable=,black:directory=white,black:link=white,black:device=white,black:special=white,black:core=,black:stalelink=red,black:editnormal=white,black
@billiegoose
billiegoose / ArduinoSerialBypass.ino
Created July 19, 2013 01:37
Use your Arduino as a direct USB to serial converter! Tested on an Arduino Duemilanove. Probably 3.3V TTL but worked for communicating with my supposedly 5V TTL HerkuleX servo at 115200 baud.
/*
* Arduino Serial Bypass - use an Arduino as a dumb USB 2 Serial Converter
*
* This code makes the Arduino not interfere with pins 0 and 1
* which are connected to RX and TX on the FTDI chip. This allows
* the data coming from the FTDI USB 2 Serial chip to flow directly
* to another device. Since RX and TX are labeled from the Arduino's
* point of view, don't cross the wires, but plug the device's
* RX wire into the RX pin 0 and the TX wire into the TX pin 0.
*
@fukuroder
fukuroder / wave_play_wasapi_shared.cpp
Last active July 8, 2021 06:38
wave file player (WASAPI shared mode)
/*
* wave_play_wasapi_shared.cpp
*
* Created by fukuroda (https://github.com/fukuroder)
*/
// windows API
#include <windows.h>
#include <audioclient.h>
#include <mmdeviceapi.h>
@tuttlem
tuttlem / test.c
Created December 28, 2013 06:41
freeglut simple
#include <GL/glut.h>
void resize(int width, int height) {
// avoid div-by-zero
if (height == 0) {
height = 1;
}
// calculate the aspect ratio
@projectgus
projectgus / linpack_bench.ino
Last active March 31, 2021 19:49
Linpack Floating Point benchmark that runs as an Arduino sketch. (Yes, I know...) I wanted to generically measure Arduino Floating Point performance, this seemed like a reasonable(ish) way to do it. Runs with N=10, single precision, but produces sane looking results & residual. (89 Linpack kFLOPS on a Freetronics Eleven, ie Arduino Uno compatibl…
# include <stdlib.h>
# include <stdio.h>
# include <math.h>
int do_benchmark ( void );
double cpu_time ( void );
void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy );
double ddot ( int n, double dx[], int incx, double dy[], int incy );
int dgefa ( double a[], int lda, int n, int ipvt[] );
void dgesl ( double a[], int lda, int n, int ipvt[], double b[], int job );
@rakesh-gopal
rakesh-gopal / listusb.c
Created January 7, 2015 13:02
List the USB devices connected
#ifdef __cplusplus
extern "C" {
#endif
#include <windows.h>
#include <tchar.h>
#include <setupapi.h>
#include <initguid.h>
@9prady9
9prady9 / cpuinfo.cpp
Created September 15, 2015 18:32
Sample code to extract cpu information using CPUID instruction
#include <algorithm>
#include <iostream>
#include <string>
#ifdef _WIN32
#include <limits.h>
#include <intrin.h>
typedef unsigned __int32 uint32_t;
#else
#include <stdint.h>
@lukicdarkoo
lukicdarkoo / FFT.c
Last active July 21, 2024 20:18
Basic implementation of Cooley-Tukey FFT algorithm in C++
#include "FFT.h"
void fft(int *x_in,
std::complex<double> *x_out,
int N) {
// Make copy of array and apply window
for (int i = 0; i < N; i++) {
x_out[i] = std::complex<double>(x_in[i], 0);
x_out[i] *= 1; // Window