コード例 #1
0
 public boolean seekTo(int p) {
   stop();
   th = new PlayThread();
   startpos = p / 1000;
   th.start();
   return true;
 }
コード例 #2
0
ファイル: TestIt.java プロジェクト: jtrfp/javamod
  /** @param args */
  public static void main(String[] args) {
    try {
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\ENJOYTHE.MOD").toURI().toURL(); //
      // VolumeSlideTest
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Karsten
      // Obarski\\SARCOPHA.MOD").toURI().toURL(); // Arpeggio
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\PLANETS.MOD").toURI().toURL(); // Porta
      // Down / Porta Up
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\SPDEBRIS.MOD").toURI().toURL(); // Porta
      // to Note
      URL modUrl =
          new File("M:\\Multimedia\\Files MOD\\BEYOND.MOD")
              .toURI()
              .toURL(); // Vibrato, Sample offset, Retrig
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\BOOM.MOD").toURI().toURL(); //
      // NoteDelays?!
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Jogeir
      // Liljedahl\\GSLINGER.MOD").toURI().toURL(); // Finetune
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Games\\Cybernoid\\cybernoid
      // ii.mod").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\COUNTRY.MOD").toURI().toURL(); // Mod is
      // too short for 4 Bytes
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Shining\\NEMESIS.MOD").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Lizardking\\1942.MOD").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\DEFLORAT.MOD").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Chorus-Sid-Razor
      // 1911\\COFEBLU3.MOD").toURI().toURL(); // Pattern Break, Position Jump
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\1989.MOD").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Anarchy\\ACSSHIGH.MOD").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\kermit.mod").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\einstein.mod").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\2010.mod").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\rymix\\synthesis.mod").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files
      // MOD\\Lizardking\\DOSKPOPI.MOD").toURI().toURL(); // Porta To Note without a note
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\THESKYOF.MOD").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\HEAVEN&H.MOD").toURI().toURL(); // Ends
      // with Note Delay

      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Captain Future\\KEN.XM").toURI().toURL();
      // // NoteDelay
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\THEVOICE.XM").toURI().toURL(); //
      // PanningSlide
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\THEWAIT.XM").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\DOMATRON.XM").toURI().toURL(); // Panning
      // envelope, index 3, instrument 19
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Rure2fly.xm").toURI().toURL(); //
      // Instrument with empty envelope
      // URL modUrl = new File("M:\\Multimedia\\Files
      // MOD\\Games\\Turrican\\TurricanHS.XM").toURI().toURL(); // Perfomance!!!
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Laxity - Maniac of
      // Noise\\LUCK.XM").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Laxity - Maniac of
      // Noise\\MIXED_F.XM").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\chipboat.xm").toURI().toURL(); //
      // Arpeggio
      // URL modUrl = new File("M:\\Multimedia\\Files
      // MOD\\Lagoona_-_Land_of_imagination.xm").toURI().toURL(); // Sample Index
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\unforg_p.xm").toURI().toURL(); // Vibrato
      // without noteIndex set
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\TheGoaReligion.xm").toURI().toURL(); //
      // PingPongLoops
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\evening_sun.xm").toURI().toURL(); //
      // Empty pattern
      // URL modUrl = new File("M:\\Multimedia\Files
      // MOD\\ambrozia-album\\MYSTYLES.XM").toURI().toURL(); // Empty pattern
      // URL modUrl = new File("M:\\Multimedia\\Files
      // MOD\\Games\\Turrican\\TurricanHS.XM").toURI().toURL(); // Empty pattern
      // URL modUrl = new File("M:\\Multimedia\\Files
      // MOD\\ambrozia-album\\UNTOUCH.XM").toURI().toURL(); // Empty pattern
      // URL modUrl = new File("M:\\Multimedia\\Files
      // MOD\\__testmods__\\Fjant2.xm").toURI().toURL(); // Envelopes
      // URL modUrl = new File("M:\\Multimedia\\Files
      // MOD\\__testmods__\\Module2.xm").toURI().toURL();

      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\airbor.stm").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\at.stm").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\niagra.stm").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\larry.stm").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Karsten
      // Obarski\\amegas.stm").toURI().toURL();

      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\ATHOUGHT.S3M").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Aftersun.s3m").toURI().toURL(); // s3m
      // VolumeSlide Effekt
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\BEYON_NI.S3M").toURI().toURL(); // Portas
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\BURNINGL.S3M").toURI().toURL(); //
      // NoteDelay
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\DARKTIME.S3M").toURI().toURL(); // Volume
      // Slide fine
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\INFINITY.S3M").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\ARYX.S3M").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\FALLENAN.S3M").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files
      // MOD\\Games\\Unreal\\Unreal2ndpm.s3m").toURI().toURL();

      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\JEFF93.IT").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\AOMMCMIX.IT").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\pandora.it").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\Storm & JJMax -
      // Heaven.it").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\XeeGee
      // Trance\\[email protected]").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\XeeGee
      // Trance\\xeegee-atlantislostlongedit.it").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\XeeGee
      // Trance\\xeegee-atlantislostpartii.it").toURI().toURL();
      // URL modUrl = new File("M:\\Multimedia\\Files MOD\\XeeGee
      // Trance\\xeegee-lostinforest.it").toURI().toURL(); // MEMORY!!!

      // CommandLine.main(new String[]{"-i3","-s+","-w-","-n+","-m+","-b16","-r96000",
      // "C:\\Download\\JavaMod\\test.m3u"});

      playerThread = new PlayThread(modUrl);
      playerThread.start();

      //			BasicModMixer modMixer = null;
      //			final Mixer mixer = playerThread.getCurrentMixer();
      //			if (mixer!=null && mixer instanceof ModMixer)
      //				modMixer = ((ModMixer)mixer).getModMixer();
      while (playerThread.isAlive()) {
        //				if (modMixer!=null)
        //				{
        //					System.out.print(String.format("%08X\r",
        // Integer.valueOf(modMixer.getCurrentPatternPosition())));
        //				}
      }
    } catch (Exception ex) {
      Log.error("MIST", ex);
    }
  }
