Last active
January 13, 2024 00:18
-
-
Save catfact/8bf36920459afd0605bb4bc401cfaddd to your computer and use it in GitHub Desktop.
noise_vs_buf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 1000; | |
m = 20; | |
d = 0.1; | |
a = 0.1 / n; | |
h = Array.newClear(m); | |
s.waitForBoot { Routine { | |
i = 0; | |
b = Bus.audio(s, 1); | |
f = Buffer.alloc(s, s.sampleRate, 1); | |
s.sync; | |
// { b.scope }.defer; | |
postln("playing " ++ n ++ " channels of white noise"); | |
z = { | |
Out.ar(b.index, Mix.new(Array.fill(n, WhiteNoise.ar)) * a) | |
}.play(s); | |
1.0.wait; | |
postln("sampling peak CPU..."); | |
m.do { | |
h[i] = s.peakCPU; | |
// h[i].postln; | |
i = i + 1; | |
d.wait; | |
}; | |
postln("...done.\n"); | |
1.0.wait; | |
s.freeAll; | |
postln("min: " ++ h.minItem); | |
postln("median: " ++ h.median); | |
postln("max: " ++ h.maxItem); | |
postln("\n-------------\n"); | |
// { h.plot }.defer; | |
// { h.plotHisto }.defer; | |
postln("playing " ++ n ++ " channels of buffer read"); | |
z = { | |
Out.ar(b.index, Mix.new(Array.fill(n, PlayBuf.ar(1, f))) * a) | |
}.play(s); | |
1.0.wait; | |
postln("sampling peak CPU..."); | |
i = 0; | |
m.do { | |
h[i] = s.peakCPU; | |
// h[i].postln; | |
i = i + 1; | |
d.wait; | |
}; | |
1.0.wait; | |
s.freeAll; | |
postln("...done.\n"); | |
postln("min: " ++ h.minItem); | |
postln("median: " ++ h.median); | |
postln("max: " ++ h.maxItem); | |
// { h.plot }.defer; | |
// { h.plotHisto }.defer; | |
}.play } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment