class Circle { MidiOut midiOut; int channel; Segment[] s; int x, y; int w, n; float rotation = 0.0; float rotatingSpeed; Circle(int x, int y, int w, int n, float rotatingSpeed, int channel) { this.x = x; this.y = y; this.w = w; this.n = n; this.rotatingSpeed = rotatingSpeed; this.channel = channel; s = new Segment[n]; for (int i = 0; i < n; i++) { s[i] = new Segment(0, 0, 0, 0); } calculateSegments(); resetMidiOut(); } void resetMidiOut() { midiOut = midiIO.getMidiOut(channel, MIDI_OUT_DEVICE); } void calculateSegments() { float a = 0; float da = TWO_PI/n; s[0].x1 = x + w*cos(rotation); s[0].y1 = y + w*sin(rotation); s[n-1].x2 = s[0].x1; s[n-1].y2 = s[0].y1; for (int i = 1; i < n; i++) { a += da; s[i].x1 = x + w*cos(rotation + a); s[i].y1 = y + w*sin(rotation + a); s[i-1].x2 = s[i].x1; s[i-1].y2 = s[i].y1; s[i-1].calculateNormal(); } s[n-1].calculateNormal(); } void display() { if (rotatingSpeed != 0) { rotation += rotatingSpeed; calculateSegments(); } for (int i = 0; i < n; i++) { s[i].display(); } } void playSound(Segment s) { midiOut.sendNote(s.note); } }