Closed anprogrammer closed 9 years ago
Thank you for looking at and working on the project! I really appreciate the help.
I'm trying to run some of my old scripts to test the changes out, and I'm having some trouble getting things running. Do you have a test script that runs that I could check out? I'd love to strip some of the old garbage out of the repository and have a nice example script.
Thank you for this library, I would have had to spend a lot of time writing an audio solution if this didn't exist!
I'll work on putting together a new example script over the next few days so that you can see this in action and verify the functionality.
I'm really looking forward to the example script @anprogrammer :smile:
I just added an example script @ZECTBynmo After you "npm install node-core-audio" and "npm install node-qt" you can "node input_output_graphical_test.js"
It outputs sine waves which pan between left and right (cool effect with head-phones) to demonstrate audio output functionality. At the same time it displays the microphone input oscilloscope-style in real-time, which demonstrates that the audio is not significantly blocking the graphics loop.
Let me know if it works for you!
Awesome! Thanks @anprogrammer. I'll take a look at this as soon as I get a chance.
@ZECTBynmo Have you had a chance to test this?
I'm working on a game I'm planning to release early next week, so I may create a "node-core-audio-parallel" package in NPM so that people can easily install for my game. I'll of course get rid of that and reference the proper node-core-audio package once the pull request is in :)
No need for that, I'll test it right now. Thanks for your patience. @anprogrammer
@anprogrammer Can you add me as a contributor on your fork please? I'd like to make a couple commits before merging
Actually, it's such a small change I can just make it after the merge. This looks great. Thank you so much for contributing! @anprogrammer
@anprogrammer Version 0.4.0 is now live on npm :+1: Thanks again!
@anprogrammer On another note: You might want to do some testing on mac, particularly a macbook pro with a retina display. For some reason, when I open the Qt window on my retina display, it starts to lag badly, to the point where the audio thread is totally lagged out and only emitting pulses of the sine wave. However, when I drag the window to my other (normal) monitor, everything goes back to normal. This might indicate there's a similar issue with your game.
@ZECTBynmo Thanks for merging that (and cleaning up my lack of Linux/OSX support with sleep)! I don't have access to an OSX machine w/ Retina display, although I'm assuming it's some sort of inefficiency with QT. My game is actually pure OpenGL so I doubt it'll be affected. Once I have my game released, I can break part of it off to use as an improved test-script.
When testing this library, I noticed that it was blocking Javascript from running for large portions of time. I discovered that the background thread doesn't actually do anything but lock up immediately after starting, meanwhile Pa_WriteStream (which blocks until the audio passed to it finishes playing) is being called from the main Javascript thread.
I've refactored the architecture, so that the "write" function simply stores the buffer, while the background thread sends said buffer to Port Audio. This way, JavaScript can run while the audio is played.
With these changes this library works rock-solid for the game I'm developing, and has good performance.
I've also added an option to disable microphone input, and a couple of code clean-up tweaks.
Let me know what you think.