| 21 | |

| 22 | == Audio == |

| 23 | |

| 24 | === aevalsrc === |

| 25 | |

| 26 | Making some random "musical" keys: |

| 27 | |

| 28 | {{{ |

| 29 | % cat expr |

| 30 | # floor(t): 0 0 0 0 0 ... 1 1 1 1 1 ... 2 2 2 2 2 |

| 31 | # => set a random key when floor(t) changes |

| 32 | if(eq(floor(t),ld(2)), |

| 33 | st(0,random(4)*3000+1000)); |

| 34 | |

| 35 | # the next value to compare floor(t) with |

| 36 | st(2,floor(t)+1); |

| 37 | |

| 38 | # mod(t,1) makes t always in the range [0;1) for each key |

| 39 | st(1,mod(t,1)); |

| 40 | |

| 41 | # 0.6*... + 0.4*... for "echo" effect |

| 42 | # exp() to mitigate the sound according to the time |

| 43 | (0.6*sin(1*ld(0)*ld(1))+ |

| 44 | 0.4*sin(2*ld(0)*ld(1)))*exp(-4*ld(1)) |

| 45 | }}} |

| 46 | |

| 47 | And to test it: |

| 48 | |

| 49 | {{{ |

| 50 | ffplay -f lavfi -i "aevalsrc=$(grep -v '^#' expr|tr -d '\n'|sed 's/\([,;]\)/\\\1/g')" |

| 51 | }}} |