Created
September 22, 2015 17:24
-
-
Save Sciss/4d512e61f6fb2587c30f to your computer and use it in GitHub Desktop.
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 scala.concurrent.{Future, ExecutionContext} | |
| import de.sciss.processor._ | |
| def mkFuzzy(in: File, out: File, side: Float = -12.dbamp): Processor[Unit] = { | |
| require(!out.exists) | |
| import ExecutionContext.Implicits.global | |
| val afIn = io.AudioFile.openRead(in) | |
| val afOut = io.AudioFile.openWrite(out, afIn.spec) | |
| val res = Processor[Unit]("fuzzy") { self => | |
| val bufIn = afIn .buffer(8192) | |
| val bufOut = afOut.buffer(8192) | |
| var read = 0L | |
| import afIn.{numFrames, numChannels} | |
| while (read < numFrames) { | |
| val chunk = math.min(8192, numFrames - read).toInt | |
| afIn.read(bufIn, 0, chunk) | |
| for (i <- 0 until chunk) { | |
| for (ch <- 0 until numChannels) { | |
| val sideSig = bufIn((ch + 1) % numChannels)(i) + | |
| bufIn((ch - 1 + numChannels) % numChannels)(i) | |
| bufOut(ch)(i) = bufIn(ch)(i) + sideSig * side | |
| } | |
| } | |
| afOut.write(bufOut, 0, chunk) | |
| read += chunk | |
| self.progress = read.toDouble / numFrames | |
| self.checkAborted() | |
| } | |
| } | |
| res.onComplete { _ => | |
| afIn.close() | |
| afOut.close() | |
| } | |
| res | |
| } | |
| mkFuzzy(in = file("/home/hhrutz/Documents/applications/150615_DEGEM_Konzert/MachinaeCoelestis131229_1/audio_work/bounces/Coelestis150922.aif"), | |
| out = file("/home/hhrutz/Documents/applications/150615_DEGEM_Konzert/MachinaeCoelestis131229_1/audio_work/bounces/Coelestis150922_Fuzzy.aif") | |
| ) .monitor() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment