import java.awt.*; import java.applet.Applet; import java.applet.AudioClip; public class SoundNoise extends Applet { AudioClip clip[] = new AudioClip[12]; AudioClip now_clip; String audio_file[] = {"W_NHK","M_NHK","W_SN+10","M_SN+10","W_SN+5","M_SN+5", "W_SN0","M_SN0","W_SN-5","M_SN-5","W_SN-10","M_SN-10"}; Choice s_choice; Button play, stop; Panel image_panel; Panel select_panel; Panel button_panel; public void init() { for (int i = 0; i < 12; i++) { clip[i] = getAudioClip(getCodeBase(), "mask/" + audio_file[i] + ".au"); } now_clip = clip[0]; setBackground(Color.white); setLayout(new GridLayout(1,1)); Font fp = new Font("Helvetica", Font.PLAIN, 16); Font fb = new Font("Helvetica", Font.BOLD, 16); select_panel = new Panel(); select_panel.setLayout(new FlowLayout()); s_choice = new Choice(); s_choice.setFont(fp); s_choice.addItem("WomanVoice"); s_choice.addItem("ManVoice"); s_choice.addItem("Woman_SN=10"); s_choice.addItem("Man_SN=10"); s_choice.addItem("Woman_SN=5"); s_choice.addItem("Man_SN=5"); s_choice.addItem("Woman_SN=0"); s_choice.addItem("Man_SN=0"); s_choice.addItem("Woman_SN=-5"); s_choice.addItem("Man_SN=-5"); s_choice.addItem("Woman_SN=-10"); s_choice.addItem("Man_SN=-10"); select_panel.add(s_choice); button_panel = new Panel(); button_panel.setLayout(new FlowLayout()); play = new Button("Play!"); play.setFont(fb); stop = new Button("Stop!"); stop.setFont(fb); button_panel.add(play); button_panel.add(stop); select_panel.add(button_panel); add(select_panel); } public boolean action(Event evt, Object o) { if (evt.target instanceof Choice) { if (o.equals("WomanVoice")) { now_clip = clip[0]; } else if (o.equals("ManVoice")) { now_clip = clip[1]; } else if (o.equals("Woman_SN=10")) { now_clip = clip[2]; } else if (o.equals("Man_SN=10")) { now_clip = clip[3]; } else if (o.equals("Woman_SN=5")) { now_clip = clip[4]; } else if (o.equals("Man_SN=5")) { now_clip = clip[5]; } else if (o.equals("Woman_SN=0")) { now_clip = clip[6]; } else if (o.equals("Man_SN=0")) { now_clip = clip[7]; } else if (o.equals("Woman_SN=-5")) { now_clip = clip[8]; } else if (o.equals("Man_SN=-5")) { now_clip = clip[9]; } else if (o.equals("Woman_SN=-10")) { now_clip = clip[10]; } else if (o.equals("Man_SN=-10")) { now_clip = clip[11]; } } if (evt.target instanceof Button) { if (o.equals("Play!")) { now_clip.play(); } else if (o.equals("Stop!")) { now_clip.stop(); } } return true; } public void stop() { now_clip.stop(); } }