ws-audio2: music/669 (Composer 669 / UNIS 669): s3m family with Hz periods, fast + auto slides, frequency adjust, per-pattern speed and break rows
This commit is contained in:
1 parent
384cdc407d
commit
33d87e0c4d
6 files changed
+366
-1
No files matched your search
@@ -545,3 +545,33 @@ def write_mtm(title, samples, orders, patterns, channels, pans=None, rows=64, co
|
||||
|
||||
def u16(xs):
|
||||
return b"".join(struct.pack("<H", max(0, min(65535, int(round(x * 32767)) + 32768))) for x in xs)
|
||||
|
||||
|
||||
def write_669(message, samples, orders, patterns, tempos, breaks, restart=0, extended=False):
|
||||
"""samples: [{name, data (unsigned bytes), loop: (start, end) | None}]; patterns: [[row: [(note, ins, vol, effect)]
|
||||
* 8] * 64] with note 0 = none else our note (>= 37), ins 1-based, vol 0..15 or None, effect byte (cmd << 4 | param)
|
||||
or None; tempos / breaks: per pattern"""
|
||||
out = bytearray(b"JN" if extended else b"if")
|
||||
msg = message.encode()[:108]
|
||||
out += msg + b" " * (108 - len(msg))
|
||||
out += bytes([len(samples), len(patterns), restart])
|
||||
out += bytes(orders) + b"\xff" * (128 - len(orders))
|
||||
out += bytes(tempos) + b"\x04" * (128 - len(tempos))
|
||||
out += bytes(breaks) + b"\x3f" * (128 - len(breaks))
|
||||
for s in samples:
|
||||
ls, le = s.get("loop") or (0, 0xFFFFF)
|
||||
out += name(s.get("name", ""), 13) + struct.pack("<III", len(s["data"]), ls, le)
|
||||
for pat in patterns:
|
||||
for row in pat:
|
||||
for (note, ins, vol, eff) in row:
|
||||
if note:
|
||||
n, i = note - 37, ins - 1
|
||||
out += bytes([(n << 2) | (i >> 4), ((i & 15) << 4) | (vol if vol is not None else 0)])
|
||||
elif vol is not None:
|
||||
out += bytes([0xFE, vol])
|
||||
else:
|
||||
out += b"\xff\x00"
|
||||
out.append(0xFF if eff is None else eff)
|
||||
for s in samples:
|
||||
out += s["data"]
|
||||
return bytes(out)
|
||||
Reference in new issue
Block a user