mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
wip: generate song
This commit is contained in:
parent
1ca16043bc
commit
e282843f1f
30
convert.js
30
convert.js
@ -6,12 +6,18 @@ const doc = {
|
||||
bpm: groove.BPM,
|
||||
rowsperbeat: 4,
|
||||
score: {
|
||||
length: groove.patterns[0].length,
|
||||
length: groove.instrumentPatternLists[0].length,
|
||||
rowsperpattern: groove.patternsize,
|
||||
tracks: groove.instrumentPatternLists.map(track => {
|
||||
|
||||
const patterns = track.map(patternIndex => groove.patterns[patternIndex]);
|
||||
const order = track.map((patternIndex, ndx) => ndx);
|
||||
const patternMap = {};
|
||||
track.forEach(patternIndex => {
|
||||
patternMap[`${patternIndex}`] = groove.patterns[patternIndex];
|
||||
});
|
||||
const patternIndices = Object.keys(patternMap);
|
||||
const patterns = patternIndices.map(patternIndex => patternMap[`${patternIndex}`]);
|
||||
const order = track.map((patternIndex) => {
|
||||
return patternIndices.indexOf(`${patternIndex}`);
|
||||
});
|
||||
return {
|
||||
numvoices: 1,
|
||||
order,
|
||||
@ -25,13 +31,11 @@ const doc = {
|
||||
const addInstrument = (name, strdef) => {
|
||||
const units = strdef.split('\n')
|
||||
.map(opline => {
|
||||
console.log(opline);
|
||||
const opcode_params = opline.replace(/\s\s+/,'\t').split(/[\t]/);
|
||||
const opcode = opcode_params[0];
|
||||
const params = opcode_params[1].split(',');
|
||||
const parameters = {};
|
||||
params.forEach(param => {
|
||||
console.log(param)
|
||||
const paramParts = param.split('(');
|
||||
const paramName = paramParts[0];
|
||||
const paramValue = paramParts[1].substr(0, paramParts[1].length - 1);
|
||||
@ -51,15 +55,25 @@ const addInstrument = (name, strdef) => {
|
||||
case 'GAIN':
|
||||
parameters['gain'] = parseInt(paramValue);
|
||||
break;
|
||||
case 'GAIN':
|
||||
parameters['gain'] = parseInt(paramValue);
|
||||
break;
|
||||
case 'FLAGS':
|
||||
if (opcode == 'GO4K_VCO') {
|
||||
parameters['type'] = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
return {
|
||||
"type": {
|
||||
"GO4K_ENV": "envelope"
|
||||
"GO4K_ENV": "envelope",
|
||||
"GO4K_OUT": "out",
|
||||
//"GO4K_VCO": "oscillator"
|
||||
}[opcode],
|
||||
parameters
|
||||
}
|
||||
});
|
||||
}).filter(unit => unit.type ?? false);
|
||||
doc.patch.push({numvoices: 1, units});
|
||||
};
|
||||
|
||||
|
BIN
groove.wasm
Normal file
BIN
groove.wasm
Normal file
Binary file not shown.
69
groove.wat
69
groove.wat
File diff suppressed because one or more lines are too long
@ -1,5 +1,8 @@
|
||||
{
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "node convert.js && ./sointu-compile -o . -arch=wasm tests/groove.yaml && wat2wasm groove.wat && node testwasm.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"json-to-pretty-yaml": "^1.2.2"
|
||||
}
|
||||
|
13143
tests/groove.yaml
13143
tests/groove.yaml
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
import { readFile, writeFile } from 'fs/promises';
|
||||
|
||||
const wasm = (await readFile('./chords.wasm'));
|
||||
const wasm = (await readFile('./groove.wasm'));
|
||||
|
||||
const mod = await WebAssembly.instantiate(wasm, {
|
||||
m: {
|
||||
|
Loading…
Reference in New Issue
Block a user