Permalink
Browse files

Updated the MIDI systems to take new instruments into account.

  • Loading branch information...
me4502 committed Jun 2, 2017
1 parent 53407d9 commit 43a3fc83770a374f4d7c83c950749ad3caab0355
View
@@ -58,7 +58,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12-pre5-SNAPSHOT</version>
<version>1.12-pre6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
@@ -1,13 +1,32 @@
package com.sk89q.craftbook.util.jinglenote;
import org.bukkit.Sound;
public enum Instrument {
GUITAR, PIANO, BASS, BASS_GUITAR, STICKS, BASS_DRUM, SNARE_DRUM;
/*
0 = BLOCK_NOTE_HARP = PIANO
1 = BLOCK_NOTE_BASS = BASS
2 = BLOCK_NOTE_SNARE = SNARE_DRUM
3 = BLOCK_NOTE_HAT = STICKS
4 = BLOCK_NOTE_BASEDRUM = BASS_DRUM
5 = BLOCK_NOTE_GUITAR = GUITAR
6 = BLOCK_NOTE_BELL = BELL
7 = BLOCK_NOTE_CHIME = CHIME
8 = BLOCK_NOTE_FLUTE = FLUTE
9 = BLOCK_NOTE_XYLOPHONE = XYLOPHONE
10 = BLOCK_NOTE_PLING = PLING
*/
PIANO, BASS, SNARE_DRUM, STICKS, BASS_DRUM, GUITAR,
BELL, CHIME, FLUTE, XYLOPHONE, PLING;
public static Instrument toMCSound(byte instrument) {
switch (instrument) {
case 0:
return Instrument.PIANO;
case 1:
return Instrument.BASS_GUITAR;
return Instrument.BASS;
case 2:
return Instrument.SNARE_DRUM;
case 3:
@@ -17,7 +36,15 @@ public static Instrument toMCSound(byte instrument) {
case 5:
return Instrument.GUITAR;
case 6:
return Instrument.BASS;
return Instrument.BELL;
case 7:
return Instrument.CHIME;
case 8:
return Instrument.FLUTE;
case 9:
return Instrument.XYLOPHONE;
case 10:
return Instrument.PLING;
default:
return Instrument.PIANO;
}
@@ -21,37 +21,38 @@
* A sequencer that reads MIDI files.
*
* @author sk89q
* @author me4502
*/
public final class MidiJingleSequencer implements JingleSequencer {
private static final int[] instruments = {
0, 0, 0, 0, 0, 0, 0, 5, // 8
6, 0, 0, 0, 0, 0, 0, 0, // 16
0, 0, 0, 0, 0, 0, 0, 5, // 24
5, 5, 5, 5, 5, 5, 5, 5, // 32
6, 6, 6, 6, 6, 6, 6, 6, // 40
5, 5, 5, 5, 5, 5, 5, 2, // 48
5, 5, 5, 5, 0, 0, 0, 0, // 56
0, 0, 0, 0, 0, 0, 0, 0, // 64
0, 0, 0, 0, 0, 0, 0, 0, // 72
0, 0, 0, 0, 0, 0, 0, 0, // 80
9, 9, 9, 9, 9, 6, 0, 9, // 16
9, 0, 0, 0, 0, 0, 0, 5, // 24
5, 5, 5, 5, 5, 5, 5, 1, // 32
1, 1, 1, 1, 1, 1, 1, 5, // 40
1, 5, 5, 5, 5, 5, 5, 5, // 48
5, 5, 5, 8, 8, 8, 8, 8, // 56
8, 8, 8, 8, 8, 8, 8, 8, // 64
8, 8, 8, 8, 8, 8, 8, 8, // 72
8, 8, 8, 8, 8, 8, 8, 8, // 80
0, 0, 0, 0, 0, 0, 0, 0, // 88
0, 0, 0, 0, 0, 0, 0, 0, // 96
0, 0, 0, 0, 0, 0, 0, 0, // 104
0, 0, 0, 0, 0, 0, 0, 0, // 112
1, 1, 1, 3, 1, 1, 1, 5, // 120
1, 1, 1, 1, 1, 2, 4, 3, // 128
0, 0, 0, 0, 0, 0, 0, 5, // 104
5, 5, 5, 9, 8, 5, 8, 6, // 112
6, 3, 3, 2, 2, 2, 6, 5, // 120
1, 1, 1, 6, 1, 2, 4, 7, // 128
};
private static final int[] percussion = {
3, 3, 4, 4, 3, 2, 3, 2, //8 - Electric Snare
2, 2, 2, 2, 2, 2, 2, 2, //16 - Hi Mid Tom
3, 2, 3, 3, 3, 0, 3, 3, //24 - Cowbell
3, 3, 3, 2, 2, 3, 3, 3, //32 - Low Conga
2, 2, 0, 0, 2, 2, 0, 0, //40 - Long Whistle
3, 3, 3, 3, 3, 3, 5, 5, //48 - Open Cuica
3, 3, //50 - Open Triangle
9, 6, 4, 4, 3, 2, 3, 2, //40 - Electric Snare
2, 2, 2, 2, 2, 2, 2, 2, //48 - Hi Mid Tom
7, 2, 7, 7, 6, 3, 7, 6, //56 - Cowbell
7, 3, 7, 2, 2, 3, 3, 3, //64 - Low Conga
2, 2, 6, 6, 2, 2, 0, 0, //72 - Long Whistle
3, 3, 3, 3, 3, 3, 5, 5, //80 - Open Cuica
10, 10, //82 - Open Triangle
};
private Sequencer sequencer = null;
@@ -40,18 +40,24 @@ private static Sound toSound(Instrument instrument) {
switch(instrument) {
case PIANO:
return Sound.BLOCK_NOTE_HARP;
case GUITAR:
return Sound.BLOCK_NOTE_PLING;
case BASS:
return Sound.BLOCK_NOTE_BASS;
case BASS_GUITAR:
return Sound.BLOCK_NOTE_BASS;
case SNARE_DRUM:
return Sound.BLOCK_NOTE_SNARE;
case STICKS:
return Sound.BLOCK_NOTE_HAT;
case BASS_DRUM:
return Sound.BLOCK_NOTE_BASEDRUM;
case SNARE_DRUM:
return Sound.BLOCK_NOTE_SNARE;
case BELL:
return Sound.BLOCK_NOTE_BELL;
case CHIME:
return Sound.BLOCK_NOTE_CHIME;
case FLUTE:
return Sound.BLOCK_NOTE_FLUTE;
case XYLOPHONE:
return Sound.BLOCK_NOTE_XYLOPHONE;
case PLING:
return Sound.BLOCK_NOTE_PLING;
default:
return Sound.BLOCK_NOTE_HARP;
}

0 comments on commit 43a3fc8

Please sign in to comment.