Skip to content

Instantly share code, notes, and snippets.

View mtmccrea's full-sized avatar
🦚
☁️_☁️

Mike McCrea mtmccrea

🦚
☁️_☁️
  • Helsinki, Finland
View GitHub Profile
@mtmccrea
mtmccrea / GridLines_with_AbstractGridLines.sc
Last active September 24, 2022 10:30
A proposed solution to the `GridLines` taxonomy.
AbstractGridLines {
var <>spec;
*new { arg spec;
^super.newCopyArgs(spec.asSpec).prCheckWarp;
}
asGrid { ^this }
@mtmccrea
mtmccrea / function_plot_sample_alignment.scd
Created August 28, 2022 20:30
Detailed examples illustrating the sample alignment to grid lines (sc #5855)
// Examples demonstrate alignment based on fs = 48kHz.
// SinOsc: the second cycle should begin exactly at
// time t = period (centered in the plot).
// The last sample should NOT fall on 2*period,
// rather within one sample duration before.
// Plot/grid extents should still show requested duration.
(
var period = 0.0005, dur = period * 2;
f = { SinOsc.ar(period.reciprocal) };
@mtmccrea
mtmccrea / quatRotations_vs_foaRotations
Last active April 23, 2022 14:17
Compare the quaternion rotation matrices to ATK's FOA implementations
(
~getQuat = {|alpha, ang_x, ang_y, ang_z|
var rot = sin(alpha/2);
var q = Quaternion(
cos(alpha/2),
rot * cos(ang_x),
rot * cos(ang_y),
rot * cos(ang_z)
);
q
@mtmccrea
mtmccrea / preview_palettes.scd
Created June 15, 2020 21:04
preview the palette attribute colors in SC
(
~win = Window();
~win.layout_(HLayout());
~palettes = IdentityDictionary(know: true);
[
\light,
// \midlight, // undefinted, see above
// \middark, // undefinted, see above
\dark,
// \shadow,// undefinted, see above
# (this isn't actually a valid shell script, just instructions for reference)
# To supplement the instructions in Assignment #1, Section 3.6, Native audio plugins.
# After downloading the "NativePluginCode.zip" from MyCourses,
# unpack the provided source code into: /Your/Unity/Project/Folder
# i.e., the *contents* of NativePluginCode (not the folder itself)
# should be placed in /Your/Unity/Project/Folder. If you've already
# started editing the project, e.g. made a "Move.cs" script, there
# is likely already "Assets" folder, so move the contents from the
# unpacked /Assets folder to the already-existing /Assets folder.
@mtmccrea
mtmccrea / nth_root.scd
Created December 23, 2019 12:53
Calculate the nth root of a number. With tests.
(
// Find *root* of *num* within *eps* precision
// https://en.wikipedia.org/wiki/Nth_root_algorithm
// eps is precision of converging answer
~rootOf = { | num, root, eps = 0.001, initFac = 2, post=true |
var cnt = 0;
var exp = 0;
var two_exp = 1;
var guess;
var rt_recip = root.reciprocal;
@mtmccrea
mtmccrea / test_plotter.scd
Created December 20, 2019 20:11
Various tests to run when making changes to Plotter.
// notice the endpoint drifts when shrinking window width
p = (1, 2 .. 1000).plot.plotMode_(\linear).domainSpecs_([1, 1000, \exp].asSpec).refresh;
p.domain_((1, 2 .. 1000)/2).refresh;
// note it's a bit hard to see without gridlines working properly! (this PR fixes that too)
// illustration of the original problem:
(
var xs, ys, rs = 0, plt2;
// Plotter defaults to a domain of 0 to size-1.
// Here we sample, in non-uniform intervals,
@mtmccrea
mtmccrea / Code for guidelines.scd
Last active September 10, 2019 19:28
Other formatting issue to consider guidelines for.

/* Code to consider suggesting formatting "guidelines". Note that in all following examples, the first example is taken from existing ATK code, and following variations suggest "improvements" (or not!). */

/* Obj.new() or Obj() */

@mtmccrea
mtmccrea / HoaMatrix Receiver - verbose.scd
Last active September 2, 2019 19:53
HoaMatrix, formatted in a style of Receiver-verbose
HoaMatrix : AtkMatrix {
var <directions;
// call by subclass, only
*newFromFile { |filePathOrName, searchExtensions = true, order = (AtkHoa.defaultOrder)|
^super.new('fromFile', order).initFromFile(filePathOrName, searchExtensions)
}
initDirections { |argDirections|
@mtmccrea
mtmccrea / HoaMatrix Receiver - sparse.scd
Created September 2, 2019 19:46
HoaMatrix, formatted in a style of Receiver-sparse
HoaMatrix : AtkMatrix {
var <directions;
// call by subclass, only
*newFromFile { |filePathOrName, searchExtensions = true, order = (AtkHoa.defaultOrder)|
^super.new('fromFile', order).initFromFile(filePathOrName, searchExtensions)
}
initDirections { |argDirections|