Skip to main content

OfflineMachine

Struct OfflineMachine 

Source
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

Source

pub fn new(config: SoundConfig, sample_rate: u32) -> Result<Self>

Create an offline machine at the supplied sample rate, with zero latency.

Source

pub fn now(&self) -> Tick

Current emulated machine time.

Source

pub fn inb(&mut self, port: u16) -> u8

Read a port at current machine time.

Source

pub fn outb(&mut self, port: u16, value: u8) -> Result<()>

Write a port at current machine time.

Source

pub fn next_dma_tick(&self) -> Option<Tick>

Earliest outstanding Sound Blaster DMA request.

Source

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.

Source

pub fn dma_write16(&mut self, channel: DmaChannel, value: u16) -> Result<()>

Deliver one word-wide SB16 DMA unit at the current machine timestamp.

Source

pub fn attach_dma(&mut self, memory: Arc<ConventionalMemory>) -> Result<()>

Attach conventional memory and route the internal 8237’s programming ports.

Source

pub fn poll_dma_completion(&mut self) -> Option<DmaCompletion>

Observe one memory-DMA block completion without acknowledging its IRQ.

Source

pub fn next_dma_block_tick(&self) -> Option<Tick>

Next predicted DSP block boundary, unless stopped or paused.

Source

pub fn irq_request(&self) -> Option<IrqRequest>

Current Sound Blaster IRQ line and level, without acknowledging it.

Source

pub fn sound(&mut self, hz: f64) -> Result<()>

Start a PC speaker tone through the PIT registers.

Source

pub fn nosound(&mut self) -> Result<()>

Disconnect the PC speaker.

Source

pub fn play( &mut self, sequence: impl Into<PreparedMusic>, ) -> Result<MusicHandle>

Install a finite, non-looping soundtrack at current output time.

Source

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.

Source

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.

Source

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.

Source

pub fn advance_to(&mut self, at: Tick) -> Result<()>

Advance both halves and capture every complete output sample up to at.

Source

pub fn render_for(&mut self, duration: Duration) -> Result<()>

Advance by a duration, retaining the existing machine timestamp.

Source

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.

Source

pub fn finish(self) -> Wav

Finish a manually timed capture without adding any samples.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.