Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (542)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (606)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Java Theremin  (Read 12131 times)
0 Members and 1 Guest are viewing this topic.
Online philfrei
« Reply #30 - Posted 2011-10-22 07:31:53 »

I made some changes, putting items in arrays via overwriting rather than via adding and dropping objects. After doing so, I was able to lower the latency from 4096 to 1536 samples. (An improvement--but still a ways to go to reach 600.) Below that, I'm getting a slight sfzt sound at the start. At least, the echo and its length are no longer an issue.

With a 1024 sample buffer the sfzt start is pretty prominent, but other than that, the JTheremin runs fine. So I'm assuming there is something about how I start up the sound that needs improving more than anything else.

Neil, the routine which receives from the GUI (RTESmoother) only gets a double. It then adds a time stamp. [Hmmm. Maybe it would be more correct to issue the time stamp immediately and pass it in as a second parameter.] What I've done is to get rid of the LinkedBlockingQueue and put in two arrays, one a double[] for the GUI values and the other a long[] for the time stamps. The add() method and the block of code where the value is read are both enclosed by a "lock" Object and synchronized. Neither occur very often relative to how short they both are, so I think this should be okay.

I KNOW the GUI add() calls are not causing the starting sfzt via blocking, because I can prevent any add() calls, and the sfzt still is audible, is unchanged.

I'll post the "improved" RTESmoother one its thread in the "Shared Code" area, for the curious.

You echo code looks interesting. I can't totally imagine how it sounds (I'm not the best at reading code) but I see the interpolation happening.

I had this idea for an echo array that allows detuning the echo: let the "read-head" progress incrementally by 1's, but allow the "write-head" to lag behind by a variable increment. One can hold onto the previous write value and its location and the current write value and its location, and interpolate to post into all the intervening array slots.

I suppose this could be combined with a read-head that can progress a varying amount as well. Not sure what one gains that way, though. Seems like one can do one or the other, no need to do both. I can get my head around the varying write-head model a little easier than a varying read/write-head. (Dating myself, using a tape deck metaphor?)

I remember once using a digital echo VST that allows pitch-bending, but it was written in C++ I'm pretty sure. I can't recall what I did with it though, and I miss the effect. My analog units are rather noisy and colored. So I'm pretty motivated to make one for myself. Another good learning project. Whoopee!

"It's after the end of the world! Don't you know that yet?"
Offline nsigma
« Reply #31 - Posted 2011-10-22 12:34:32 »

With a 1024 sample buffer the sfzt start is pretty prominent, but other than that, the JTheremin runs fine. So I'm assuming there is something about how I start up the sound that needs improving more than anything else.

Are you starting the line each time the sound starts?  You'd be better holding the line open and writing silence to it.

Neil, the routine which receives from the GUI (RTESmoother) only gets a double. It then adds a time stamp. [Hmmm. Maybe it would be more correct to issue the time stamp immediately and pass it in as a second parameter.] What I've done is to get rid of the LinkedBlockingQueue and put in two arrays, one a double[] for the GUI values and the other a long[] for the time stamps. The add() method and the block of code where the value is read are both enclosed by a "lock" Object and synchronized. Neither occur very often relative to how short they both are, so I think this should be okay.

I owe you a big thank-you here, as you've inadvertently pointed me to a bug I introduced in refactoring Praxis a while back.  I was about to write and tell you that you've probably made this slower by adding in a lock, but actually to be lock-free you should have been using ConcurrentLinkedQueue and not LinkedBlockingQueue anyway.  I'm always getting those two mixed up for some reason.  You could try the previous code you had with a ConcurrentLinkedQueue and see what the performance is like then - locking is possibly more than the object overhead here.

EDIT: Actually, scratch the previous paragraph.  Looking again at LinkedBlockingQueue it uses two locks - put and take.  There shouldn't be much thread contention at all, so it is likely to be better than the locking strategy you just implemented.

I think there's a subtle bug in your code as well (though I'm no good at reading code either!  Smiley ) in that you should poll() the queue in a while loop to ensure it's drained on each tick - not that it's likely to get swamped by the GUI.

I had this idea for an echo array that allows detuning the echo: let the "read-head" progress incrementally by 1's, but allow the "write-head" to lag behind by a variable increment. One can hold onto the previous write value and its location and the current write value and its location, and interpolate to post into all the intervening array slots.

I suppose this could be combined with a read-head that can progress a varying amount as well. Not sure what one gains that way, though. Seems like one can do one or the other, no need to do both. I can get my head around the varying write-head model a little easier than a varying read/write-head. (Dating myself, using a tape deck metaphor?)

