libtrackerboy/common

  Source   Edit

Module contains common types used throughout the library. This module is exported by other modules so you typically do not need to import it yourself.

Types

ByteIndex = range[low(uint8).int .. high(uint8).int]
Index type using the range of a uint8 (0-255)   Source   Edit
ChannelId = enum
  ch1, ch2, ch3, ch4
Channel identifier. Used to specify a hardware channel of the game boy APU   Source   Edit
Immutable[T] = distinct T
Wrapper type that forces immutability on T. Useful for ref or ptr types. Accessing the source is done through the [] overload proc. Both value and ref semantics can be used. When the source is a ref or ptr, accessing the source will dereference the ref/ptr.   Source   Edit
MixMode = enum
  mixMute = 0, mixLeft = 1, mixRight = 2, mixMiddle = 3
Enum of possible mix operations: mute, left-only, right-only or middle (both).   Source   Edit
Pcm = PcmF32
Type alias for the PCM type used in this library   Source   Edit
PcmF32 = float32
32-bit floating point PCM sample   Source   Edit
PositiveByte = range[1 .. int(high(uint8)) + 1]
Positive type using the range of a uint8 (1-256)   Source   Edit

Procs

func pansLeft(mode: MixMode): bool {.inline, ...raises: [], tags: [].}
Determine whether the mode pans left, returns true when mode is mixLeft or mixMiddle   Source   Edit
func pansRight(mode: MixMode): bool {.inline, ...raises: [], tags: [].}
Determine whether the mode pans right, returns true when mode is mixRight or mixMiddle   Source   Edit

Templates

template `==`[T: ptr | ref](lhs: nil.typeof; rhs: Immutable[T]): bool
  Source   Edit
template `==`[T](i: Immutable[T]; rhs: T): bool
Test if the Immutable's source is equivalent to the given value   Source   Edit
template `==`[T](lhs: T; i: Immutable[T]): bool
  Source   Edit
template `[]`[T: not ptr | ref](i: Immutable[T]): lent T
Access the Immutable's value source.

Example:

let myval = 2
let immutableVal = myval.toImmutable
assert immutableVal[] == myval
assert not compiles(immutableVal[] = 3)
  Source   Edit
template `[]`[T](i: Immutable[[type node]]): lent T
Access the Immutable's ref/ptr source. The source is dereferenced and is returned.

Example:

let myref = new(int)
myref[] = 2
let immutableRef = myref.toImmutable
assert immutableRef[] == myref[]
assert not compiles(immutableRef[] = 3)
  Source   Edit
template isNil[T](i: Immutable[[type node]]): bool
Test if the Immutable source is nil.   Source   Edit
template toImmutable[T](s: T): Immutable[T]
Converts a value to an Immutable. Note that a copy of the value might be made.   Source   Edit