Fancy hap show, include part in snapshots (#291)

* fix _mod import

* prettier hap show, use both whole and parts in snapshots, rebuild snapshots
This commit is contained in:
Alex McLean 2022-12-10 10:56:16 +00:00 committed by GitHub
parent f827201ee0
commit 98e9780819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13601 additions and 13576 deletions

View File

@ -79,9 +79,34 @@ export class Hap {
);
}
show() {
show(compact = false) {
const value = typeof this.value === 'object'
? compact
? JSON.stringify(this.value).slice(1, -1).replaceAll('"', '').replaceAll(',', ' ')
: JSON.stringify(this.value)
: this.value
var spans = '';
if (this.whole == undefined) {
spans = '~' + this.part.show;
}
else {
var is_whole = this.whole.begin.equals(this.part.begin) && this.whole.end.equals(this.part.end);
if (!this.whole.begin.equals(this.part.begin)) {
spans = this.whole.begin.show() + ' ⇜ ';
}
if (!is_whole) {
spans += '(';
}
spans += this.part.show();
if (!is_whole) {
spans += ')';
}
if (!this.whole.end.equals(this.part.end)) {
spans += ' ⇝ ' + this.whole.end.show()
}
}
return (
'(' + (this.whole == undefined ? '~' : this.whole.show()) + ', ' + this.part.show() + ', ' + this.value + ')'
'[ ' + spans + ' | ' + value + ' ]'
);
}

View File

@ -110,7 +110,7 @@ export class TimeSpan {
}
show() {
return this.begin.show() + ' -> ' + this.end.show();
return this.begin.show() + ' ' + this.end.show();
}
}

View File

@ -4,7 +4,7 @@ Copyright (C) 2022 Strudel contributors - see <https://github.com/tidalcycles/st
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Pattern, mod } from '@strudel.cycles/core';
import { Pattern, _mod } from '@strudel.cycles/core';
export function edo(name) {
if (!/^[1-9]+[0-9]*edo$/.test(name)) {
@ -42,7 +42,7 @@ function getXenScale(scale, indices) {
}
function xenOffset(xenScale, offset, index = 0) {
const i = mod(index + offset, xenScale.length);
const i = _mod(index + offset, xenScale.length);
const oct = Math.floor(offset / xenScale.length);
return xenScale[i] * Math.pow(2, oct);
}

View File

@ -187,7 +187,7 @@ evalScope(
export const queryCode = async (code, cycles = 1) => {
const { pattern } = await evaluate(code);
const haps = pattern.queryArc(0, cycles);
return haps.map((h) => h.showWhole());
return haps.map((h) => h.show(true));
};
export const testCycles = {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff