add more currying to delay to help performance
[ModSynth.git] / com / wha / modsynth / JackIO.scala
bloba59f82d8497175dd517384ac81522bc1ad91766e
1 package com.wha.modsynth;
2 import scala.actors._
3 import scala.actors.Actor._
4 import scala.concurrent.SyncVar;
6 import de.gulden.framework.jjack._;
8 class JackIO extends Module {
9 var inBuf = new SyncVar[List[List[float]]]
10 var outBuf = new SyncVar[List[List[float]]]
12 val name = "JackIn"
14 val getSampleRate = JJackSystem.getSampleRate
16 class JackProcessor(ji: Module) extends JJackAudioProcessor with Actor {
17 override def process(e: JJackAudioEvent) = {
18 log("in process")
19 channels = e.countChannels
20 outBuf.unset
21 inBuf.set(for (i <- List.range(0, channels))
22 yield {
23 val in = e.getInput(i)
24 for (j <- List.range(0, in.capacity)) yield in.get(j)})
25 ji ! new Audio(inBuf.get)
26 doOut(e, outBuf.get)
29 def act() {
34 val jackProcessor = new JackProcessor(this)
36 def doOut(e: JJackAudioEvent, b: List[List[float]]) : Unit = {
37 log("in doOut")
38 channels = e.countChannels
39 List.range(0, channels).foreach(i => {
40 log("output channel: " + i)
41 val out = e.getOutput(i)
42 b(i).foreach(sample => out.put(sample))})
45 override def doAudio(buf: List[List[float]]) = {
46 log("in doAudio " + inBuf.isSet)
47 if (inBuf.isSet) {
48 val b = transformAudio(buf)
49 inBuf.unset
50 outputs foreach (x => {log("sending audio to " + x.name); x ! new Audio(b)})
52 else {
53 outBuf.set(buf)