Skip to content

Commit

Permalink
Merge pull request #550 from tidalcycles/fix-soundfont-loading
Browse files Browse the repository at this point in the history
fix: load soundfonts in prebake
  • Loading branch information
felixroos committed Apr 5, 2023
2 parents 8edb086 + 6cd3cc9 commit c26f6b7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 0 additions & 2 deletions packages/soundfonts/fontloader.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,3 @@ export function registerSoundfonts() {
);
});
}

registerSoundfonts();
2 changes: 1 addition & 1 deletion test/runtime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import '@strudel.cycles/xen/xen.mjs';
// import '@strudel.cycles/webaudio/webaudio.mjs';
// import '@strudel.cycles/serial/serial.mjs';
// import controls from '@strudel.cycles/core/controls.mjs';
import '../website/src/repl/prebake';
import '../website/src/repl/piano';

class MockedNode {
chain() {
Expand Down
16 changes: 16 additions & 0 deletions website/src/repl/piano.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Pattern, noteToMidi, valueToMidi } from '@strudel.cycles/core';

const maxPan = noteToMidi('C8');
const panwidth = (pan, width) => pan * width + (1 - width) / 2;

Pattern.prototype.piano = function () {
return this.clip(1)
.s('piano')
.release(0.1)
.fmap((value) => {
const midi = valueToMidi(value);
// pan by pitch
const pan = panwidth(Math.min(Math.round(midi) / maxPan, 1), 0.5);
return { ...value, pan: (value.pan || 1) * pan };
});
};
7 changes: 4 additions & 3 deletions website/src/repl/prebake.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Pattern, noteToMidi, valueToMidi } from '@strudel.cycles/core';
//import { registerSoundfonts } from '@strudel.cycles/soundfonts';
import { registerSoundfonts } from '@strudel.cycles/soundfonts';
import { registerSynthSounds, samples } from '@strudel.cycles/webaudio';
import './piano.mjs';

export async function prebake() {
// https://archive.org/details/SalamanderGrandPianoV3
// License: CC-by http://creativecommons.org/licenses/by/3.0/ Author: Alexander Holm
registerSynthSounds();
//registerSoundfonts();
await Promise.all([
registerSynthSounds(),
registerSoundfonts(),
samples(`./piano.json`, `./piano/`, { prebake: true }),
// https://github.com/sgossner/VCSL/
// https://api.github.com/repositories/126427031/contents/
Expand Down

0 comments on commit c26f6b7

Please sign in to comment.