Dear all,
I am writing to request some simple and effective code snippets that clearly demonstrate the benefits of SC and SAPF—and, more importantly, illustrate why coding is necessary for digital sound production. I am planning to incorporate these examples into a class scheduled for the end of the semester, which will be either one class (75 minutes) or two classes (150 minutes).
This is a general education course, and the students are not professional musicians. About a third of the students are either computer science majors or are quite familiar with programming concepts. Although they will have a basic understanding of tools such as Reaper and Audacity, the material should remain accessible to students without a specific musical background.
I appreciate your valuable suggestions and look forward to your prompt response. I am asking here because I think these examples could be included in the Schelp documentation in the future.
I guess it’s a classic, make a thousand sine waves evenly spaced from 100 to 800 hz, and spread them across the stereo field:
(
{
var n = 1000;
var sines = { |i| SinOsc.ar(i.linexp(0, n, 100, 800), Rand(0, 0.015)) }.dup(n);
Splay.ar(sines, 1, 0.5).tanh * 0.5;
}.play;
)
coding is not necessary for digital sound production. This is gatekeeping. Real programmmers use Mx-Butterfly
@Eric_Sluyter Thank you for the example!
@Herman
Thanks! You are correct. I should have written the following sentence
as follows:
I am writing to request some simple yet effective code snippets that clearly demonstrate the benefits of SC and SAPF—and, more importantly, how coding can play a vital role in digital sound production.
A classic, the theremin emulation:
(
{
SinOsc.ar(
freq: MouseX.kr(220, 1760),
mul: MouseY.kr(0, 0.25)
);
}.play;
)
I think coding is a great way to use abstraction which acts as a great leverage for laying out sound in time.
Code-golfing/SCTweets are a neat example where one constructs a small idea which is hopefully interesting to listen for a little while, e.g.
play{var x={|a,b,c|Latch.ar(SinOsc.ar(a,b),Impulse.ar(c))},y={|a,b|Decay.ar(Impulse.ar(a),b)};x.(x.(y.(1,0.1)*400,0.4,15432)*x.(0.03,2.9,4021)*[3500,1000],[0.5, 0.3]*y.(1,0.1),x.(0.2,2.2,12.2)*x.(1000.2,x.(0.5,[1.2,9.0],0.5),0.9)*10000)*y.(x.(0.2,0.5,1.0)*10,x.(0.01,[20.5,10.3],10.9).abs*x.([1.3,2.2],1.3,1.0).abs)};
Not the best SC tweet of all times, but it is only using 2 building blocks (the functions x
and y
) and basically a modulated SinOsc
- something that I just came up with for this thread. You can try to write it out to understand what happens or go the other way by starting to modulate the parameters in function y
through function x
and try to find good combinations and magic numbers.
BTW - the patch does not use any random signals.
Contrary to “engineering programming” I find that creative coding is not tied to move big things around in a controlled and more serious manner - I can let go of the control and use it as a creative process or use some structures that I learned or observed elsewhere and can apply them here w/o any justification - just for fun or curiosity.
For me personally, approaching computer music allowed me to not limit my musical ideas to a (piano-)keyboard anymore - I still love the piano and there are things that I can only attach to a piano-keyboard, but now I can tie my curiosity for abstract models to expressing sound by using code.
edit: and ofc - its cheaper than modular^^
Thank you all for your excellent suggestions!
I also came across Fredrik Olofsson’s webpage, which offers pairs of SuperCollider (SC) code and SAPF examples. For further details, you may refer to the following discussion thread:
Although I personally find all the provided codes remarkable, I often encounter challenges in lessons where students have varying levels of coding expertise and different areas of interest. The primary challenge lies in captivating the majority with a handful of straightforward code examples within the limited time available, particularly as many struggle with complexity.
I plan to make good use of the examples you have shared and Olofsson’s codes. Furthermore, I shall devote time to researching and refining my explanations to ensure they are both simpler and more engaging for students.
I’m not sure if this is quite simple enough but I like the PMOsc example from the help a lot. It’s really mostly about overlapping the oscillators and gradually fading in the spectral content (i.e., the Line on the mod index) such that the near-sinusoidal new pitches are sort of covered over by the older, already more fm-'ed pitches. It’s really quite musical despite the randomness and reminds me of a certain kind of ensemble writing…
(
e = Env.linen(2, 5, 2);
Routine.run({
loop({
play({
LinPan2.ar(EnvGen.ar(e) *
PMOsc.ar(2000.0.rand,800.0.rand, Line.kr(0.0, 12.0.rand,9),0,0.1), 1.0.rand2)});
2.wait;
})
}))