fix example
This commit is contained in:
parent
2cda78d2db
commit
08f0825561
4 changed files with 17 additions and 9 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState, useRef, useCallback, useMemo, useEffect } from 'react';
|
import { useStlte, useRef, useCallback, useMemo, useEffect } from 'react';
|
||||||
import { Icon } from './Icon';
|
import { Icon } from './Icon';
|
||||||
import { silence, noteToMidi, _mod } from '@strudel/core';
|
import { silence, noteToMidi, _mod } from '@strudel/core';
|
||||||
import { getPunchcardPainter } from '@strudel/draw';
|
import { getPunchcardPainter } from '@strudel/draw';
|
||||||
|
|
@ -73,6 +73,9 @@ export function MiniRepl({
|
||||||
onUpdateState: (state) => {
|
onUpdateState: (state) => {
|
||||||
setReplState({ ...state });
|
setReplState({ ...state });
|
||||||
},
|
},
|
||||||
|
afterEval:() => {
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// init settings
|
// init settings
|
||||||
editor.setCode(code);
|
editor.setCode(code);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
export const examples = [
|
export const examples = [
|
||||||
`// "coastline" @by eddyflux
|
`// "coastline" @by eddyflux
|
||||||
|
// @version 1.0
|
||||||
samples('github:eddyflux/crate')
|
samples('github:eddyflux/crate')
|
||||||
setcps(.75)
|
setcps(.75)
|
||||||
let chords = chord("<Bbm9 Fm9>/4").dict('ireal')
|
let chords = chord("<Bbm9 Fm9>/4").dict('ireal')
|
||||||
|
|
@ -18,7 +19,7 @@ stack(
|
||||||
n("<0!3 1*2>").set(chords).mode("root:g2")
|
n("<0!3 1*2>").set(chords).mode("root:g2")
|
||||||
.voicing().s("gm_acoustic_bass"),
|
.voicing().s("gm_acoustic_bass"),
|
||||||
chords.n("[0 <4 3 <2 5>>*2](<3 5>,8)")
|
chords.n("[0 <4 3 <2 5>>*2](<3 5>,8)")
|
||||||
.set(x).anchor("D5").voicing()
|
.anchor("D5").voicing()
|
||||||
.segment(4).clip(rand.range(.4,.8))
|
.segment(4).clip(rand.range(.4,.8))
|
||||||
.room(.75).shape(.3).delay(.25)
|
.room(.75).shape(.3).delay(.25)
|
||||||
.fm(sine.range(3,8).slow(8))
|
.fm(sine.range(3,8).slow(8))
|
||||||
|
|
|
||||||
|
|
@ -94,13 +94,7 @@ export function Repl({ embedded = false }) {
|
||||||
window.location.hash = '#' + code2hash(code);
|
window.location.hash = '#' + code2hash(code);
|
||||||
setDocumentTitle(code);
|
setDocumentTitle(code);
|
||||||
const viewingPatternData = getViewingPatternData();
|
const viewingPatternData = getViewingPatternData();
|
||||||
try {
|
setVersionDefaultsFrom(code);
|
||||||
const metadata = getMetadata(code);
|
|
||||||
setVersionDefaults(metadata.version);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error parsing metadata..');
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
const data = { ...viewingPatternData, code };
|
const data = { ...viewingPatternData, code };
|
||||||
let id = data.id;
|
let id = data.id;
|
||||||
const isExamplePattern = viewingPatternData.collection !== userPattern.collection;
|
const isExamplePattern = viewingPatternData.collection !== userPattern.collection;
|
||||||
|
|
|
||||||
|
|
@ -164,3 +164,13 @@ export const setAudioDevice = async (id) => {
|
||||||
}
|
}
|
||||||
initializeAudioOutput();
|
initializeAudioOutput();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function setVersionDefaultsFrom(code) {
|
||||||
|
try {
|
||||||
|
const metadata = getMetadata(code);
|
||||||
|
setVersionDefaults(metadata.version);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error parsing metadata..');
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue