Skip to content

Commit 32ca348

Browse files
committed
bugfix: Fix an error when exporting songs without layers data to audio
1 parent 7f4ecb1 commit 32ca348

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

nbs2audio.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def convert(data: NbsSong) -> File:
5050

5151
layers = [Layer(id=i, name=layer.name, lock=layer.lock, volume=layer.volume,
5252
panning=layer.pan) for i, layer in enumerate(data.layers)]
53+
while len(layers) < data.maxLayer+1:
54+
layers.append(Layer(id=len(layers)))
5355

5456
instruments = [Instrument(id=i, name=inst.name, file=inst.filePath, pitch=inst.pitch,
5557
press_key=inst.pressKeys) for i, inst in enumerate(VANILLA_INSTS + data.customInsts)]
@@ -105,9 +107,8 @@ async def _mix(
105107
last_pan = None
106108

107109
note_count = len(sorted_notes)
110+
sound = sound1 = sound2 = sound3 = sound4 = AudioSegment.empty()
108111
for i, note in enumerate(sorted_notes):
109-
sound = sound1 = sound2 = sound3 = sound4 = AudioSegment()
110-
111112
ins = note.instrument
112113
key = note.key
113114
vol = note.velocity

0 commit comments

Comments
 (0)