Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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  
  JStella - Pitfall II sound is scratchy, but I don't know why  (Read 5091 times)
0 Members and 1 Guest are viewing this topic.
Offline Mauvila

Senior Newbie





« Posted 2007-09-27 23:12:27 »

Hey folks,
I doubt anyone can easily answer this question, but just in case someone wants an in-depth mystery to solve, I'll ask anyway:
I manage the JStella Atari 2600 emulator project at SourceForge.  It is a translation of Stella, which is open source C++ software.  The sound class is only a loose translation...I sort of had to do the main framework myself, learning about Java Sound as I went. 

Problem : Pitfall II has very scratchy sound, especially jumping, but Stella (its C++ parent) has decent sounds.   I can't figure out why...this may be a fault with another part of the emulator, but I figure the scratchy quality is indicative of some common phenomenon. 

If anyone wants to  hear the scratchy sound, visit http://www.ataritimes.com/jstella/index.php and select Pitfall II.  (Click on applet, then hit F1 to flip RESET switch).
Source code can be found by browsing CVS at https://sourceforge.net/projects/jstella.

Thanks,
JLA
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #1 - Posted 2007-09-28 13:20:03 »

I haven't tried it yet (I'm still at work), but scratchy sound usually means buffer underflows.
Preventing this can be tricky.
What I did in JEmu2 is to measure the time between frames, and generate the correct amount of samples based on both the frame time, and how much the buffer is filled (if the buffer gets too empty, generate more samples to keep the buffer sufficiently filled; if the buffer is getting too full, generate less samples otherwise JavaSound will block).

In case of JStella, maybe you don't really need to measure the time between frames and just assume it will run at the correct speed, preventing you to depend on accurate timing.

But as I said, I'm haven't tried the sound in JStella yet so I don't know if you actually have buffer underflows.
In any case, I'll have a look when I get home.

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #2 - Posted 2007-09-28 19:25:53 »

I just tried it out, but it's definitely not buffer underruns. Maybe it's just 8bit quantization noise I'm hearing?
I'm not sure yet how Atari 2600 sound really works, but it sounds like it could also be some timing error in the sound generation, resulting in the noise. Anyway, I'll do some experimenting...

As an aside, isn't it just totally mindblowing how they could get a game like Pitfall II on the humble Atari 2600?  Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #3 - Posted 2007-09-28 19:44:20 »

Just tried it on the original Stella, but there it sounds about the same... So maybe the noise is just the limition of the original machine?

Offline Mauvila

Senior Newbie





« Reply #4 - Posted 2007-09-29 01:26:23 »

(Yeah, Pitfall II was the coolest game when it came out...so much better than the first.)

On the original (C++) Stella (ver 2.4.1) on my computer, the jumping sound is clear, while on JStella, it is very scratchy.  (JStella standalone has an option to use stereo, where the jumping and sound effects are separate from the music--the sound effects channel is scratchy as a whole).  Moreover, Pitfall 1 sounds are fine...on most ROMs, the sound is great.  A lot of people assumed Java couldn't do this type of sound, and I was skeptical as well, but it overall sounds very good (that is, sounds like the Atari sounded).  Except for this game...

Also, occasionally the emulator will play static/pops from manipulating the menu bar, etc.  I've tried to turn off the sound whenever it's paused to prevent this stuff, but I was curious if there was another way.
Thanks,
JLA 
Offline Mauvila

Senior Newbie





« Reply #5 - Posted 2007-09-29 01:28:36 »

I wonder if it has anything to do with "base amplitude", that is, the number I add to every sample value to prevent popping (or so I've been told).
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #6 - Posted 2007-09-29 02:30:08 »

Ok, now I noticed the problem with the jump sound.
If the original code emulates unsigned 8-bit samples, then I think you did it right (if you mean by the 'base amplitude' the -128 you do there).
I'm not sure yet what is causing the difference in sound, but I don't think it has anything to do with JavaSound but it must be a problem in the emulation code itself. Maybe you can do a trace; somehow isolate the jump sound (patch out the music code in the rom?) and compare the generated samples from JStella with Stella. I'm not very good at 6502 code, so maybe you are more qualified to that :-)

Offline Mauvila

Senior Newbie





« Reply #7 - Posted 2007-09-29 23:40:53 »

Thanks.
Off the subject, how does your Sega Master System emulator work without OpenGL / native add-ons / etc.?
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #8 - Posted 2007-09-30 10:20:51 »

Thanks.
Off the subject, how does your Sega Master System emulator work without OpenGL / native add-ons / etc.?

I'm rendering to an int[] array, which is drawn to screen using ImageProducer (MemoryImageSource is an ImageProducer) in the applet. This is really an old legacy method for rendering, but it works pretty well except that scaling the Image to a bigger size is slow.

Offline broumbroum

Junior Member





« Reply #9 - Posted 2007-09-30 22:04:18 »

So you did not use the MediaTracker and the ImageObserver, did you? Hence it is true that MediaTracker brings faster results out of serveral ImageObserver's. ImageObserver's use the same ImageProducer <-> ImageConsumer relationship to download pictures. They're faster because they download on seperate Threads. So did I understand... Well, the Sound support might be impl. in MediaTracker with one new MediaTracker.SoundMediaEntry (quoting the MediaTracker JDK src).  Roll Eyes
As a consequence, buffering data processes might be slightly modified in the way that they use no DataBuffer's but Reference instead. So that might change the whole rendering process. But I can assume that your JStella is quite fast enough, even though Amiga (is that the correct emulated system ?) gets older and older....

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #10 - Posted 2007-10-01 11:19:25 »

So you did not use the MediaTracker and the ImageObserver, did you? Hence it is true that MediaTracker brings faster results out of serveral ImageObserver's. ImageObserver's use the same ImageProducer <-> ImageConsumer relationship to download pictures. They're faster because they download on seperate Threads. So did I understand... Well, the Sound support might be impl. in MediaTracker with one new MediaTracker.SoundMediaEntry (quoting the MediaTracker JDK src).  Roll Eyes
As a consequence, buffering data processes might be slightly modified in the way that they use no DataBuffer's but Reference instead. So that might change the whole rendering process. But I can assume that your JStella is quite fast enough, even though Amiga (is that the correct emulated system ?) gets older and older....

Emulation is about real time rendering the emulated video and audio outputs, not image/audio loading, so there's no use for MediaTracker.
JStella emulates Atari VCS 2600 console, not the Amiga.

Offline broumbroum

Junior Member





« Reply #11 - Posted 2007-10-02 01:06:02 »

sorry, I'm confusing in the emulatiion universe.  ::)Is the amiga older though?

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Offline Mauvila

Senior Newbie





« Reply #12 - Posted 2007-10-02 06:37:01 »

No, I think the VCS is older...the VCS (2600) to my knowledge was 99.9% games.  it was born around the same time as Star Wars, and it was popular until NES & SMS came along in the mid 80s.
Hmmm...what about an open-source combined 1980s console emulator in Java?  This would treat the VCS as an 80s machine, but the Sega Genesis as a 90s machine...of course, there would need to be a NES component (and possibly the various other machines), which would be work, but at least there is plenty of available C++ code to port.
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.

Riven (4 views)
2014-07-23 21:16:32

Riven (5 views)
2014-07-23 21:07:15

Riven (5 views)
2014-07-23 20:56:16

ctomni231 (40 views)
2014-07-18 06:55:21

Zero Volt (36 views)
2014-07-17 23:47:54

danieldean (30 views)
2014-07-17 23:41:23

MustardPeter (32 views)
2014-07-16 23:30:00

Cero (47 views)
2014-07-16 00:42:17

Riven (48 views)
2014-07-14 18:02:53

OpenGLShaders (38 views)
2014-07-14 16:23:47
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!