I think it's better to let the write-head progress normally (by 1) and let the read-head read from a variable moment back in time.  This is closer to an actual tape-delay, I think.  The write-head is recording the present and the read-head is playing back some moment in the past.

PS. I'm old enough to be perfectly happy with the tape-deck metaphor.  Grin




Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline fruitmaze

Senior Devvie


Medals: 3
Projects: 2



« Reply #32 - Posted 2011-10-23 14:41:08 »

Thats awesome! Works really nice and fun to play with. Are you planning on using this in another project, like a game or something else?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davedes
« Reply #33 - Posted 2011-10-23 18:06:05 »

The echo effect is really cool, but it stops as soon as you let go of the mouse. Sad

Online philfrei
« Reply #34 - Posted 2011-10-23 22:40:47 »

@davedes
Quote
The echo effect is really cool, but it stops as soon as you let go of the mouse. Sad
Mickelukas had the same suggestion, and I agree that would be nice to have. I am thinking I will try and implement Neil's suggestion to keep the Theremin "running" but silent even if the mouse is released, and include that feature then as well as some sort of volume ratio or independence between the source and the echo.

Maybe the mouse position should drive the overall echo volume even when the mouse is up.
Or the echo setting could be static, on the control panel, rather than tracking the mouse. Pointing

@fruitmaze
Quote
Thats awesome! Works really nice and fun to play with. Are you planning on using this in another project, like a game or something else?
Thanks! Yes in terms of using it in "another project" but I don't have any concrete plans yet. Any suggestions?

I'm still in the learning-project stage. Right now, I'm working on another sound app for a friend for a few days, that plays a "tree" of sine waves, where I am learning about how to create and use envelopes (got a simple Attack-Release working so far), and about using a JTable in the GUI for holding/editing the info used to configure the sines. Am very pleased that I figured out how to play multiple sine waves all from the same WaveTable.

On the queue for the Theremin: vibrato. Which as a learning-project means I get to implement a bit of FM! (FM is my main synth, via DX-7 and Native Instruments FM7 [FM8 if I upgrade]. I've done a lot of high level FM programming (musician user level).)

Also on wish list: ability to record, save & playback the data currently generated by the GUI, as this is much lighter than raw audio.

Also on wish list: implement a filter to get rid of the aliasing! I think if you go down SteveShannon's links below you will find a demo where you can hear how important that is.

Also on wish list: have this light and fast enough that it can be used/integrated into a game as a SF/X source, for example, with tracking the motions of some object moving on a display. The results could be more varied and expressive of game action, potentially, than canned sounds, if done right. Though at the moment, the simplest (conceptually) would be if you had a use for a slide-whistle or trombone slide that could be tied to game state, or game events.

But there is also the potential for some nice, sinister "industrial" background sounds that have more expressive variability than a prerecorded loop. Try this:
     100% Sawtooth
     Lowest possible pitch setting
     99% Echo feedback
     Echo delay setting in the range 10msec to 50msec.
This could be very cool if variable echo delay rates get programmed. Smiley

"It's after the end of the world! Don't you know that yet?"
Online philfrei
« Reply #35 - Posted 2011-10-26 06:59:47 »

Turned out to be really simple to make the Echo continue independently of the Theremin volume.
Done.
Everything still goes silent if you let go of the mouse. But if you drop down to the volume floor, the Theremin is silent, but the echo (assuming it is on, of course) will linger.

"It's after the end of the world! Don't you know that yet?"
Offline fruitmaze

Senior Devvie


Medals: 3
Projects: 2



« Reply #36 - Posted 2011-10-26 07:52:51 »

@fruitmaze
Quote
Thats awesome! Works really nice and fun to play with. Are you planning on using this in another project, like a game or something else?
Thanks! Yes in terms of using it in "another project" but I don't have any concrete plans yet. Any suggestions?


Well as a game maybe something surrealistic and atmospheric, thats the feeling I get when I hear the sounds. Or a game about a bee Smiley Another idea could be to combine graphics and sound, like when you move the mouse to create different sounds the background changes as well.
Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Elsealabs (16 views)
2014-12-28 10:39:27

CopyableCougar4 (20 views)
2014-12-28 02:10:29

BurntPizza (25 views)
2014-12-27 22:38:51

Mr.CodeIt (15 views)
2014-12-27 04:03:04

TheDudeFromCI (20 views)
2014-12-27 02:14:49

Mr.CodeIt (26 views)
2014-12-23 03:34:11

rwatson462 (58 views)
2014-12-15 09:26:44

Mr.CodeIt (47 views)
2014-12-14 19:50:38

BurntPizza (96 views)
2014-12-09 22:41:13

BurntPizza (116 views)
2014-12-08 04:46:31
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!