This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC=clang | |
LIB= | |
INCLUDES=-Iinclude/ | |
FLAGS=-Wall -Werror -pedantic | |
SOURCES=$(wildcard src/*.c) | |
#OBJECTS=$(SOURCES:.c=.o) # This way works too | |
OBJECTS=$(patsubst %.c, %.o, $(SOURCES)) | |
EXE=executable_name.out | |
all: $(EXE) clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.signal as sig | |
from scipy.io.wavfile import write as write | |
from matplotlib import pyplot as plt | |
SR = 48000 | |
SECS = 10.0 | |
NSAMPS = int(SECS * SR) | |
NTAPS = 61 | |
INT_MAX = 2**15-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Two examples to remember how decorators should be written. | |
# The first has no arguments in the decorator | |
# The second shows how to pass arguments like @dec(...) | |
#no args to decorator tag. ie: | |
def decorator_name(func_getting_decorated): | |
def func_being_returned(args_to_func_getting_decorated): | |
#decoration step here | |
print "decoration occured" | |
#make sure the returned decorator does whatever |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "portmidi.h" | |
int main(int argc, const char * argv[]) { | |
PortMidiStream *stream; | |
PmEvent events[512]; | |
int i, num; | |
Pm_Initialize(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, Response | |
app = Flask(__name__) | |
@app.route("/wav") | |
def streamwav(): | |
def generate(): | |
with open("signals/song.wav", "rb") as fwav: | |
data = fwav.read(1024) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Sexy bash prompt by twolfson | |
# https://github.com/twolfson/sexy-bash-prompt | |
# Forked from gf3, https://gist.github.com/gf3/306785 | |
# | |
# Updated color scheme by Matt Hosack | |
# If we are on a colored terminal | |
if tput setaf 1 &> /dev/null; then | |
# Reset the shell from our `if` check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from _pymidi import ffi # , lib | |
'''Only initialize Portmidi once''' | |
SINGLETON = None | |
'''Detect OS and use correct file extension for shared library''' | |
if sys.platform == 'darwin': | |
ext = 'dylib' | |
elif sys.platform.startswith('linux'): | |
ext = 'so' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
from cffi import FFI | |
__all__ = ('ffi',) | |
p = subprocess.Popen(['clang -E include/portmidi.h'], | |
shell=True, stdout=subprocess.PIPE) | |
code = p.communicate()[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cffi import FFI | |
ffi = FFI() | |
with open('supercool.h', 'r') as f: | |
ffi.cdef(f.read()) | |
ffi.set_source('supercool', None) | |
ffi.compile() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cffi import FFI | |
ffi = FFI() | |
ffi.cdef('...super cool header file contents...') | |
lib = ffi.dlopen('libsupercool.dylib') | |
#call a function from libsupercool | |
lib.MyCoolFunction(42) |