예제 #1
0
 public void imageBegin(int w, int h, int bucketSize)
 {
     lock (lockObj)
     {
         if (frame != null && image != null && w == image.getWidth() && h == image.getHeight())
         {
             // nothing to do
         }
         else
         {
             // allocate new framebuffer
             pixels = new int[w * h];
             image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
             // prepare frame
             if (frame == null)
             {
                 setPreferredSize(new Dimension(w, h));
                 frame = new JFrame("Sunflow v" + SunflowAPI.VERSION);
                 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//fixme: change to WinForms
                 //frame.addKeyListener(new KeyAdapter() {
                 //    @Override
                 //    public void keyPressed(KeyEvent e) {
                 //        if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                 //            System.exit(0);
                 //    }
                 //});
                 frame.setContentPane(this);
                 frame.pack();
                 frame.setLocationRelativeTo(null);
                 frame.setVisible(true);
             }
         }
         // start counter
         t.start();
     }
 }
예제 #2
0
 public void imageBegin(int w, int h, int bucketSize)
 {
     lock (lockObj)
     {
         if (frame != null && image != null && w == image.getWidth() && h == image.getHeight())
         {
             // nothing to do
         }
         else
         {
             // allocate new framebuffer
             pixels = new int[w * h];
             image  = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
             // prepare frame
             if (frame == null)
             {
                 setPreferredSize(new Dimension(w, h));
                 frame = new JFrame("Sunflow v" + SunflowAPI.VERSION);
                 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//fixme: change to WinForms
                 //frame.addKeyListener(new KeyAdapter() {
                 //    @Override
                 //    public void keyPressed(KeyEvent e) {
                 //        if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                 //            System.exit(0);
                 //    }
                 //});
                 frame.setContentPane(this);
                 frame.pack();
                 frame.setLocationRelativeTo(null);
                 frame.setVisible(true);
             }
         }
         // start counter
         t.start();
     }
 }
예제 #3
0
 public static void main(string[] args)
 {
     AudioTool.prefs    = Preferences.userRoot().node("/edu/cmu/sphinx/tools/audio/AudioTool");
     AudioTool.filename = AudioTool.prefs.get("filename", "untitled.raw");
     AudioTool.file     = new File(AudioTool.filename);
     if (args.Length == 1 && String.instancehelper_equals(args[0], "-dumpMixers"))
     {
         AudioTool.dumpMixers();
         java.lang.System.exit(0);
     }
     try
     {
         if (args.Length > 0)
         {
             AudioTool.filename = args[0];
         }
         URL url;
         if (args.Length == 2)
         {
             url = new File(args[1]).toURI().toURL();
         }
         else
         {
             url = ClassLiteral <AudioTool> .Value.getResource("spectrogram.config.xml");
         }
         ConfigurationManager configurationManager = new ConfigurationManager(url);
         AudioTool.recorder = (Microphone)configurationManager.lookup("microphone");
         AudioTool.recorder.initialize();
         AudioTool.audio = new AudioData();
         FrontEnd         frontEnd      = (FrontEnd)configurationManager.lookup("frontEnd");
         StreamDataSource dataSource    = (StreamDataSource)configurationManager.lookup("streamDataSource");
         FrontEnd         frontEnd2     = (FrontEnd)configurationManager.lookup("cepstrumFrontEnd");
         StreamDataSource dataSource2   = (StreamDataSource)configurationManager.lookup("cstreamDataSource");
         PropertySheet    propertySheet = configurationManager.getPropertySheet("windower");
         float            @float        = propertySheet.getFloat("windowShiftInMs");
         JFrame           jframe        = new JFrame("AudioTool");
         AudioTool.fileChooser = new JFileChooser();
         AudioTool.createMenuBar(jframe);
         float num = @float * AudioTool.audio.getAudioFormat().getSampleRate() / 1000f;
         AudioTool.audioPanel       = new AudioPanel(AudioTool.audio, 1f / num, 0.004f);
         AudioTool.spectrogramPanel = new SpectrogramPanel(frontEnd, dataSource, AudioTool.audio);
         AudioTool.cepstrumPanel    = new CepstrumPanel(frontEnd2, dataSource2, AudioTool.audio);
         JPanel jpanel = new JPanel();
         jpanel.setLayout(new BoxLayout(jpanel, 3));
         jpanel.add(AudioTool.audioPanel);
         AudioTool.audioPanel.setAlignmentX(0f);
         jpanel.add(AudioTool.spectrogramPanel);
         AudioTool.spectrogramPanel.setAlignmentX(0f);
         jpanel.add(AudioTool.cepstrumPanel);
         AudioTool.cepstrumPanel.setAlignmentX(0f);
         JScrollPane jscrollPane = new JScrollPane(jpanel);
         JPanel      jpanel2     = new JPanel(new BorderLayout());
         jpanel2.add(AudioTool.createButtonPanel(), "North");
         jpanel2.add(jscrollPane);
         AudioTool.player = new AudioPlayer(AudioTool.audio);
         AudioTool.player.start();
         AudioTool.getAudioFromFile(AudioTool.filename);
         jframe.setDefaultCloseOperation(3);
         jframe.setContentPane(jpanel2);
         jframe.pack();
         jframe.setSize(640, 400);
         jframe.setVisible(true);
     }
     catch (System.Exception ex)
     {
         Throwable.instancehelper_printStackTrace(ex);
     }
 }