make 0.5hz cps the default (#931)

* 0.5 default cps

* 1 -> 0.5 cps defaults

* start moving examples to 2Hz

* more 2Hz doc edits

* small tweaks

* format

* adapt cycles page

* adapt pitch page

* tonal page

* accumulation

* synth page

* adapt conditional-modifiers

* audio effects page

* adapt signals doc

* fix: errors for signals

* adapt signals page

* start time modifiers

* adapt time modifiers

* adapt factories

* hydra + pattern intro

* adapt mini notation page

* start recipes

* adapt recipes page

* use code_v1 table

* delete old dbdump + add new csv based tool

* fix: tests

* fix: cpm

* shuffle featured patterns

* fix: snapshot

---------

Co-authored-by: Felix Roos <flix91@gmail.com>
This commit is contained in:
Alex McLean 2024-01-22 19:02:34 +00:00 committed by GitHub
parent 46c2c72637
commit 6422047cff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 3852 additions and 2386 deletions

View file

@ -30,7 +30,6 @@ import { getRandomTune, initCode, loadModules, shareCode, ReplContext } from './
import PlayCircleIcon from '@heroicons/react/20/solid/PlayCircleIcon';
import './Repl.css';
const { code: randomTune, name } = getRandomTune();
const { latestCode } = settingsMap.get();
let modulesLoading, presets, drawContext, clearCanvas, isIframe;
@ -98,7 +97,7 @@ export function Repl({ embedded = false }) {
// init settings
initCode().then((decoded) => {
initCode().then(async (decoded) => {
let msg;
if (decoded) {
editor.setCode(decoded);
@ -107,6 +106,7 @@ export function Repl({ embedded = false }) {
editor.setCode(latestCode);
msg = `Your last session has been loaded!`;
} else {
const { code: randomTune, name } = await getRandomTune();
editor.setCode(randomTune);
msg = `A random code snippet named "${name}" has been loaded!`;
}
@ -159,7 +159,7 @@ export function Repl({ embedded = false }) {
const resetEditor = async () => {
clearCanvas();
resetLoadedSounds();
editorRef.current.repl.setCps(1);
editorRef.current.repl.setCps(0.5);
await prebake(); // declare default samples
};
@ -176,7 +176,7 @@ export function Repl({ embedded = false }) {
editorRef.current.evaluate();
};
const handleShuffle = async () => {
const patternData = getRandomTune();
const patternData = await getRandomTune();
const code = patternData.code;
logger(`[repl] ✨ loading random tune "${patternData.id}"`);
setActivePattern(patternData.id);

View file

@ -314,7 +314,7 @@ stack(
)
.fast(2/3)
.pianoroll()`;
/*
export const bridgeIsOver = `// "Bridge is over"
// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
// @by Felix Roos, bassline by BDP - The Bridge Is Over
@ -333,7 +333,7 @@ stack(
s("mad").slow(2)
).cpm(78).slow(4)
.pianoroll()
`;
`; */
export const goodTimes = `// "Good times"
// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
@ -709,6 +709,8 @@ export const dinofunk = `// "Dinofunk"
// @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/
// @by Felix Roos
setcps(1)
samples({bass:'https://cdn.freesound.org/previews/614/614637_2434927-hq.mp3',
dino:{b4:'https://cdn.freesound.org/previews/316/316403_5123851-hq.mp3'}})
setVoicingRange('lefthand', ['c3','a4'])

View file

@ -9,8 +9,7 @@ import { createClient } from '@supabase/supabase-js';
import { nanoid } from 'nanoid';
import { writeText } from '@tauri-apps/api/clipboard';
import { createContext } from 'react';
import { stockPatterns } from './useExamplePatterns';
import { loadDBPatterns } from '@src/user_pattern_utils.mjs';
import { $featuredPatterns, loadDBPatterns } from '@src/user_pattern_utils.mjs';
// Create a single supabase client for interacting with your database
export const supabase = createClient(
@ -18,8 +17,9 @@ export const supabase = createClient(
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBpZHhkc3hwaGxoempuem1pZnRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTYyMzA1NTYsImV4cCI6MTk3MTgwNjU1Nn0.bqlw7802fsWRnqU5BLYtmXk_k-D1VFmbkHMywWc15NM',
);
let dbLoaded;
if (typeof window !== 'undefined') {
loadDBPatterns();
dbLoaded = loadDBPatterns();
}
export async function initCode() {
@ -34,7 +34,7 @@ export async function initCode() {
return hash2code(codeParam);
} else if (hash) {
return supabase
.from('code')
.from('code_v1')
.select('code')
.eq('hash', hash)
.then(({ data, error }) => {
@ -61,10 +61,11 @@ export const parseJSON = (json) => {
}
};
export function getRandomTune() {
const allTunes = Object.entries(stockPatterns);
export async function getRandomTune() {
await dbLoaded;
const featuredTunes = Object.entries($featuredPatterns.get());
const randomItem = (arr) => arr[Math.floor(Math.random() * arr.length)];
const [id, data] = randomItem(allTunes);
const [_, data] = randomItem(featuredTunes);
return data;
}
@ -111,7 +112,7 @@ export async function shareCode(codeToShare) {
// generate uuid in the browser
const hash = nanoid(12);
const shareUrl = window.location.origin + window.location.pathname + '?' + hash;
const { error } = await supabase.from('code').insert([{ code: codeToShare, hash, ['public']: isPublic }]);
const { error } = await supabase.from('code_v1').insert([{ code: codeToShare, hash, ['public']: isPublic }]);
if (!error) {
lastShared = codeToShare;
// copy shareUrl to clipboard