https://composerprogrammer.com/teaching/supercollider/sctutorial/9.1%20Algorithmic%20Strategies.html

Hello to you all! Hope you are fine and in health!
I’m doing a school project on Markov analysis in music. I have managed to make all the transition matrices and all that’s left to do, is “make” the supercollider “play” those matrices, so that I can compare the program’s result to the original song. I’ve watched a million videos and read almost every article and forum that could help me. Nothing so far… no result.

Hello and welcome to the forum!
Could you post a simplified example of your code and tell a bit more about what step does not work? It will help others in the forum give a better answer your question.
Cheers,
Bruno

I’m new to supercollider. I found this example on the internet and I tried to run it, and then adjust it on my matrices. But it doesn’t work… I fully understand the logic, but I cannot make it play…

(

var markovmatrix;
var currentstate=3.rand; //start in one of three states
markovmatrix= [
[0.7,0.2,0.1],
[0.0,0.5,0.5],
[0.3,0.4,0.3]
];
{
20.do{

``````		Synth(\acsound,[\freq, [48,60,64].at(currentstate).midicps]);
``````

//which probability distribution to use depends on what state we’re in right now

``````                  currentstate = [0,1,2].wchoose(markovmatrix[currentstate]);
0.25.wait;
``````

};

}.fork;
)

I may need to download something extra for the synthdef toy play. Right?

The code try to launch a Synth according to the synth definition \acsound (SynthDef). This is what is missing from the code. This is not something to download, this should be regular code like:

`SynthDef(\acsound, { ...... }).add`

Also when you post code, please select code and use the forum preformatted text button to display it like code with syntax coloring. Else it will be hard for other people to understand or try it

Looking at the link you copied in the title of this post, I see that the \acsound SynthDef was defined at the very top of that tutorial page:

``````(
SynthDef(\acsound,{|freq=440,amp=0.1,dur= 0.2,cutoff=2000|
var sound, filter;
sound = Saw.ar(freq, amp)*EnvGen.kr(Env([0,1,1,0],[0.01,0.05,(dur.max(0.07))-0.06]),doneAction:2);
filter = LPF.ar(sound,Line.kr(cutoff,300,dur));
Out.ar(0,filter.dup(2))
)
``````

A SynthDef is basically a “recipe to make sound” that you add to the SuperCollider server. When you call Synth(\acsound), you are requesting that a note be produced using that recipe. This will only work if you actually have loaded the SynthDef after booting the server, and you have to do this again every time you restart SuperCollider anew.

So assuming you have already booted the server (control B, or command B on a Mac), simply run the SynthDef(\acsound, …etc) snippet to add it to the server, then you can run any examples with Synth(\acsound, …etc), and they should work.

Hope this helps,

Bruno

One thing to add to what Bruno said: You can run the SynthDef block at any time before or after booting the server. If you run it after booting, the SynthDef is transmitted directly; if before, it’s memorized in a library of SynthDefs and will be sent on the next boot.

It’s true that you won’t get any sound without both booting the server and creating the SynthDef.

There are a few sections of the Getting Started tutorial series that cover this: Start Your Engines, Functions and Sound, SynthDef and Synth. If it isn’t clear what “booting the server” means, I’d strongly suggest to go through the introductory material in the tutorials.

hjh

Oh my God! I can’t thank you enough… that was the stupidest mistake!
It works!!

1 Like