Skip to content

Commit

Permalink
add webchugins to IDE and chugin examples
Browse files Browse the repository at this point in the history
  • Loading branch information
terryzfeng committed Jul 17, 2024
1 parent 90aa9ec commit 7320556
Show file tree
Hide file tree
Showing 4 changed files with 268 additions and 18 deletions.
208 changes: 196 additions & 12 deletions public/examples/moreExamples.json

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions scripts/examplesToJSON.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re

# TODO: Mini Audicle examples path here
CHUCK_EXAMPLES_PATH= "/Users/terryfeng/Documents/research/chuck/chuck/examples"
CHUCK_EXAMPLES_PATH= "YOUR/PATH/HERE"
OUTPUT_JSON_FILE = "../public/examples/moreExamples.json"

# Chuck examples Web URL
Expand All @@ -16,14 +16,21 @@
# IMPORTANT: Exclude examples containing the words, features not compatible with WebChucK
excludeFileWords = ["OscIn", "OscOut", "Hid", "HidMsg", "MidiIn", "MidiOut", "MidiMsg", "MidiFileIn", "ConsoleInput", "WvOut"]
# Exclude Chugins
chugins_list = [ "ABSaturator", "Bitcrusher", "Elliptic", "Faust", "FIR", "FoldbackSaturator", "GVerb", "KasFilter", "MagicSine", "Pan4", "Pan8", "Pan16", "PitchTrack", "Mesh2D", "MIAP", "PowerADSR", "Spectacle", "WarpBuf", "WinFuncEnv" ]
excludeFileWords += chugins_list
#chugins_list = [ "ABSaturator", "Bitcrusher", "Elliptic", "Faust", "FIR", "FoldbackSaturator", "GVerb", "KasFilter", "MagicSine", "Pan4", "Pan8", "Pan16", "PitchTrack", "Mesh2D", "MIAP", "PowerADSR", "Spectacle", "WarpBuf", "WinFuncEnv" ]
#excludeFileWords += chugins_list
# add a space to the end of each word to match Object classes
excludeFileWords = [word + " " for word in excludeFileWords]
excludeFileWords += ["SerialIO", "Serial", "gtzan", "otf_0"]
# add words that aren't UGens
excludeFileWords += ["SerialIO", "Serial", "gtzan"]

# Exclude files
excludeFilenames = ["feature-extract.ck", "write.ck", "Dyno-limit.ck", "Dyno-duck.ck"]
excludeFilenames = ["feature-extract.ck", "write.ck", "otf_01.ck", "otf_02.ck",
"otf_03.ck", "otf_04.ck", "otf_05.ck", "otf_06.ck", "otf_07.ck"]

# NOTE: some files need by hand corrections (terry)
# - dyno-limit.ck - adjust snd buf path
# - dyno-duck.ck - adjust snd buf path
# - Sigmund.ck - lower npeak from 4096 to 1024

# Examples Dictionary
examplesDict = {}
Expand All @@ -37,7 +44,6 @@ def filterChuckExample(f, fileText):
for word in excludeFileWords:
if word in fileText:
return False

return True

# regex to find "*.wav" or "*.txt" strings in chuckExample
Expand Down
5 changes: 5 additions & 0 deletions src/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { Chuck, HID } from "webchuck";
import { calculateDisplayDigits } from "@utils/time";
import { ChuckNow } from "@/components/vmMonitor";
import { loadWebChugins } from "@/utils/webChugins";
import Console from "@/components/console";
import Visualizer from "@/components/visualizer";
import HidPanel from "@/components/hidPanel";
Expand Down Expand Up @@ -62,6 +63,10 @@ export async function initChuck() {
sampleRate = audioContext.sampleRate;
calculateDisplayDigits(sampleRate);

// TODO: Hack for WebChugins 7/16/2024
const chugins: string[] = loadWebChugins();
chugins.forEach((chuginPath) => Chuck.loadChugin(chuginPath))

Check failure on line 68 in src/host.ts

View workflow job for this annotation

GitHub Actions / build

Missing semicolon

// Create theChuck
theChuck = await Chuck.init(
[],
Expand Down
55 changes: 55 additions & 0 deletions src/utils/webChugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//------------------------------------------------------------------------------
// title: Web Chugins
// desc: Hacky way to load webchugins stored online
// date: July 2024
// author: terry feng
//------------------------------------------------------------------------------

const WEBCHUGIN_URL = "https://ccrma.stanford.edu/~tzfeng/static/webchugins/"

Check failure on line 8 in src/utils/webChugins.ts

View workflow job for this annotation

GitHub Actions / build

Missing semicolon

const chugins = [
"ABSaturator.chug.wasm",
"AmbPan.chug.wasm",
"Binaural.chug.wasm",
"Bitcrusher.chug.wasm",
"Elliptic.chug.wasm",
"ExpDelay.chug.wasm",
"ExpEnv.chug.wasm",
"FIR.chug.wasm",
"FoldbackSaturator.chug.wasm",
"GVerb.chug.wasm",
"KasFilter.chug.wasm",
"Ladspa.chug.wasm",
"Line.chug.wasm",
"MagicSine.chug.wasm",
"Mesh2D.chug.wasm",
"Multicomb.chug.wasm",
"NHHall.chug.wasm",
"Overdrive.chug.wasm",
"PanN.chug.wasm",
"Patch.chug.wasm",
"Perlin.chug.wasm",
"PitchTrack.chug.wasm",
"PowerADSR.chug.wasm",
"Random.chug.wasm",
"Range.chug.wasm",
"RegEx.chug.wasm",
"Sigmund.chug.wasm",
"Spectacle.chug.wasm",
"WPDiodeLadder.chug.wasm",
"WPKorg35.chug.wasm",
"Wavetable.chug.wasm",
"WinFuncEnv.chug.wasm",
"XML.chug.wasm"
]

Check failure on line 44 in src/utils/webChugins.ts

View workflow job for this annotation

GitHub Actions / build

Missing semicolon

/**
* Create paths to webchugins for loading into WebChucK
* TODO: implement some kind of caching
* @returns {string[]} array of chugin paths
*/
export function loadWebChugins(): string[] {
return chugins.map((chuginName) => {
return WEBCHUGIN_URL + chuginName;
})

Check failure on line 54 in src/utils/webChugins.ts

View workflow job for this annotation

GitHub Actions / build

Missing semicolon
}

0 comments on commit 7320556

Please sign in to comment.