Skip to content
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

Error with official example #27

Open
page200 opened this issue Dec 26, 2022 · 1 comment
Open

Error with official example #27

page200 opened this issue Dec 26, 2022 · 1 comment

Comments

@page200
Copy link

page200 commented Dec 26, 2022

When I try const Timidity = require('timidity') from the readme, I get Uncaught ReferenceError: require is not defined.

Then I browserify the example from the readme. But then it can't find libtimidity.wasm.

Then I replace

const player = new Timidity()
player.load('/my-file.mid')

by

baseUrl = 'https://bitmidi.com/timidity/'
const player = new Timidity(baseUrl)
player.load('https://bitmidi.com/uploads/16752.mid')

Then I get the warning "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.".

I click on the webpage (which works after applying browserify to bg-sound). But there's still no sound.

So how exactly can I use timidity?

@page200
Copy link
Author

page200 commented Dec 27, 2022

I got it to work by additionally wrapping the modified (see above) code inside setTimeout(() => {...}, 5000) and clicking on the webpage within those 5 seconds.

(Edit: That works locally in Chrome, where window.location.origin is 'file://'. In Firefox, where window.location.origin is null, its use in class Timidity causes Uncaught TypeError: URL constructor: null is not a valid URL.)

Overall, there were many successive errors and required workarounds (see also the previous post).

Please modify the example in the readme such that there are precise instructions for getting it to work.

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

1 participant