tracker inst format update

This commit is contained in:
minjaesong
2023-01-23 16:55:56 +09:00
parent 0f82727152
commit 801ae0c29b
2 changed files with 15 additions and 11 deletions

View File

@@ -575,13 +575,13 @@ Instrument bin: Registry for 256 instruments, formatted as:
Uint16 Sample Pointer Uint16 Sample Pointer
Uint16 Sample length Uint16 Sample length
Uint16 Sampling rate at C3 Uint16 Sampling rate at C3
Uint16 Loop start Uint16 Play Start (usually 0 but not always)
Uint16 Loop end Uint16 Loop Start (can be smaller than Play Start)
Bit16 Flags Uint16 Loop End
Bit32 Flags
0b h000 00pp 0b h000 00pp
h: sample pointer high bit 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) 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 Bit16x24 Volume envelopes
Byte 1: Volume Byte 1: Volume
Byte 2: Second offset from the prev point, in 3.5 Unsigned Minifloat Byte 2: Second offset from the prev point, in 3.5 Unsigned Minifloat

View File

@@ -480,13 +480,14 @@ class AudioAdapter(val vm: VM) : PeriBase(VM.PERITYPE_SOUND) {
var samplePtr: Int, // 17-bit number var samplePtr: Int, // 17-bit number
var sampleLength: Int, var sampleLength: Int,
var samplingRate: Int, var samplingRate: Int,
var samplePlayStart: Int,
var sampleLoopStart: Int, var sampleLoopStart: Int,
var sampleLoopEnd: Int, var sampleLoopEnd: Int,
// flags // flags
var loopMode: Int, var loopMode: Int,
var envelopes: Array<TaudInstVolEnv> // first int: volume (0..255), second int: offsets (minifloat indices) 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) { fun getByte(offset: Int): Byte = when (offset) {
0 -> samplePtr.toByte() 0 -> samplePtr.toByte()
@@ -498,14 +499,17 @@ class AudioAdapter(val vm: VM) : PeriBase(VM.PERITYPE_SOUND) {
4 -> samplingRate.toByte() 4 -> samplingRate.toByte()
5 -> samplingRate.ushr(8).toByte() 5 -> samplingRate.ushr(8).toByte()
6 -> sampleLoopStart.toByte() 6 -> samplePlayStart.toByte()
7 -> sampleLoopStart.ushr(8).toByte() 7 -> samplePlayStart.ushr(8).toByte()
8 -> sampleLoopEnd.toByte() 8 -> sampleLoopStart.toByte()
9 -> sampleLoopEnd.ushr(8).toByte() 9 -> sampleLoopStart.ushr(8).toByte()
10 -> (samplePtr.ushr(16).and(1).shl(7) or loopMode.and(3)).toByte() 10 -> sampleLoopEnd.toByte()
11,12,13,14,15 -> -1 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 16..63 step 2 -> envelopes[offset - 16].volume.toByte()
in 17..63 step 2 -> envelopes[offset - 16].offset.index.toByte() in 17..63 step 2 -> envelopes[offset - 16].offset.index.toByte()
else -> throw InternalError("Bad offset $offset") else -> throw InternalError("Bad offset $offset")