├── .classpath
├── .gitignore
├── .project
├── .settings
└── org.eclipse.jdt.core.prefs
├── LICENSE.md
├── README.md
├── build.xml
├── manifest.mf
├── nbproject
├── build-impl.xml
├── genfiles.properties
├── project.properties
└── project.xml
├── pom.xml
└── src
└── info
└── ata4
└── minecraft
└── muscode
├── MusCodeCli.java
├── MusCoder.java
└── io
├── MusInputStream.java
└── MusOutputStream.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # netbeans
2 | /nbproject/configs/
3 | /nbproject/private/
4 |
5 | # builds
6 | /build/
7 | /dist/
8 |
9 | # other
10 | /backup/
11 | /private/
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | muscode
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
3 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | ## License
2 |
3 | This is free and unencumbered software released into the public domain.
4 |
5 | Anyone is free to copy, modify, publish, use, compile, sell, or
6 | distribute this software, either in source code form or as a compiled
7 | binary, for any purpose, commercial or non-commercial, and by any
8 | means.
9 |
10 | In jurisdictions that recognize copyright laws, the author or authors
11 | of this software dedicate any and all copyright interest in the
12 | software to the public domain. We make this dedication for the benefit
13 | of the public at large and to the detriment of our heirs and
14 | successors. We intend this dedication to be an overt act of
15 | relinquishment in perpetuity of all present and future rights to this
16 | software under copyright law.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | OTHER DEALINGS IN THE SOFTWARE.
25 |
26 | For more information, please refer to
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | MusCode
2 | =======
3 |
4 | MusCode converts XOR-encrypted .mus files for Minecraft into ordinary Ogg Vorbis files and vice versa.
5 |
6 | Usage
7 | -----
8 |
9 | Basic usage:
10 |
11 | java -jar muscode.jar
12 |
13 | Decode music.mus in the current working directory:
14 |
15 | java -jar muscode.jar music.mus
16 |
17 | Encode music.ogg in the current working directory:
18 |
19 | java -jar muscode.jar music.ogg
20 |
21 | Convert all files in the Minecraft music directory under Windows:
22 |
23 | java -jar muscode.jar %APPDATA\.minecraft\resources\streaming
24 |
25 | Convert all files in the Minecraft music directory under Linux/MacOS X:
26 |
27 | java -jar muscode.jar ~/.minecraft/resources/streaming
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project muscode.
12 |
13 |
74 |
75 |
--------------------------------------------------------------------------------
/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/nbproject/build-impl.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
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 | Must set src.dir
232 | Must set test.src.dir
233 | Must set build.dir
234 | Must set dist.dir
235 | Must set build.classes.dir
236 | Must set dist.javadoc.dir
237 | Must set build.test.classes.dir
238 | Must set build.test.results.dir
239 | Must set build.classes.excludes
240 | Must set dist.jar
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 | Must set javac.includes
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 | No tests executed.
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 |
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 | Must set JVM to use for profiling in profiler.info.jvm
708 | Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
709 |
710 |
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 |
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 | Must select some files in the IDE or set javac.includes
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 | To run this application from the command line without Ant, try:
971 |
972 |
973 |
974 |
975 |
976 |
977 | java -cp "${run.classpath.with.dist.jar}" ${main.class}
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 |
1002 | To run this application from the command line without Ant, try:
1003 |
1004 | java -jar "${dist.jar.resolved}"
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 |
1017 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 | Must select one file in the IDE or set run.class
1034 |
1035 |
1036 |
1037 | Must select one file in the IDE or set run.class
1038 |
1039 |
1040 |
1045 |
1046 |
1047 |
1048 |
1049 |
1050 |
1051 |
1052 |
1053 |
1054 |
1055 |
1056 |
1057 |
1058 |
1059 |
1060 |
1061 |
1062 |
1063 |
1064 | Must select one file in the IDE or set debug.class
1065 |
1066 |
1067 |
1068 |
1069 | Must select one file in the IDE or set debug.class
1070 |
1071 |
1072 |
1073 |
1074 | Must set fix.includes
1075 |
1076 |
1077 |
1078 |
1079 |
1080 |
1081 |
1086 |
1089 |
1090 | This target only works when run from inside the NetBeans IDE.
1091 |
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1098 |
1099 | Must select one file in the IDE or set profile.class
1100 | This target only works when run from inside the NetBeans IDE.
1101 |
1102 |
1103 |
1104 |
1105 |
1106 |
1107 |
1108 |
1109 | This target only works when run from inside the NetBeans IDE.
1110 |
1111 |
1112 |
1113 |
1114 |
1115 |
1116 |
1117 |
1118 |
1119 |
1120 |
1121 |
1122 | This target only works when run from inside the NetBeans IDE.
1123 |
1124 |
1125 |
1126 |
1127 |
1128 |
1129 |
1130 |
1131 |
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 |
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 | Must select one file in the IDE or set run.class
1161 |
1162 |
1163 |
1164 |
1165 |
1166 | Must select some files in the IDE or set test.includes
1167 |
1168 |
1169 |
1170 |
1171 | Must select one file in the IDE or set run.class
1172 |
1173 |
1174 |
1175 |
1176 | Must select one file in the IDE or set applet.url
1177 |
1178 |
1179 |
1180 |
1185 |
1186 |
1187 |
1188 |
1189 |
1190 |
1191 |
1192 |
1193 |
1194 |
1195 |
1196 |
1197 |
1198 |
1199 |
1200 |
1201 |
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1208 |
1209 |
1210 |
1211 |
1212 |
1213 |
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
1220 |
1221 |
1226 |
1227 |
1228 |
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1241 |
1242 |
1243 |
1244 |
1245 |
1246 |
1247 |
1248 |
1249 |
1250 |
1251 |
1252 | Must select some files in the IDE or set javac.includes
1253 |
1254 |
1255 |
1256 |
1257 |
1258 |
1259 |
1260 |
1261 |
1262 |
1263 |
1264 |
1269 |
1270 |
1271 |
1272 |
1273 |
1274 |
1275 |
1276 | Some tests failed; see details above.
1277 |
1278 |
1279 |
1280 |
1281 |
1282 |
1283 |
1284 |
1285 | Must select some files in the IDE or set test.includes
1286 |
1287 |
1288 |
1289 | Some tests failed; see details above.
1290 |
1291 |
1292 |
1293 | Must select some files in the IDE or set test.class
1294 | Must select some method in the IDE or set test.method
1295 |
1296 |
1297 |
1298 | Some tests failed; see details above.
1299 |
1300 |
1301 |
1306 |
1307 | Must select one file in the IDE or set test.class
1308 |
1309 |
1310 |
1311 | Must select one file in the IDE or set test.class
1312 | Must select some method in the IDE or set test.method
1313 |
1314 |
1315 |
1316 |
1317 |
1318 |
1319 |
1320 |
1321 |
1322 |
1323 |
1324 |
1329 |
1330 | Must select one file in the IDE or set applet.url
1331 |
1332 |
1333 |
1334 |
1335 |
1336 |
1337 |
1342 |
1343 | Must select one file in the IDE or set applet.url
1344 |
1345 |
1346 |
1347 |
1348 |
1349 |
1350 |
1351 |
1356 |
1357 |
1358 |
1359 |
1360 |
1361 |
1362 |
1363 |
1364 |
1365 |
1366 |
1367 |
1368 |
1369 |
1370 |
1371 |
1372 |
1373 |
1374 |
1375 |
1376 |
1377 |
1378 |
1379 |
1380 |
1381 |
1382 |
1383 |
1384 |
1385 |
1386 |
1387 |
1388 |
1389 |
1390 |
1391 |
1392 |
1393 |
1394 |
1395 |
1396 |
1397 |
1398 |
1399 |
1400 |
1401 |
--------------------------------------------------------------------------------
/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=67dd6fec
2 | build.xml.script.CRC32=e53a29f7
3 | build.xml.stylesheet.CRC32=28e38971@1.50.1.46
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=67dd6fec
7 | nbproject/build-impl.xml.script.CRC32=df538d4b
8 | nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
9 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processors.list=
4 | annotation.processing.run.all.processors=true
5 | application.title=muscode
6 | application.vendor=Barracuda
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # This directory is removed when the project is cleaned:
24 | dist.dir=dist
25 | dist.jar=${dist.dir}/muscode.jar
26 | dist.javadoc.dir=${dist.dir}/javadoc
27 | endorsed.classpath=
28 | excludes=
29 | includes=**
30 | jar.archive.disabled=${jnlp.enabled}
31 | jar.compress=false
32 | jar.index=${jnlp.enabled}
33 | javac.classpath=\
34 | ${libs.Apache_Commons_IO_2.4.classpath}
35 | # Space-separated list of extra javac options
36 | javac.compilerargs=
37 | javac.deprecation=false
38 | javac.processorpath=\
39 | ${javac.classpath}
40 | javac.source=1.8
41 | javac.target=1.8
42 | javac.test.classpath=\
43 | ${javac.classpath}:\
44 | ${build.classes.dir}
45 | javadoc.additionalparam=
46 | javadoc.author=false
47 | javadoc.encoding=${source.encoding}
48 | javadoc.noindex=false
49 | javadoc.nonavbar=false
50 | javadoc.notree=false
51 | javadoc.private=false
52 | javadoc.splitindex=true
53 | javadoc.use=true
54 | javadoc.version=false
55 | javadoc.windowtitle=
56 | jnlp.codebase.type=no.codebase
57 | jnlp.descriptor=application
58 | jnlp.enabled=false
59 | jnlp.mixed.code=default
60 | jnlp.offline-allowed=false
61 | jnlp.signed=false
62 | jnlp.signing=
63 | jnlp.signing.alias=
64 | jnlp.signing.keystore=
65 | main.class=info.ata4.minecraft.muscode.MusCodeCli
66 | manifest.file=manifest.mf
67 | meta.inf.dir=${src.dir}/META-INF
68 | mkdist.disabled=false
69 | platform.active=default_platform
70 | run.classpath=\
71 | ${javac.classpath}:\
72 | ${build.classes.dir}
73 | # Space-separated list of JVM arguments used when running the project
74 | # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
75 | # or test-sys-prop.name=value to set system properties for unit tests):
76 | run.jvmargs=
77 | run.test.classpath=\
78 | ${javac.test.classpath}:\
79 | ${build.test.classes.dir}
80 | source.encoding=UTF-8
81 | src.dir=src
82 | test.src.dir=test
83 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | muscode
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | info.ata4.minecraft
8 | muscode
9 | 1.2
10 | jar
11 |
12 | muscode
13 | https://github.com/ata4/muscode
14 |
15 |
16 | build
17 | src
18 |
19 |
20 | org.apache.maven.plugins
21 | maven-jar-plugin
22 | 3.2.2
23 |
24 |
25 |
26 | true
27 | info.ata4.minecraft.muscode.MusCodeCli
28 |
29 |
30 |
31 |
32 |
33 | maven-assembly-plugin
34 | 3.3.0
35 |
36 |
37 |
38 | true
39 | info.ata4.minecraft.muscode.MusCodeCli
40 |
41 |
42 | production
43 | https://github.com/ata4/muscode
44 |
45 |
46 |
47 | jar-with-dependencies
48 |
49 |
50 |
51 |
52 | make-assembly
53 | package
54 |
55 | single
56 |
57 |
58 |
59 |
60 |
61 | org.apache.maven.plugins
62 | maven-resources-plugin
63 | 2.6
64 |
65 |
66 | default-resources
67 | none
68 |
69 |
70 | default-testResources
71 | none
72 |
73 |
74 |
75 |
76 | org.apache.maven.plugins
77 | maven-compiler-plugin
78 | 3.1
79 |
80 |
81 | default-testCompile
82 | none
83 |
84 |
85 |
86 |
87 | org.apache.maven.plugins
88 | maven-surefire-plugin
89 | 2.12.4
90 |
91 |
92 | default-test
93 | none
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | info.ata4.minecraft.muscode.MusCodeCli
102 | 1.8
103 | 1.8
104 | UTF-8
105 |
106 |
107 |
108 |
109 | commons-io
110 | commons-io
111 | 2.11.0
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/src/info/ata4/minecraft/muscode/MusCodeCli.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** 2011 March 16
3 | **
4 | ** The author disclaims copyright to this source code. In place of
5 | ** a legal notice, here is a blessing:
6 | ** May you do good and not evil.
7 | ** May you find forgiveness for yourself and forgive others.
8 | ** May you share freely, never taking more than you give.
9 | */
10 | package info.ata4.minecraft.muscode;
11 |
12 | import java.io.*;
13 |
14 | /**
15 | * Main class for musdecode, used for file handling.
16 | *
17 | * @author Nico Bergemann
18 | */
19 | public class MusCodeCli {
20 |
21 | private static final String VERSION = "1.2";
22 |
23 | public static void main(String[] args) {
24 | if (args.length == 0) {
25 | System.out.println("MusCode " + VERSION);
26 | System.out.println("Decodes .mus files for Minecraft into ordinary Ogg Vorbis files and vice versa");
27 | System.out.println("Usage: muscode ");
28 | System.exit(0);
29 | }
30 |
31 | File file = new File(args[0]);
32 |
33 | if (file.isFile() && file.canRead()) {
34 | process(file);
35 | } else if (file.isDirectory()) {
36 | File[] files = file.listFiles();
37 |
38 | for (File dirFile : files) {
39 | if (!dirFile.isFile()) {
40 | continue;
41 | }
42 |
43 | process(dirFile);
44 | }
45 | } else {
46 | System.err.println("Invalid input file or directory");
47 | }
48 | }
49 |
50 | private static void process(File file) {
51 | try {
52 | MusCoder.transcode(file);
53 | System.out.println("Converted file " + file.getName());
54 | } catch (Exception ex) {
55 | System.err.println("Can't convert file " + file.getName() + ": " + ex);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/info/ata4/minecraft/muscode/MusCoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** 2012 September 25
3 | **
4 | ** The author disclaims copyright to this source code. In place of
5 | ** a legal notice, here is a blessing:
6 | ** May you do good and not evil.
7 | ** May you find forgiveness for yourself and forgive others.
8 | ** May you share freely, never taking more than you give.
9 | */
10 | package info.ata4.minecraft.muscode;
11 |
12 | import info.ata4.minecraft.muscode.io.MusInputStream;
13 | import info.ata4.minecraft.muscode.io.MusOutputStream;
14 | import java.io.File;
15 | import java.io.FileInputStream;
16 | import java.io.FileNotFoundException;
17 | import java.io.FileOutputStream;
18 | import java.io.IOException;
19 | import java.io.InputStream;
20 | import java.io.OutputStream;
21 | import org.apache.commons.io.FileUtils;
22 | import org.apache.commons.io.FilenameUtils;
23 | import org.apache.commons.io.IOUtils;
24 |
25 | /**
26 | * Mus/Ogg encoding and decoding routines.
27 | *
28 | * @author Nico Bergemann
29 | */
30 | public class MusCoder {
31 |
32 | private MusCoder() {
33 | }
34 |
35 | /**
36 | * Decodes a .mus file and saves it as a new file with .ogg extension.
37 | *
38 | * @param musFile .mus file
39 | * @throws FileNotFoundException
40 | * @throws IOException
41 | */
42 | public static void decode(File musFile) throws FileNotFoundException, IOException {
43 | InputStream is = null;
44 |
45 | String oggPath = FilenameUtils.removeExtension(musFile.getPath()) + ".ogg";
46 | File oggFile = new File(oggPath);
47 |
48 | try {
49 | is = new MusInputStream(new FileInputStream(musFile), musFile.getName().hashCode());
50 | FileUtils.copyInputStreamToFile(is, oggFile);
51 | FileUtils.deleteQuietly(musFile);
52 | } finally {
53 | IOUtils.closeQuietly(is);
54 | }
55 | }
56 |
57 | /**
58 | * Encodes a .ogg file and saves it as a new file with .mus extension.
59 | *
60 | * @param oggFile .ogg file
61 | * @throws FileNotFoundException
62 | * @throws IOException
63 | */
64 | public static void encode(File oggFile) throws FileNotFoundException, IOException {
65 | InputStream is = null;
66 | OutputStream os = null;
67 |
68 | String musPath = FilenameUtils.removeExtension(oggFile.getPath()) + ".mus";
69 | File musFile = new File(musPath);
70 |
71 | try {
72 | is = FileUtils.openInputStream(oggFile);
73 | os = new MusOutputStream(new FileOutputStream(musFile), musFile.getName().hashCode());
74 | IOUtils.copy(is, os);
75 | IOUtils.closeQuietly(is);
76 | FileUtils.deleteQuietly(oggFile);
77 | } finally {
78 | IOUtils.closeQuietly(is);
79 | IOUtils.closeQuietly(os);
80 | }
81 | }
82 |
83 | /**
84 | * Automatically de-/encodes a mus/ogg file depending on the file extension.
85 | *
86 | * @param file
87 | * @throws FileNotFoundException
88 | * @throws IOException
89 | */
90 | public static void transcode(File file) throws FileNotFoundException, IOException {
91 | String ext = FilenameUtils.getExtension(file.getName());
92 | if (ext.equals("mus")) {
93 | decode(file);
94 | } else if (ext.equals("ogg")) {
95 | encode(file);
96 | } else {
97 | throw new IllegalArgumentException("Invalid file extension");
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/info/ata4/minecraft/muscode/io/MusInputStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** 2011 March 16
3 | **
4 | ** The author disclaims copyright to this source code. In place of
5 | ** a legal notice, here is a blessing:
6 | ** May you do good and not evil.
7 | ** May you find forgiveness for yourself and forgive others.
8 | ** May you share freely, never taking more than you give.
9 | */
10 | package info.ata4.minecraft.muscode.io;
11 |
12 | import java.io.FilterInputStream;
13 | import java.io.IOException;
14 | import java.io.InputStream;
15 |
16 | /**
17 | * Hash-based XOR-decoder for .mus streams.
18 | *
19 | * @author Nico Bergemann
20 | */
21 | public class MusInputStream extends FilterInputStream {
22 |
23 | private int hash;
24 |
25 | public MusInputStream(InputStream in, int hashCode) {
26 | super(in);
27 | hash = hashCode;
28 | }
29 |
30 | private byte decode(byte b) {
31 | b = (byte) (b ^ hash >> 8);
32 | hash = hash * 498729871 + 85731 * b;
33 | return b;
34 | }
35 |
36 | @Override
37 | public int read() throws IOException {
38 | return decode((byte) in.read());
39 | }
40 |
41 | @Override
42 | public int read(byte[] b, int off, int len) throws IOException {
43 | len = super.read(b, off, len);
44 | for (int i = 0; i < len; ++i) {
45 | b[off + i] = decode(b[off + i]);
46 | }
47 | return len;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/info/ata4/minecraft/muscode/io/MusOutputStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | ** 2012 February 6
3 | **
4 | ** The author disclaims copyright to this source code. In place of
5 | ** a legal notice, here is a blessing:
6 | ** May you do good and not evil.
7 | ** May you find forgiveness for yourself and forgive others.
8 | ** May you share freely, never taking more than you give.
9 | */
10 | package info.ata4.minecraft.muscode.io;
11 |
12 | import java.io.FilterOutputStream;
13 | import java.io.IOException;
14 | import java.io.OutputStream;
15 |
16 | /**
17 | * Hash-based XOR-encoder for .mus streams.
18 | *
19 | * @author Nico Bergemann
20 | */
21 | public class MusOutputStream extends FilterOutputStream {
22 |
23 | private int hash;
24 |
25 | public MusOutputStream(OutputStream out, int hashCode) {
26 | super(out);
27 | hash = hashCode;
28 | }
29 |
30 | private byte encode(byte b) {
31 | byte b2 = (byte) (b ^ hash >> 8);
32 | hash = hash * 498729871 + 85731 * b;
33 | return b2;
34 | }
35 |
36 | @Override
37 | public void write(int b) throws IOException {
38 | out.write(encode((byte) b));
39 | }
40 |
41 | @Override
42 | public void write(byte[] b, int off, int len) throws IOException {
43 | for (int i = 0; i < len; ++i) {
44 | b[off + i] = encode(b[off + i]);
45 | }
46 | out.write(b, off, len);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------