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
| # shapes/box.nim | |
| # Axis-aligned box — slab method intersection. | |
| # params layout: [minx, miny, minz, maxx, maxy, maxz] | |
| # | |
| # Standardised shape file interface: | |
| # intersectBox*(params, ray) : HitResult | |
| # bboxBox*(params) : BBox | |
| # box*(corner1, corner2, matId): ShapeSpec | |
| import ../types |
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 std/[times] | |
| # https://en.wikipedia.org/wiki/Julian_day | |
| type | |
| JulianDay* = object | |
| julianDay*: int | |
| julianDayfraction*: 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 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
| import std/[math] | |
| #import emitters | |
| template fromTyp(typ, base: typedesc) = | |
| proc `$`*(x: typ): string {.borrow.} | |
| proc `+`*(a, b: typ): typ {.borrow.} | |
| proc `-`*(a, b: typ): typ {.borrow.} | |
| proc `*`*(a: typ, b: base): typ {.borrow.} | |
| proc `*`*(a: base, b: typ): typ {.borrow.} |
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
| # Original C++ code: | |
| # | |
| # Created by Nigel Redmon on 12/18/12. | |
| # EarLevel Engineering: earlevel.com | |
| # Copyright 2012 Nigel Redmon | |
| # | |
| # For a complete explanation of the ADSR envelope generator and code, | |
| # read the series of articles by the author, starting here: | |
| # http://www.earlevel.com/main/2013/06/01/envelope-generators/ | |
| # |
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 std/[math, random] | |
| import iterit, iterkspercussion | |
| const | |
| SampleRate {.intdefine.} = 44100 | |
| SRate* = SampleRate.float | |
| type | |
| Trigger* = object |
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 os, random, math | |
| import iterit | |
| const | |
| SampleRate {.intdefine.} = 44100 | |
| SRate* = SampleRate.float | |
| MaxKSDelay* = (SampleRate / 20.0).int #Hz delay line length: SampleRate / Frequency | |
| type | |
| Ticker* = object | |
| tick: uint |
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, random | |
| import iterit | |
| const | |
| SampleRate {.intdefine.} = 44100 | |
| SRate* = SampleRate.float | |
| MaxKSDelay* = (SampleRate / 20).int #Hz delay line length: SampleRate / Frequency | |
| proc iterKS[Tf: 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
| # https://www.musicdsp.org/en/latest/Synthesis/11-weird-synthesis.html | |
| # "Karplus-Strong-inspired comb filter effect?" | |
| # Processes incoming audio continuously, not just initial excitation | |
| import std/[math, random] | |
| import iterit | |
| import iteroscillator | |
| const | |
| SampleRate {.intdefine.} = 44100 |
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 | |
| InvRate* = 1.0 / SRate | |
NewerOlder