Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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  
  Ogg Vorbis is a red herring  (Read 3956 times)
0 Members and 1 Guest are viewing this topic.
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Posted 2011-11-19 01:48:59 »

...turns out that just putting code in to decode Oggs into ByteBuffers cost about 4k, and then, the samples themselves are sort of massive really compared to anything else. So sound effects from Oggs don't appear to be such a great idea after all Smiley  Back to the drawing board on that one.

In other news, just to show you how completely rubbish I am at all this, so far I've got a black screen up in about 6800 bytes. Admittedly it's a very nice black screen which resizes, remembers its position between runs, can be toggled between fullscreen and windowed, paused, fades volume out when inactive and back in again, is perfectly rate locked at 60Hz, and automatically adjusts its aspect ratio correctly for any size of display. But, er, you get the idea. Hm...

Cas Smiley

Offline thaaks

Junior Member


Medals: 1
Projects: 1



« Reply #1 - Posted 2011-11-20 14:59:31 »

In other news, just to show you how completely rubbish I am at all this, so far I've got a black screen up in about 6800 bytes. Admittedly it's a very nice black screen which resizes, remembers its position between runs, can be toggled between fullscreen and windowed, paused, fades volume out when inactive and back in again, is perfectly rate locked at 60Hz, and automatically adjusts its aspect ratio correctly for any size of display. But, er, you get the idea. Hm...
Sounds like a perfect powerful black screen to me  Grin

Would you mind to release the source? I mean - that sounds like it's basically one of the best startup codes you could get for any LWJGL game, right? A commented version would be a jewel in the LWJGL wiki for example  Cool

Offline philfrei
« Reply #2 - Posted 2011-11-20 20:09:56 »

I got discouraged about using Ogg/Vorbis as well.

I'm currently pursuing two ideas. One is to see what can be done generating SF/X with FM synthesis (frequency modulation). The overhead for FM is remarkably light. Biggest cost is maybe two K for a good sized sine wave table. It's just a matter of figuring out how to program the various needed SF/X. I'm hopeful as I have a good decade of DX7 programming behind me, including a fair number of SF/X in my library that can potentially be plundered. Hoping to make some more progress later in the week. (It COULD also be a way to encode and play back musical ditties.)

What kind of SF/X exactly are you hoping for?

The second idea is to work off of samples, but in a more efficient fashion. The ClipTrack is the most recent thing I wrote. It works like a Clip, but allows one to replay with overlap, including playback at different speeds. I am thinking, also, the source data doesn't have to be stereo, and there may be other ways to compact things. For example, using a form of granular synthesis, make continuous effects (rain, running water, fire, wind) from random assembly of a few fragments rather than multi-second samples. Or even just use a lower resolution in the storage. It can be totally arbitrary, as long as the operation to convert to the correct resolution is no more than a multiply. Maybe even A-law or mu-law quantization of the audio would work, as these are cheap in terms of cpu to decode (compared to mp3 or ogg/vorbis).

With the ClipTrack, for example, one can take a single sample of a bell, and play it back at several different speeds, making a melody. The gun shot effect I demo on this site
http://www.hexara.com/VSL/AudioMixerDemoWarOfWorlds.htm
kind of works as an explosion as well (again, different speeds). But slowed down effects are better if they originate in the distance, due to frequency rolloff.

I am happy to share any of this code (would be honored).

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ShannonSmith
« Reply #3 - Posted 2011-11-20 20:40:29 »

I got a pretty decent FM synth to fit in ~2k intended for the 4K contest.

http://www.angryoctopus.co.nz/java4k/Synth4K

I'm re-writing it for this years contest, trying to get it under 1K.
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2011-11-20 22:35:36 »

That 4k synth sounds ideal.

All my source code ends up completely open generally - I'll release my brilliant Black Screen Game on the first milestone deadline Smiley

Cas Smiley

Offline philfrei
« Reply #5 - Posted 2011-11-21 08:35:20 »

I totally overlooked that this topic was a "limited space" contest.  Clueless

The AngryOctapus FM code has been fun to look through! Thanks for posting that ShannonSmith! Impressive how long some of those musical cues are, given the size of the code.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2011-11-21 09:35:39 »

Maybe too limited Cheesy We'll see how it goes. If I had my way it'd be LWJGK64k but I have a feeling someone would indulge in a massive techno-wank and do some shader based extravaganza and demoralize everyone with a stunning graphical demo. I'd still give it 0/10 for shit gameplay though Smiley

Cas Smiley

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #7 - Posted 2011-11-21 21:44:19 »

Ogg/Vorbis files got about 3.5k of header overhead. This overhead collapses inside a solid archive, because that whole thing is essentially the same for all of your samples (except for 12 bytes somewhere at the beginning).

Zip (or jar for that matter) doesn't allow you to create solid archives.

(Solid archive = everything is compressed in one go, not individually.)

弾幕 ☆ @mahonnaiseblog
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2011-11-21 22:26:52 »

I pack my wavs into a single OGG file normally. Unfortunately all of my OGGs are huge anyway and I can't find a way of compressing them further.
Not to worry though, I've got an FM soft synth working in about 5kb so far. Though I can't get it to produce satisfactory noise. Any tips on producing noise that actually varies with pitch? (Just using Math.random() produces uniform white noise at any pitch!)

Cas Smiley

Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #9 - Posted 2011-11-21 22:48:24 »

I pack my wavs into a single OGG file normally. Unfortunately all of my OGGs are huge anyway and I can't find a way of compressing them further.
Not to worry though, I've got an FM soft synth working in about 5kb so far. Though I can't get it to produce satisfactory noise. Any tips on producing noise that actually varies with pitch? (Just using Math.random() produces uniform white noise at any pitch!)

Cas Smiley

