public class SoundDevice
extends java.lang.Object
The sound isn"t quite played according to those specs : it's played at 22050 Hz.
There are 9 "devices", SOUND1 to SOUND9:
The advantage of this device over the SmpledSound is that here I know when the sound will stop: this corresponds to the closing of the SMSQ/E channel to the device. I know that after that, no more data will be coming and i can drain the sourcedataline. This gets around the Java bug (see the SampledSopund" class.
The sound itself is played via an independent thread.
This device only allow ONE channel to be open to it at a time.
The actual playback is handled by an independent thread.
This implements a simplistic buffering scheme. AT each call from SMSQE (send multiple bytes), these bytes are put into an array of type byte. This array is added to an ArrayList. The playback thread gets a element from this ArrayList and writes it into a sourcedataline.
Constructor and Description |
---|
SoundDevice(int volume,
Warnings warn,
MC68000Cpu cpu)
Creates this object, a DataLine object and an independent thread for filling the DataLine.
|
Modifier and Type | Method and Description |
---|---|
void |
addBytes(MC68000Cpu cpu)
Called to add bytes to the queue.
|
void |
closeChannel()
Called when the sound channel is closed.
|
void |
doIO(MC68000Cpu cpu)
Handle the IO calls.
|
void |
openChannel(MC68000Cpu cpu)
A new channel was opened to this device, start thread, but only if no channel is still open to this device.
|
int |
queryVolume()
Queries the current volume or -1 if line no longer active.
|
void |
setVolume(int percentage)
Sets the sound volume.
|
public SoundDevice(int volume, Warnings warn, MC68000Cpu cpu)
volume
- at what volume sound is played (0...1000)warn
- warning objectcpu
- the cpu used.public void openChannel(MC68000Cpu cpu)
cpu
- the cpu used.public void closeChannel()
public void doIO(MC68000Cpu cpu)
cpu
- the cpu used.public void addBytes(MC68000Cpu cpu)
cpu
- the cpu pointing to the data.public void setVolume(int percentage)
percentage
- the volume, from 0 (no sound) to 100 (loudest).public int queryVolume()