Thursday, March 12, 2009

marsyas




I am currently doing things with Marsyas that it never was intended to do, but that the way my old UNIX hacker ways demand. Specifically, I'm writing small little programs in Marsyas that take RealVecSources as input, and output to an AudioSink or a SoundFileSink. This is so that I can put small programs together, each of which does one thing well into a bigger whole.

The way you usually do this in Marsyas is to write another module, which is great, but I'm just doing an assignment for class, and it's so much easier to do the processing in Ruby rather than C++.

The trick to using a RealVecSource with a SoundFileSink is that it's only after you fill the RealVecSource with data through it's data control that the network knows what data you're going to be sending through the network.

So, instead of doing something like this:


MarSystem* net = mng.create("Series", "net");
net->addMarSystem(mng.create("RealvecSource", "src"));
net->addMarSystem(mng.create("SoundFileSink", "dest"));
net->updctrl("SoundFileSink/dest/mrs_string/filename",outAudioFileName);

while (!done) {
net->updctrl("RealvecSource/src/mrs_realvec/data", r);
}


You want to do something more like:



MarSystem* net = mng.create("Series", "net");
net->addMarSystem(mng.create("RealvecSource", "src"));
net->addMarSystem(mng.create("SoundFileSink", "dest"));

bool init = false;
while (!done) {
realvec r(1.0,3,4);
net->updctrl("RealvecSource/src/mrs_realvec/data", r);

if (!init) {
net->updctrl("SoundFileSink/dest/mrs_string/filename",outAudioFileName);
}
}



Same thing for AudioSink:



MarSystem* net = mng.create("Series", "net");
net->addMarSystem(mng.create("RealvecSource", "src"));
net->addMarSystem(mng.create("SoundFileSink", "dest"));

bool init = false;
while (!done) {
realvec r(1.0,3,4);
net->updctrl("RealvecSource/src/mrs_realvec/data", r);

if (!init) {
net->updctrl("AudioSink/dest/mrs_bool/initAudio", true);
}
}