Struct exmod::Context[][src]

pub struct Context(_);
Expand description

Module context.

Can contain only one module and provides functions for manipulating it.

Implementations

Create a context.

The module parameter sets a contents of the module. The rate parameter specifies a sample rate (in Hz) with which samples will be generated.

Example
use exmod::Context;

let context = Context::new(include_bytes!("module.xm"), 44100).unwrap();

// And start working with it...

Returns a raw pointer to the inner context.

Creates a context directly from the raw pointer of another context.

Safety

pointer must be previously allocated via new and then as_ptr functions or their unsafe equivalent - xm_create_context_safe.

Play the module and put a generated samples in the samples slice.

Creates silence if the loop count specified by set_max_loop_count is reached. By default plays endlessly.

Requires mutability because generating samples moves a playback cursor within context.

Example

See examples repository folder for comprehensive examples.

Get the current number of playback loops of the module.

The number will increase with each loop. When the maximum number of loops is reached, calls to generate_samples will only generate silence. You can set number of maximum loops with set_max_loop_count.

Set the max number of playback loops of the module.

Set to 0 to loop indefinitely. By default max loop count is 0 (i. e. infinity).

See also current_loop_number.

Get the number of module channels.

Get the module length.

Get the number of module patterns.

Get the number of module rows.

Get the number of module instruments.

Get the number of samples of the given instrument.

Get the panning of the given channel.

Returns a panning between 0 (L) and 1 (R).

Get the volume of the given channel.

Returns a volume between 0 or 1.

Get the frequency in Hz of the given channel.

Check if the channel is active.

Get the latest trigger of the given instrument.

Get the latest time (in number of generated samples) when the given instrument was triggered in any channel.

Get the latest trigger of the given sample of the given instrument.

Get the latest time (in number of generated samples) when the given sample of the given instrument was triggered in any channel.

Get the latest trigger of the given channel.

Get the latest time (in number of generated samples) when any instrument was triggered in the given channel.

Get the module playing speed.

Get the current playback position.

Mute the given channel.

Mute the given instrument.

Seek the playback cursor to the specified position.

Safety

Seek feature is broken by design and usually leads to access violation error, use at your own risk.

Get the module name.

Get the the name of the tracker in which the module was created.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.