Skip to content

Instantly share code, notes, and snippets.

View ckmahoney's full-sized avatar
🐱

Cortland Mahoney ckmahoney

🐱
  • 15:30 (UTC -04:00)
View GitHub Profile
@ckmahoney
ckmahoney / infinisound.js
Last active August 22, 2023 05:12
Infinite music player with Web Audio API
// copy and paste me into your browser console to play music!
function createReverbNode(context, decayTime = 3, wetLevel = 0.33) {
const reverbNode = context.createConvolver();
// Create an impulse response buffer for the reverb
const bufferLength = context.sampleRate * decayTime;
const impulseResponse = context.createBuffer(2, bufferLength, context.sampleRate);
// Fill the buffer with random noise for a simple reverb effect
@ckmahoney
ckmahoney / sampler.sc
Last active February 9, 2023 01:12
A pitched sampler for supercollider
(
// major scale
var freqs= [ 1.0, 1.0, 1.125, 1.25, 1.3333333333333, 1.5, 1.5, 1.6666666666667, 1.875 ];
// whare are ur snares
var samples = PathName("~/stage/assets/samples/snare").files;
// for Promise-like behavior in supercollider, use a FlowVar
var flows = Array.fill(samples.size, {FlowVar.new});
@ckmahoney
ckmahoney / fm-synth-gen.sc
Last active January 6, 2023 17:30
Generator for a constrained range of FM SynthDef
/*
Generate a list of new FM synths
This is a good preset for target frequencies in 50 - 600 Hz range.
Above that produces aliasing effects on the highs, and below on the lows.
*/
(
@ckmahoney
ckmahoney / support-for-harmonic-theory.sc
Created March 16, 2022 15:55
An empirical example demonstrating the use of harmonics to generate music from noise
/**
How to Emperically measure the Quality of Music,
or Applying Harmonics to Non-Musical Source to Produce a Musical Signal
When people ask for empirical evidence that Harmonic Theory works,
we must first agree on a method to measure the "musicality" of a signal.
Generally we can agree that a pure White Noise signal (even distribution of frequencies across the given range in Hertz) is not musical. In the domain of sound, it is the antithesis of music because there is no discrete rhythmic structure and no discrete harmonic structure (example 1)
@ckmahoney
ckmahoney / static-files-dynamic-compressor.sc
Last active December 6, 2022 01:29
Creating a dynamic compressor applied from two standard audio files in SuperCollider.
/**
Here we create a "sidechain compressor" effect.
Given two audio files, we are able to have one of the files change its volume in response to the other.
This is an extremely useful and versatile effect: All professional music mastering involves dynamic compression
at many scales.
In contemporary and art music, it is applied lightly. In dance music and popular styles, it is often heavy.
This is a heavy example, for drastic effect. Here we are:
@ckmahoney
ckmahoney / sclang-dynamic-effects.sc
Last active June 2, 2022 06:50
Demonstrating a method to route effects dynamically in SuperCollider.
/**
Routing dynamic effects for any Synth
The issue was that a list of arguments can not be passed in as args for SynthDef.
For examle say you want to apply both a reverb and delay to a hat sound.
One way is to write explicit args for each effect :
SynthDef(\hat, {|out=0, reverbChannel =4, delayChannel = 6|