Expand description
DOS-era sound devices sharing one timestamped hardware timeline.
Game code owns DosAudio; an audio callback owns AudioEngine. Port
commands cross a bounded queue with Tick timestamps from
game-toolkit-dosbus. Music is prepared before playback and sequenced on the
audio thread. OfflineMachine uses the same renderer without audio I/O.
use game_toolkit_dosaudio::{OfflineMachine, SoundConfig};
use std::time::Duration;
let mut machine = OfflineMachine::new(SoundConfig::none().speaker(true), 48_000)?;
machine.sound(440.0)?;
machine.render_for(Duration::from_millis(100))?;
machine.nosound()?;
machine.render_for(Duration::from_millis(20))?;
let wav_bytes = machine.finish().to_bytes()?;
assert_eq!(&wav_bytes[..4], b"RIFF");Re-exports§
pub use midi::MidiBackend;pub use midi::MidiMessage;pub use midi::MidiSynth;pub use music::MusicController;pub use music::MusicDevice;pub use music::MusicEvent;pub use music::MusicHandle;pub use music::MusicTarget;pub use music::PlayOptions;pub use music::PreparedMusic;pub use music::Sequence;pub use music::Soundtrack;pub use music::TimedEvent;pub use sfx::SfxHandle;pub use sfx::SfxMixer;pub use sfx::SfxVoiceHandle;
Modules§
- formats
- Music files decoded into immutable, timestamped sequences before playback.
- midi
- MIDI messages and synthesis adapters shared by ports and prepared music.
- music
- Immutable, timestamped music and playback controls.
- prelude
- Common machine, device and music types.
- sfx
- Controls for a finite Sound Blaster PCM buffer on the machine timeline.
Structs§
- Audio
Engine - Audio-thread synthesis, also used by offline rendering.
- Capture
- A game-thread register trace. Capturing allocates only on the control thread.
- Conventional
Memory - Shared, zero-initialized conventional memory spanning physical addresses 00000h through FFFFFh. Clones share the same bytes without locking.
- DmaChannel
- An ISA DMA data channel: 0 through 3 or 5 through 7.
- DmaCompletion
- A DSP block completion observed while servicing attached conventional memory.
- DmaController
- The two PC/AT 8237 DMA controllers, serviced one unit per device request.
- DmaRequest
- An asserted DMA request (DRQ), without a memory address or transfer count.
- DosAudio
- Game-thread hardware control, including port reads and device timers.
- Engine
Stats - Observable synthesis counters, independent of callback buffer size.
- IrqLine
- An ISA interrupt request line, IRQ 0 through IRQ 15.
- IrqRequest
- The current level driven by a device on an IRQ line.
- Melody
- A finite, prepared subset of the QBasic PLAY music macro language.
- Music
Capture - Control-thread reader for synthesis register writes applied by the audio engine.
- Note
- An equal-tempered MIDI note, with A4 tuned to 440 Hz.
- Offline
Machine - Both hardware halves on one thread, with no audio device or window.
- Opl
- Borrowed musical access to the same FM hardware used by port I/O and music.
- OplBank
- An owned, sorted bank with allocation-free binary-search lookup.
- OplBank
Entry - One named instrument in a sorted bank.
- OplBank
Key - An address in an OPL MIDI instrument bank. Programs and drum keys are zero-based.
- OplInstrument
- A two-operator instrument, optionally layered with a second independent voice.
- OplMidi
Driver - General MIDI messages translated to the installed OPL’s two-operator voices.
- OplOperator
- The five register values describing one FM operator.
- OplPatch
- A two-operator instrument, including channel feedback and connection mode.
- Port
Range - A nonempty inclusive range of 16-bit I/O ports.
- Port
Write - A successful game-thread port write and its absolute machine timestamp.
- Sound
Blaster Config - ISA resources shared by Sound Blaster playback models.
- Sound
Config - Hardware and output configuration. Builders are validated by
DosAudio::split. - Speaker
Handle - Cloneable controls for an independently sequenced PC-speaker track. Dropping the last clone requests a stop, just like a music handle.
- Tick
- An instant or duration in cycles of the PC’s 315/22 MHz crystal.
- Tick
Accumulator - Converts cycles at a fixed integer frequency to crystal ticks without drift.
- Wav
- Stereo 16-bit PCM WAV output from a deterministic offline render.
Enums§
- DmaDirection
- Direction of a DMA transfer, named from the device’s perspective.
- DmaUnit
- One bus-width unit delivered by the host DMA controller.
- DmaWidth
- Width of one ISA DMA transfer unit.
- Drum
- Percussion key bits in the first OPL bank’s rhythm register.
- Error
- Errors reported during configuration, port I/O and format loading.
- OplBackend
- FM synthesis implementation selected at machine creation.
- OplChip
- Installed Yamaha FM hardware.
- SbModel
- Sound Blaster playback hardware and DSP generation.
Traits§
- IoDevice
- A device on the host’s timestamped, byte-wide I/O bus.
- OplCore
- A synthesis core running at one frame per 288 master-crystal ticks.
Functions§
- speaker_
pwm - Prepare binary speaker pulses with duty cycle
sample / 255per input period.