@@ -14,7 +14,7 @@ class Canvas {
def set(modName: String, controlName: String, v: Double) {
println(modName + ":" + controlName + ":" + v)
if (modules contains modName) {
- get(modName) ! new Control(controlName, v)
+ get(modName) ! new ControlSig(controlName, v)
}
}
}
@@ -12,16 +12,18 @@ class Delay (n: String) extends Module {
var ring: List[FloatRingBuffer] = Nil
def computePut(mixSig: Float, mixFx: Float)(sig: Float)(fx: Float): Float = {
- sig * mixSig + fx * mixFx
+ val x = sig * mixSig + fx * mixFx
+ //println (x + " ")
+ x
}
override def transformAudio(buf: List[List[float]]): List[List[float]] = {
val sampleRate = JJackSystem.getSampleRate
val time = controls("time")
val diff = (time * sampleRate / 1000).toInt
- if (ring == Nil) List.range(0, channels).foreach(x => new FloatRingBuffer(diff) :: ring)
+ if (ring == Nil) List.range(0, buf.size).foreach(x => ring = new FloatRingBuffer(diff) :: ring)
else ring.foreach(x => x.resize(diff))
-
+
val mixSig = controls("mixSig") / 100
val mixFx = controls("mixFx") / 100
val outSig = controls("outSig") / 100
@@ -30,8 +32,10 @@ class Delay (n: String) extends Module {
val compSigMix = computePut(outSig.toFloat, outFx.toFloat)_
for (channel <- buf; ringbuf <- ring)
yield {
+ var i = 0
for (sample <- channel)
yield {
+ //if (i == 0) {println(sample + " "); i = 1}
val compFx = compFxMix(sample)
val compSig = compSigMix(sample)
compSig(ringbuf.getPut(compFx))
@@ -39,7 +39,7 @@ class JackIO extends Module {
List.range(0, channels).foreach(i => {
log("output channel: " + i)
val out = e.getOutput(i)
- b(i).foreach(sample => out.put(sample))})
+ b(i).foreach(sample => {out.put(sample)})})
}
override def doAudio(buf: List[List[float]]) = {
@@ -9,7 +9,7 @@ case class Connect(client: Module) extends Connector
case class Disconnect(client: Module) extends Connector
trait Signal
-case class Control(name: String, f: Double) extends Signal
+case class ControlSig(name: String, f: Double) extends Signal
case class Audio(buf: List[List[float]]) extends Signal
trait Module extends Actor {
@@ -28,7 +28,7 @@ trait Module extends Actor {
case Connect(client) => {outputs = client :: outputs; log("Output client: " + client.name)}
case Disconnect(client) => {outputs = outputs filter(x => x != client); log("Output client: " + client.name)}
case Audio(buf) => {doAudio(buf) ; log("Audio(client)")}
- case Control(name, f) => {doControl(name, f) ; log("Audio(client)")}
+ case ControlSig(name, f) => {doControl(name, f) ; log("Audio(client)"); reply(new ControlSig(name, f))}
}
}
}
--- /dev/null
+package com.wha.modsynth_test;
+
+import com.wha.modsynth._
+
+object TestDelay {
+ def main(args : Array[String]) : Unit = {
+ val delay = new Delay("Delay1")
+ delay.channels = 2
+ delay.start()
+ List(1.0, 2.0, 3.0, 5.0).foreach ( time => {
+ delay !? new ControlSig("time", time)
+ val temp1 = for(x <- List.range(1, 10)) yield 100.0f
+ val temp2 = temp1 ::: {for(x <- List.range(1, 1000)) yield 0.0f}
+ val input = List(temp2, temp2)
+ val output = delay.transformAudio(input)
+ output.foreach(x => {x.foreach(sample => print(sample + ",")); println})
+ })
+ }
+}