Skip to content

Instantly share code, notes, and snippets.

View petersalomonsen's full-sized avatar

Peter Salomonsen petersalomonsen

View GitHub Profile
@petersalomonsen
petersalomonsen / Makefile
Last active November 22, 2024 16:16
WebAssembly music to native executable
# 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
setBPM(90);
addInstrument('piano');
addInstrument('string');
addInstrument('drums');
addInstrument('guitar');
addInstrument('bass');
addInstrument('tubelead');
addInstrument('flute');
addInstrument('padsynth');
@petersalomonsen
petersalomonsen / shader.glsl
Created September 13, 2023 04:50
WebAssembly Music: "Much"
precision highp float;
uniform vec2 resolution;
uniform float time;
uniform float targetNoteStates[128];
float wave(float x, float freq, float speed, float amp) {
return amp * sin(x * freq + time * speed);
}
void main() {
@petersalomonsen
petersalomonsen / song.js
Last active August 21, 2023 19:36
sointu test song
global.bpm = 110;
global.pattern_size_shift = 4;
// global.looptimes = 100;
//soloInstrument('kick');
/*soloInstrument('pad1');
soloInstrument('pad2');
soloInstrument('pad3');*/
// soloInstrument('lead1');
@petersalomonsen
petersalomonsen / build.sh
Last active April 6, 2023 14:03
sointu renderer
../sointu/sointu-compile -arch amd64 ../sointu/temp_song_file.yml
# if you just want to redner a short version
# node rendershort.mjs
yasm -f macho64 -a x86 temp_song_file.asm --objfile=temp_song_file.o
MACOSX_DEPLOYMENT_TARGET=11 gcc -Wl,-no_pie -arch x86_64 temp_song_file.o test.c -o test
@petersalomonsen
petersalomonsen / song.js
Created May 21, 2022 06:17
WebAssembly Music - Veronika's Waltz
/*
* Copyright (c) 2022 - Peter Johan Salomonsen
*/
setBPM(50);
addInstrument('piano');
addInstrument('string');
addInstrument('drums');
addInstrument('guitar');
/*
* Copyright (c) 2021 - Peter Johan Salomonsen
*/
setBPM(85);
addInstrument('piano');
addInstrument('string');
addInstrument('drums');
addInstrument('guitar');
@petersalomonsen
petersalomonsen / song.js
Last active January 14, 2022 18:05
Noise & Madness
/**
* Copyright 2020 - Peter Johan Salomonsen
*/
setBPM(100);
addInstrument('pad');
addInstrument('drums');
addInstrument('sawtap');
addInstrument('distlead');
#version 100
precision highp float;
uniform vec2 resolution;
uniform float time;
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
/*
* Copyright (c) 2021 - Peter Johan Salomonsen
*/
setBPM(100);
addInstrument('BoltToysPluck');
addInstrument('SphericalBowl');
addInstrument('KnotPressureModeled');
addInstrument('empty1');