-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Dist files? #27
Comments
Also, fyi, the reason why I can't use your npm package is because of this error:
I'd prefer to use npm due to the typings. I can try adding the file manually to see if this fixes the problem, but I run automated solutions on my server with npm updates. |
js-synthesizer package in npm includes JS files (ES modules) in dist/lib directory and if you use webpack, If you can, please provide a reproduction for the problem. |
Hi, thank you for your response. This is actually the error I get with npm:
Given the error above, I just wonder if the npm installer is not downloading the correct file. I have decided that I am going to use your solution with my application since it does work otherwise, and offers a lot of the control I need. I might have to download your project later and test it locally if we can't figure out the npm issue. |
I created the repository https://github.com/jet2jet/js-synthesizer-test-webpack for the test. |
I was able to successfully run and launch this project, with the browser outputting [object Object]. Here's a copy of the log information. Please note, I upgraded my node to the latest version:
|
Hi, How can I contact you? I'm going to be using this library in my product Music Jotter since I am able to get it to work. However, I have some questions, especially regarding efficiency. Some question would be:
Looking forward to hearing from you. |
No, it's OK to load Soundfont only once (until calling
I don't know Kontakt well, but I think it is necessary to pass MIDI messages to WebMIDI API, which is different from WebAudio. js-synthesizer only passes rendered data to WebAudio, but if you want to pick MIDI messages, |
A bit confused with your documentation. I'm assuming this bit of code must be called each time in order to play the midi. Wouldn't each call load the soundfont? This is the problem I am having, high memory usage. As of now, I have to keep calling this block of code in order to get the play function to work with seek. I feel like I am missing something though.
|
I was able to fix the memory problem by following your code example here. Actually, it seems to work really well now and I am not even noticing too much latency. I'll show you the product in action once I am ready to make my next YouTube video. What are your plans for upkeep with this module? I know that down the line I will need to do more synth work once I start making more consistent sales with Music Jotter. I'll be doing work with virtual midi ports as well. |
Sorry for the unkind code, but Soundfont is only needed to load once. That sample code was simply intended to play a MIDI file once.
Currently there are no plans to update the module, but if necessary (such as bug fixes or valuable feature requests), I'll work for the update. |
Can your module connect to an available midi port? I'm still trying to see if fluidsynth allows connection via a midi port (in this case, a virtual midi port, such as LoopMidi). Instead of using the loaded soundfont to playback via the synth, I'm trying to see if I can use an external sampler for this (Kontakt is an example, but any external sampler would be similar). If this is not possible I may have to use WebMidi for this (if that is even possible, still researching). However, if fluidsynth can handle this, I'd rather just use this one piece of technology. |
No, Emscripten, used to build wasm version of fluidsynth, does not have ability to send messages to a MIDI port, so wasm version of fluidsynth cannot use the MIDI port. Therefore, you must use WebMIDI manually. |
Thanks! I figured as much. I also figured out how to use WebMIDI to connect to an external synth such as Kontakt. I'll still be using your module for soundfont integration. |
Hi, I have possibly one more question. I'm unsure how to send a midiNoteOn event with a specific instrument. And when I send a midiNoteOn event, can I load a new instance of synth? Would I have to set PlayPlayer at all? For example, once I initialize the synth, I may do something like this: And if I am using a GM soundfont, instrument 41 would be a violin. How would I play a noteOn event with a violin? |
For MIDI, it is necessary to send Program Change message to change the instrument. So, you need to call
|
Bingo, that got it to work. Thank you. When I do my next YouTube video about playback, I will let you know. You might be interested in seeing how my product works, and makes use of this module. I also will demonstrate how Music Jotter works with Kontakt. But if you are generally interested in music composition, feel free to subscribe and spread the word of my small music channel. |
Also, do you have any tips on how to keep memory usage low? I'm stress testing right now, and memory usage keeps climbing as I add more notes to the score for playback. I do not seem to have this problem with external daws since memory management is handled by the daw. I don't know if synth.close() must be called each time the player stops (to clean up memory), but I can't get that function to work correctly. When the player stops, and I call close, the notes get stuck. Sorry, another followup question: is there a way to increase the polyphony with this API? |
BTW, this is the error I get when I go add notes (stress testing).
When I enter notes (and modify notes), I run a series of midiNoteOn events (paired with midiNoteOff events). But this doesn't seem to work well for note entry. The playback still seems to work fine. I have a new synth just for note entry. And another synth object just for playback. Not sure if I am missing something. When I connect to a soundfont manager such as Coolsoft VirtualMidiSynth, there are no issues. I'm not sure if FluidSynth just has issues with memory management, or if there are settings that can't be accessed via this API. One solution would be to disallow (turn off) sending midiNoteOn events when placing notes. Not ideal, but I'm not sure how else to overcome the memory problems. |
The second parameter of
I'm not sure, but it seems that flushing data in voices does not work properly. This may occur when |
Ah, I ignored the render function in your documentation because I wasn't sure what it was or how to use it. Do I simply call synth.render() in the play loop, like this?
Also from your docs: What exactly is outBuffer? How do I retrieve that value? |
Assuming the output buffer is defined here:
Also assuming render gets called in the hookPlayerMIDIEvents loop like this:
If my assumptions are correct, I am getting this error now: Edit: Ok figured out what output buffer is. It's this:
Only thing left is to figure out where I put render(outputBuffer) in the code. If I place it in the loop, the midi file plays twice as fast! So I am guessing that is not the right placement. |
Ok I figured out that putting (render) when the player stops is the best way. And running "render" after each note off event should do the trick (upon executing note events). Unfortunately, there is skipping when I stress test (place notes at a fast pace rapid fire). |
When using const node = synth.createAudioNode(ac, 2048); // 2048 is optional
ac.destination.connect(node);
// after this, `synth.render` is called automatically (from 'audioprocess' event of audio node) Note that |
If I use AudioWorklet, I need access to the midi events. I got everything to work except I have no idea how to access |
I found what the issue is. I've been getting this error all along but I've just been ignoring it. However this is why the AudioWorkletGlobalScope isn't being registered:
I load these scripts in the header of my html main template:
And each time I run my project, I get that reference error. I believe if we could pinpoint why there is a reference error, then I can finally access |
|
Thanks! I am still unable to access I can implement the audioworklet technique for midiNoteOn and midiNoteOff events, but I am unable to implement the technique with playback (since I have to capture midi events during playback). If we are unable to figure this out, I will have to reverse engineer the code one of these days to see whats going on. The global variable is for some reason not being registered correctly. |
|
Hi,
Can you publish the distribution files here? You have them published here, however the files were compiled with webpack in development mode (since the map files are required).
I am evaluating solutions for my product Music Jotter, and I'd like to see if your neat solution here can work. Is it possible to run note on and note off events? I have to dig in a little more.
Thanks!
The text was updated successfully, but these errors were encountered: