mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
tracker inst format update
This commit is contained in:
@@ -575,13 +575,13 @@ Instrument bin: Registry for 256 instruments, formatted as:
|
||||
Uint16 Sample Pointer
|
||||
Uint16 Sample length
|
||||
Uint16 Sampling rate at C3
|
||||
Uint16 Loop start
|
||||
Uint16 Loop end
|
||||
Bit16 Flags
|
||||
Uint16 Play Start (usually 0 but not always)
|
||||
Uint16 Loop Start (can be smaller than Play Start)
|
||||
Uint16 Loop End
|
||||
Bit32 Flags
|
||||
0b h000 00pp
|
||||
h: sample pointer high bit
|
||||
pp: loop mode. 0-no loop, 1-loop, 2-backandforth, 3-oneshot (ignores note length unless overridden by other notes)
|
||||
Bit32 Unused
|
||||
Bit16x24 Volume envelopes
|
||||
Byte 1: Volume
|
||||
Byte 2: Second offset from the prev point, in 3.5 Unsigned Minifloat
|
||||
|
||||
@@ -480,13 +480,14 @@ class AudioAdapter(val vm: VM) : PeriBase(VM.PERITYPE_SOUND) {
|
||||
var samplePtr: Int, // 17-bit number
|
||||
var sampleLength: Int,
|
||||
var samplingRate: Int,
|
||||
var samplePlayStart: Int,
|
||||
var sampleLoopStart: Int,
|
||||
var sampleLoopEnd: Int,
|
||||
// flags
|
||||
var loopMode: Int,
|
||||
var envelopes: Array<TaudInstVolEnv> // first int: volume (0..255), second int: offsets (minifloat indices)
|
||||
) {
|
||||
constructor() : this(0, 0, 0, 0, 0, 0, Array(24) { TaudInstVolEnv(0, ThreeFiveMiniUfloat(0)) })
|
||||
constructor() : this(0, 0, 0, 0, 0, 0, 0, Array(24) { TaudInstVolEnv(0, ThreeFiveMiniUfloat(0)) })
|
||||
|
||||
fun getByte(offset: Int): Byte = when (offset) {
|
||||
0 -> samplePtr.toByte()
|
||||
@@ -498,14 +499,17 @@ class AudioAdapter(val vm: VM) : PeriBase(VM.PERITYPE_SOUND) {
|
||||
4 -> samplingRate.toByte()
|
||||
5 -> samplingRate.ushr(8).toByte()
|
||||
|
||||
6 -> sampleLoopStart.toByte()
|
||||
7 -> sampleLoopStart.ushr(8).toByte()
|
||||
6 -> samplePlayStart.toByte()
|
||||
7 -> samplePlayStart.ushr(8).toByte()
|
||||
|
||||
8 -> sampleLoopEnd.toByte()
|
||||
9 -> sampleLoopEnd.ushr(8).toByte()
|
||||
8 -> sampleLoopStart.toByte()
|
||||
9 -> sampleLoopStart.ushr(8).toByte()
|
||||
|
||||
10 -> (samplePtr.ushr(16).and(1).shl(7) or loopMode.and(3)).toByte()
|
||||
11,12,13,14,15 -> -1
|
||||
10 -> sampleLoopEnd.toByte()
|
||||
11 -> sampleLoopEnd.ushr(8).toByte()
|
||||
|
||||
12 -> (samplePtr.ushr(16).and(1).shl(7) or loopMode.and(3)).toByte()
|
||||
13,14,15 -> -1
|
||||
in 16..63 step 2 -> envelopes[offset - 16].volume.toByte()
|
||||
in 17..63 step 2 -> envelopes[offset - 16].offset.index.toByte()
|
||||
else -> throw InternalError("Bad offset $offset")
|
||||
|
||||
Reference in New Issue
Block a user