Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  PFTheremin  (Read 5607 times)
0 Members and 1 Guest are viewing this topic.
Offline philfrei
« Posted 2016-04-10 19:17:04 »

    jar downloads:


Continuing on the theme of making scalable audio assets...a theremin in the works. The JavaFX GUI allows it to be played in real time.

I started writing about this and went overboard, so deleted everything. Minimum needed to know to try it out:

> mouse down in the orange area to get playback
> X-axis is pitch, Y-axis is volume (and optionally mapped "Expression Axis" features)

Next post will be an api for use as an external library, if you want to try incorporating this audio functionality in a game you are writing.[/list]

music and music apps: http://adonax.com
Offline philfrei
« Reply #1 - Posted 2016-04-10 19:21:12 »

PFTheremin, SoundHandler API

   SoundHandler sh = new SoundHandler();

Class is located in the package: com.adonax.jtheremin

   // Following are methods of SoundHandler, e.g., sh.start();
   void start() // turns on audio thread
   void stop()  // turns off audio thread

   void startSync()  // save a reference sound frame and nanotime for internal event
             // used to schedule the pitch updates, can be called any time the
         // pitch updates develop lag beyond a built-in 1800 frames

   void setSynth(String name) // {"FM Sawtooth", "FM Square"}

   void startNote()  // theremin note starts playing, called by mouse-down
   void releaseNote()  // theremin note released, called by mouse-up
   void updateVolume(float normalizedFloat)  // Y-axis position scaled to float [0..1]
   void updatePitch(float pitch, long timeStamp) // pitch = actual Hz to be played
         // timeStamp (nanotime) = when that pitch occurs
         // the frame where the pitch will be scheduled is calculated from the
         // values stored in startSync()
   void updateVibDepth(float normalizeFloat) // vibrato affects both pitch and volume
   void updateVibRate(float normalizedFloat) // [0..1] corresponds to 2Hz..18Hz
         // distributed via a power function x^2
   void updateTimbre(float normalizedFloat)  // [0..1], corresponds to a range of values
         // preset in synth, sometimes referred to as FM Modulator Index
   void setModulatorFeedback(float normalizedFloat) // more FM stuff, affects timbre

   // control of Echo via the SoundHandler, e.g., sh.setEchoRunning(true);
   void setEchoRunning(boolean echoRunning)  // make the echo effect audible/quiet
   void setEchoMillis(int millis) // time until first echo
   void setEchoVolume(float normalizedFloat)  // volume of echo
   void setEchoFeedback(float d) //

**************
The following function may be useful for generating pitch values procedurally. Midi note values are linear, one per "piano key", with "middle C" = 36. Fractional notes are possible.

   double PitchFunctions.getHertzFromMidi(float midiNoteValue)

The package of this static class: com.adonax.pfaudio.midi

(Please message me if you want to use this as an external library in any game or application you are making.)

music and music apps: http://adonax.com
Offline leif81

Innocent Bystander





« Reply #2 - Posted 2016-09-09 13:16:28 »

Very cool.

Do you happen to have the source for this on github or a similar site?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CommanderKeith
« Reply #3 - Posted 2016-09-09 13:27:35 »

Nice app, worked fine for me on windows 10 java 8.
The default settings make a spooky wail. Will be interesting to see how you and others tune and use it.
I have no experience in how to make or use sound but intend to learn one day.

Offline philfrei
« Reply #4 - Posted 2016-09-09 19:43:04 »

Very cool.

Do you happen to have the source for this on github or a similar site?

Thank you for the compliment!

The only code that is posted has been posted here on JGO over the years. I've been working on getting better at using Java Sound (javax.sound.sampled) for several years now, and the posting reflect progress made and issues dealt with. Some of the later code is better than the earlier stuff I posted.

I am happy to answer questions on it or on how to make things using Java Sound. I have a notification attached to the jgo audio forum and always check on anything posted there.

music and music apps: http://adonax.com
Offline philfrei
« Reply #5 - Posted 2016-09-09 19:56:09 »

Nice app, worked fine for me on windows 10 java 8.
The default settings make a spooky wail. Will be interesting to see how you and others tune and use it.
I have no experience in how to make or use sound but intend to learn one day.

Good to hear!

Re learning audio: no time like the present!

You comment brings up a point though which is that I haven't made a place where people can share patches. Maybe, since they are text files (xml, that is), the simplest thing is to post patches on this thread if anyone wants to share? I don't think I can support a forum on my website. Maybe it is possible but I haven't figured out how.

I've been meaning to post more myself, but I'm letting "perfect pictures" get in the way. I've been intending to do things like rent "The Day the Earth Stood Still" or "The Red Planet" and try and replicate the effects used there, or maybe try and match the theremin in "Good Vibrations" or "Dark Shadows". Too ambitious, should just post some that illustrate basic capabilities.

I did make one upgrade to the program a few weeks ago. There's a trade off with screen size, pitch range and pitch precision. The wider the range, the more difficult it is to hit specific notes. What I came up with is this: when hitting the shift key, the mouse pitch stays the same, playing or not, where ever you move. Thus either in silences or on held notes, use of the shift key and maneuvering can shift the screen pitch range to the area you wish to play in.

music and music apps: http://adonax.com
Offline Riven
Administrator

« JGO Overlord »


Medals: 1324
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2017-08-30 08:24:03 »

Unlocked Pointing

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline philfrei
« Reply #7 - Posted 2017-08-31 22:35:04 »

Progress report, and an attempt to figure out what to do next. It is hard to write about the design issues without cranking out a full article.

Updated project file: PFTheremin.jar.

I've started collecting YouTubes of famouse examples, and then try to duplicate the sounds. It's been an interesting exercise.

Question:

Can I publish a video with short clips from famouse uses: clip of Theremin himself playing, clip from "Day the Earth Stood Still", "My Favorit Martian", "Dark Shadows", wav clip from Beach-Boys "Good Vibrations" and keep the shots under something like 5-10 seconds and have it be considered a "Fair Use"?

It would be nice to show this theremin recreating those sounds, to the best of its ability. Seems like a video like this could be made inexpensively (assuming the only additional footage is just deskcam and screenshots). I have a decent microphone, so it seems like it should be possible to make something like this to support sales without spending multiple thousands on video production. As an indy programmer, we get some latitude on video "polish", yes?

Mulling (need to prioritize):

1) Maybe make a finer discrimination on the pitch width: to the nearest 0.5 or 0.25 octave rather than just a number of octaves. [EDIT: Just changed it to 0.5. Haven't uploaded yet.]

PURPOSE: can more finely tune the screen to spread an intended note range (e.g., you have a specific song in mind) over as much screen real estate as possible.

The <Shift> function also addresses the pitch-range vs. accuracy problem, by allowing one to move the screen location of a pitch.

2) Make the window resizable. This was partially addressed by making the settings panal have two sizes. To do this, I made the horizontal width a variable rather than a constant. That gets us partially there.

PURPOSE: again, addressing the pitch range vs accuracy issue.

3) Add a couple more synths? I came across an algo for making an FM synth have a "formant". If it works, it would be possible to make the Y-axis cover a range of vowel sounds. Could be going oooh-aaah-eeee-aaah with the synth. IF it works as a synth. Algo was from Bill Schottstaedt, mentioned in Charles Dodge's "Computer Music" book.

Other synths might be an actual sawtooth or square via wave-table synthesis + filter, or some nice string synth options.

PURPOSE: more tonal qualities possible.

4) Add another "effect", e.g., a flanger with standard modulator controls. Flangers are relatively easy effects to code. Or add some other effect? Chorus and distortion come to mind. If so, and a question in general: should the effects settings be part of the save/load? Or separate save/loads?

5) Record mouse/keyboard events as macros. Allow playback of macros. Allow export to wav of macros. (I am reluctant to simply try to put in a direct save-to-wav for various reasons.) I did some refactoring so that the data going to the audio player comes exclusively via the AnimationTimer (JavaFX) and not from the asynchronous inputs. This makes the input data 60FPS, and it should be straightforward to read from a "macro" file rather than from the "control" level variables.

6) Mouse tails? Design mouse cursors? What to do about skins on the design. Keep this color-scheme, keep it simple, or do something to give it a cooler look?

7) Ability to move or stretch the keyboard guide vertically?

8 ) Add an alternative "vibrato" key? (V? I am reserving <SpaceBar> for macro recording.) This would be used as an alternate way to intensify the vibrato for given pitches. The configuration could get complex: as we have both the amount it would add and the rate at which this additional vibrato would come on and drop off.

PURPOSE: theremin players often reserve vibrato for given notes, like a musician or singer would. On a real theremin, this is done with a separate hand, not with the mouse doing everying. Clear example: listen to "Good Vibrations" where the vibrato is mostly on the third note of the pattern that is played.

9) Come up with a better name for the program?

10) Free or $1 version and "deluxe" version (only a couple more $)? If so, what features would go on each?

I'm thinking of marketing on itch.io, for starters.

Definite TO-DO list:
  • Clean up the use of .properties file. [I've been avoiding finshing/testing the details of save/load.]
  • Add JVM so it can be stand-alone.
  • Add "Help/instructions" (how much? post online link instead?) and "About" info.
  • Make some patches to go along with the instrument.

Current GUI:


music and music apps: http://adonax.com
Offline basil_

« JGO Bitwise Duke »


Medals: 418
Exp: 13 years



« Reply #8 - Posted 2017-09-01 10:25:28 »

nice one Smiley
reminds me on https://play.google.com/store/apps/details?id=com.zebproj.etherpad

i'd throw it in into my mix if it'd support ..

- asio
- midi-in
- midi-mapping

o/
Offline philfrei
« Reply #9 - Posted 2017-09-01 23:32:29 »

@basil_
Quote
i'd throw it in into my mix if it'd support ..

- asio
- midi-in
- midi-mapping

I had closed my mind to making plugins for DAW's because there seems to be so little in terms of Java support for this. Most audio is written in C++ afaik. But maybe if one is including a JVM in the jar, there would be a way to use Java as a VST.

Do you know of resources to learn how to do this? Did you have another plan in mind besides VST?

As far as the theremin, it seems to me there might already be good ones available. Any digital implementation of a ribbon controller, for example, could suffice.

It might be nice to have the 2D screen pop up within the DAW for live recording. In that case, I'm wondering about saving as 60fps stream data rather than converting to midi control events. But maybe interfacing the MIDI system is more practical.

One thing, though, there would be no need to worry about the built in echo or adding more effects, as it is easy to add them in the mix on a DAW.

music and music apps: http://adonax.com
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Catharsis

JGO Ninja


Medals: 73
Projects: 1
Exp: 21 years


TyphonRT rocks!


« Reply #10 - Posted 2017-09-02 00:59:38 »

I had closed my mind to making plugins for DAW's because there seems to be so little in terms of Java support for this. Most audio is written in C++ afaik. But maybe if one is including a JVM in the jar, there would be a way to use Java as a VST.

Do you know of resources to learn how to do this? Did you have another plan in mind besides VST?
more effects, as it is easy to add them in the mix on a DAW.

I can't exactly point you to any 3rd party resources I might have used in the distant past (circa '08 last time I recall), but it's possible to create VST plugins with Java w/ a GUI and all. Instead of audio processing I had several Java / VST plugins which didn't process audio at all, but took VST control data input w/ a Java2D GUI outputting OSC to SuperCollider allowing these plugins to be automated in any VST host; AudioMulch was the test bed back then.

Just search for "java VST" or "java VST tutorial". It's definitely possible and things worked fine and I suppose audio processing w/ Java would be as well though I was mainly focused on the GUI / control data to OSC aspect in my own efforts.

Check out the TyphonRT Video Suite:
http://www.typhonvideo.com/

Founder & Principal Architect; TyphonRT, Inc.
http://www.typhonrt.org/
http://www.egrsoftware.com/
https://plus.google.com/u/0/+MichaelLeahy/
Offline philfrei
« Reply #11 - Posted 2017-09-02 01:07:16 »

Search uncovered this:
http://jvaptools.sourceforge.net/index.html
Will check it out.

I don't remember this being here a couple years ago, last time I looked. (Date on bottom says last update 2006!)

I had a couple ideas for VST's. Wanted to do a fancy volume (key velocity) overlay (kind of like a transpose amount for key selection) to a given midi part, with tools geared to metrical patterns.

music and music apps: http://adonax.com
Offline Catharsis

JGO Ninja


Medals: 73
Projects: 1
Exp: 21 years


TyphonRT rocks!


« Reply #12 - Posted 2017-09-02 01:13:41 »

http://jvaptools.sourceforge.net/index.html
I don't remember this being here a couple years ago, last time I looked.

The nice thing is that the VST host handles all the MIDI / control data input and forwards it onto the plugin. As mentioned I can't recall which 3rd party Java integration tooling I used.. This also comes up http://jvstwrapper.sourceforge.net/. Hah, being SourceForge that is about right circa aughts. It was pretty straightforward and performance was fine and this was a while ago.

It'd be great to see some of your efforts integrate w/ VST as that will provide a continuity w/ general music production environments that is better than standalone apps.

Check out the TyphonRT Video Suite:
http://www.typhonvideo.com/

Founder & Principal Architect; TyphonRT, Inc.
http://www.typhonrt.org/
http://www.egrsoftware.com/
https://plus.google.com/u/0/+MichaelLeahy/
Pages: [1]
  ignore  |  Print  
 
 

 
xxMrPHDxx (22 views)
2017-11-21 16:21:00

xxMrPHDxx (14 views)
2017-11-21 16:14:31

xxMrPHDxx (17 views)
2017-11-21 16:10:57

Ecumene (117 views)
2017-09-30 02:57:34

theagentd (151 views)
2017-09-26 18:23:31

cybrmynd (260 views)
2017-08-02 12:28:51

cybrmynd (254 views)
2017-08-02 12:19:43

cybrmynd (248 views)
2017-08-02 12:18:09

Sralse (260 views)
2017-07-25 17:13:48

Archive (882 views)
2017-04-27 17:45:51
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!