Skip to content

Instantly share code, notes, and snippets.

View jarmitage's full-sized avatar

Jack Armitage jarmitage

View GitHub Profile
@jarmitage
jarmitage / lava_new_version.py
Created June 15, 2024 14:37
Taichi Python version of "Lava New Version" by MelisaHot on Shadertoy https://www.shadertoy.com/view/ssKBzm
"""
"Lava New Version" by MelisaHot on Shadertoy
https://www.shadertoy.com/view/ssKBzm
"""
import taichi as ti
ti.init(arch=ti.vulkan)
@ti.func
@jarmitage
jarmitage / sardine_signalflow.py
Last active June 20, 2024 15:56
Sardine x SignalFlow example
from sardine_core.run import *
import os
import signalflow as sf
graph = sf.AudioGraph()
audio_path = "/signalflow/examples/audio/stereo-count.wav"
buf = sf.Buffer(audio_path)
player = sf.BufferPlayer(buf, loop=True)
player.play()
@jarmitage
jarmitage / sinebank.py
Created February 17, 2024 21:56
tolvera signalflow sketch
import numpy as np
from tolvera import Tolvera, run
from tolvera.osc.update import Updater
from tolvera.utils import map_range
from signalflow import *
class Sine(Patch):
def __init__(self, freq=880, gain=1.0, pan=0.0):
super().__init__()
freq = self.add_input("freq", freq)
@jarmitage
jarmitage / IntechGrid.svg
Created September 12, 2023 14:22
Intech Studio Grid SVG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jarmitage
jarmitage / cirklon_json_to_tidal.py
Last active September 5, 2023 15:45
Cirklon JSON MIDI mapping file to Tidal MIDI CC mapping
import json
import argparse
def load_json(name):
with open(name) as f:
data = json.load(f)
return data
def make_tidal_map(cc_dict, prefix):
tidal_map = []
@jarmitage
jarmitage / taichi_cv_videocapture.py
Created May 8, 2023 22:08
Taichi OpenCV VideoCapture Webcam GGUI Window
import taichi as ti
import cv2 as cv
cap = cv.VideoCapture(0)
if not cap.isOpened():
print("Cannot open camera")
exit()
ti.init(arch=ti.vulkan)
x,y = 1920,1080
@jarmitage
jarmitage / taichi_audio.py
Last active May 3, 2024 12:06
Using Python Taichi to render audio on the GPU and output via Sound Device
from iipyper import Audio, run
import sounddevice as sd
import taichi as ti
from math import pi
import sys
@ti.kernel
def generate_data(outdata: ti.ext_arr(),
frames: ti.i32,
start_idx: ti.template(),
fs: ti.f32):
@jarmitage
jarmitage / taichi_polygon_func.py
Last active March 25, 2023 13:10
Taichi Python function to draw a polygon (excerpt functions from a class)
'''
Original: http://www.dgp.toronto.edu/~mac/e-stuff/point_in_polygon.py
'''
@ti.func
def polygon(self, x: ti.template(), y: ti.template(), rgba: vec4):
x_min, x_max = x.min(), x.max()
y_min, y_max = y.min(), y.max()
l = len(x)
for i, j in ti.ndrange(x_max-x_min, y_max-y_min):
p = [x_min+i, y_min+j]
import taichi as ti
ti.init()
n = 16
x = ti.field(ti.i32)
dyn = ti.root.dynamic(ti.i, n).place(x)
@ti.kernel
def add_data():
for i in range(10):
x.append(i)
print(x.length(), x[i]) # will print i
@jarmitage
jarmitage / taichi_sparse_particle_field.py
Created March 16, 2023 10:08
Sparse particle field in Taichi using Pointers
import taichi as ti
ti.init(arch=ti.cuda) # not supported on vulkan
@ti.dataclass
class Particle:
position: ti.math.vec2
velocity: ti.math.vec2
@ti.data_oriented