Created
August 2, 2012 16:01
-
-
Save gre/3238163 to your computer and use it in GitHub Desktop.
Pure Enumeratee-based sound generation POC for Zound PlayFramework experiment
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
| object Application extends Controller { | |
| val buffSize = 10000 | |
| var f = 200. | |
| val rawStream = { | |
| var i = 0; | |
| val ticker = Enumerator.generateM[Int]({ | |
| i += 1; | |
| Promise.timeout(Some(i), (1000.*buffSize.toDouble/44100.).toInt) | |
| }) // These lines are very crap, but it works, we need a REAL ticker | |
| val sine = Enumeratee.map[Int]({ i => | |
| (0 until buffSize).map { j => | |
| math.sin((i.toDouble+j.toDouble/buffSize)*f) | |
| }.toArray | |
| }) | |
| ticker &> sine | |
| } | |
| // ... (see http://github.com/gre/zound) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment