Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Salomonsen petersalomonsen

View GitHub Profile
@petersalomonsen
petersalomonsen / Makefile
Last active Jul 7, 2020
WebAssembly music to native executable
View Makefile
# replace with wasm2c location
WASM2C=/home/peter/git/wabt/wasm2c
all:
wasm2c song.wasm -o song.c
gcc -O3 -I$(WASM2C) main.c song.c $(WASM2C)/wasm-rt-impl.c -lm -lsoundio -o song
View song20200520.js
// SONGMODE=YOSHIMI
setBPM(80);
const lbd = () => c3(1/8,8);
const mbd = () => c3(1/8,35);
const bd = () => c3(1/8,45);
const lsd = () => e3(1/16,20);
const sd = () => e3(1/4,120);
View yoshimi_chill.js
// SONGMODE=YOSHIMI
/**
* "Chill And Feel" - (c) 2020 Peter Johan Salomonsen
*/
setBPM(100);
createTrack(5).steps(4,[controlchange(7, 120)]);
createTrack(2).steps(4,[controlchange(7, 100),controlchange(64, 0)]); // piano
View yoshimitest3.js
// SONGMODE=YOSHIMI
setBPM(75);
createTrack(0).steps(4, [e3]);
createTrack(2).play([[ 0.25, a5(0.15, 48) ],
[ 0.75, a5(0.26, 43) ],
[ 0.49, f6(0.58, 72) ],
View yoshimitest2.js
// SONGMODE=YOSHIMI
setBPM(80);
createTrack(0).steps(4, [
e3
]);
createTrack(2).play([[ 3.51, e6(0.50, 59) ],
[ 4.00, d6(0.46, 65) ],
View yoshimiconfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Yoshimi-data>
<Yoshimi-data Yoshimi-author="Alan Ernest Calvert" Yoshimi-major="1"
Yoshimi-minor="6">
<INFORMATION>
<string name="XMLtype">Parameters</string>
</INFORMATION>
<BASE_PARAMETERS>
<par name="max_midi_parts" value="16" />
<par name="max_kit_items_per_instrument" value="16" />
View amigashuffle.js
// SONGMODE=PROTRACKER
import { writeMod, cmd, clr } from './lib/protrackermodwriter.js';
import { createSamples } from './lib/instrumentgenerator.js';
import { createSampleEcho, insertNotesIntoPattern, insertSampleNotesIntoPattern, toPatternArray, createEmptyPatternArray } from './lib/patterntools.js';
onmessage = function(msg) {
const samples = createSamples(msg.data.WASM_SYNTH_BYTES, [
(instance) => {
instance.setChannelValue(0, 69 - (12 ));
@petersalomonsen
petersalomonsen / 4klangfirstattempt.js
Last active Mar 18, 2020
"4klang first attempt" remake for WASM livecode env
View 4klangfirstattempt.js
/**
*
* "4klang first attempt" - originally made for 4klang, remake for livecode wasm env.
*
* Copyright (c) 2019-2020 - Peter Johan Salomonsen - All rights reserved
*
*/
global.bpm = 106;
global.pattern_size_shift = 4;
@petersalomonsen
petersalomonsen / buildandrun.sh
Created Feb 11, 2020
sin vs math.sin benchmark
View buildandrun.sh
./node_modules/.bin/asc -O3 --use Math=JSMath --runtime none test.ts -o test.wasm
node test.js
View webchip.js
/**
* Copyright (c) 2019 - Peter Johan Salomonsen - All rights reserved
*/
global.bpm = 110;
global.pattern_size_shift = 4;
var pianoVoices = [];
for(let n=1;n<=8;n++) {
pianoVoices.push('piano'+n);
You can’t perform that action at this time.