gibber-cc / tidal.pegjs Goto Github PK
View Code? Open in Web Editor NEWA parsing expression grammar for the TidalCycles pattern language.
A parsing expression grammar for the TidalCycles pattern language.
Hello, first of all, thanks for this fantastic port of tidal syntax to JS!
I am currently implementing a little live coding playground with it, and realized that when I create a pattern and start querying from a non zero start, the result has the wrong phase.
This works:
const values = (e) => e.value;
const pattern = Pattern('[A <B C>]')
expect(pattern.query(0, 1).map(values)).toEqual(['A', 'B']);
expect(pattern.query(1, 1).map(values)).toEqual(['A', 'C']);
This does not work
const values = (e) => e.value;
const pattern = Pattern('[A <B C>]')
// expect(pattern.query(0, 1).map(values)).toEqual(['A', 'B']);
expect(pattern.query(1, 1).map(values)).toEqual(['A', 'C']); // yields ['A', 'B']
I think I can work around the problem, but it would be much easier if query had no side effects.
FYI I also wrote a little post about this lib.
console.log(parser.parse('[bd,hh]'))
outputs
{ '0': { '0': { type: 'string', value: 'bd' }, type: 'group' },
'1/2': { '0': { type: 'string', value: 'hh' }, type: 'group' },
type: 'layer' }
instead of
{ '0': { '0': { type: 'string', value: 'bd' }, type: 'group' },
'0': { '0': { type: 'string', value: 'hh' }, type: 'group' },
type: 'layer' }
Is this expected that this sequence works fine
'<0.5 .5/*2>'
but this one doesn't
'<.5/*2>'
( at least in gibber v2 ) ?
Note that I put a forward slash before the '*' so that it is displayed correctly in GitHub but it shouldn't be there in reality.
It looks like the parser doesn't expect the first atom to have a multiplier ?
title says it all. The same pattern will work as follows:
{kd, ch(3,8)} {sd, kd(5,9)}
... but it'd be better if the []
worked for this.
Current issues seem to be:
npm install tidal.pegjs
, there is no ./dist/tidal.js
because pegjs tidal.pegjs
has not been run.tidal.js
exists and do import {Pattern} from 'tidal.pegjs'
you get 'Pattern' is not exported by node_modules/tidal.pegjs/src/pattern.js
.import * as Tidal from "tidal.pegjs"
you get Uncaught ReferenceError: util is not defined
.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.