Here's another SuperCollider port of msafluid by Memo Akten. It is very similar to the MSAFluidSolver2D I ported from Java, but this one is from the C++ version (openFrameworks ofxMSAFluid) and has more features and a GUI interface.
Unfortunately, it runs slower than the Java port.
Classes, help files and an example are attached as a zip archive below.
Updates:
210525: optimised drawing using the Image class (see demo-2)
Today I recorded and uploaded my latest six SuperCollider sctweets to my SoundCloud account. They were all recorded using SC 3.7a0 and Audacity for trimming, normalising, adding a quick fade out and exporting.
Recording short sound files of these one-liners help non-sc-users get an idea about what is going on and it's also good for archiving. They make it possible to, in the future when SC 3.7a0 is long gone, go back and listen to what the code did produce.
This is a SuperCollider port of Memo Akten's Processing library MSAFluid. I looked at his MSAFluidSolver2D.java version 1.3.0 and rewrote it for SuperCollider. I also optimised it as much as I could but still it is slow and the framerate is very low. I blame the slow SuperCollider graphics. The fluid system itself should perform ok - it's just the drawing that doesn't live up to be useful.
The good news is that one doesn't need to use the fancy graphics. SuperCollider is anyway made for sound synthesis and the fluid simulator can run and particles can be mapped to sound without displaying anything.
Classes, help files and examples are attached as a zip archive below.
msafluid2d
Updates:
210525: optimised drawing using the Image class (see demo-2)
During today's clean-up-of-old-projects I got stuck shrinking an old piece of SuperCollider code down to under 140 characters (sctweet). The shortest I could get it down to was 165 characters. Still, I thought I'd post the results of my efforts here - both if someone has suggestions or if someone wants to study the process. It's the same code, just rewritten over and over to be shorter - using every trick I could think of.
Of course one could imagine other goals than briefness - better sounding or less CPU taxing are two (probably better and more) common goals when optimising code in this manner.
141024: I did delete all my red quarks on the 4th of October (because of my 3rd October transition to green phase) but failed with the SVN commit. The error I got was Transmitting file data ...svn: E160028: Commit failed (details follow): svn: E160028: Directory '/redSys' is out of date. I saw it as a sign that they shouldn't go.
But today I figured out that I had checked out the HTTP version and that I needed the https to be able to commit. So after the command... svn relocate https://svn.code.sf.net/p/quarks/code I can now commit changes to the quarks SVN repository again.
Yet another small piece of code I found in my SuperCollider extensions folder.
It's very basic and just generates a PWM signal (Pulse-Width Modulation). You could do the same thing quicker with the standard LFPulse, but sometimes it's good to roll your own just to see another approach.
Found an old extension to Wouter Snoei's nice MasterEQ class (it's in his wslib quark). My extension just takes the current setting and posts code that recreates that. It's handy for when you want to hardcode an equaliser into some piece of code and when you don't want to be dependent on wslib being installed.
Since long I had this idea of sonifying what my laptop is doing. Before, when laptops had spinning hard drives, one could at least hear the faint little noises when there was disk activity. But today with the SD disks, this insight is gone.
Below is a draft of how it could work. It tracks activity in the system.log file. To try it start SuperCollider and run the code. Then launch some apps, save files, disconnect network etc. It's quite fun to have it running in the background for a while.
One day I plan to do a more thorough sonification, tracking many more things. Here is a good reference for what to tap into in the future.
/*
sudo iosnoop
sudo execsnoop -v
sudo opensnoop -ve
sudo dtruss -n SuperCollider
sudo errinfo -c
sudo iotop -CP 1
man -k dtrace
*/
//osx only
(
s.latency= 0.05;
s.waitForBoot{
var num= 10;
var delta= 0.1;
var maxlen= 256;
var rate= 0.5;
var curr= List.new;
var mySplit= {|str|
var res= "";
var arr= [];
var separator= Char.nl.ascii;
var tab= Char.tab.ascii;
str.do{|chr, i|
if(chr.ascii!=separator or:{str.clipAt(i+1).ascii==tab}, {
res= res++chr;
}, {
arr= arr.add(res);
res= "";
});
};
arr.add(res);
};
var read= Routine({
var res, arr, last, new;
inf.do{
res= ("tail -n"+num+"/var/log/system.log").unixCmdGetStdOut;
if(res!=last, {
last= res;
arr= mySplit.value(res);
new= arr.select{|x| curr.indexOfEqual(x).isNil};
new.do{|x|
curr.addFirst(x);
};
});
delta.wait; //time between checking system log
};
});
var play= Routine({
var data;
inf.do{
if(curr.size>0, {
data= curr.pop;
("buf"++curr.size++": ").post;
data.postln;
s.bind{
Synth(\log, [\data, data.ascii.extend(maxlen, 0)]);
};
(data.size/maxlen*rate).wait;
}, {
delta.wait;
});
};
});
SynthDef(\log, {|out= 0, amp= 0.5, minFreq= 300, maxFreq= 14400|
var data= Control.names([\data]).ir(Array.fill(maxlen, 0));
var freq= Duty.ar(1/maxlen*rate, 0, Dseq(data), 2);
var src= SinOsc.ar(freq.linexp(0, 255, minFreq, maxFreq), 0, (freq>0).lag(0.02));
OffsetOut.ar(out, Pan2.ar(src, 0, amp));
}).add;
s.sync;
read.play(AppClock);
play.play;
};
)