I am currently developing an application that helps the user to tune his guitar and generate guitar effects. This is in real-time. I've been looking through java applications that could give an idea to generate guitar effects such as overdrive and delay but I couldn't find any. Also a source on creating a waveform in real time is needed. Your comments would be so much help, thanks in advance.
4 Answers
John says:
First, forget Java ... Secondly, you will be interfacing with the hardware ... Java does not support this kind of thing.
Jeez, that's kinda harsh - you should have told Sun that this wasn't possible before they published the API for this: http://java.sun.com/products/java-media/sound/. There's lots done with sound in Java, and I've never had an issue with latency or buffers, even on somewhat decrepit hardware.
Good examples @ http://www.jsresources.org/examples/index.html
Good help @ http://java.sun.com/products/java-media/sound/list.html
... having said that, John's comments on learning DSP & waveform analysis are on the $$$.
Have fun - Dave

- 1
- 1

- 1,042
- 2
- 12
- 23
-
I believe the impact of garbage collection will reveal itself when you use small buffers which are necessary to minimize latency (the ~2ms range). Though I never meant that Java wasn't capable of playing back sound. You use something like JNI to bridge a native engine for performance reasons with a managed UI framework for productivity. That's typically what I go for whenever the performance is critical. – John Leidegren Jun 12 '10 at 09:51
-
I recently came across this little tid bit, thought I'd share it. http://stackoverflow.com/a/1602139/58961 – John Leidegren Jul 15 '13 at 14:51
-
@JohnLeidegren: I've often thought that what would be helpful would be if streams kept track of an absolute amount of time since they were opened, and one could specify that a stream of audio data should replace anything that's already buffered, starting at a particular absolute time, with the semantics that if that time was in the past, the appropriate amount of new data would be skipped, so that each sample which had been enqueued to play at a particular time would get replaced with data that was intended to play at the same time. That would allow code to enqueue speculative data... – supercat Jan 19 '14 at 23:34
-
...but replace it instantly if controls were changed so that it became obsolete. Any idea if systems do anything like that? – supercat Jan 19 '14 at 23:34
-
Well sure, but it's gonna depend on how the data stream is encoded, PCM is straightforward since seek time relates linearly with sample rate, bit depth and channel count. For other encoded streams I wouldn't know but typically you have the concept of a bit rate which probably is a good approximation but not exact, for exact seek times you'd probably rely on more knowledge of how the stream is encoded. Maybe there are markers in the data stream that you can jump to and then seek from them, that's probably a good tradeoff between efficiency and what's practical. – John Leidegren Jan 20 '14 at 06:52
-
You could do away with the encoding problem entirely if it's enough to just jump around PCM data streams, most providers that I know of tend to emit PCM data stream in the end. It's probably a combination of both but I'm not that sure I understand your use case, exactly right. – John Leidegren Jan 20 '14 at 06:54
This open source project maybe a good reference for you. There's a function that construct the waveform http://code.google.com/p/musicg/

- 345
- 3
- 7
Regarding the feasability of low latency sound processing: Have a look at this article about Harmonicon, a java soft-synth. It's a sample playing synth implemented entirely in java, using the Metronome GC, which has upper latency guaranties in < 2 ms running on a realtime OS.
Regarding wave form generation/dsp, check out the example in this question, Java generating sound, a very simple wave form generation example.
First, forget Java. Java is a managed run-time which does garbage collection. When this happens you will hear shuttering because you wanna keep your sound buffer small to minimize latency,
Secondly, you will be interfacing with the hardware i.e. sound card, Java does not support this kind of thing and so you'll either have to write some hardware abstraction in JNI or find an existing solution, but there's a problem with that to. It's unlikely that you'll get the real-time performance from the Java platform.
What you wanna do is that you wanna go with C++
for this, and you will wanna learn more about partial-differentiation, DSP, sound synthesis and waveform analysis. This is quite a lot to take on but it should give you a good sense of direction if you start reading up on relevant research...

- 16,163
- 12
- 91
- 106

- 59,920
- 20
- 131
- 152