Skip to content

Error when creating a layer #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
davay42 opened this issue Aug 3, 2021 · 7 comments
Open

Error when creating a layer #15

davay42 opened this issue Aug 3, 2021 · 7 comments

Comments

@davay42
Copy link

davay42 commented Aug 3, 2021

I started experimenting with beet to create a non-euclidean rhythm generator. I'm using the npm version of it inside my vuejs project. And whenever I create a layer from a pattern (as the docs say) I get this error.

Uncaught (in promise) TypeError: can't convert undefined to object
    webworkify beet_js.js:4256
    Metro wa-metro.js:21
    Layer layer.js:10
    js beet_js.js:4549

My code:

import Beet from 'beet.js'

const context = new AudioContext();

const beet = new Beet({
  context: context,
  tempo: 120
});

let pattern = beet.pattern(3, 7);
let layer = beet.layer(pattern, (t) => console.log(t));

@zya
Copy link
Owner

zya commented Aug 3, 2021

@davay42 At first glance, it seems like an issue with web workers in the underlying scheduling library 'wa-metro'.
My guess is that by installing via npm and including in vue, the worker file does not get included.
Are you using something like webpack to bundle your application?

@davay42
Copy link
Author

davay42 commented Aug 3, 2021

Yeah, I'm using vitepress based on vitejs. https://vitejs.dev/

@zya
Copy link
Owner

zya commented Aug 3, 2021

I'm not familiar with those tools you mentioned..

My suggestion would be to try and setup webpack such that it contains the file located here '/node_modules/wa-metro/lib/worker.js/' in the correct location where that library can load it in.

I'm currently a bit busy I can not try it out myself. But might be able to give it a go if you wait some time.

@zya
Copy link
Owner

zya commented Aug 3, 2021

There potentially need to be some changes to this library to support webpack.

@davay42
Copy link
Author

davay42 commented Aug 4, 2021

Webback is like a thing of the past as it's way slower, than new build tools built around esbuild. Vite is a breakthrough in the js ecosystem. That is I couldn't make webpack work for many times and stayed fully client-side with my vue apps. But vite just does the job almost effortlessly and works right from the box. Nobody would ever get back to webpack after such an dev experience ))

I tried installing wa-metro as a separate package, but it doesn't change anything - the error is still there... I'm OK to wait. I also can make a small reproduction repo with vite for you to test against.

@zya
Copy link
Owner

zya commented Aug 5, 2021

The thing is that when wa-metro was build originally, it was built with browserify in mind. Now browserify is not that popular anymore, webpack is also going away. We don't want to make the library dependant on any bundling library. I need to change it such that it works with any bundling.

@davay42
Copy link
Author

davay42 commented Aug 5, 2021

Yeah, sure! Plain JS is enough here! vite and other more modern tools are based on native js import - export and don't need any kind of special treatment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants