Comments (9)
Hi! Thanks for using a fastmath
! Yeah, it's quite big bag of functions :)
I don't see an easy way to make this working as you described. Currently effect keeps only internal state not the configuration and allows to reset state.
The true is I created that for an image manipulation techniques (sonification for glitch art) rather than real DSP :)
If you wish we can try to refactor it and to enable more vst or ladspa way ie: input/output channels and state management. I believe it's doable.
from fastmath.
(:
I don't see an easy way to make this working as you described.
No worries! I saw the same, thank you for the confirmation.
The true is I created that for an image manipulation techniques (sonification for glitch art) rather than real DSP :)
Sounds fun! That makes sense.
If you wish we can try to refactor it and to enable more vst or ladspa way ie: input/output channels and state management. I believe it's doable.
I also believe it's doable, though it might require changes that touch a lot of the code in signal.clj
.
This is not critical for me at the moment. I have other directions that I am going to take my audio project in first. I am grateful to you for fastmath and this signal code in particular. I am learning a lot by reading and using it.
Take care!
from fastmath.
Since you can build your own effects you can do the following:
(defn sweep-alpha
[^double rate]
(let [tinterval (/ rate)
t (atom (long -1))]
(fn []
(let [cutoff (m/norm (m/cos (* 100.0 tinterval (swap! t clojure.core/inc))) 1.0 -1.0 500.0 5000.0)
tau (/ (* cutoff m/TWO_PI))]
(/ tinterval (+ tau tinterval))))))
(repeatedly 10 (sweep-alpha 44100.0))
;; => (0.06650056607164513
;; 0.06650128426969248
;; 0.06650343885351115
;; 0.06650702979213088
;; 0.06651205703393591
;; 0.06651852050666654
;; 0.06652642011742149
;; 0.06653575575266107
;; 0.06654652727821102
;; 0.06655873453926664)
(defmethod effect :simple-lowpass-sweep
([m] (effect m {}))
([m {:keys [rate]
:or {rate 44100.0}}]
(let [next-alpha (sweep-alpha rate)]
(effect-node m (fn
([^double sample ^double prev]
(let [alpha (next-alpha)
s1 (* sample alpha)
s2 (- prev (* prev alpha))
nprev (+ s1 s2)]
(SampleAndState. nprev nprev)))
([] 0.0))))))
(apply-effects [0.1 0.2 0.3 0.4 0.5] (effect :simple-lowpass-sweep)) ;; dynamic cutoff
;; => (0.006650056607164514 0.019508076156260417 0.03816175366250626 0.06222654069160635 0.09134375398506965)
(apply-effects [0.1 0.2 0.3 0.4 0.5] (effect :simple-lowpass {:cutoff 500})) ;; static cutoff
;; => (0.006650056607164514 0.019507937292708617 0.03816081824134688 0.06222332865519821 0.09133572511258808)
cutoff
is generated from sine and (in above example) bounces between 500.0 to 5000.0Hz 100 times per second.
from fastmath.
Ha! That's great.
audio output example: square-lowpass-sweep.wav.gz 😄
I am off and running.
One thing I encountered is that fastmath.signal/effect-node
is a private function. This means that to define my effect in my own file I ended up writing this (note the #'signal/effect-node
bit):
(defmethod signal/effect :simple-lowpass-sweep
([m] (signal/effect m {}))
([m {:keys [rate]
:or {rate 44100.0}}]
(let [alpha-fn (produce-alpha-fn rate)]
(#'signal/effect-node
m (fn
([^double sample ^double prev]
(let [alpha (alpha-fn)
s1 (* sample alpha)
s2 (- prev (* prev alpha))
nprev (+ s1 s2)]
(SampleAndState. nprev nprev)))
([] 0.0))))))
Maybe effect-node
should be public? I don't know.
from fastmath.
Oh, that's cool! Glad it works. Actually this filter is really simple with quite flat slope. Anyway, it works :)
I can add state variable filter, which I have implemented elsewhere (https://github.com/genmeblog/soundsynth)
I will correct the visibility of crucial functions and publish a snapshot soon.
from fastmath.
Yup! A multipole filter (steeper slope) and/or one with resonance would be appreciated.
It appears we have overlapping interests.
from fastmath.
Yeah :) However writing the software synthesizer was kind of a study to help with my son's project.
Eventually I've made effect-node
as a public function. Sorry for delay.
No SVF yet. I have to figure out how to make parameters in terms of frequencies.
from fastmath.
Perhaps you son and I are the ones with overlapping interests then, ha!
Thanks for your thoughts here. I have finished the project I was working on in this area for now, but when I come back to it I will integrate fastmath deeper.
Take care.
from fastmath.
Closing, since it's nothing to do with this.
from fastmath.
Related Issues (19)
- cosine distance gives values outside a range
- result of clustering is inconsistent regarding "sizes" HOT 3
- Should abs be added to vars-to-exclude? HOT 2
- Fastmath always loads MKL binaries HOT 10
- Error when creating a list of vectors HOT 6
- Apache Commons IntervalUtils support HOT 2
- add ZAGA distribution HOT 8
- ClojureScript support HOT 4
- unable to use the v1.3.0-SNAPSHOT due to `[clj-boost "0.0.4"]` HOT 10
- kde integration hangs on narrow distributions
- consider adding soft-cosine distance HOT 4
- chi-squred test ? HOT 10
- `RombergIntegrator` is not thread-safe HOT 3
- Rewrite Gaussian Processes to use Commons Math libs
- Is vector4 intended to be = to clojure persistent vector? HOT 3
- Question about license HOT 3
- How to call frandom with 2-3 arguments wihout getting ArityException? HOT 2
- Using the triangle grid - possible bug? HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastmath.