Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*!
- *
- * welcome to wavepot
- * ------------------
- *
- * this is a live editor. you create a function named `dsp`
- * that accepts the parameter `t`, the coefficient of time,
- * which you use to generate a single sample (range -1..1)
- *
- * below is the smallest example possible, a simple sine wave
- * generator. check out more complex demos on the right ---->
- *
- * have fun!
- *
- */
- tau = Math.PI*2
- function beat(t){
- t = t%1;
- if(t > .5 && t < .55){
- return Math.random();
- }
- return 0;
- }
- function triangle(t,m){
- n = 1/m;
- return n - Math.abs(t % (2*n) - n) * m + .5;
- }
- function a_minor_arpegiator(t){
- t = t%1;
- if(t < 0.25){
- return triangle(t,440)
- //return Math.sin(tau*440*t);
- } else if(t < .50) {
- return triangle(t,523.25)
- // return Math.sin(tau*523.25*t);
- } else if(t < .75) {
- return triangle(t,659.25)
- // return Math.sin(tau*659.25*t);
- }
- return triangle(t,523.25)
- // return Math.sin(tau*523.25*t);
- }
- function dsp(t) {
- return 0.05 * Math.sin(tau*t*440)*(1-t%1)
- + Math.sin(tau*t*220)*Math.sin(tau*t*2)*0.15
- + beat(t)*0.1
- + a_minor_arpegiator(t)*0.1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement