We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi All,
Apologies right off the bat for what may be a stupid question - but I'm working in Python mode and would like to be able to use the sound library. Specifically, I have an FFT visualization script from Java mode that I'd like to be able to adapt for something I'm working on in Python mode. I'm not sure how to go about translating the code that references the library, though (I'm pasting some for example here). Are there any resources out there that might help with this? I've looked for documentation on the sound library within Python mode but haven't found anything yet. Any other suggestions? Thanks!
// Create an Input stream which is routed into the Amplitude analyzer fft = new FFT(this, bands); in = new AudioIn(this, 0);
// start the Audio Input in.start();
// patch the AudioIn fft.input(in);
Answers
I'm sorry I didn't see this until now. Here's the sound library's example sketch "FFTSpectrum" ported to Python Mode. I hope it helps.
Hi Jonathan,
Thanks for this, this is great and very helpful! However... I've been trying to incorporate it into something I'm working on, but I keep getting "java platform SE binary has stopped working" error messages. It doesn't happen consistently, but about 50% of the time that I run a script whenever I have imported the sound library (I never get it otherwise). I'm running windows 10, have searched for this issue but haven't found any documentation that seems to apply. I've also tried uninstalling / reinstalling Java, but that did not help. Any suggestions on how to troubleshoot this further?
One other question - I know python mode is new, but I'm wondering if the use of the sound library within Python mode documented somewhere? I think I might not be totally understanding how the translation between the library, which I think is in Java, to the scripting, which is happening in Python, occurs. I'd be interested in understanding this more clearly if there's anything I can read about it.
Thanks again!
The error is vexing, and I have no insight into what might be causing it, other than to suggest that you try to do what this rticle suggests:
There's basically no Python-specific documentation for Processing libraries, unfortunately. The best I can tell you is "read the documentation for the library, then do it in Python"! The code I posted above is an example of that idea, but I don't know how to explain it any better. To make certain libraries easier to use, Python Mode does expose a special variable
this
, which acts just like the Javathis
for the Python sketch.Ok, I'll check out the link, and thanks for the answer to my other question as well!