Skip to content

Commit 1a4304d

Browse files
committed
Added a testing function to combine two songs
1 parent 206ae49 commit 1a4304d

145 files changed

Lines changed: 5749 additions & 9822 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Minecraft Note Block Studio.yyp

Lines changed: 1020 additions & 1020 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/control_draw/control_draw.yy

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/load_song/load_song.yy

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
function load_song_combine() { // Used to combine two parts of a song together e.g. Megacollab (Only for testing use)
2+
// load_song(fn [, backup])
3+
var fn, backup, file_ext, f, str, stats, tstr, ca, cb, bstr, a, b, c, d, w, hei, byte1, byte2, song_first_custom_index, custom_index_diff, song_nbs_version, endingtick
4+
fn = argument[0]
5+
endingtick = enda + 1
6+
backup = false
7+
if (argument_count > 1) {
8+
backup = argument[1]
9+
}
10+
//if (confirm() < 0) return 0
11+
//if (!backup && fn = "") {
12+
//if (!directory_exists_lib(songfolder)) songfolder = songs_directory
13+
fn = string(get_open_filename_ext("Note Block Songs (*.nbs)|*.nbs", "", songfolder, condstr(language != 1, "Load song", "打开歌曲")))
14+
//}
15+
if (fn = "" || !file_exists_lib(fn)) return 0
16+
17+
// When not opening from auto-recovery, delete the backup file
18+
//if (!backup) {
19+
// backup_clear()
20+
//}
21+
//reset()
22+
file_ext = filename_ext(fn)
23+
//if (file_ext = ".mid" || file_ext = ".midi") {
24+
// open_midi(fn)
25+
// return 1
26+
//}
27+
//if (file_ext = ".schematic") {
28+
// open_schematic(fn)
29+
// return 1
30+
//}
31+
if (file_ext != ".nbs") { message(condstr(language != 1, "Error: This file cannot be opened in this program.", "警告:本软件无法打开此类型文件。"), condstr(language != 1, "Error", "错误")) return 0 }
32+
if (file_ext = ".nbs") {
33+
buffer = buffer_import(fn)
34+
35+
byte1 = buffer_read_byte()
36+
byte2 = buffer_read_byte()
37+
38+
if (byte1 = 0 && byte2 = 0) {
39+
song_nbs_version = buffer_read_byte()
40+
if (language != 1) {if (show_oldwarning && song_nbs_version < nbs_version) message("Warning: You are opening an older NBS file. Saving this file will make it incompatible with older Note Block Studio versions.","Warning")}
41+
else {if (show_oldwarning && song_nbs_version < nbs_version) message("警告:你正在打开旧版的 NBS 文件。保存此文件会使其与旧版 Note Block Studio 不兼容。","警告")}
42+
if song_nbs_version > nbs_version {
43+
if (language != 1) message("Warning: You are opening an NBS file created in a later version of Note Block Studio.\nPlease save the song as a version " + string(nbs_version) + " file or lower via the Save Options menu.","Error")
44+
else message("警告:你正在打开在新版 Note Block Studio 里保存的文件。\n请用保存选项菜单将其保存到" + string(nbs_version) + "版本或以下。","错误")
45+
return -1
46+
}
47+
song_first_custom_index = buffer_read_byte()
48+
custom_index_diff = first_custom_index - song_first_custom_index
49+
50+
//From nbs version 3, we save the song length again
51+
if(song_nbs_version >= 3) {
52+
buffer_read_short()
53+
}
54+
} else {
55+
if (language != 1) {if (show_oldwarning) message("Warning: You are opening an older NBS file. Saving this file will make it incompatible with older Note Block Studio versions.","Warning")}
56+
else {if (show_oldwarning) message("警告:你正在打开旧版的 NBS 文件。保存此文件会使其与旧版 Note Block Studio 不兼容。","警告")}
57+
song_nbs_version = 0
58+
custom_index_diff = 0
59+
song_first_custom_index = 0
60+
}
61+
62+
hei = buffer_read_short()
63+
64+
// SONG NAME
65+
buffer_read_string_int()
66+
// SONG AUTHOR
67+
buffer_read_string_int()
68+
// SONG ORIGINAL AUTHOR
69+
buffer_read_string_int()
70+
// SONG DESCRIPTION
71+
buffer_read_string_int()
72+
// TEMPO
73+
buffer_read_short()
74+
// AUTOSAVE (deprecated)
75+
buffer_read_byte()
76+
// AUTOSAVE MINUTES (deprecated)
77+
buffer_read_byte()
78+
// TIME SIGNATURE
79+
buffer_read_byte()
80+
//timesignature = median(2, a, 8)
81+
// WORK
82+
buffer_read_int()
83+
//work_mins = max(0, a)
84+
buffer_read_int()
85+
//work_left = max(0, a)
86+
buffer_read_int()
87+
//work_right = max(0, a)
88+
buffer_read_int()
89+
//work_add = max(0, a)
90+
buffer_read_int()
91+
//work_remove = max(0, a)
92+
// MIDI FILENAME
93+
buffer_read_string_int()
94+
// LOOP
95+
if (song_nbs_version >= 4) {
96+
buffer_read_byte()
97+
//loop_session = loop
98+
if (string_count("format4beta", filename_name(fn)) = 1) {
99+
buffer_read_byte()
100+
//loopmax = 0
101+
} else {
102+
buffer_read_byte()
103+
buffer_read_short()
104+
}
105+
}
106+
// Note blocks
107+
ca = -1
108+
while (1) {
109+
a = buffer_read_short()
110+
if (a = 0) break
111+
ca += a
112+
cb = -1
113+
while (1) {
114+
a = buffer_read_short()
115+
if (a = 0) break
116+
cb += a
117+
var ins = buffer_read_byte();
118+
if(ins >= song_first_custom_index) ins += custom_index_diff //If instrument is custom, add custom_index_diff so it works when adding future instruments
119+
var key = buffer_read_byte();
120+
if song_nbs_version>=4 {
121+
var vel = buffer_read_byte();
122+
var pan = buffer_read_byte();
123+
var pit = buffer_read_short();
124+
} else {
125+
vel = 100
126+
pan = 100
127+
pit = 0
128+
}
129+
add_block(endingtick + ca, cb, ins, median(0, key, 87), vel, pan, pit, true)
130+
}
131+
}
132+
show_message("Combine complete.")
133+
if (true) { // End?
134+
buffer_delete(buffer)
135+
//add_to_recent(fn)
136+
//window = w_menu
137+
//filename = fn
138+
changed = 1
139+
//blocks_set_instruments()
140+
var a, b;
141+
142+
for (a = endingtick; a <= enda; a += 1) {
143+
if (colamount[a] > 0) {
144+
for (b = 0; b <= collast[a]; b += 1) {
145+
if (song_exists[a, b]) {
146+
song_ins[a, b] = instrument_list[| song_ins[a, b]]
147+
//song_ins[a, b].num_blocks++
148+
//if (song_ins[a, b].user) block_custom++
149+
}
150+
}
151+
}
152+
}
153+
return 0
154+
}
155+
// a = buffer_read_short()
156+
// Layer names
157+
for (b = 0; b < hei; b += 1) {
158+
layername[b] = buffer_read_string_int()
159+
if song_nbs_version >= 4 && string_count("format4beta", filename_name(fn)) != 1 {
160+
layerlock[b] = buffer_read_byte()
161+
}
162+
else layerlock[b] = 0
163+
layervol[b] = buffer_read_byte()
164+
if (layervol[b] = -1) layervol[b] = 100
165+
layervol[b] = median(0, layervol[b], 100)
166+
if (layervol[b] < 100) realvolume = 1
167+
if song_nbs_version >= 2 {
168+
layerstereo[b] = buffer_read_byte()
169+
}
170+
else {
171+
layerstereo[b] = 100
172+
}
173+
endb2 += 1
174+
}
175+
if (buffer_is_eof()) { // End?
176+
buffer_delete(buffer)
177+
add_to_recent(fn)
178+
window = w_menu
179+
filename = fn
180+
changed = 0
181+
blocks_set_instruments()
182+
return 0
183+
}
184+
185+
// Custom instruments
186+
a = buffer_read_byte()
187+
str = ""
188+
for (b = 0; b < a; b++) {
189+
var name = buffer_read_string_int();
190+
var insfn = buffer_read_string_int();
191+
var key = buffer_read_byte();
192+
var press = buffer_read_byte();
193+
var ins = new_instrument(name, insfn, true, press, key);
194+
with (ins)
195+
if (!instrument_load() && insfn != "")
196+
str += insfn + "\n"
197+
ds_list_add(instrument_list, ins)
198+
}
199+
200+
if (str != "")
201+
if (language != 1) {if (question("This song uses custom instruments. However, some sounds could not be loaded:\n\n" + str+"\nMake sure that you have put the sounds in the \"Sounds\" folder. Open Instrument settings?", "Error")) window = w_instruments}
202+
else {if (question("此歌曲使用自定义音色。但是一些音色未能被加载:\n\n" + str+"\n确保您已将声音文件放到“Sounds”文件夹。打开音色设置吗?", "错误")) window = w_instruments}
203+
buffer_delete(buffer)
204+
}
205+
if (!backup) {
206+
add_to_recent(fn)
207+
if (window != w_instruments && song_name != "") window = w_songinfo
208+
filename = fn
209+
changed = 0
210+
}
211+
else {
212+
changed = 1
213+
}
214+
backup_clear()
215+
blocks_set_instruments()
216+
io_clear()
217+
218+
219+
220+
}

scripts/load_song_combine/load_song_combine.yy

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/save_song/save_song.yy

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sprites/bg_message/bg_message.yy

Lines changed: 10 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)