-
Notifications
You must be signed in to change notification settings - Fork 0
/
FMOD_MV.js
2724 lines (2032 loc) · 85.1 KB
/
FMOD_MV.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*:
* @plugindesc This plugin integrated with FMOD by Firelight Technologies Pty Ltd.
* Version : alpha-1.0.8
* @author Creta Park (https://creft.me/cretapark)
*
* @help
* This plugin integrated with FMOD by Firelight Technologies Pty Ltd.
* You can use industry-leading audio engine for RPG Maker MV.
*
* Created by Creta Park (https://creft.me/cretapark)
*
* GitHub page : https://github.com/creta5164/fmod-rmmv
* Recommended MV version : 1.6.2^
* Recommended FMOD version : 2.01.13^
* Recommended NW.js version : 0.66.0^
* Tested on NW.js 0.66.0
* * The NW.js version provided by the existing RPG Maker MV is-
* experiencing an ArrayBuffer allocation failed issue.
* If possible, I recommended to update to NW.js 0.66.0 to resolve it.
* I'm looking for a solution, but until then, please take this way.
*
* License : https://github.com/creta5164/fmod-rmmv/blob/main/LICENSE
*
* - License conditions -
*
* 1. When using this plugin with other software, the software must be
* a game developed and made with RPG Maker, and 'FMOD_MV.js by Creta Park'
* must be written in the credit of these game.
*
* 2. Should not be confused 1's content with the attribution of FMOD.
* Mark completely separate from the attribution of the FMOD.
*
* 3. Neither this plugin nor any of its individual components,
* in Original or Modified Versions, may be sold by itself.
*
* 4. When redistributed after modification, the original author must be indicated.
*
* Please refer to the README.md of the repository
* if you looking for How to setup, usage, limitation etc.
* https://github.com/creta5164/fmod-rmmv/blob/main/README.md
*
* @param total-memory
* @text Total memory
* @desc FMOD's virtual memory maximum size. (byte units)
* Default value is 64MB. (64 * 1024 * 1024)
* @default 67108864
* @type number
*
* @param bank-path
* @text Bank asset path
* @desc Specify the path where the FMOD's Bank assets are.
* @default audio/bank
* @type text
*
* @param bank-assets
* @text Bank assets
* @parent bank-path
* @desc Specify banks to load.
* @type text[]
* @default ["Master","Master.strings"]
*
* @param guids-path
* @text GUIDs js path
* @desc Specify GUID collection script.
* (i.e. audio/bank/fmod_studio_guids.js)
* @type text
* @default audio/bank/fmod_studio_guids.js
*
* @param integrated-vcas
* @text Integrated VCAs
*
* @param integrated-vcas-bgm
* @parent integrated-vcas
* @text Specified BGM VCA name
* @type text
* @desc Specify which VCA is used for Background Musics.
* If BGM exists in fmod GUIDs (VCA), leave it blank.
*
* @param integrated-vcas-bgs
* @parent integrated-vcas
* @text Specified BGS VCA name
* @type text
* @desc Specify which VCA is used for Background Sounds. (Ambient)
* If BGS exists in fmod GUIDs (VCA), leave it blank.
*
* @param integrated-vcas-me
* @parent integrated-vcas
* @text Specified ME VCA name
* @type text
* @desc Specify which VCA is used for Music Effects. (Fanfare)
* If ME exists in fmod GUIDs (VCA), leave it blank.
*
* @param integrated-vcas-se
* @parent integrated-vcas
* @text Specified SE VCA name
* @type text
* @desc Specify which VCA is used for Sound Effects. (SFX)
* If SE exists in fmod GUIDs (VCA), leave it blank.
*
* @param listener-is-player
* @text Listener is player
* @desc Specifies listener is player or not(camera).
* @default false
* @type boolean
*
* @param save-event-timeline-position
* @text Save event's time state
* @desc Specifies whether to save up to the time of the
* event when save and load.
* @default true
* @type boolean
*
* @param system-bgm
* @text System musics
*
* @param system-bgm-title
* @parent system-bgm
* @type text
* @text Title
*
* @param system-bgm-battle
* @parent system-bgm
* @type text
* @text Battle
*
* @param system-bgm-airship
* @parent system-bgm
* @type text
* @text Airship
*
* @param system-bgm-boat
* @parent system-bgm
* @type text
* @text Boat
*
* @param system-bgm-ship
* @parent system-bgm
* @type text
* @text Ship
*
* @param system-me
* @text System music effects
*
* @param system-me-victory
* @parent system-me
* @type text
* @text Victory
*
* @param system-me-defeat
* @parent system-me
* @type text
* @text Defeat
*
* @param system-me-game-over
* @parent system-me
* @type text
* @text Game over
*
* @param system-se
* @text System sound effects
*
* @param system-se-cursor
* @parent system-se
* @type text
* @text Cursor
*
* @param system-se-ok
* @parent system-se
* @type text
* @text Confirm (OK)
*
* @param system-se-cancel
* @parent system-se
* @type text
* @text Cancel
*
* @param system-se-buzzer
* @parent system-se
* @type text
* @text Buzzer
*
* @param system-se-equip
* @parent system-se
* @type text
* @text Equip
*
* @param system-se-save
* @parent system-se
* @type text
* @text Save
*
* @param system-se-load
* @parent system-se
* @type text
* @text Load
*
* @param system-se-battle-start
* @parent system-se
* @type text
* @text Battle start
*
* @param system-se-escape
* @parent system-se
* @type text
* @text Escape
*
* @param system-se-enemy-attack
* @parent system-se
* @type text
* @text Enemy attack
*
* @param system-se-enemy-damage
* @parent system-se
* @type text
* @text Enemy damage
*
* @param system-se-enemy-collapse
* @parent system-se
* @type text
* @text Enemy collapse
*
* @param system-se-boss-collapse1
* @parent system-se
* @type text
* @text Boss collapse 1
*
* @param system-se-boss-collapse2
* @parent system-se
* @type text
* @text Boss collapse 2
*
* @param system-se-actor-damage
* @parent system-se
* @type text
* @text Actor damage
*
* @param system-se-actor-collapse
* @parent system-se
* @type text
* @text Actor collapse
*
* @param system-se-recovery
* @parent system-se
* @type text
* @text Recovery
*
* @param system-se-miss
* @parent system-se
* @type text
* @text Miss
*
* @param system-se-evasion
* @parent system-se
* @type text
* @text Evasion
*
* @param system-se-magic-evasion
* @parent system-se
* @type text
* @text Magic evasion
*
* @param system-se-reflection
* @parent system-se
* @type text
* @text Reflection
*
* @param system-se-shop
* @parent system-se
* @type text
* @text Shop
*
* @param system-se-use-item
* @parent system-se
* @type text
* @text Use item
*
* @param system-se-use-skill
* @parent system-se
* @type text
* @text Use skill
*/
/*:ko
* @plugindesc 이 플러그인은 Firelight Technologies Pty Ltd의 FMOD를 적용합니다.
* 버전 : alpha-1.0.8
* @author Creta Park (https://creft.me/cretapark)
*
* @help
* 이 플러그인은 Firelight Technologies Pty Ltd의 FMOD를 적용합니다.
* 게임 업계 최고의 오디오 엔진을 RPG 만들기 MV에 사용해 보세요.
*
* 제작 : Creta Park (https://creft.me/cretapark)
*
* GitHub 페이지 : https://github.com/creta5164/fmod-rmmv
* 권장 MV 버전 : 1.6.2 이상
* 권장 FMOD 버전 : 2.01.13 이상
* 권장 NW.js 버전 : 0.66.0 이상
* NW.js 0.66.0에서 테스트 완료
* * 기존 RPG 만들기 MV에서 제공하는 NW.js 버전에는
* ArrayBuffer allocation failed 문제가 발생하고 있습니다.
* 가급적이면 0.66.0 NW.js 버전을 올려서 해결하는 것을 권장합니다.
* 현재 해결방법을 찾고 있습니다, 그 전까지는 이렇게 사용하세요.
*
* 라이센스 : https://github.com/creta5164/fmod-rmmv/blob/main/LICENSE
*
* - 라이센스 조건 -
*
* 1. 이 플러그인을 다른 소프트웨어와 함께 사용하는 경우,
* 소프트웨어는 RPG 만들기로 개발 및 제작 된 게임이어야 하며,
* 게임의 크레딧에는 `FMOD_MV.js by Creta Park`가 반드시 들어가야 합니다.
*
* 2. 1의 내용을 FMOD의 저작자 표기와 혼동해서는 안 됩니다.
* FMOD의 저작자 표기와 완전히 별개로 표기하세요.
*
* 3. 이 플러그인의 원본 또는 수정된 버전이나
* 개별 구성 요소는 단독으로 판매될 수 없습니다.
*
* 4. 수정 후 재배포를 하는 경우, 원저작자를 반드시 표기해야 합니다.
*
* 설정, 사용법, 제한 사항 등은
* 저장소의 README.md에서 확인해 주세요.
* https://github.com/creta5164/fmod-rmmv/blob/main/README-ko.md
*
* @param total-memory
* @text 최대 메모리
* @desc FMOD의 가상 메모리 최대 크기입니다. (바이트 단위)
* 기본값은 64MB 입니다. (64 * 1024 * 1024)
* @default 67108864
* @type number
*
* @param bank-path
* @text 뱅크 파일 경로
* @desc FMOD에 사용할 뱅크 파일이 있는 경로를 지정합니다.
* @default audio/bank
* @type text
*
* @param bank-assets
* @text 사용할 뱅크 파일들
* @parent bank-path
* @desc 불러올 뱅크 파일을 지정합니다.
* @type text[]
* @default ["Master","Master.strings"]
*
* @param guids-path
* @text GUID 스크립트 경로
* @desc GUID가 담겨있는 스크립트 파일의 위치를 지정합니다.
* (i.e. audio/bank/fmod_studio_guids.js)
* @type text
* @default audio/bank/fmod_studio_guids.js
*
* @param integrated-vcas
* @text 연동할 VCA들
*
* @param integrated-vcas-bgm
* @parent integrated-vcas
* @text 지정한 BGM VCA 이름
* @type text
* @desc 어떤 VCA가 음악으로 쓰이는지 이름을 쓰세요.
* 만약 BGM인 VCA가 fmod GUID에 있다면 비워두세요.
*
* @param integrated-vcas-bgs
* @parent integrated-vcas
* @text 지정한 BGS VCA 이름
* @type text
* @desc 어떤 VCA가 환경음으로 쓰이는지 이름을 쓰세요.
* 만약 BGS인 VCA가 fmod GUID에 있다면 비워두세요.
*
* @param integrated-vcas-me
* @parent integrated-vcas
* @text 지정한 ME VCA 이름
* @type text
* @desc 어떤 VCA가 음악 효과음으로 쓰이는지 이름을 쓰세요.
* 만약 ME인 VCA가 fmod GUID에 있다면 비워두세요.
*
* @param integrated-vcas-se
* @parent integrated-vcas
* @text 지정한 SE VCA 이름
* @type text
* @desc 어떤 VCA가 효과음으로 쓰이는지 이름을 쓰세요.
* 만약 SE인 VCA가 fmod GUID에 있다면 비워두세요.
*
* @param listener-is-player
* @text 플레이어를 청취자로 설정
* @desc 플레이어를 청취자로 설정할 지 여부입니다.
* (아닌 경우 카메라가 청취자가 됨)
* @default false
* @type boolean
*
* @param save-event-timeline-position
* @text 이벤트 시간 상태 저장 여부
* @desc 게임을 저장하고 불러올 때 이벤트의
* 시간까지 저장할지 여부를 지정합니다.
* @default true
* @type boolean
*
* @param system-bgm
* @text 시스템 음악(BGM)들
*
* @param system-bgm-title
* @parent system-bgm
* @type text
* @text 타이틀
*
* @param system-bgm-battle
* @parent system-bgm
* @type text
* @text 전투
*
* @param system-bgm-airship
* @parent system-bgm
* @type text
* @text 비행선
*
* @param system-bgm-boat
* @parent system-bgm
* @type text
* @text 보트
*
* @param system-bgm-ship
* @parent system-bgm
* @type text
* @text 선박
*
* @param system-me
* @text 시스템 음악 효과음(ME)들
*
* @param system-me-victory
* @parent system-me
* @type text
* @text 승리
*
* @param system-me-defeat
* @parent system-me
* @type text
* @text 패배
*
* @param system-me-game-over
* @parent system-me
* @type text
* @text 게임 종료 (게임오버)
*
* @param system-se
* @text 시스템 효과음(SE)들
*
* @param system-se-cursor
* @parent system-se
* @type text
* @text 커서
*
* @param system-se-ok
* @parent system-se
* @type text
* @text OK
*
* @param system-se-cancel
* @parent system-se
* @type text
* @text 취소
*
* @param system-se-buzzer
* @parent system-se
* @type text
* @text 버저
*
* @param system-se-equip
* @parent system-se
* @type text
* @text 장착
*
* @param system-se-save
* @parent system-se
* @type text
* @text 저장
*
* @param system-se-load
* @parent system-se
* @type text
* @text 로딩 (불러오기)
*
* @param system-se-battle-start
* @parent system-se
* @type text
* @text 전투 시작
*
* @param system-se-escape
* @parent system-se
* @type text
* @text 도망
*
* @param system-se-enemy-attack
* @parent system-se
* @type text
* @text 적 공격
*
* @param system-se-enemy-damage
* @parent system-se
* @type text
* @text 적 피해
*
* @param system-se-enemy-collapse
* @parent system-se
* @type text
* @text 적 소멸 (처치)
*
* @param system-se-boss-collapse1
* @parent system-se
* @type text
* @text 보스 소멸 1 (처치)
*
* @param system-se-boss-collapse2
* @parent system-se
* @type text
* @text 보스 소멸 2 (처치)
*
* @param system-se-actor-damage
* @parent system-se
* @type text
* @text 아군 피해
*
* @param system-se-actor-collapse
* @parent system-se
* @type text
* @text 아군 전투 불능
*
* @param system-se-recovery
* @parent system-se
* @type text
* @text 회복
*
* @param system-se-miss
* @parent system-se
* @type text
* @text 실수 (빗나감)
*
* @param system-se-evasion
* @parent system-se
* @type text
* @text 회피
*
* @param system-se-magic-evasion
* @parent system-se
* @type text
* @text 마법 회피
*
* @param system-se-reflection
* @parent system-se
* @type text
* @text 마법 반사
*
* @param system-se-shop
* @parent system-se
* @type text
* @text 상점 (구매 / 판매)
*
* @param system-se-use-item
* @parent system-se
* @type text
* @text 아이템 사용
*
* @param system-se-use-skill
* @parent system-se
* @type text
* @text 스킬 사용
*/
function Guid(a, b, c, d, e, f, g, h, i, j, k) {
if (typeof a === 'string') {
this.initFromString(a);
return;
} else if (typeof a === 'object') {
this.initFromObject(a);
return;
}
if (a < 0 || a > 4294967295)
throw new Error("Argument a is out of range for uint. (0 ~ 4,294,967,295)");
if (b < 0 || b > 65535)
throw new Error("Argument b is out of range for ushort. (0 ~ 65,535)");
if (c < 0 || c > 65535)
throw new Error("Argument c is out of range for ushort. (0 ~ 65,535)");
if (d < 0 || d > 255)
throw new Error("Argument d is out of range for byte. (0 ~ 255)");
if (e < 0 || e > 255)
throw new Error("Argument e is out of range for byte. (0 ~ 255)");
if (f < 0 || f > 255)
throw new Error("Argument f is out of range for byte. (0 ~ 255)");
if (g < 0 || g > 255)
throw new Error("Argument g is out of range for byte. (0 ~ 255)");
if (h < 0 || h > 255)
throw new Error("Argument h is out of range for byte. (0 ~ 255)");
if (i < 0 || i > 255)
throw new Error("Argument i is out of range for byte. (0 ~ 255)");
if (j < 0 || j > 255)
throw new Error("Argument j is out of range for byte. (0 ~ 255)");
if (k < 0 || k > 255)
throw new Error("Argument k is out of range for byte. (0 ~ 255)");
this.Data1 = a;
this.Data2 = b;
this.Data3 = c;
this.Data4 = [d, e, f, g, h, i, j, k];
}
Guid.prototype.initFromObject = function(object) {
if (!object.hasOwnProperty('Data1')
|| !object.hasOwnProperty('Data2')
|| !object.hasOwnProperty('Data3')
|| !object.hasOwnProperty('Data4'))
throw new Error("Cannot cast from object.");
this.Data1 = object.Data1;
this.Data2 = object.Data2;
this.Data3 = object.Data3;
this.Data4 = object.Data4;
}
Guid.prototype.initFromString = function(string) {
var start = string.indexOf('{');
var end = string.indexOf('}');
if (start < 0 || end < 0)
throw new Error("Guid string is not valid.");
string = string.substring(start + 1, end)
.split('-').map(hex => hex.trim());
this.Data1 = Number(`0x${string[0]}`);
this.Data2 = Number(`0x${string[1]}`);
this.Data3 = Number(`0x${string[2]}`);
this.Data4 = [];
for (var i = 0; i < string[3].length; i += 2)
this.Data4.push(Number(`0x${string[3][i]}${string[3][i + 1]}`));
for (var i = 0; i < string[4].length; i += 2)
this.Data4.push(Number(`0x${string[4][i]}${string[4][i + 1]}`));
}
Guid.prototype.toString = function() {
var a = this.Data1.toString(16).padStart(8, '0');
var b = this.Data2.toString(16).padStart(4, '0');
var c = this.Data3.toString(16).padStart(4, '0');
var d = this.Data4[0].toString(16).padStart(2, '0')
+ this.Data4[1].toString(16).padStart(2, '0');
var e = this.Data4[2].toString(16).padStart(2, '0')
+ this.Data4[3].toString(16).padStart(2, '0')
+ this.Data4[4].toString(16).padStart(2, '0')
+ this.Data4[5].toString(16).padStart(2, '0')
+ this.Data4[6].toString(16).padStart(2, '0')
+ this.Data4[7].toString(16).padStart(2, '0');
return `{${a}-${b}-${c}-${d}-${e}}`;
}
let FMOD;
function FMOD_MV() {
throw new Error("This is a static class.");
}
(function() {
FMOD_MV.Params = PluginManager.parameters("FMOD_MV");
FMOD_MV.BankPath = FMOD_MV.Params["bank-path"];
FMOD_MV.BankAssets = JSON.parse(FMOD_MV.Params["bank-assets"])
.map(name => name.endsWith('.bank') ? name : (name + '.bank'));
FMOD_MV.GUIDsPath = FMOD_MV.Params["guids-path"];
FMOD_MV.VCA_BGM = FMOD_MV.Params["integrated-vcas-bgm"];
FMOD_MV.VCA_BGS = FMOD_MV.Params["integrated-vcas-bgs"];
FMOD_MV.VCA_ME = FMOD_MV.Params["integrated-vcas-me"];
FMOD_MV.VCA_SE = FMOD_MV.Params["integrated-vcas-se"];
FMOD_MV.SaveEventTimelinePosition = FMOD_MV.Params["save-event-timeline-position"] === 'true';
FMOD_MV.ListenerIsPlayer = FMOD_MV.Params["listener-is-player"] === 'true';
FMOD_MV.SystemBGM_Title = FMOD_MV.Params["system-bgm-title"];
FMOD_MV.SystemBGM_Battle = FMOD_MV.Params["system-bgm-battle"];
FMOD_MV.SystemBGM_Airship = FMOD_MV.Params["system-bgm-airship"];
FMOD_MV.SystemBGM_Boat = FMOD_MV.Params["system-bgm-boat"];
FMOD_MV.SystemBGM_Ship = FMOD_MV.Params["system-bgm-ship"];
FMOD_MV.SystemME_Victory = FMOD_MV.Params["system-me-victory"];
FMOD_MV.SystemME_Defeat = FMOD_MV.Params["system-me-defeat"];
FMOD_MV.SystemME_GameOver = FMOD_MV.Params["system-me-game-over"];
FMOD_MV.SystemSE_Cursor = FMOD_MV.Params["system-se-cursor"];
FMOD_MV.SystemSE_Ok = FMOD_MV.Params["system-se-ok"];
FMOD_MV.SystemSE_Cancel = FMOD_MV.Params["system-se-cancel"];
FMOD_MV.SystemSE_Buzzer = FMOD_MV.Params["system-se-buzzer"];
FMOD_MV.SystemSE_Equip = FMOD_MV.Params["system-se-equip"];
FMOD_MV.SystemSE_Save = FMOD_MV.Params["system-se-save"];
FMOD_MV.SystemSE_Load = FMOD_MV.Params["system-se-load"];
FMOD_MV.SystemSE_BattleStart = FMOD_MV.Params["system-se-battle-start"];
FMOD_MV.SystemSE_Escape = FMOD_MV.Params["system-se-escape"];
FMOD_MV.SystemSE_EnemyAttack = FMOD_MV.Params["system-se-enemy-attack"];
FMOD_MV.SystemSE_EnemyDamage = FMOD_MV.Params["system-se-enemy-damage"];
FMOD_MV.SystemSE_EnemyCollapse = FMOD_MV.Params["system-se-enemy-collapse"];
FMOD_MV.SystemSE_BossCollapse1 = FMOD_MV.Params["system-se-boss-collapse1"];
FMOD_MV.SystemSE_BossCollapse2 = FMOD_MV.Params["system-se-boss-collapse2"];
FMOD_MV.SystemSE_ActorDamage = FMOD_MV.Params["system-se-actor-damage"];
FMOD_MV.SystemSE_ActorCollapse = FMOD_MV.Params["system-se-actor-collapse"];
FMOD_MV.SystemSE_Recovery = FMOD_MV.Params["system-se-recovery"];
FMOD_MV.SystemSE_Miss = FMOD_MV.Params["system-se-miss"];
FMOD_MV.SystemSE_Evasion = FMOD_MV.Params["system-se-evasion"];
FMOD_MV.SystemSE_MagicEvasion = FMOD_MV.Params["system-se-magic-evasion"];
FMOD_MV.SystemSE_Reflection = FMOD_MV.Params["system-se-reflection"];
FMOD_MV.SystemSE_Shop = FMOD_MV.Params["system-se-shop"];
FMOD_MV.SystemSE_UseItem = FMOD_MV.Params["system-se-use-item"];
FMOD_MV.SystemSE_UseSkill = FMOD_MV.Params["system-se-use-skill"];
FMOD_MV.QueuedPauseBGMs = null;
FMOD_MV.QueuedPauseBGSs = null;
FMOD_MV.QueuedPauseBGMsByME = null;
FMOD_MV.VCA_BGM_VOLUME = 1;
FMOD_MV.VCA_BGS_VOLUME = 1;
FMOD_MV.VCA_ME_VOLUME = 1;
FMOD_MV.VCA_SE_VOLUME = 1;
FMOD_MV.MaximumHeapSize = Number(FMOD_MV.Params["total-memory"]) || 64 * 1024 * 1024;
FMOD_MV.EventType = {
None: 0,
BGM: 1,
BGS: 2,
ME: 3,
SE: 4
}
FMOD_MV.EventTypeValues = Object.values(FMOD_MV.EventType);
FMOD_MV.LISTENER_CAMERA = 0;
FMOD_MV.Initialized = false;
FMOD_MV.IsAudioResumed = false;
FMOD_MV.FGlobalSystem = null;
FMOD_MV.FGlobalSystemCore = null;
FMOD_MV.FBanks = null;
FMOD_MV.ListenerAttributes = [];
FMOD_MV.MaximumInstanceCount = 200;
FMOD_MV.Log = function(obj) {
console.log(`[FMOD_MV] ${obj}`);
}
FMOD_MV.Warn = function(obj) {
console.warn(`[FMOD_MV] ${obj}`);
}
FMOD_MV.Error = function(obj) {
console.error(`[FMOD_MV] ${obj}`);
}
FMOD_MV.Assert = function(result) {
if (result != FMOD.OK) {
if (result in FMOD_MV.FMODError)
throw new Error(`[FMOD_MV] FMOD Engine error occurred!<br>\n<br>\nThis might be caused by incorrect settings with Studio, you can search error code with 'FMOD Studio' to find more information.<br>\n<br>\n > Error code : ${FMOD_MV.FMODError[result]}<br>\n > Message : ${FMOD.ErrorString(result)}`);
else
throw new Error(`[FMOD_MV] FMOD Engine error occurred!<br>\n<br>\nThis might be caused by incorrect settings with Studio, you can search error code with 'FMOD Studio' to find more information.<br>\n<br>\n > Error code : UNKNOWN (ID : ${result})<br>\n > Message : ${FMOD.ErrorString(result)}`);
}
}
FMOD_MV.OnPreRun = function() {
var bankAssets = FMOD_MV.BankAssets;
var canRead = true;
var canWrite = false;
for (var bankAsset of bankAssets)
FMOD.FS_createPreloadedFile('/', bankAsset, FMOD_MV.BankPath + '/' + bankAsset, canRead, canWrite);
}
FMOD_MV.Initialize = function() {
FMOD_MV.FMODError = {[FMOD.OK]:"OK",[FMOD.ERR_BADCOMMAND]:"ERR_BADCOMMAND",[FMOD.ERR_CHANNEL_ALLOC]:"ERR_CHANNEL_ALLOC",[FMOD.ERR_CHANNEL_STOLEN]:"ERR_CHANNEL_STOLEN",[FMOD.ERR_DMA]:"ERR_DMA",[FMOD.ERR_DSP_CONNECTION]:"ERR_DSP_CONNECTION",[FMOD.ERR_DSP_DONTPROCESS]:"ERR_DSP_DONTPROCESS",[FMOD.ERR_DSP_FORMAT]:"ERR_DSP_FORMAT",[FMOD.ERR_DSP_INUSE]:"ERR_DSP_INUSE",[FMOD.ERR_DSP_NOTFOUND]:"ERR_DSP_NOTFOUND",[FMOD.ERR_DSP_RESERVED]:"ERR_DSP_RESERVED",[FMOD.ERR_DSP_SILENCE]:"ERR_DSP_SILENCE",[FMOD.ERR_DSP_TYPE]:"ERR_DSP_TYPE",[FMOD.ERR_FILE_BAD]:"ERR_FILE_BAD",[FMOD.ERR_FILE_COULDNOTSEEK]:"ERR_FILE_COULDNOTSEEK",[FMOD.ERR_FILE_DISKEJECTED]:"ERR_FILE_DISKEJECTED",[FMOD.ERR_FILE_EOF]:"ERR_FILE_EOF",[FMOD.ERR_FILE_ENDOFDATA]:"ERR_FILE_ENDOFDATA",[FMOD.ERR_FILE_NOTFOUND]:"ERR_FILE_NOTFOUND",[FMOD.ERR_FORMAT]:"ERR_FORMAT",[FMOD.ERR_HEADER_MISMATCH]:"ERR_HEADER_MISMATCH",[FMOD.ERR_HTTP]:"ERR_HTTP",[FMOD.ERR_HTTP_ACCESS]:"ERR_HTTP_ACCESS",[FMOD.ERR_HTTP_PROXY_AUTH]:"ERR_HTTP_PROXY_AUTH",[FMOD.ERR_HTTP_SERVER_ERROR]:"ERR_HTTP_SERVER_ERROR",[FMOD.ERR_HTTP_TIMEOUT]:"ERR_HTTP_TIMEOUT",[FMOD.ERR_INITIALIZATION]:"ERR_INITIALIZATION",[FMOD.ERR_INITIALIZED]:"ERR_INITIALIZED",[FMOD.ERR_INTERNAL]:"ERR_INTERNAL",[FMOD.ERR_INVALID_FLOAT]:"ERR_INVALID_FLOAT",[FMOD.ERR_INVALID_HANDLE]:"ERR_INVALID_HANDLE",[FMOD.ERR_INVALID_PARAM]:"ERR_INVALID_PARAM",[FMOD.ERR_INVALID_POSITION]:"ERR_INVALID_POSITION",[FMOD.ERR_INVALID_SPEAKER]:"ERR_INVALID_SPEAKER",[FMOD.ERR_INVALID_SYNCPOINT]:"ERR_INVALID_SYNCPOINT",[FMOD.ERR_INVALID_THREAD]:"ERR_INVALID_THREAD",[FMOD.ERR_INVALID_VECTOR]:"ERR_INVALID_VECTOR",[FMOD.ERR_MAXAUDIBLE]:"ERR_MAXAUDIBLE",[FMOD.ERR_MEMORY]:"ERR_MEMORY",[FMOD.ERR_MEMORY_CANTPOINT]:"ERR_MEMORY_CANTPOINT",[FMOD.ERR_NEEDS3D]:"ERR_NEEDS3D",[FMOD.ERR_NEEDSHARDWARE]:"ERR_NEEDSHARDWARE",[FMOD.ERR_NET_CONNECT]:"ERR_NET_CONNECT",[FMOD.ERR_NET_SOCKET_ERROR]:"ERR_NET_SOCKET_ERROR",[FMOD.ERR_NET_URL]:"ERR_NET_URL",[FMOD.ERR_NET_WOULD_BLOCK]:"ERR_NET_WOULD_BLOCK",[FMOD.ERR_NOTREADY]:"ERR_NOTREADY",[FMOD.ERR_OUTPUT_ALLOCATED]:"ERR_OUTPUT_ALLOCATED",[FMOD.ERR_OUTPUT_CREATEBUFFER]:"ERR_OUTPUT_CREATEBUFFER",[FMOD.ERR_OUTPUT_DRIVERCALL]:"ERR_OUTPUT_DRIVERCALL",[FMOD.ERR_OUTPUT_FORMAT]:"ERR_OUTPUT_FORMAT",[FMOD.ERR_OUTPUT_INIT]:"ERR_OUTPUT_INIT",[FMOD.ERR_OUTPUT_NODRIVERS]:"ERR_OUTPUT_NODRIVERS",[FMOD.ERR_PLUGIN]:"ERR_PLUGIN",[FMOD.ERR_PLUGIN_MISSING]:"ERR_PLUGIN_MISSING",[FMOD.ERR_PLUGIN_RESOURCE]:"ERR_PLUGIN_RESOURCE",[FMOD.ERR_PLUGIN_VERSION]:"ERR_PLUGIN_VERSION",[FMOD.ERR_RECORD]:"ERR_RECORD",[FMOD.ERR_REVERB_CHANNELGROUP]:"ERR_REVERB_CHANNELGROUP",[FMOD.ERR_REVERB_INSTANCE]:"ERR_REVERB_INSTANCE",[FMOD.ERR_SUBSOUNDS]:"ERR_SUBSOUNDS",[FMOD.ERR_SUBSOUND_ALLOCATED]:"ERR_SUBSOUND_ALLOCATED",[FMOD.ERR_SUBSOUND_CANTMOVE]:"ERR_SUBSOUND_CANTMOVE",[FMOD.ERR_TAGNOTFOUND]:"ERR_TAGNOTFOUND",[FMOD.ERR_TOOMANYCHANNELS]:"ERR_TOOMANYCHANNELS",[FMOD.ERR_TRUNCATED]:"ERR_TRUNCATED",[FMOD.ERR_UNIMPLEMENTED]:"ERR_UNIMPLEMENTED",[FMOD.ERR_UNINITIALIZED]:"ERR_UNINITIALIZED",[FMOD.ERR_UNSUPPORTED]:"ERR_UNSUPPORTED",[FMOD.ERR_VERSION]:"ERR_VERSION",[FMOD.ERR_EVENT_ALREADY_LOADED]:"ERR_EVENT_ALREADY_LOADED",[FMOD.ERR_EVENT_LIVEUPDATE_BUSY]:"ERR_EVENT_LIVEUPDATE_BUSY",[FMOD.ERR_EVENT_LIVEUPDATE_MISMATCH]:"ERR_EVENT_LIVEUPDATE_MISMATCH",[FMOD.ERR_EVENT_LIVEUPDATE_TIMEOUT]:"ERR_EVENT_LIVEUPDATE_TIMEOUT",[FMOD.ERR_EVENT_NOTFOUND]:"ERR_EVENT_NOTFOUND",[FMOD.ERR_STUDIO_UNINITIALIZED]:"ERR_STUDIO_UNINITIALIZED",[FMOD.ERR_STUDIO_NOT_LOADED]:"ERR_STUDIO_NOT_LOADED",[FMOD.ERR_INVALID_STRING]:"ERR_INVALID_STRING",[FMOD.ERR_ALREADY_LOCKED]:"ERR_ALREADY_LOCKED",[FMOD.ERR_NOT_LOCKED]:"ERR_NOT_LOCKED",[FMOD.ERR_RECORD_DISCONNECTED]:"ERR_RECORD_DISCONNECTED",[FMOD.ERR_TOOMANYSAMPLES]:"ERR_TOOMANYSAMPLES"}
var ptr_out = {}
var result;
result = FMOD.Studio_System_Create(ptr_out);
FMOD_MV.Assert(result);
var globalSystem = FMOD_MV.FGlobalSystem = ptr_out.val;
result = globalSystem.getCoreSystem(ptr_out);
FMOD_MV.Assert(result);
var globalSystemCore = FMOD_MV.FGlobalSystemCore = ptr_out.val;
result = globalSystemCore.setDSPBufferSize(2048, 2);
FMOD_MV.Assert(result);
result = globalSystem.initialize(1024, FMOD.STUDIO_INIT_NORMAL, FMOD.INIT_NORMAL, null);
FMOD_MV.Start();
FMOD_MV.RegisterListeners();
FMOD_MV.Assert(FMOD_MV.FGlobalSystemCore.mixerResume());
FMOD_MV.IsAudioResumed = true;
if (typeof OutputAudioWorklet_resumeAudio === "function")
OutputAudioWorklet_resumeAudio();
FMOD_MV.Initialized = true;
}
FMOD_MV.RegisterListeners = function() {
document.addEventListener("keydown", FMOD_MV.ResumeAudio.bind(this));
document.addEventListener("mousedown", FMOD_MV.ResumeAudio.bind(this));
document.addEventListener("touchend", FMOD_MV.ResumeAudio.bind(this), false);
document.addEventListener('touchstart', FMOD_MV.ResumeAudio.bind(this));
document.addEventListener('visibilitychange', FMOD_MV.OnVisibilityChange.bind(this));
document.addEventListener('blur', FMOD_MV.OnBlur.bind(this));
document.addEventListener('focus', FMOD_MV.OnFocus.bind(this));
if (!Utils.isNwjs())
return;
var window = nw.Window.get();
if (window._FMOD_MV_OnFocus)
window.removeListener('focus', window._FMOD_MV_OnFocus);
if (window._FMOD_MV_OnBlur)
window.removeListener('blur', window._FMOD_MV_OnBlur);
window._FMOD_MV_OnFocus = FMOD_MV.OnFocus.bind(this);
window._FMOD_MV_OnBlur = FMOD_MV.OnBlur.bind(this);
window.on('focus', window._FMOD_MV_OnFocus);
window.on('blur', window._FMOD_MV_OnBlur);
}
FMOD_MV.Vector = function(x, y, z, to) {
if (!to)
to = {}
to.x = x;
to.y = y;
to.z = z;
return to;
}
FMOD_MV.Create3DAttributes = function(x, y, z) {
var attributes = FMOD._3D_ATTRIBUTES();
FMOD_MV.Vector(x || 0, y || 0, z || 0, attributes.position);
FMOD_MV.Vector(0, 0, 0, attributes.velocity);
FMOD_MV.Vector(0, 0, 1, attributes.forward);
FMOD_MV.Vector(0, 1, 0, attributes.up);
return attributes;
}
FMOD_MV.SetListenerPosition = function(id, x, y, z) {
if (id < 0)
throw new Error('Invalid listener id');
if (!FMOD_MV.ListenerAttributes[id])
FMOD_MV.ListenerAttributes[id] = FMOD_MV.Create3DAttributes(x, y, z);
var attributes = FMOD_MV.ListenerAttributes[id];
FMOD_MV.Vector(x, y, z, attributes.position);
FMOD_MV.Assert(FMOD_MV.FGlobalSystem.setListenerAttributes(id, attributes, null));
}
FMOD_MV.Start = function() {
FMOD_MV.InstantiatedEvents = {
[FMOD_MV.EventType.None]: {},
[FMOD_MV.EventType.BGM]: {},
[FMOD_MV.EventType.BGS]: {},
[FMOD_MV.EventType.ME]: {},
[FMOD_MV.EventType.SE]: {}
}
FMOD_MV.SetListenerPosition(FMOD_MV.LISTENER_CAMERA, 0, 0, 0);
FMOD_MV.GlobalSpeaker = new Speaker({x: 0, y: 0});
FMOD_MV.Temp3DAttributes = FMOD_MV.Create3DAttributes();
FMOD_MV.FBanks = {}
var bankAssets = FMOD_MV.BankAssets;
var bank;
for (var bankAsset of bankAssets) {
bank = FMOD_MV.LoadBank(bankAsset);
FMOD_MV.FBanks[bankAsset] = bank;
if (bankAsset.endsWith('.strings.bank'))
FMOD_MV.GatherAllStrings(bankAsset, bank);
}
FMOD_MV.VCA_BGM = FMOD_MV.GetVCA(FMOD_MV.VCA_BGM);
FMOD_MV.VCA_BGS = FMOD_MV.GetVCA(FMOD_MV.VCA_BGS);
FMOD_MV.VCA_ME = FMOD_MV.GetVCA(FMOD_MV.VCA_ME);
FMOD_MV.VCA_SE = FMOD_MV.GetVCA(FMOD_MV.VCA_SE);
if (!FMOD_MV.VCA_BGM) FMOD_MV.Warn("FMOD MV Couldn't found VCA for BGM, volume for BGM channel will be ignored. (only applied to RM core system)");
if (!FMOD_MV.VCA_BGS) FMOD_MV.Warn("FMOD MV Couldn't found VCA for BGS, volume for BGS channel will be ignored. (only applied to RM core system)");
if (!FMOD_MV.VCA_ME) FMOD_MV.Warn("FMOD MV Couldn't found VCA for ME, volume for ME channel will be ignored. (only applied to RM core system)");
if (!FMOD_MV.VCA_SE) FMOD_MV.Warn("FMOD MV Couldn't found VCA for SE, volume for SE channel will be ignored. (only applied to RM core system)");
FMOD_MV.SetBGMVolume(AudioManager.bgmVolume);
FMOD_MV.SetBGSVolume(AudioManager.bgsVolume);
FMOD_MV.SetMEVolume(AudioManager.meVolume);
FMOD_MV.SetSEVolume(AudioManager.seVolume);
FMOD_MV.Snapshots = FMOD_MV.LoadAllSnapshots();
}
FMOD_MV.GetVCA = function(guid) {
if (!(guid instanceof Guid))
return null;
var ptr_out = {};
try {
FMOD_MV.Assert(FMOD_MV.FGlobalSystem.getVCAByID(guid, ptr_out));
} catch (ex) {
return null;
}
return ptr_out.val;
}
FMOD_MV.LoadAllSnapshots = function() {
var result = {}
if (!FMOD_FSPRO)
return result;
var ptr_event = {}
var ptr_instance = {}
var guid;
for (var snaps in FMOD_FSPRO.Snapshot) {
guid = FMOD_FSPRO.Snapshot[snaps];
FMOD_MV.Assert(FMOD_MV.FGlobalSystem.getEventByID(guid, ptr_event));
FMOD_MV.Assert(ptr_event.val.createInstance(ptr_instance));
result[guid] = ptr_instance.val;
}
return result;
}
FMOD_MV.GetEvent = function(type, guid) {
if (!(type in FMOD_MV.EventTypeValues))