Fieds_labo3
sound-基本
最終更新:
fieds_labo3
-
view
サウンド 基本
newAudioClipを使ったサウンドのONOFF
サウンドファイルのパスのとり方がネック。
サウンドファイルのパスのとり方がネック。
サンプルコード(NetBeansIDE6.1 一部省略)
import java.applet.*; import java.net.*; public class SoundTest extends javax.swing.JFrame { URL f_url ; AudioClip clip; public SoundTest() { initComponents(); try { f_url = new URL("file:" + System.getProperty("user.dir") + "/" + "SND009.au"); clip = java.applet.Applet.newAudioClip(f_url); } catch (MalformedURLException ex) { System.exit(1); } } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void BGMSTOPActionPerformed(java.awt.event.ActionEvent evt) { clip.play(); } private void formComponentShown(java.awt.event.ComponentEvent evt) { } private void PUSHLOOPActionPerformed(java.awt.event.ActionEvent evt) { clip.loop(); } private void PUSHSTOPActionPerformed(java.awt.event.ActionEvent evt) { clip.stop(); } private void PUSHPLAY2ActionPerformed(java.awt.event.ActionEvent evt) { //AudioClip clip2 = newAudioClip(getClass().getResource("../audio/bgm/SBG001.WAV")); } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new SoundTest().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton BGMSTART; private javax.swing.JButton BGMSTOP; private javax.swing.JButton PUSHLOOP; private javax.swing.JButton PUSHPLAY; private javax.swing.JButton PUSHPLAY2; private javax.swing.JButton PUSHSTOP; // End of variables declaration }
参考リンク
- newAudioClipによるJavaアプリケーションのMIDI/WAVE再生
- みんなのプログラミング無料講座-音声出力
- WAVEの再生
- サウンドエンジン:標準class使うとかなり苦しむそうです。サウンドエンジンを使え~とw
- 音声データの取得と操作:アプレットの場合