コード例 #3
0
ファイル: EventPlayer.java プロジェクト: samlanning/core
 private synchronized void startThread(long playerStartTime) {
   if (playThread == null || !playThread.isAlive()) {
     playThread = new PlayThread(playerStartTime);
     playThread.start();
   }
 }
コード例 #4
0
ファイル: Piano.java プロジェクト: kimboha/CatchMelody
    @SuppressWarnings("unused")
    public void run() {
      try {
        String line = null;
        String flag = null;

        // 서버로부터 수신
        while ((line = br.readLine()) != null) {
          flag = line.substring(0, 1);

          if (flag.equals(FLAG_MSG)) { // 메시지가 왔으면
            String msg = line.substring(1);
            chatBox.append(msg + "\n");
            chatBox.setCaretPosition(chatBox.getDocument().getLength() - 1); // 스크롤
            // 맨아래로
          } else if (flag.equals(FLAG_CODE)) { // 버튼입력이 왔으면
            String code = line.substring(2);
            String inst = line.substring(1, 2);
            int InstFlag = Integer.parseInt(inst);

            PlayThread playThread = new PlayThread(InstFlag, code);
            playThread.start();

          } else if (flag.equals(FLAG_USERS)) { // 접속해있는 유저들 정보
            userLabels[0] = UserLabel1;
            userLabels[1] = UserLabel2;
            userLabels[2] = UserLabel3;
            userLabels[3] = UserLabel4;
            userImages[0] = UserImage1;
            userImages[1] = UserImage2;
            userImages[2] = UserImage3;
            userImages[3] = UserImage4;
            userList = line.substring(1).split(";");
            userImgList = new String[4];
            System.out.println(userList[0]);

            // user ID update
            for (int i = 0; i < 4; i++) userLabels[i].setText(" ");

            for (int i = 0; i < userList.length; i++)
              userLabels[i].setText(userList[i].substring(1));

            // user Image update
            for (int i = 0; i < 4; i++) {
              userImgList[i] = "images/user00.png";
            }

            for (int i = 0; i < userList.length; i++) {
              userImgList[i] = "images/user0" + userList[i].substring(0, 1) + ".png";
            }

            ImageIcon img = null;
            for (int i = 0; i < 4; i++) {
              img = new ImageIcon(userImgList[i]);
              userImages[i].setIcon(img);
            }

            // 혼자남으면 방장 업데이트
            if ((cntClient = userList.length) == 1) {
              if (bMaster == false) {
                bMaster = true;
                pw.println(FLAG_MASTER);
                pw.flush();
                JOptionPane.showMessageDialog(null, "방장이 되셨습니다.");
              }
            }

            // 클라이언트 개수 update
            if (bMaster) {
              // 내가 방장일때만
              if ((cntClient = userList.length) > 1) {
                // 클라이언트 2명 이상일 때만 start버튼 활성화
                btStart.setEnabled(true);
              } else {
                btStart.setEnabled(false);
              }
            }

          } else if (flag.equals(FLAG_START)) { // 게임 시작 메세지
            bGameStart = true;
            JOptionPane.showMessageDialog(null, "게임을 시작합니다.");
            if (!bMaster) {
              pw.println(FLAG_START); // 자신의 서버 스레드에 start 플래그 전송
              pw.flush();
            }
            JLabel ScoreLabels[] = {ScoreLabel1, ScoreLabel2, ScoreLabel3, ScoreLabel4};
            for (int i = 0; i < cntClient; i++) ScoreLabels[i].setText("0");

          } else if (flag.equals(FLAG_ANS)) { // 정답
            String id = line.substring(1);
            chatBox.append("***" + id + "님이 정답을 맞췄습니다!***" + "\n");
            chatBox.setCaretPosition(chatBox.getDocument().getLength() - 1); // 스크롤

            // 맞춘사람
            userLabels[0] = UserLabel1;
            userLabels[1] = UserLabel2;
            userLabels[2] = UserLabel3;
            userLabels[3] = UserLabel4;
            scoreLabels[0] = ScoreLabel1;
            scoreLabels[1] = ScoreLabel2;
            scoreLabels[2] = ScoreLabel3;
            scoreLabels[3] = ScoreLabel4;
            int score = 0, i = 0;
            for (i = 0; i < cntClient; i++) {
              if (userLabels[i].getText().equals(id)) {
                score = Integer.parseInt(scoreLabels[i].getText()) + 11 + (gameTime / 10);
                scoreLabels[i].setText(String.valueOf(score));
                break;
              }
            }

            // 출제자
            score = Integer.parseInt(scoreLabels[numExaminer].getText()) + 10 + (gameTime / 10);
            scoreLabels[numExaminer].setText(String.valueOf(score));

            pw.println(FLAG_ANS);
            pw.flush();
          } else if (flag.equals(FLAG_TIME)) {
            String curTime = line.substring(1);
            time.setText(curTime);
            gameTime = Integer.parseInt(curTime);
            if (gameTime <= 0) {
              if (bMaster) {
                pw.println(FLAG_ANS);
                pw.flush();
              }

              if (tt != null) {
                if (tt.isAlive()) {
                  tt.interrupt();
                }
              }
            }
          } else if (flag.equals(FLAG_END)) { // 게임 종료
            if (tt != null) {
              if (tt.isAlive()) {
                tt.interrupt();
              }
            }
            bGameStart = false;
            time.setText("시간");
            answer.setText("노래 정답");
            hintImg.setDescription("images/hint0.jpg");
            hint.setIcon(hintImg);

            // pw.println(FLAG_END);
            pw.flush();
            JOptionPane.showMessageDialog(null, "게임 종료!");
            if (bMaster) {
              btStart.setEnabled(true);
              pw.println(FLAG_END);
              pw.flush();
            }
            chatInputText.setEnabled(true);
            chatBtn.setEnabled(true);

            if (tt != null) {
              if (tt.isAlive()) {
                tt.interrupt();
              }
            }

            int[] score = new int[cntClient];
            for (int i = 0; i < score.length; i++) {
              score[i] = Integer.parseInt(scoreLabels[i].getText());
            }

            new ResultFrame(score, userList, cntClient);

            for (int i = 0; i < scoreLabels.length; i++) {
              scoreLabels[i].setText("");
            }
            for (int i = 0; i < labelPanes.length; i++) {
              labelPanes[i].setBackground(Color.GRAY);
            }

          } else if (flag.equals(FLAG_PROB)) { // 출제자와 문제정보 받음
            String[] IDnPnH = line.substring(1).split(";"); // ID & Problem & Hint
            ImageIcon img = null;
            KeyFlag = 1;

            userLabels[0] = UserLabel1;
            userLabels[1] = UserLabel2;
            userLabels[2] = UserLabel3;
            userLabels[3] = UserLabel4;
            labelPanes[0] = labelPane1;
            labelPanes[1] = labelPane2;
            labelPanes[2] = labelPane3;
            labelPanes[3] = labelPane4;

            int i = 0;

            for (i = 0; i < cntClient; i++) {
              // 출제자 포커싱
              if (userLabels[i].getText().equals(IDnPnH[0])) {
                labelPanes[i].setBackground(Color.RED);
                numExaminer = i;
              }
              // 비출제자 언포커싱
              else labelPanes[i].setBackground(Color.GRAY);
            }

            if (userID.equals(IDnPnH[0])) { // 내가 출제자이면
              bExaminer = true;
              answer.setText(IDnPnH[1]);
              img = new ImageIcon(IDnPnH[2]);
              hint.setIcon(img);

              // 채팅 못하게
              chatInputText.setEnabled(false);
              chatBtn.setEnabled(false);
              pw.println(line);
              pw.flush();
              gameTime = 60;
              tt = new TimeThread(time, sock, pw);
              tt.start();

            } else {
              bExaminer = false;
              answer.setText(" ");
              hintImg.setDescription("images/hint0.jpg");
              hint.setIcon(hintImg);

              // 채팅 가능하게
              chatInputText.setEnabled(true);
              chatBtn.setEnabled(true);
              pw.println(line);
              pw.flush();
              if (tt != null) {
                if (tt.isAlive()) {
                  tt.interrupt();
                }
              }
            }
          } else if (flag.equals(FLAG_BMASTER)) {
            if (bMaster == false) {
              bMaster = true;
              pw.println(FLAG_MASTER);
              pw.flush();
              JOptionPane.showMessageDialog(null, "방장이 되셨습니다.");
            }
            if (bMaster) {
              if ((cntClient = userList.length) > 1) {
                btStart.setEnabled(true);
              } else {
                btStart.setEnabled(false);
              }
            }
          }
        }
      } catch (Exception ex) {
      } finally {
        try {
          if (br != null) br.close();
        } catch (Exception ex) {
        }
        try {
          if (sock != null) sock.close();
        } catch (Exception ex) {
        }
      }
    }