import java.awt.*;
import java.applet.*;
class MyCanvas2 extends Canvas {
char n = 'x';
char d = 'x';
int dval=0;
int xval=10;
int line=0;
public int amount = 64;
public char notes[];
public MyCanvas2()
{
notes = new char[4000];
for(int z=0;z<4000;z++)
notes[z]='x';
for(int z=1;z<=127;z+=2)
notes[z]='s';
notes[0]='c';
notes[2]='e';
notes[4]='g';
notes[6]='C';
notes[8]='E';
notes[10]='g';
notes[12]='C';
notes[14]='E';
notes[16]='c';
notes[18]='e';
notes[20]='g';
notes[22]='C';
notes[24]='E';
notes[26]='g';
notes[28]='C';
notes[30]='E';
notes[32]='c';
notes[34]='d';
notes[36]='a';
notes[38]='D';
notes[40]='F';
notes[42]='a';
notes[44]='D';
notes[46]='F';
notes[48]='c';
notes[50]='d';
notes[52]='a';
notes[54]='D';
notes[56]='F';
notes[58]='a';
notes[60]='D';
notes[62]='F';
notes[64]='d';
notes[66]='f';
notes[68]='g';
notes[70]='D';
notes[72]='F';
notes[74]='g';
notes[76]='D';
notes[78]='F';
notes[80]='d';
notes[82]='f';
notes[84]='g';
notes[86]='D';
notes[88]='F';
notes[90]='g';
notes[92]='D';
notes[94]='F';
notes[96]='c';
notes[98]='e';
notes[100]='g';
notes[102]='C';
notes[104]='E';
notes[106]='g';
notes[108]='C';
notes[110]='E';
notes[112]='c';
notes[114]='e';
notes[116]='g';
notes[118]='C';
notes[120]='E';
notes[122]='g';
notes[124]='C';
notes[126]='E';
}
public void paint(Graphics g)
{
xval = 10;
line =0;
for(int lineNumber=20;lineNumber<2000;lineNumber+=50)
{
for(int q=0;q<=24;q+=6)
g.drawLine(10,lineNumber+q,346,lineNumber+q);
for(int i=122;i<=234;i+=112)
g.drawLine(i,lineNumber,i,lineNumber+24);
}
for(int y=0;y=346)
{
xval -= 336;
line++;
}
}
}
}
public class MusicSample extends Applet {
private Button highE, highF, G, A, B, C, D, lowE, lowF, lowD,lowC,
play, backspace;
int xpos, ypos;
private List type;
private ScrollPane scalesScroller;
private MyCanvas2 scales;
private GridBagLayout gbLayout;
private GridBagConstraints gbConstraints;
private AudioClip lowCwhole, lowChalf, lowCquarter, lowCeigth, lowCsixteenth,
lowDwhole, lowDhalf, lowDquarter, lowDeigth, lowDsixteenth,
lowEwhole, lowEhalf, lowEquarter, lowEeigth, lowEsixteenth,
lowFwhole, lowFhalf, lowFquarter, lowFeigth, lowFsixteenth,
Gwhole, Ghalf, Gquarter, Geigth, Gsixteenth,
Awhole, Ahalf, Aquarter, Aeigth, Asixteenth,
Bwhole, Bhalf, Bquarter, Beigth, Bsixteenth,
Cwhole, Chalf, Cquarter, Ceigth, Csixteenth,
Dwhole, Dhalf, Dquarter, Deigth, Dsixteenth,
highEwhole, highEhalf, highEquarter, highEeigth, highEsixteenth,
highFwhole, highFhalf, highFquarter, highFeigth, highFsixteenth;
public void init()
{
gbLayout = new GridBagLayout();
setLayout(gbLayout);
gbConstraints = new GridBagConstraints();
highE = new Button("E");
highF = new Button("F");
G = new Button("G");
A = new Button("A");
B = new Button("B");
C = new Button("C");
D = new Button("D");
lowE = new Button("E");
lowF = new Button("F");
lowD = new Button("D");
lowC = new Button("C");
play = new Button("Play");
backspace = new Button("Backspace");
type = new List(5, false);
type.addItem("whole");
type.addItem("half");
type.addItem("quarter");
type.addItem("eigth");
type.addItem("sixteenth");
scales = new MyCanvas2();
scales.setSize(356, 2000);
scalesScroller = new ScrollPane();
scalesScroller.add(scales);
scalesScroller.setSize(356,300);
gbConstraints.weightx = 1;
gbConstraints.weighty = 1;
gbConstraints.fill = GridBagConstraints.BOTH;
addComponent(scalesScroller,gbLayout,gbConstraints,0,0,2,15);
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
gbConstraints.weighty = 0;
gbConstraints.weightx = 0;
addComponent(type,gbLayout,gbConstraints,3,2,1,5);
addComponent(play,gbLayout,gbConstraints,0,2,1,1);
addComponent(backspace,gbLayout,gbConstraints,1,2,1,1);
addComponent(highF,gbLayout,gbConstraints,0,3,1,1);
addComponent(highE,gbLayout,gbConstraints,1,3,1,1);
addComponent(D,gbLayout,gbConstraints,2,3,1,1);
addComponent(C,gbLayout,gbConstraints,3,3,1,1);
addComponent(B,gbLayout,gbConstraints,4,3,1,1);
addComponent(A,gbLayout,gbConstraints,5,3,1,1);
addComponent(G,gbLayout,gbConstraints,6,3,1,1);
addComponent(lowF,gbLayout,gbConstraints,7,3,1,1);
addComponent(lowE,gbLayout,gbConstraints,8,3,1,1);
addComponent(lowD,gbLayout,gbConstraints,9,3,1,1);
addComponent(lowC,gbLayout,gbConstraints,10,3,1,1);
gbConstraints.weighty = 0;
lowCwhole = getAudioClip(getDocumentBase(), "Cwhole.au");
lowChalf = getAudioClip(getDocumentBase(), "Chalf.au");
lowCquarter = getAudioClip(getDocumentBase(), "Cquarter.au");
lowCeigth = getAudioClip(getDocumentBase(), "Ceigth.au");
lowCsixteenth = getAudioClip(getDocumentBase(), "Csixteenth.au");
lowDwhole = getAudioClip(getDocumentBase(), "Dwhole.au");
lowDhalf = getAudioClip(getDocumentBase(), "Dhalf.au");
lowDquarter = getAudioClip(getDocumentBase(), "Dquarter.au");
lowDeigth = getAudioClip(getDocumentBase(), "Deigth.au");
lowDsixteenth = getAudioClip(getDocumentBase(), "Dsixteenth.au");
lowEwhole = getAudioClip(getDocumentBase(), "Ewhole.au");
lowEhalf = getAudioClip(getDocumentBase(), "Ehalf.au");
lowEquarter = getAudioClip(getDocumentBase(), "Equarter.au");
lowEeigth = getAudioClip(getDocumentBase(), "Eeigth.au");
lowEsixteenth = getAudioClip(getDocumentBase(), "Esixteenth.au");
lowFwhole = getAudioClip(getDocumentBase(), "Fwhole.au");
lowFhalf = getAudioClip(getDocumentBase(), "Fhalf.au");
lowFquarter = getAudioClip(getDocumentBase(), "Fquarter.au");
lowFeigth = getAudioClip(getDocumentBase(), "Feigth.au");
lowFsixteenth = getAudioClip(getDocumentBase(), "Fsixteenth.au");
Gwhole = getAudioClip(getDocumentBase(), "Gwhole.au");
Ghalf = getAudioClip(getDocumentBase(), "Ghalf.au");
Gquarter = getAudioClip(getDocumentBase(), "Gquarter.au");
Geigth = getAudioClip(getDocumentBase(), "Geigth.au");
Gsixteenth = getAudioClip(getDocumentBase(), "Gsixteenth.au");
Awhole = getAudioClip(getDocumentBase(), "Awhole.au");
Ahalf = getAudioClip(getDocumentBase(), "Ahalf.au");
Aquarter = getAudioClip(getDocumentBase(), "Aquarter.au");
Aeigth = getAudioClip(getDocumentBase(), "Aeigth.au");
Asixteenth = getAudioClip(getDocumentBase(), "Asixteenth.au");
Bwhole = getAudioClip(getDocumentBase(), "Bwhole.au");
Bhalf = getAudioClip(getDocumentBase(), "Bhalf.au");
Bquarter = getAudioClip(getDocumentBase(), "Bquarter.au");
Beigth = getAudioClip(getDocumentBase(), "Beigth.au");
Bsixteenth = getAudioClip(getDocumentBase(), "Bsixteenth.au");
Cwhole = getAudioClip(getDocumentBase(), "highCwhole.au");
Chalf = getAudioClip(getDocumentBase(), "highChalf.au");
Cquarter = getAudioClip(getDocumentBase(), "highCquarter.au");
Ceigth = getAudioClip(getDocumentBase(), "highCeigth.au");
Csixteenth = getAudioClip(getDocumentBase(), "highCsixteenth.au");
Dwhole = getAudioClip(getDocumentBase(), "highDwhole.au");
Dhalf = getAudioClip(getDocumentBase(), "highDhalf.au");
Dquarter = getAudioClip(getDocumentBase(), "highDquarter.au");
Deigth = getAudioClip(getDocumentBase(), "highDeigth.au");
Dsixteenth = getAudioClip(getDocumentBase(), "highDsixteenth.au");
highEwhole = getAudioClip(getDocumentBase(), "highEwhole.au");
highEhalf = getAudioClip(getDocumentBase(), "highEhalf.au");
highEquarter = getAudioClip(getDocumentBase(), "highEquarter.au");
highEeigth = getAudioClip(getDocumentBase(), "highEeigth.au");
highEsixteenth = getAudioClip(getDocumentBase(), "highEsixteenth.au");
highFwhole = getAudioClip(getDocumentBase(), "highFwhole.au");
highFhalf = getAudioClip(getDocumentBase(), "highFhalf.au");
highFquarter = getAudioClip(getDocumentBase(), "highFquarter.au");
highFeigth = getAudioClip(getDocumentBase(), "highFeigth.au");
highFsixteenth = getAudioClip(getDocumentBase(), "highFsixteenth.au");
}
public boolean action(Event e, Object o)
{
if(e.target instanceof Button)
{
if (e.target == highF) {
scales.notes[(scales.amount * 2)] = 'F';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
else if (e.target == highE) {
scales.notes[(scales.amount * 2)] = 'E';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
if (e.target == D) {
scales.notes[(scales.amount * 2)] = 'D';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
if (e.target == C) {
scales.notes[(scales.amount * 2)] = 'C';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
if (e.target == B) {
scales.notes[(scales.amount * 2)] = 'b';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
if (e.target == A) {
scales.notes[(scales.amount * 2)] = 'a';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
if (e.target == G) {
scales.notes[(scales.amount * 2)] = 'g';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
if (e.target == lowF) {
scales.notes[(scales.amount * 2)] = 'f';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
if (e.target == lowE) {
scales.notes[(scales.amount * 2)] = 'e';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
if (e.target == lowD) {
scales.notes[(scales.amount * 2)] = 'd';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
if (e.target == lowC) {
scales.notes[(scales.amount * 2)] = 'c';
scales.notes[(scales.amount * 2)+1] = checkDuration();
}
if((e.target != backspace) && (e.target != play)) {
scales.amount++;
scales.repaint();
}
if(e.target == backspace) {
scales.amount--;
scales.repaint();
}
if(e.target == play) {
for(int j=0;j