import java.util.*; import image.*; import world.sound.SoundWorld; import world.sound.tunes.*; public class MousePointsSoundWorld extends SoundWorld{ ArrayList music; int currnote = 0; // Simple Main Program public static void main(String[] args) { new MousePointsSoundWorld().bigBang(); } // The inner Scene Scene scene = new EmptyScene(200, 200); // The current pitch to be played int pitch = NoteDownC; // Create a new World MousePointsSoundWorld(){ super(); // Initialize 4 instruments to play with // Channel 0 - Accordion // Channel 1 - AcousticGrandPiano // ... this.musicBox.initChannels(Accordion,AcousticGrandPiano,Clavi,Celesta); } // Draw by returning the inner Scene public Scene onDraw(){ return this.scene; } // On a mouse click add a circle to the inner Scene, increment the // current pitch and play a short note public void onMouse(int x, int y, String me){ if(me.equals("button-down")){ this.pitch++; // Add a note to play on channel 0 (Accordion) this.tickTunes.addNote(0, new Note(this.pitch, 3)); // Add a note to play on channel 1 (AcousticGrandPiano) this.tickTunes.addNote(1, new Note(this.pitch+3, 3)); this.tickTunes.addNote(2, new Note(this.pitch-2, 3)); this.tickTunes.addNote(3, new Note(this.pitch-4, 3)); this.scene = this.scene.placeImage( new Circle(20, "solid", "red") .overlay(new Circle(20, "outline", "black")), x, y); } } public double tickRate() { return .5; } } class Examples { MousePointsSoundWorld mp = new MousePointsSoundWorld(); { this.mp.bigBang(); } }