uk.co.javagear
Class SN76496

java.lang.Object
  extended by uk.co.javagear.SN76496

public final class SN76496
extends java.lang.Object

Texas SN76496 Emulation.

Version:
18th January 2003
Author:
Copyright (C) 2002-2003 Chris White
See Also:
"JavaGear Final Project Report"

Field Summary
private  javax.sound.sampled.AudioFormat audioFormat
          Specifies the arrangement of sound data.
private  byte[] buffer
          Buffer for sound data.
private  ToneGenerator chan0
          Tone Generator 1.
private  ToneGenerator chan1
          Tone Generator 2.
private  ToneGenerator chan2
          Tone Generator 3.
private  NoiseGenerator chan3
          Noise Generator.
private  double clockSpeed
          PSG Clock Speed.
private  ToneGenerator currentGenerator
          Pointer to current Tone Generator.
private  boolean enabled
          Sound Enabled.
private  java.io.FileWriter fileWriter
          For Recording Sound to Disk.
private  javax.sound.sampled.SourceDataLine line
          The line that transmits audio to speakers.
private  boolean recording
          Record Sound to Disk.
private  int sampleRate
          Output Sample Rate.
private  int samplesPerFrame
          Samples to Generate per video frame.
 
Constructor Summary
SN76496(double c, int s)
          SN76496 Constructor.
 
Method Summary
private  void convertToWav()
          Convert RAW output to WAV file.
 boolean isEnabled()
          Returns true if this instance of SN76496 is enabled and false otherwise.
 void output()
          Convert PSG settings to Java Sound.
 void reset()
          Reset SN76496 to Default Values.
 void setChannelEnabled(int channel)
          Toggle a particular channel On/Off.
 void setEnabled()
          Toggle SN76496 On/Off.
 void setFPS(int v)
          Set current FPS Rate.
 void setRecord()
          Toggle sound recording to WAV file.
private  void startRecording()
          Start sound recording to WAV file.
 void startSound()
          Start emulation.
 void stopRecording()
          Stop sound recording to WAV file.
 void stopSound()
          Stop emulation.
 void write(int value)
          Program the PSG.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chan0

private ToneGenerator chan0
Tone Generator 1.


chan1

private ToneGenerator chan1
Tone Generator 2.


chan2

private ToneGenerator chan2
Tone Generator 3.


chan3

private NoiseGenerator chan3
Noise Generator.


currentGenerator

private ToneGenerator currentGenerator
Pointer to current Tone Generator.


buffer

private byte[] buffer
Buffer for sound data.


fileWriter

private java.io.FileWriter fileWriter
For Recording Sound to Disk.


audioFormat

private javax.sound.sampled.AudioFormat audioFormat
Specifies the arrangement of sound data.


line

private javax.sound.sampled.SourceDataLine line
The line that transmits audio to speakers.


clockSpeed

private double clockSpeed
PSG Clock Speed.


sampleRate

private int sampleRate
Output Sample Rate.


samplesPerFrame

private int samplesPerFrame
Samples to Generate per video frame.


enabled

private boolean enabled
Sound Enabled.


recording

private boolean recording
Record Sound to Disk.

Constructor Detail

SN76496

public SN76496(double c,
               int s)
SN76496 Constructor.

Parameters:
c - Clock Speed (Hz)
s - Sample Rate (Hz)
Method Detail

reset

public void reset()
Reset SN76496 to Default Values.


isEnabled

public boolean isEnabled()
Returns true if this instance of SN76496 is enabled and false otherwise.

Returns:
true if enabled.

setEnabled

public void setEnabled()
Toggle SN76496 On/Off.


setChannelEnabled

public void setChannelEnabled(int channel)
                       throws java.lang.IllegalArgumentException
Toggle a particular channel On/Off.

Parameters:
channel - channel to toggle (0-3)
Throws:
java.lang.IllegalArgumentException - if the value of channels is not 1, 2 or 3.

setFPS

public void setFPS(int v)
Set current FPS Rate. Required to generate the correct number of samples per frame.

Parameters:
v - FPS Rate

write

public void write(int value)
Program the PSG. Connected this procedure to a Z80 Port.

Parameters:
value - Value to write (0-0xFF)

startSound

public void startSound()
Start emulation.


stopSound

public void stopSound()
Stop emulation.


output

public void output()
Convert PSG settings to Java Sound.


setRecord

public void setRecord()
Toggle sound recording to WAV file.


startRecording

private void startRecording()
Start sound recording to WAV file.


stopRecording

public void stopRecording()
Stop sound recording to WAV file.


convertToWav

private void convertToWav()
Convert RAW output to WAV file.



Copyright © 2007 JavaGear. All Rights Reserved.