public class SampledSound
extends java.lang.Object
PlayThread
thread. This thread is created once and, when it has nothing to do (no sound is to be played)
it will just go to sleep. A new thread is NOT created every time a sound is to be played.The only soundfile allowed are 20KHz ".UB" files. The general contract with the SMSQ/E's ssss is that whenever a sampled is to be sent to the ssss, smsq gets here via the corresponding trap (playsound). Then the independent job is started which copies the data from the SMSQE buffer to the buffer set up here.
There is a bug in the java SourceDataLine : if one repeatedly sends it small sound samples, the sound is repeated indefintely (in total or in part) until the dataline is closed/stopped. To try to get around this, a special flag may be set that tells this, a new vector is introduced into the SSSS in SMSQ/E, that will cause the PlayThread to empty and STOP the SoundDataLine once the queue is empty.
Constructor and Description |
---|
SampledSound(short[] DMAAccess,
MC68000Cpu cpu,
int volume,
Warnings warn,
java.lang.String frequency)
Creates this object, a DataLine object and an independent thread for filling the DataLine.
|
Modifier and Type | Method and Description |
---|---|
void |
closeSound(boolean close)
Signals that once queue is empty sound should be killed:
This tries to get around a java bug.
|
void |
fillPointers(MC68000Cpu cpu)
Fill in the pointers to the data area for this sampled sound.
|
void |
killSound(MC68000Cpu cpu)
Tries to kill the currently played sound.
|
void |
playSound(MC68000Cpu cpu)
Wakes up the Sound job, if need be.
|
boolean |
querySoundClose()
Checks whether sound is set to be killed when queue empty.
|
int |
queryVolume()
Queries the current volume or -1 if line no longer active.
|
void |
setMemory(short[] memory)
Sets the memory used by the cpu.
|
void |
setVolume(int percentage)
Sets the sound volume.
|
public SampledSound(short[] DMAAccess, MC68000Cpu cpu, int volume, Warnings warn, java.lang.String frequency)
cpu
- the cpu.DMAAccess
- : the cpu's memory, for direct access to it.volume
- the volume the sound is to have : 0 -100.warn
- a flag, if true
, warn if sound problems may arise in the future.frequency
- either "22.05" or "20" (any other value will be set to 22.05) : frequency in KHz.public void fillPointers(MC68000Cpu cpu)
cpu
- the smsqmulator.cpu.MC68000Cpu used.public void setMemory(short[] memory)
memory
- the memory (array of short) to set.public void setVolume(int percentage)
percentage
- the volume, from 0 (no sound) to 100 (loudest).public void killSound(MC68000Cpu cpu)
cpu
- the smsqmulator.cpu.MC68000Cpu used.public void playSound(MC68000Cpu cpu)
cpu
- the cpu used.public int queryVolume()
public void closeSound(boolean close)
close
- set to true
if the sound should be killed if queue empty.public boolean querySoundClose()
true
if the sound should be killed if queue empty.