From d9fc63a75e7aa5c01caa9ced8243dc1996fc89ed Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sun, 1 Oct 2023 11:27:54 +0700 Subject: [PATCH] original pitch fucking shit --- .../chayapak/chomens_bot/commands/MusicCommand.java | 1 + .../chomens_bot/plugins/MusicPlayerPlugin.java | 10 +++++----- .../chayapak/chomens_bot/song/MidiConverter.java | 4 ++-- .../chayapak/chomens_bot/song/NBSConverter.java | 4 ++-- .../land/chipmunk/chayapak/chomens_bot/song/Note.java | 3 +++ .../chayapak/chomens_bot/song/TextFileConverter.java | 1 + 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java index 7ca37a5..9bac125 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java @@ -469,6 +469,7 @@ public class MusicCommand extends Command { new Note( Instrument.fromId(instrumentId), j, + j, 1, i * 50, -1, diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java index 2540f65..5aac945 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java @@ -320,13 +320,13 @@ public class MusicPlayerPlugin extends Bot.Listener { if (average > 100) blockPosition = -(float) average / 100; // left else if (average < 100) blockPosition = (float) average / 100; // right } else { - // this uses the pitch to calculate - final float pitch = note.pitch; + // this uses the MIDI PITCH to calculate + final float pitch = note.originalPitch; - if (pitch > 8) blockPosition = -(float) (pitch / -8) - 2; // left - else if (pitch < 2) blockPosition = (pitch / 2) - 2; // right + if (pitch > 93) blockPosition = -(float) (pitch / -93) - 2; // right + else if (pitch < 10) blockPosition = (pitch / 10) - 2; // left - blockPosition = MathUtilities.clamp(blockPosition, -0.5F, 0.5F); + blockPosition = MathUtilities.clamp(blockPosition, -0.4F, 0.4F); } key += 33; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java index 773f9bb..f190bb6 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/MidiConverter.java @@ -193,7 +193,7 @@ public class MidiConverter implements Converter { float volume = (float) velocity / 127.0f; long time = microTime / 1000L; - return new Note(instrument, pitch, volume, time, -1, 100); + return new Note(instrument, pitch, midiPitch, volume, time, -1, 100); } private static Note getMidiPercussionNote (int midiPitch, int velocity, long microTime) { @@ -204,7 +204,7 @@ public class MidiConverter implements Converter { Instrument instrument = Instrument.fromId(noteId / 25); long time = microTime / 1000L; - return new Note(instrument, pitch, volume, time, -1, 100); + return new Note(instrument, pitch, midiPitch, volume, time, -1, 100); } return null; } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/NBSConverter.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/NBSConverter.java index d7daf23..2205fc6 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/NBSConverter.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/NBSConverter.java @@ -232,9 +232,9 @@ public class NBSConverter implements Converter { int pitch = key-33; try { - song.add(new Note(instrument, pitch, (float) note.velocity * (float) layerVolume / 10000f, getMilliTime(note.tick, tempo), note.panning, nbsLayers.get(note.layer).stereo)); + song.add(new Note(instrument, pitch, key, (float) note.velocity * (float) layerVolume / 10000f, getMilliTime(note.tick, tempo), note.panning, nbsLayers.get(note.layer).stereo)); } catch (Exception e) { - song.add(new Note(instrument, pitch, (float) note.velocity * (float) layerVolume / 10000f, getMilliTime(note.tick, tempo), -1, 100)); + song.add(new Note(instrument, pitch, key, (float) note.velocity * (float) layerVolume / 10000f, getMilliTime(note.tick, tempo), -1, 100)); } } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Note.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Note.java index a10b4ae..8df618c 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Note.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Note.java @@ -4,6 +4,7 @@ package land.chipmunk.chayapak.chomens_bot.song; public class Note implements Comparable { public final Instrument instrument; public final int pitch; + public final int originalPitch; public final float volume; public final long time; public final int panning; @@ -12,6 +13,7 @@ public class Note implements Comparable { public Note ( Instrument instrument, int pitch, + int originalPitch, float volume, long time, int panning, @@ -19,6 +21,7 @@ public class Note implements Comparable { ) { this.instrument = instrument; this.pitch = pitch; + this.originalPitch = originalPitch; this.volume = volume; this.time = time; this.panning = panning; diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/TextFileConverter.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/TextFileConverter.java index 084a89d..2555bd5 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/TextFileConverter.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/TextFileConverter.java @@ -57,6 +57,7 @@ public class TextFileConverter implements Converter { Instrument.of(instrument) : Instrument.fromId(intInstrument), pitch, + pitch, volume, time, -1,