diff --git a/scripts/MusicRenderer.gd b/scripts/MusicRenderer.gd index 365c5b6..93e25b0 100644 --- a/scripts/MusicRenderer.gd +++ b/scripts/MusicRenderer.gd @@ -7,7 +7,7 @@ const music := preload('res://scripts/loaders/snes/music_ff5.gd') const EventType := music.EventType var MUSIC := music.new() const NUM_TRACKS := 8 # TODO -const MAX_NOTE_EVENTS := 2048 +const MAX_NOTE_EVENTS := 4096 class NoteEvent: var p_event_start: int # In pulse space var p_note_start: int # For tied notes, this will be earlier than p_event_start and is used for envelope calculations @@ -358,6 +358,8 @@ static func render_channels(tracks: Array, inst_map: Array, _debug_name := 'none _: break # End of track + if len(channel_note_events) > (MAX_NOTE_EVENTS-2): + print('%s channel %d has too many note events! %d is more than %d' % [_debug_name, channel, len(channel_note_events), MAX_NOTE_EVENTS-2]) all_note_events.append(channel_note_events) curve_channel_pans.append(curve_pan) diff --git a/scripts/audio_renderer.gd b/scripts/audio_renderer.gd index 819f826..db76cd2 100644 --- a/scripts/audio_renderer.gd +++ b/scripts/audio_renderer.gd @@ -6,7 +6,7 @@ signal render_complete(key) # The full track has been rendered and is read enum RENDER_MODE {BATCH, DYNAMIC, JAOT, TEST_READBACK} var render_mode = RENDER_MODE.JAOT -const INPUT_TEX_WIDTH := 2048 +const INPUT_TEX_WIDTH := 4096 const INPUT_FORMAT := Image.FORMAT_RGBA8 # Image.FORMAT_LA8 const INPUT_BYTES_PER_TEXEL := 4 # 2 const OUTPUT_BYTES_PER_TEXEL := 4 diff --git a/scripts/loaders/SoundLoader.gd b/scripts/loaders/SoundLoader.gd index 47040e8..24e4fc5 100644 --- a/scripts/loaders/SoundLoader.gd +++ b/scripts/loaders/SoundLoader.gd @@ -14,10 +14,6 @@ const BYTES_PER_SAMPLE := 2 # 16bit samples const ATTACK_TIME_SMPS := PoolIntArray([131072, 81920, 49152, 32768, 20480, 12288, 8192, 5120, 3072, 2048, 1280, 768, 512, 320, 192, 2]) const ATTACK_TIME_SMPS_ENTRIES := 16 -# const DECAY_TIME_SMPS := PoolIntArray([38400, 23680, 14080, 9280, 5760, 3520, 2368, 1184]) -# const DECAY_TIME_SMPS_ENTRIES := 8 -# const SUSTAIN_DECAY_TIME_SMPS = PoolIntArray([0, 1216000, 896000, 768000, 608000, 448000, 384000, 300800, 227200, 188800, 150400, 112000, 92800, 76800, 57600, 48000, 38400, 28160, 23680, 18880, 14080, 11840, 9280, 7040, 5760, 4800, 3520, 2944, 2368, 1760, 1184, 576]) -# const SUSTAIN_DECAY_TIME_SMPS_ENTRIES = 32 const SPC_DECAY_CURVE := PoolIntArray([2047, 2039, 2031, 2023, 2015, 2007, 1999, 1991, 1983, 1975, 1967, 1959, 1951, 1943, 1935, 1927, 1919, 1911, 1903, 1895, 1887, 1879, 1871, 1863, 1855, 1847, 1839, 1831, 1823, 1815, 1807, 1799, 1791, 1784, 1777, 1770, 1763, 1756, 1749, 1742, 1735, 1728, 1721, 1714, 1707, 1700, 1693, 1686, 1679, 1672, 1665, 1658, 1651, 1644, 1637, 1630, 1623, 1616, 1609, 1602, 1595, 1588, 1581, 1574, 1567, 1560, 1553, 1546, 1539, 1532, 1526, 1520, 1514, 1508, 1502, 1496, 1490, 1484, 1478, 1472, 1466, 1460, 1454, 1448, 1442, 1436, 1430, 1424, 1418, 1412, 1406, 1400, 1394, 1388, 1382, 1376, 1370, 1364, 1358, 1352, 1346, 1340, 1334, 1328, 1322, 1316, 1310, 1304, 1298, 1292, 1286, 1280, 1275, 1270, 1265, 1260, 1255, 1250, 1245, 1240, 1235, 1230, 1225, 1220, 1215, 1210, 1205, 1200, 1195, 1190, 1185, 1180, 1175, 1170, 1165, 1160, 1155, 1150, 1145, 1140, 1135, 1130, 1125, 1120, 1115, 1110, 1105, 1100, 1095, 1090, 1085, 1080, 1075, 1070, 1065, 1060, 1055, 1050, 1045, 1040, 1035, 1030, 1025, 1020, 1016, 1012, 1008, 1004, 1000, 996, 992, 988, 984, 980, 976, 972, 968, 964, 960, 956, 952, 948, 944, 940, 936, 932, 928, 924, 920, 916, 912, 908, 904, 900, 896, 892, 888, 884, 880, 876, 872, 868, 864, 860, 856, 852, 848, 844, 840, 836, 832, 828, 824, 820, 816, 812, 808, 804, 800, 796, 792, 788, 784, 780, 776, 772, 768, 765, 762, 759, 756, 753, 750, 747, 744, 741, 738, 735, 732, 729, 726, 723, 720, 717, 714, 711, 708, 705, 702, 699, 696, 693, 690, 687, 684, 681, 678, 675, 672, 669, 666, 663, 660, 657, 654, 651, 648, 645, 642, 639, 636, 633, 630, 627, 624, 621, 618, 615, 612, 609, 606, 603, 600, 597, 594, 591, 588, 585, 582, 579, 576, 573, 570, 567, 564, 561, 558, 555, 552, 549, 546, 543, 540, 537, 534, 531, 528, 525, 522, 519, 516, 513, 510, 508, 506, 504, 502, 500, 498, 496, 494, 492, 490, 488, 486, 484, 482, 480, 478, 476, 474, 472, 470, 468, 466, 464, 462, 460, 458, 456, 454, 452, 450, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0]) const SPC_DECAY_CURVE_ENTRIES := len(SPC_DECAY_CURVE) #697 diff --git a/shaders/audio_renderer.gdshader b/shaders/audio_renderer.gdshader index 0e2079a..7ddfb65 100644 --- a/shaders/audio_renderer.gdshader +++ b/shaders/audio_renderer.gdshader @@ -9,7 +9,7 @@ uniform highp int INT_OUTPUT_WIDTH = 4096; uniform highp vec2 OUTPUT_FRAMEBUFFER_SIZE = vec2(4096.0, 4096.0); uniform highp float reference_note = 71.0; // [0, 255], possibly [0, 127] uniform highp float output_mixrate = 32000.0; // SNES SPC output is 32kHz -uniform highp vec2 midi_events_size = vec2(2048.0, 32.0); +uniform highp vec2 midi_events_size = vec2(4096.0, 32.0); uniform highp int tempo_scale_thousandths = 1000; const highp int TEMPO_SCALE_MULTIPLIER = 1000; // I feel like these magic numbers are a bit more intuitive in hex @@ -202,8 +202,8 @@ highp float get_exponential_decay(highp float periods) { // input in periods, o const int NUM_CHANNELS = 8; -const highp int MAX_CHANNEL_NOTE_EVENTS = 2048; -const int NUM_CHANNEL_NOTE_PROBES = 11; // log2(MAX_CHANNEL_NOTE_EVENTS) +const highp int MAX_CHANNEL_NOTE_EVENTS = 4096; +const int NUM_CHANNEL_NOTE_PROBES = 12; // log2(MAX_CHANNEL_NOTE_EVENTS) highp vec4 get_midi_texel(highp sampler2D tex, highp float x, highp float y) { return texture(tex, vec2(x, y)/midi_events_size).xyzw; } diff --git a/test/audio_system.gd b/test/audio_system.gd index 035de39..eb4d602 100644 --- a/test/audio_system.gd +++ b/test/audio_system.gd @@ -98,7 +98,7 @@ func _create_bgm_playback() -> void: self._update_bgm_label() $btn_bgm_live.connect('pressed', self, '_play_bgm_live') $btn_bgm_prerendered.connect('pressed', self, '_play_bgm_prerendered') - $btn_render.connect('pressed', self, 'render_all_bgm') + $btn_render.connect('pressed', MusicManager, 'render_all_bgm') for i in SoundLoader.SFX_NUM: self.inst_sample_map[i] = SoundLoader.sfx_samples[i]