1  
2  
3  
                int n = (int)(RATE/(2.0*frequency));
                if (j%n==0) {
                    sample = 2.0*Math.random()-1.0;


Only a code fragment from a 3 channel + noise synth I was playing with.  The noise channel worked by only taking a new random number at the frequency specified by the note, effectively giving a noise low pass filtered at the note frequency.  It's a bit rough and ready, but takes very little code.

Time flies like a bird. Fruit flies like a banana.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline philfrei
« Reply #10 - Posted 2011-11-22 02:15:13 »

@Alan_W: cool idea! I have to try it out, myself.

Would varying amounts of lp filtering do the job? There's a "classic" cheap and easy low pass filter.

For an audio stream of random values:

1  
outputValue[N] = outputValue[N-1] + filterAmount * (audioStream[N] - outputValue[N-1])


filterAmount ranges from 0 to 1.

http://en.wikipedia.org/wiki/Low_pass_filter
from "Algorithmic Implementation" near the end of the article.

I haven't tried it on noise, but it worked pretty well on a sawtooth wave I generated via a wavetable, yesterday. (Just starting to learn about filters.) I found I had to make the values pretty close to 0 to hear any effect, so some scaling other than linear will probably be needed.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline ShannonSmith
« Reply #11 - Posted 2011-11-22 05:41:04 »

As has been suggested, you can easily generate 1 bit pitched noise by generating a new sample (randomly 1 or -1) every period. This is how old consoles like the NES work and it sounds pretty good. Alternatively you can low pass filter white noise and there are a bunch of different filters with varying characteristics. State variable filters are about as simple you can get, have resonance to play with and low/high/bandpass simultaneously available:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
// z1 z2 are member variables for filter memory
// f = sin(2*PI*cut)  cut = normalized cutoff frequency (0-1)
// q = 1/res            res = resonance (0 - ~10)
public float process(float in){
  float lowPass = (z2 + f*z1);
  float highPass = in - lowPass - q*z1;
  float bandPass = z1 + f*highPass;
  z1 = bandPass;
  z2 = lowPass;
  return lowPass; // could return high or bandpass outputs for different sounds
}


This filter becomes a bit unstable at extremes so you probably want to constrain the cutoff to 0.01 - 0.99.
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #12 - Posted 2011-11-22 05:41:41 »

@philfrei

Looks good to me.  I hadn't realised a LPF could be done in so little code.  It would be interesting to compare the two results.  I imagine the roll-off could be different.

Edit: @ShannonSmith.  The HPF and BPF look good too.  I'm thinking about reworking my synth.  The main drawback is that it doesn't support tempo changes.  Once that's fixed, the next thing on the list is programmable channels.  I was considering a program definition that specified the amount of each harmonic used in the note generation to see what variety that would give me.  Also easy is programmable attack/decay (currently fixed attack/decay is used to avoid glitches).  I was wondering about some sort of pitch bend capability, perhaps as simple as specifying a rate of increase/decrease in frequency from the starting note. Other nice to have features are hall effect and modulation.  Of course this all adds more code, so perhaps a music based game.

Regards, Alan

Time flies like a bird. Fruit flies like a banana.
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #13 - Posted 2011-11-22 09:29:17 »

I reckon once optimised, proguarded, and compressed the whole synth will be under about 3kb and will provide a huge wealth of sounds for a game.

Sound is critical to most games. I wish more people realised this!

Cas Smiley

Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #14 - Posted 2011-11-22 13:51:47 »

@ShannonSmith - love that filter code - just excellent! My synth is now doing noise, triangle, sine and square waves, FM, AM, polyphony, and has envelopes for ADSR, pitch, resonance, and cutoff. Combined with reverb and echo from OpenALSoft I think I should be able to get a whole load of cool sounds out of it.

Cas Smiley

Offline ShannonSmith
« Reply #15 - Posted 2011-11-22 16:26:10 »

Be careful, I wanted a to write a simple soft-synth for use in a game engine a few years ago and since then I've finished 15 Synths and 0 Games.
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #16 - Posted 2011-11-22 16:38:24 »

Mine is now finished thanks to you and Alan_w Smiley It's still a little large for my liking - though with Pack200, I've got this entire awesome synth and the aforementioned Nice Professional Windowing Code all in 4kb so far. I think it's time to move on to font rendering. I'm budgeting 2k for font rendering.

Cas Smiley

Offline ShannonSmith
« Reply #17 - Posted 2011-11-22 17:20:03 »

You really do have a super-human ability to stay on target and should write a tutorial on how you do that. I literally have 50 game projects that are all about 10% complete. Whoever said getting started is the hardest part needs a swift kick in the bollocks.
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #18 - Posted 2011-11-22 18:30:27 »

You only get to see the public results Smiley I have a pile of unfinished broken projects lying around too, you just don't see so much of them!
Besides, I've been at it for a few days now and still don't have a game to show for it. I'm thinking a vector asteroids game would be a good start so that's what I'm going to aim for, and vector graphics need very little art or memory to do really well. And there should be some awesome blooping and zapping noises.

Cas Smiley

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #19 - Posted 2011-11-22 21:13:07 »

On a related note:

http://www.youtube.com/watch?feature=player_detailpage&v=tCRPUv8V22o#t=314s

Crazy stuff. Cheesy

弾幕 ☆ @mahonnaiseblog
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #20 - Posted 2011-11-23 00:59:07 »

I reckon once optimised, proguarded, and compressed the whole synth will be under about 3kb and will provide a huge wealth of sounds for a game.

Sound is critical to most games. I wish more people realised this!

Cas Smiley
Off-topic: which is why Battlefield 3 is the best game ever Grin

Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #21 - Posted 2011-11-23 01:32:03 »

Indeed - I've heard (no pun intended) many people saying exactly that. The sound is so good you could just close your eyes and crank up the volume and feel like you're there for real.

Cas Smiley

Pages: [1]
  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.

Nickropheliac (15 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (38 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (25 views)
2014-08-16 06:20:21

Tekkerue (35 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (48 views)
2014-08-09 21:09:32
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

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!