japj / node-sdlmixer Goto Github PK
View Code? Open in Web Editor NEWsdlmixer addon for nodejs
Home Page: http://github.com/japj/node-sdlmixer
License: Other
sdlmixer addon for nodejs
Home Page: http://github.com/japj/node-sdlmixer
License: Other
With an optional second playingStarted callback in the play API (containing fileName, channel) even more information can be moved from printf C++ code to javascript
According to http://groups.google.com/group/nodejs/msg/6a748d7a49fdd7ef
package name should be just sdlmixer, not node-sdlmixer.
The playingDone callback should have more information (i.e. fileName, channel). This could be usefull in order to move all the printf statements from the C++ code to the javascript side.
NPM install did not work so re-built it.
Seemed to build OK
when trying to run simple.js (and having checked require path)
I get "Cannot find module './build/default/node-sdlmixer'"
I'm not sure if this project is in active maintenance, but you accepted my pull req for node-gyp changes so I'll file this issue. SDL is such a cool way to do sound in node.
If I play several sounds the process eventually segfaults. Sometimes this happens after the first sound and sometimes it takes a few to trigger it. It always seems to happen after about 10 calls to play().
I built my node-sdlmixer binary with debug symbols against libSDL2 although I get the same crash with SDL1. I tried this on OSX and Fedora.
var sdlmixer = require("../sdlmixer");
console.log("Opened audio at " + sdlmixer.audioRate + " Hz " + sdlmixer.audioFormat + " bit " +
sdlmixer.audioChannels + " and " + sdlmixer.numberOfAudioChannels + " channels.")
setInterval(function() {
sdlmixer.play(__dirname + '/../wavs/drums/tick.wav', function(fileName, channel) {
console.log(channel +": "+fileName + " done")
});
}, 1000);
retnex:test dan$ node test.js
Opened audio at 22050 Hz 16 bit stereo and 32 channels.
0: /Users/dan/sandbox/thirdparty/node-sdlmixer/test/../wavs/drums/tick.wav done
1: /Users/dan/sandbox/thirdparty/node-sdlmixer/test/../wavs/drums/tick.wav done
2: /Users/dan/sandbox/thirdparty/node-sdlmixer/test/../wavs/drums/tick.wav done
3: /Users/dan/sandbox/thirdparty/node-sdlmixer/test/../wavs/drums/tick.wav done
4: /Users/dan/sandbox/thirdparty/node-sdlmixer/test/../wavs/drums/tick.wav done
5: /Users/dan/sandbox/thirdparty/node-sdlmixer/test/../wavs/drums/tick.wav done
Segmentation fault: 11
$ gdb --args node test.js
Opened audio at 22050 Hz 16 bit stereo and 32 channels.
0: /Users/dan/sandbox/thirdparty/node-sdlmixer/test/../wavs/drums/tick.wav done
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000007600610087
0x0000000100124d8e in uv__async_event ()
(gdb)
(gdb) bt
#0 0x0000000100124d8e in uv__async_event ()
#1 0x0000000100124f16 in uv__async_io ()
#2 0x0000000100131b90 in uv__io_poll ()
#3 0x0000000100125343 in uv_run ()
#4 0x000000010000a5ed in node::Start ()
#5 0x00000001000017f4 in start ()
$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.45.3) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
Occasionally I'll get a "Bus error 10" and a few times I have crashed in Node::StreamWrap. I can't reproduce these situations reliably though. I'll try to update this ticket if I can repro them.
Instead of using the getNextChannel() mechanism, have some administration on channels in use and release those after a channel has been played.
Would like to use it on 0.6 but the npm version is set to 0.4.
Instructions say:
npm install sdlmixer
but the package name appears to be:
npm install node-sdlmixer
?
currently the play api actually will load (+"parse" the sound) from disk and then start playing.
if you want to play the same sound often, it makes more sense to actually load it first and have it 'parsed' only once.
http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html#SEC37
Currently the DoPlay function waits with still_playing until the audio stopped playing.
There is however an SDL mixer callback that can tell if a channel is done.
It seems we need to use an ev_async mechanism to notify the main threads from the SDL mixer callback to wakeup the javascript callback calling. Example at https://gist.github.com/763656
use the EventEmitter mechanism to provide global events like:
start/stop playing on a channel (instead of 'play' with a start callback)
Add a javascript api that can retrieve the currently available/currently playing channels
It looks like your home directory is stashed somewhere in your files. And, those files got pushed to npm. If I do spend more time on it I'll send a pull request. Otherwise, here's your ticket. :)
sudo npm install node-sdlmixer
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info preinstall [email protected]
Nothing to clean (project not configured)
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr/local
Checking for program sdl-config : /usr/bin/sdl-config
'configure' finished successfully (0.037s)
Waf: Entering directory /home/japj/github/node-sdlmixer/build' Waf: Leaving directory
/home/japj/github/node-sdlmixer/build'
Traceback (most recent call last):
File "/usr/local/bin/node-waf", line 16, in
Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 145, in prepare
prepare_impl(t, cwd, ver, wafdir)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 135, in prepare_impl
main()
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 188, in main
fun(ctx)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 386, in build
return build_impl(bld)
File "/usr/local/bin/../lib/node/wafadmin/Scripting.py", line 405, in build_impl
bld.compile()
File "/usr/local/bin/../lib/node/wafadmin/Build.py", line 268, in compile
os.chdir(self.bldnode.abspath())
OSError: [Errno 2] No such file or directory: '/home/japj/github/node-sdlmixer/build'
npm info [email protected] Failed to exec preinstall script
npm ERR! install failed Error: [email protected] preinstall: node-waf clean || true; node-waf configure build
npm ERR! install failed sh "-c" "node-waf clean || true; node-waf configure build"
failed with 1
npm ERR! install failed at ChildProcess. (/usr/local/lib/node/.npm/npm/0.3.18/package/lib/utils/exec.js:49:20)
npm ERR! install failed at ChildProcess.emit (events.js:67:17)
npm ERR! install failed at ChildProcess.onexit (child_process.js:192:12)
npm info install failed rollback
npm info uninstall [ '[email protected]' ]
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm info auto-deactive not symlink
npm info postuninstall [email protected]
npm info uninstall [email protected] complete
npm info install failed rolled back
npm ERR! Error: [email protected] preinstall: node-waf clean || true; node-waf configure build
npm ERR! sh "-c" "node-waf clean || true; node-waf configure build"
failed with 1
npm ERR! at ChildProcess. (/usr/local/lib/node/.npm/npm/0.3.18/package/lib/utils/exec.js:49:20)
npm ERR! at ChildProcess.emit (events.js:67:17)
npm ERR! at ChildProcess.onexit (child_process.js:192:12)
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the node-sdlmixer package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf clean || true; node-waf configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls node-sdlmixer
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.38-8-generic
npm ERR! argv { remain: [ 'node-sdlmixer' ],
npm ERR! argv cooked: [ 'install', 'node-sdlmixer' ],
npm ERR! argv original: [ 'install', 'node-sdlmixer' ] }
npm not ok
audio_rate, audio_format, surround/stereo/mono information to javascript.
This wil allow printf C++ code to move to javascript
Do you think it's possible to bundle together the sdl dependencies so the package could be installed via one line instead of requiring additional installation steps using brew or apt-get ?
Currently the max number of channels is set hardcoded in C++, expose it to the javascript side
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.