pub struct OfflineMachine { /* private fields */ }Expand description
Both hardware halves on one thread, with no audio device or window.
Writes and time advances use the same queue and renderer as live output. Output is accumulated as time advances. Music sequencers run in the engine, so their tempo is independent of those advances and the chosen render chunk.
Implementations§
Source§impl OfflineMachine
impl OfflineMachine
Sourcepub fn new(config: SoundConfig, sample_rate: u32) -> Result<Self>
pub fn new(config: SoundConfig, sample_rate: u32) -> Result<Self>
Create an offline machine at the supplied sample rate, with zero latency.
Sourcepub fn outb(&mut self, port: u16, value: u8) -> Result<()>
pub fn outb(&mut self, port: u16, value: u8) -> Result<()>
Write a port at current machine time.
Sourcepub fn next_dma_tick(&self) -> Option<Tick>
pub fn next_dma_tick(&self) -> Option<Tick>
Earliest outstanding Sound Blaster DMA request.
Sourcepub fn dma_write(&mut self, channel: DmaChannel, value: u8) -> Result<()>
pub fn dma_write(&mut self, channel: DmaChannel, value: u8) -> Result<()>
Deliver a host DMA byte at current machine time, after advancing to its request.
Sourcepub fn dma_write16(&mut self, channel: DmaChannel, value: u16) -> Result<()>
pub fn dma_write16(&mut self, channel: DmaChannel, value: u16) -> Result<()>
Deliver one word-wide SB16 DMA unit at the current machine timestamp.
Sourcepub fn attach_dma(&mut self, memory: Arc<ConventionalMemory>) -> Result<()>
pub fn attach_dma(&mut self, memory: Arc<ConventionalMemory>) -> Result<()>
Attach conventional memory and route the internal 8237’s programming ports.
Sourcepub fn poll_dma_completion(&mut self) -> Option<DmaCompletion>
pub fn poll_dma_completion(&mut self) -> Option<DmaCompletion>
Observe one memory-DMA block completion without acknowledging its IRQ.
Sourcepub fn next_dma_block_tick(&self) -> Option<Tick>
pub fn next_dma_block_tick(&self) -> Option<Tick>
Next predicted DSP block boundary, unless stopped or paused.
Sourcepub fn irq_request(&self) -> Option<IrqRequest>
pub fn irq_request(&self) -> Option<IrqRequest>
Current Sound Blaster IRQ line and level, without acknowledging it.
Sourcepub fn sound(&mut self, hz: f64) -> Result<()>
pub fn sound(&mut self, hz: f64) -> Result<()>
Start a PC speaker tone through the PIT registers.
Sourcepub fn play(
&mut self,
sequence: impl Into<PreparedMusic>,
) -> Result<MusicHandle>
pub fn play( &mut self, sequence: impl Into<PreparedMusic>, ) -> Result<MusicHandle>
Install a finite, non-looping soundtrack at current output time.
Sourcepub fn play_soundtrack(
&mut self,
soundtrack: Arc<Soundtrack>,
preferred: MusicDevice,
options: PlayOptions,
) -> Result<MusicHandle>
pub fn play_soundtrack( &mut self, soundtrack: Arc<Soundtrack>, preferred: MusicDevice, options: PlayOptions, ) -> Result<MusicHandle>
Play a switchable soundtrack on the same offline synthesis timeline.
Sourcepub fn play_pcm(
&mut self,
samples: impl Into<Arc<[u8]>>,
sample_rate: u32,
) -> Result<SfxHandle>
pub fn play_pcm( &mut self, samples: impl Into<Arc<[u8]>>, sample_rate: u32, ) -> Result<SfxHandle>
Start an unsigned mono PCM buffer, serviced automatically as time advances. Keep its handle alive through rendering; the last byte gets a full hold interval.
Sourcepub fn play_speaker(
&mut self,
music: impl Into<PreparedMusic>,
options: PlayOptions,
) -> Result<SpeakerHandle>
pub fn play_speaker( &mut self, music: impl Into<PreparedMusic>, options: PlayOptions, ) -> Result<SpeakerHandle>
Install independent speaker music or PWM without replacing the main soundtrack.
Sourcepub fn advance_to(&mut self, at: Tick) -> Result<()>
pub fn advance_to(&mut self, at: Tick) -> Result<()>
Advance both halves and capture every complete output sample up to at.
Sourcepub fn render_for(&mut self, duration: Duration) -> Result<()>
pub fn render_for(&mut self, duration: Duration) -> Result<()>
Advance by a duration, retaining the existing machine timestamp.
Sourcepub fn render_to_end(self) -> Result<Wav>
pub fn render_to_end(self) -> Result<Wav>
Render through finite music and/or PCM and a 250 ms release tail.
Keep playback handles alive until this call has completed.