Skip to content

Instantly share code, notes, and snippets.

using ODE, Plots
function lorenz(t, r)
# Extract the coordinates from the r vector
(x, y, z) = r
# The Lorenz equations
dx_dt = σ*(y - x)
dy_dt = x*(ρ - z) - y
dz_dt = x*y - β*z
module Plot
gnuplot = Process.new(command: "gnuplot", input: Process::Redirect::Pipe, output: Process::Redirect::Inherit)
input = gnuplot.input
# file out
input << "set terminal png\n"
input << "set output \'sin.png\'\n"
# plot
import("stdfaust.lib");
carfreq = 880;
modfreq = carfreq * freqratio;
modgain = carfreq * gainratio;
freqratio = vslider("freq ratio", 1, 0, 5, 0.05);
gainratio = vslider("gain ratio", 1, 0, 1, 0.01);
modfeed = vslider("modulator feedback", 0, 0, 1, 0.01) * modfreq;
# Julia で元号のパターン列挙
# 学年別漢字配当表(全1026字)を利用
# Wikipedia https://ja.wikipedia.org/wiki/%E5%AD%A6%E5%B9%B4%E5%88%A5%E6%BC%A2%E5%AD%97%E9%85%8D%E5%BD%93%E8%A1%A8 より
k=collect("一右雨円王音下火花貝学気九休玉金空月犬見五口校左三山子四糸字耳七車手十出女小上森人水正生青夕石赤千川先早草足村大男竹中虫町天田土二日入年白八百文木本名目立力林六引羽雲園遠何科夏家歌画回会海絵外角楽活間丸岩顔汽記帰弓牛魚京強教近兄形計元言原戸古午後語工公広交光考行高黄合谷国黒今才細作算止市矢姉思紙寺自時室社弱首秋週春書少場色食心新親図数西声星晴切雪船線前組走多太体台地池知茶昼長鳥朝直通弟店点電刀冬当東答頭同道読内南肉馬売買麦半番父風分聞米歩母方北毎妹万明鳴毛門夜野友用曜来里理話悪安暗医委意育員院飲運泳駅央横屋温化荷界開階寒感漢館岸起期客究急級宮球去橋業曲局銀区苦具君係軽血決研県庫湖向幸港号根祭皿仕死使始指歯詩次事持式実写者主守取酒受州拾終習集住重宿所暑助昭消商章勝乗植申身神真深進世整昔全相送想息速族他打対待代第題炭短談着注柱丁帳調追定庭笛鉄転都度投豆島湯登等動童農波配倍箱畑発反坂板皮悲美鼻筆氷表秒病品負部服福物平返勉放味命面問役薬由油有遊予羊洋葉陽様落流旅両緑礼列練路和愛案以衣位茨印英栄媛塩岡億加果貨課芽賀改械害街各覚潟完官管関観願岐希季旗器機議求泣給挙漁共協鏡競極熊訓軍郡群径景芸欠結建健験固功好香候康佐差菜最埼材崎昨札刷察参産散残氏司試児治滋辞鹿失借種周祝順初松笑唱焼照城縄臣信井成省清静席積折節説浅戦選然争倉巣束側続卒孫帯隊達単置仲沖兆低底的典伝徒努灯働特徳栃奈梨熱念敗梅博阪飯飛必票標不夫付府阜富副兵別辺変便包法望牧末満未民無約勇要養浴利陸良料量輪類令冷例連老労録圧囲移因永営衛易益液演応往桜可仮価河過快解格確額刊幹慣眼紀基寄規喜技義逆久旧救居許境均禁句型経潔件険検限現減故個護効厚耕航鉱構興講告混査再災妻採際在財罪殺雑酸賛士支史志枝師資飼示似識質舎謝授修述術準序招証象賞条状常情織職制性政勢精製税責績接設絶祖素総造像増則測属率損貸態団断築貯張停提程適統堂銅導得毒独任燃能破犯判版比肥非費備評貧布婦武復複仏粉編弁保墓報豊防貿暴脈務夢迷綿輸余容略留領歴胃異遺域宇映延沿恩我灰拡革閣割株干巻
@astellon
astellon / seq.cr
Last active April 1, 2019 11:13
simple sin wave synthesizer + sequencer in Crystal
require "socket"
require "osc-crystal"
lib LibC
fun nanosleep(req : Timespec*, rem : Timespec*) : Int32
end
# helper
def note_to_heltz(note : Int)
(440*Math.exp2((note - 69.0)/12.0)).to_f32
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# setting process
using Distributed, DistributedArrays
NUM_GPUS = 4
addprocs(NUM_GPUS)
@everywhere using Distributed, DistributedArrays
# using in all process
@everywhere using CUDAnative, CuArrays
# form: https://git.archlinux.org/svntogit/community.git/tree/trunk/Make.user?h=packages/julia
override prefix = /usr
override sysconfdir = /etc
override MARCH = x86-64
override JULIA_BUILD_MODE = release
override USE_BLAS64 = 0
override USE_SYSTEM_DSFMT = 0
override USE_SYSTEM_FFTW = 1
override USE_SYSTEM_GMP = 1
#include "envelope.h"
#include "common.h"
namespace synth {
/*==============================================================================
Envelope class
==============================================================================*/
Envelope::Envelope()
: Module(env_num_inputs, env_num_outputs, env_num_params) {
state_ = EnvelopeState::killed;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.