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

Can't load instruments from external sites. #9

Closed
0xfe opened this issue Jan 18, 2013 · 12 comments
Closed

Can't load instruments from external sites. #9

0xfe opened this issue Jan 18, 2013 · 12 comments

Comments

@0xfe
Copy link
Contributor

0xfe commented Jan 18, 2013

Instrument files are pretty big and better served via CDNs.

This is currently not possible because they are loaded via XMLHttpRequest which disallows cross-domain requests. Can this be changed to use the "script" tag?

Thanks!

@mudcube
Copy link
Owner

mudcube commented Jan 18, 2013

That's a great point, and yes, I believe it can! A few people were running into this issue, so definitely a worthwhile change that shouldn't take long to make. I'll put this on the TODO list for the next update.

@0xfe
Copy link
Contributor Author

0xfe commented Jan 18, 2013

Great, thanks!

@mudcube
Copy link
Owner

mudcube commented Jan 19, 2013

The latest release gives the option of XHR or SCRIPT tag. XHR allows for onProgress event to be fired, and the percentage of download left to be calculated (cross domain possible but only with CORS enabled server/browser combo). SCRIPT allows for file:// access and other cross-domain queries.

@mudcube mudcube closed this as completed Jan 19, 2013
@0xfe
Copy link
Contributor Author

0xfe commented Jan 19, 2013

w00t!

@0xfe
Copy link
Contributor Author

0xfe commented Jan 25, 2013

Before I dig in further, did you test this in Firefox? (My player seems to have stopped working in FF after this change.)

@mudcube
Copy link
Owner

mudcube commented Jan 25, 2013

Thanks for reporting. It should work now!

@0xfe
Copy link
Contributor Author

0xfe commented Jan 25, 2013

Thanks for the fix. Verified that this works.

It seems that noteOff on HTML5 Audio Tag has the same bug that the WebAudio
one had (incorrect delay setting for realtime audio.)

On Fri, Jan 25, 2013 at 6:34 PM, Michael Deal notifications@github.comwrote:

Thanks for reporting. It should work now!


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-12726151.

Mohit Muthanna [mohit (at) muthanna (uhuh) com]

@mudcube
Copy link
Owner

mudcube commented Jan 25, 2013

Currently noteOff for Audio Tag looks like this:

root.noteOff = function (channel, note, delay) { };

At one point it looked more like this;

root.noteOff = function (channel, note, delay) {
setTimeout(function() {
channels[channel].pause();
}, delay * 1000)
};

(or something like that) but, that really didn't sound great without the linear ramp down...

it sounds like you're saying there is an issue with the noteOn working again, after noteOff?

@0xfe
Copy link
Contributor Author

0xfe commented Jan 26, 2013

It sounds like noteOff doesn't work when playing realtime. Here's what I mean:

Go here: http://my.vexflow.com/playground.html

And paste in the following VexTab:

options stave-distance=30 instrument=brass_section player=true
tabstave notation=true key=A time=4/4
voice
  notes :q (5/2.5/3.7/4) :8 7p5h6/3 ^3^ 5h6h7/5 ^3^ :q 7V/4 |
  notes :8 t12p7/4 s5s3/4 :8 3s:16:5-7/5 :q p5/4
voice
  notes :h 5/6 :q  5/6 :8 3-5/6 | :w 5/5

tabstave notation=true
  notes :q (5/4.5/5)s(7/4.7/5)s(5/4.5/5) ^3^
  notes :q ## :8 (5/4.5/5)h(7/5) |
  notes :8 t(12/5.12/4)s(5/5.5/4) 3b4/5
  notes :h (5V/6.5/4.6/3.7/2) $.medium.A13$ $.italic.let ring$

Notice that Chrome correctly switches the note off, while firefox doesn't. If you set the instrument to acoustic_grand_piano it's all fine, because the tone decays quickly.

Here's how I implement note/chord playing (it's CoffeeScript). playNote gets called by setInterval based on the note's temporal position on the stave:

 playNote: (notes) ->
    for note in notes
      continue if note.isRest()

      keys = note.getPlayNote()
      duration = note.getTicks().value() / (@tpm/60)
      for key in keys
        [note, octave] = key.split("/")
        note_value = noteValues[note]

        midi_note = (21 + (octave * 12)) + noteValues[note].int_val
        MIDI.noteOn(0, midi_note, 127, 0)
        MIDI.noteOff(0, midi_note, duration)

@mudcube
Copy link
Owner

mudcube commented Jan 26, 2013

Right, so, what I was saying is the noteOff for HTML5 audio is currently an empty function, so that's why noteOff doesn't do anything. The reason for switching this off, was it was sounding pretty aweful without the linear ramping... I'll post some code for you in a few for you to hear what it sounds like.

@mudcube
Copy link
Owner

mudcube commented Jan 26, 2013

Ok, I've updated the made some slight tweaks and pushed the changes;

1513dda

Let me know what you think... might be better than nothing?

@0xfe
Copy link
Contributor Author

0xfe commented Jan 26, 2013

Oops, sorry I missed the first part of your message (noteOff has empty implementation).

Thanks for the tweaks. I'll patch in your changes and try.

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