Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/betamindy/world/blocks/logic/NotePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class NotePlayer extends Block {
public final static int[] whiteOffset = {0, 2, 4, 5, 7, 9, 11, 12, 14, 16};
public final static int[] blackOffset = {1, 3, 0, 6, 8, 10, 0, 13, 15};

//if true, this noteblock can play multiple notes per frame, but not the same note
public boolean multiNote = false;

public NotePlayer(String name){
super(name);

Expand Down Expand Up @@ -158,6 +161,7 @@ public class NotePlayerBuild extends Building {

private int octavePage = sampleOctave; //ui only
private long lastFrame;
private boolean[] played = new boolean[octaves * 12];

//sets the instrument safely
public void setMode(int m){
Expand All @@ -177,14 +181,30 @@ public void testNote(){

//plays a note
public void playNote(){
if(headless || lastFrame == Core.graphics.getFrameId()) return;
lastFrame = Core.graphics.getFrameId();
if(headless) return;
if (multiNote){
//only disable played pitches
if (lastFrame != Core.graphics.getFrameId()){
lastFrame = Core.graphics.getFrameId();
for (int i = 0; i < played.length; i++){
played[i] = false;
}
}
if (played[pitch]) return;
} else {
//disable all pitches if one pitch was played
if (lastFrame == Core.graphics.getFrameId()){
return;
}
lastFrame = Core.graphics.getFrameId();
}
if(global){
instruments[mode].play(pitch, volume / 10f);
}
else{
instruments[mode].at(pitch, x, y);
}
played[pitch] = true;
effects();
}

Expand Down