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 math, sugar | |
import iterit | |
const | |
SampleRate {.intdefine.} = 44100 | |
SRate* = SampleRate.float32 | |
proc linOsc*[Tf, Tp: float or iterator:float]( |
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 math | |
const | |
SampleRate {.intdefine.} = 44100 | |
SRate* = SampleRate.float | |
LutSize = 256 # Quarter sine wave | |
Lut = static: | |
var arr: array[LutSize, float] | |
for i in 0..<LutSize: | |
let angle = (i.float / LutSize.float) * (PI / 2.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
Modal synthesis in Nim with a pool for modes, so one excite fast and they still properly decay. Cheesy bell, gong & mallet modes. |
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
# FFT Stockham | |
# http://wwwa.pikara.ne.jp/okojisan/otfft-en/optimization1.html | |
# original source of scalar Nim version by "Amb" : | |
# https://gist.github.com/amb/4f70bcbea897024452d683b40d18be1f | |
# Timings | |
# === Scalar float64 === | |
# FFT/IFFT test on 4096 points |
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 strutils | |
import math | |
import complex | |
const | |
SampleRate = 8000.0 # 8kHz | |
TargetFrequency = 941.0 # 941 Hz | |
FFTSize = 205 | |
N = FFTSize # Block size |
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
compile | |
> nim c -d:release -d:danger renderer.nim | |
to render image from prompt: | |
> renderer sincos.nims | |
Render a function to a grey scale image, using nimscripter https://github.com/beef331/nimscripter for realtime scriptable applications. |
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 vmath | |
import math | |
type | |
ColinearSegmentError* = object of Defect | |
Input2D = object | |
dir: Vec2 # tangent vector at first input knot | |
knot: seq[Vec2] | |
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
/* | |
Database schema SQLite for a table that keeps its own history and | |
never deletes data. | |
On update, historic data is kept under a new id and references the original | |
creation id. The end of life timestamp (ts_eol) is set so a time line can be | |
built. The new data is used to update the data under the existing id. | |
On delete, nothing is deleted. Only the ts_eol timestamp is set to current. | |
*/ |
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
# Compile: | |
# nim c --gc:orc --experimental:strictFuncs -d:ssl -d:nimStressOrc --import:std/httpcore sseClient.nim | |
# based on Harpoon https://github.com/juancarlospaco/harpoon | |
import std/[net, macros, strutils, times, json, httpcore, uri] | |
type | |
SSE = object | |
comment: string |
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
# Goertzel oscillator bank (scalar): | |
# (seconds: 208, nanosecond: 253406100) | |
# duration: 4440s samplerate: 44100 samples: 195804000 | |
# 0.0000010635809590202449 seconds per sample @ 1000 oscillators | |
# Goertzel AVX oscillator bank: | |
# (seconds: 26, nanosecond: 403254200) | |
# duration: 4440s samplerate: 44100 samples: 195804000 | |
# 0.00000013484532593818306 seconds per sample @ 1000 oscillators | |
# Speedup: 7.887414351371886x |
NewerOlder