Main Page   Class Hierarchy   Compound List   File List   Compound Members  

MEAPsoftGUI.java

00001 /*
00002  *  Copyright 2006 Columbia University.
00003  *
00004  *  This file is part of MEAPsoft.
00005  *
00006  *  MEAPsoft is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License version 2 as
00008  *  published by the Free Software Foundation.
00009  *
00010  *  MEAPsoft is distributed in the hope that it will be useful, but
00011  *  WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with MEAPsoft; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00018  *  02110-1301 USA
00019  *
00020  *  See the file "COPYING" for the text of the license.
00021  */
00022 
00023 package com.meapsoft.gui;
00024 
00025 import java.awt.Color;
00026 import java.awt.Container;
00027 import java.awt.Cursor;
00028 import java.awt.GridLayout;
00029 import java.awt.event.ActionEvent;
00030 import java.awt.event.ActionListener;
00031 import java.io.File;
00032 import java.io.IOException;
00033 import java.util.Hashtable;
00034 import java.util.Vector;
00035 
00036 import javax.swing.BorderFactory;
00037 import javax.swing.BoxLayout;
00038 import javax.swing.ButtonGroup;
00039 import javax.swing.JButton;
00040 import javax.swing.JCheckBox;
00041 import javax.swing.JFileChooser;
00042 import javax.swing.JFrame;
00043 import javax.swing.JLabel;
00044 import javax.swing.JOptionPane;
00045 import javax.swing.JPanel;
00046 import javax.swing.JRadioButton;
00047 import javax.swing.JSlider;
00048 import javax.swing.JTabbedPane;
00049 import javax.swing.JTextArea;
00050 import javax.swing.JTextField;
00051 import javax.swing.border.EtchedBorder;
00052 import javax.swing.border.TitledBorder;
00053 
00054 import com.meapsoft.EDLFile;
00055 import com.meapsoft.FeatExtractor;
00056 import com.meapsoft.FeatFile;
00057 import com.meapsoft.RTSI;
00058 import com.meapsoft.Segmenter;
00059 import com.meapsoft.Synthesizer;
00060 import com.meapsoft.composers.BlipComposer;
00061 import com.meapsoft.composers.Composer;
00062 import com.meapsoft.composers.IntraChunkShuffleComposer;
00063 import com.meapsoft.composers.MashupComposer;
00064 import com.meapsoft.composers.MeapaeMComposer;
00065 import com.meapsoft.composers.NNComposer;
00066 import com.meapsoft.composers.SortComposer;
00067 import com.meapsoft.featextractors.FeatureExtractor;
00068 
00069 
00076 public class MEAPsoftGUI extends JFrame implements ActionListener
00077 {
00078     // \todo{Use object constructors for the various utilities instead
00079     // of constructing command line args}
00080 
00081         JPanel panel;
00082         
00083         //IO data
00084         //String cwd;
00085         String dataDirectory;
00086         String dataBaseName = "temp";
00087                 //segmenter
00088         String inputSoundFileNameFull;
00089         String inputSoundFileNameShort;
00090         String outputSegmentsFileName = dataBaseName + ".seg";
00091                 //features
00092         String inputSegmentsFileName = dataBaseName + ".seg";
00093         String outputFeaturesFileName = dataBaseName + ".feat";
00094                 //composer
00095         String inputFeaturesFileName = dataBaseName + ".feat";
00096         String outputEDLFileName = dataBaseName + ".edl";
00097                 //synth
00098         String inputEDLFileName = dataBaseName + ".edl";
00099         String outputSoundFileNameFull;
00100         String outputSoundFileNameShort;
00101 
00102     // Objects passed around from utility to utility
00103     FeatFile segmentFile = null;
00104     FeatFile featFile = null;
00105     EDLFile edlFile = null;
00106         
00107         //tabbed GUI
00108         JTabbedPane tabs;
00109         JPanel[] stripes = new JPanel[5];
00110         
00111         //segmenter GUI
00112         JPanel segmenterPanel;
00113         JCheckBox enableSegmenterBox;
00114         JRadioButton oldStyleButton;
00115         JRadioButton beatStyleButton;
00116         JCheckBox firstFrameBox;
00117         JTextField segmenterInputSoundFileField;
00118         JLabel segmenterOutputSegFileLabel;
00119         JSlider segmentThresholdSlider;
00120         
00121         //feature extractor GUI
00122         JPanel featExtractorPanel;
00123         JCheckBox enableFeatExtractorBox;
00124         Vector featureCheckBoxes;
00125         Vector featureDescriptions;
00126         JLabel inputSegmentsFileLabel;
00127         JLabel outputFeaturesFileLabel;
00128         JTextField featInputSegmentsFileField;
00129         JTextField featOutputFeaturesFileField;
00130         JButton displayFeaturesButton;
00131         
00132         //composers
00133         String selectedComposer;
00134         JPanel composersPanel;
00135         JPanel selectComposerPanel;
00136         JPanel composerControlsPanel;
00137         Vector composerControlsPanels;
00138         JCheckBox enableComposersBox;
00139     // EDL commands
00140     JCheckBox composersReverseChunks;
00141     JCheckBox composersFadeInOutChunks;
00142     JCheckBox composersCrossfadeChunks;
00143     JSlider composersFadeDurationSlider;
00144         //Vector composerRadioButtons;
00145         JRadioButton enableSortComposerButton;
00146         JCheckBox reverseSortComposerBox;
00147         JRadioButton enableNNComposerButton;
00148         JRadioButton enableBLComposerButton;
00149         JRadioButton enableMUComposerButton;
00150         JRadioButton enableMMComposerButton;
00151         JRadioButton enableICSComposerButton;
00152         String targetFeaturesNameFull;
00153         String targetFeaturesNameShort;
00154         JLabel composersInputFileNameLabel;
00155         JLabel composersOutputFileNameLabel;
00156         JTextField mashupTargetFileField;
00157         JTextField intraChunkShuffleNumChunksField;
00158         
00159         JButton displayComposerFeaturesButton;  
00160 
00161 
00162         //synthesizer
00163         JPanel synthPanel;
00164         String lastEDLFileName;
00165         JCheckBox enableSynthBox;
00166         JLabel synthFileNameLabel;
00167         JTextField outputFileNameField;
00168         JButton listenButton;
00169         
00170         //prefs
00171         JPanel prefsPanel;
00172         JTextField dataBaseNameField;
00173         
00174         //start button
00175         JButton startButton;
00176         
00177         
00178         private static String slash = System.getProperty("file.separator");
00179         private static int OPEN = 0;
00180         private static int SAVE = 1;
00181         private static int TARGET = 2;
00182         private static int DIR = 3;
00183         
00184         public MEAPsoftGUI()
00185         {               
00186         super("MEAPsoft");
00187         
00188                 try
00189                 {
00190                         File dir = new File(System.getProperty("user.dir"));
00191                         String cwd = dir.getCanonicalPath();
00192                         dataDirectory = cwd + slash + 
00193                                 "data";
00194                         //System.out.println("dataDir: " + dataDirectory);
00195                 }
00196                 catch (IOException e)
00197                 {
00198                         System.out.println("can't find cwd???");
00199                         e.printStackTrace();
00200                 }       
00201                 
00202         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
00203         setResizable(false);
00204                 BuildGUI();
00205                 show();
00206 
00207         UpdateInfoTexts();
00208         }
00209         
00210         private void BuildGUI()
00211         {
00213                 // meta-GUI setup
00215 
00216                 panel = new JPanel();
00217                 BoxLayout bl = new BoxLayout(panel, BoxLayout.Y_AXIS);
00218                 panel.setLayout(bl);
00219                 setContentPane(panel);
00220 
00221                 Color c = new Color((int)(Math.random() * 127 + 127),
00222                                         (int)(Math.random() * 127 + 127),
00223                                         (int)(Math.random() * 127 + 127));
00224                                         
00225                 JPanel stripe = new JPanel();
00226                 stripe.setBackground(c);
00227                 
00228                 for (int i = 0; i < 5; i++)
00229                 {
00230                         JPanel p = new JPanel();
00231                         p.add(new JLabel("      MEAP!      "));
00232                         stripes[i] = p;
00233                         stripe.add(p);
00234                 }
00235                 
00236                 panel.add(stripe);
00237                                         
00238                 tabs = new JTabbedPane();
00239                 tabs.setBackground(c);
00240                 panel.add(tabs);                
00241                 
00242 
00244                 // now do GUIs for the tabs
00246                 
00247                 BuildSegmenterGUI();
00248                 BuildFeatureExtractorsGUI();
00249                 BuildComposersGUI();
00250                 BuildSynthesizerGUI();
00251                 BuildPrefsGUI();
00252                 
00253         pack();
00254         
00255 
00257                 //go button!
00259                 //this appears at the bottom of the screen, but we do it here to use
00260                 //the same color as the rest of the main screen
00261                 JPanel goPanel = new JPanel();
00262                 goPanel.setBackground(c);
00263                 
00264                 startButton = new JButton("go!");
00265                 startButton.setBackground(c);
00266                 startButton.addActionListener(this);
00267                 startButton.setActionCommand("go");
00268                 goPanel.add(startButton);
00269                                 
00270                 panel.add(goPanel);     
00271 
00272                 pack();
00273         }
00274         
00275         private void BuildSegmenterGUI()
00276         {
00277                 segmenterPanel = new JPanel();
00278                 Color c = new Color((int)(Math.random() * 127 + 127),
00279                                         (int)(Math.random() * 127 + 127),
00280                                         (int)(Math.random() * 127 + 127));
00281                 stripes[0].setBackground(c);
00282                 segmenterPanel.setBackground(c);
00283                 BoxLayout sbl = new BoxLayout(segmenterPanel, BoxLayout.Y_AXIS);
00284                 segmenterPanel.setLayout(sbl);
00285                 
00286                 
00287                 JPanel segmenterEnablePanel = new JPanel();
00288                 segmenterEnablePanel.setBackground(c);
00289                 
00290                 enableSegmenterBox = new JCheckBox("ENABLE SEGMENTER");
00291                 enableSegmenterBox.setBackground(c);
00292                 enableSegmenterBox.setSelected(true);
00293                 segmenterEnablePanel.add(enableSegmenterBox);
00294                                 
00295                 segmenterPanel.add(segmenterEnablePanel);
00296                 
00297                 JPanel segmenterControlsPanel = new JPanel();
00298                 segmenterControlsPanel.setBackground(c);
00299                 TitledBorder title = BorderFactory.createTitledBorder(
00300                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00301                         "Segmenter Controls");
00302                 title.setTitleJustification(TitledBorder.CENTER);
00303                 segmenterControlsPanel.setBorder(title);
00304                 BoxLayout scpbl = new BoxLayout(segmenterControlsPanel, BoxLayout.Y_AXIS);
00305                 segmenterControlsPanel.setLayout(scpbl);
00306                         
00307                 JPanel inputFileNamePanel = new JPanel();
00308                 inputFileNamePanel.setBackground(c);
00309                 
00310                 JLabel inputFileNameBoxLabel = new JLabel("input sound file:");
00311                 inputFileNamePanel.add(inputFileNameBoxLabel);
00312         
00313                 segmenterInputSoundFileField = new JTextField("select a .wav file!");
00314                 segmenterInputSoundFileField.setColumns(20);
00315                 inputFileNamePanel.add(segmenterInputSoundFileField);
00316                 
00317                 JButton inputBrowseButton = new JButton("browse");
00318                 inputBrowseButton.setBackground(c);
00319                 inputBrowseButton.addActionListener(this);
00320                 inputBrowseButton.setActionCommand("setInputFile");
00321                 inputFileNamePanel.add(inputBrowseButton);
00322                 
00323                 segmenterControlsPanel.add(inputFileNamePanel);
00324                 
00325                 JPanel thresholdPanel = new JPanel();
00326                 thresholdPanel.setBackground(c);
00327                 JLabel thresholdLabel = new JLabel("segment sensitivity: ");
00328                 thresholdPanel.add(thresholdLabel);
00329                 segmentThresholdSlider = new JSlider(JSlider.HORIZONTAL, 0, 12, 1);
00330                 segmentThresholdSlider.setBackground(c);
00331                 segmentThresholdSlider.setValue(8);
00332                 Hashtable labelTable = new Hashtable();
00333                 labelTable.put( new Integer(0), new JLabel("low") );
00334                 labelTable.put( new Integer(12), new JLabel("high") );
00335                 segmentThresholdSlider.setLabelTable( labelTable );
00336                 segmentThresholdSlider.setPaintLabels(true);
00337                 segmentThresholdSlider.setMajorTickSpacing(1);
00338                 segmentThresholdSlider.setPaintTicks(true);
00339                 thresholdPanel.add(segmentThresholdSlider);
00340                 
00341                 segmenterControlsPanel.add(thresholdPanel);
00342                 
00343                 JPanel detectorTypePanel = new JPanel();
00344                 detectorTypePanel.setBackground(c);
00345                 ButtonGroup onsetDetectorTypeGroup = new ButtonGroup();
00346                 oldStyleButton = new JRadioButton("detect events");
00347                 oldStyleButton.setBackground(c);
00348                 beatStyleButton = new JRadioButton("detect beats");
00349                 beatStyleButton.setBackground(c);
00350                 onsetDetectorTypeGroup.add(oldStyleButton);
00351                 onsetDetectorTypeGroup.add(beatStyleButton);
00352                 detectorTypePanel.add(oldStyleButton);
00353                 detectorTypePanel.add(beatStyleButton);
00354                 beatStyleButton.setSelected(true);
00355                 segmenterControlsPanel.add(detectorTypePanel);
00356                 
00357                 firstFrameBox = new JCheckBox("1st event = track start");
00358                 firstFrameBox.setBackground(c);
00359                 firstFrameBox.setSelected(true);
00360                 segmenterControlsPanel.add(firstFrameBox);
00361         
00362                 JPanel outputSegFileNamePanel = new JPanel();
00363                 outputSegFileNamePanel.setBackground(c);
00364                 
00365                 JLabel sFNL = new JLabel("output segment file: ");
00366                 outputSegFileNamePanel.add(sFNL);
00367                 segmenterOutputSegFileLabel = new JLabel(" temp.seg ");
00368                 segmenterOutputSegFileLabel.setOpaque(true);
00369                 segmenterOutputSegFileLabel.setBackground(c.darker());
00370                 outputSegFileNamePanel.add(segmenterOutputSegFileLabel);
00371                 segmenterControlsPanel.add(outputSegFileNamePanel);
00372                 
00373                 segmenterPanel.add(segmenterControlsPanel);
00374                 tabs.addTab("segmenter", segmenterPanel);
00375                 tabs.setBackgroundAt(0, c);
00376         }
00377         
00378         private void BuildFeatureExtractorsGUI()
00379         {
00380                 featureDescriptions = new Vector();
00381                 
00382                 featExtractorPanel = new JPanel();
00383                 Color c = new Color((int)(Math.random() * 127 + 127),
00384                                         (int)(Math.random() * 127 + 127),
00385                                         (int)(Math.random() * 127 + 127));
00386                 stripes[1].setBackground(c);
00387                 featExtractorPanel.setBackground(c);
00388                 BoxLayout fbl = new BoxLayout(featExtractorPanel, BoxLayout.Y_AXIS);
00389                 featExtractorPanel.setLayout(fbl);
00390                                 
00391                 Vector classNames = SniffFeatureExtractors();
00392                 featureCheckBoxes = new Vector();
00393                 
00394                 JPanel featExtractorEnablePanel = new JPanel();
00395                 featExtractorEnablePanel.setBackground(c);
00396                 
00397                 enableFeatExtractorBox = new JCheckBox("ENABLE FEATURE EXTRACTOR");
00398                 enableFeatExtractorBox.setBackground(c);
00399                 enableFeatExtractorBox.setSelected(true);
00400                 featExtractorEnablePanel.add(enableFeatExtractorBox);
00401                 
00402                 featExtractorPanel.add(featExtractorEnablePanel);
00403                 
00404                 JPanel featExtractorControlsPanel = new JPanel();
00405                 featExtractorControlsPanel.setBackground(c);
00406                 BoxLayout fecp = new BoxLayout(featExtractorControlsPanel, BoxLayout.Y_AXIS);
00407                 featExtractorControlsPanel.setLayout(fecp);
00408                 
00409                 JPanel extractorInputFNPanel = new JPanel();
00410                 extractorInputFNPanel.setBackground(c);
00411                 JLabel fEINL = new JLabel("input segments file: ");
00412                 extractorInputFNPanel.add(fEINL);
00413                 inputSegmentsFileLabel = new JLabel(" temp.seg ");
00414                 inputSegmentsFileLabel.setOpaque(true);
00415                 inputSegmentsFileLabel.setBackground(c.darker());
00416                 extractorInputFNPanel.add(inputSegmentsFileLabel);
00417                 featExtractorControlsPanel.add(extractorInputFNPanel);
00418                 
00419                 JPanel selectFeaturesPanel = new JPanel();
00420                 selectFeaturesPanel.setBackground(c);
00421                 TitledBorder title = BorderFactory.createTitledBorder(
00422                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00423                         "Feature Extractor Selector");
00424                 title.setTitleJustification(TitledBorder.CENTER);
00425                 selectFeaturesPanel.setBorder(title);
00426                 BoxLayout sfp = new BoxLayout(selectFeaturesPanel, BoxLayout.Y_AXIS);
00427                 selectFeaturesPanel.setLayout(sfp);
00428                 
00429                 Vector selectFeaturesPanels = new Vector();
00430                 int numFeatures = classNames.size();
00431                 
00432                 for (int i = 0; i < numFeatures/4 + 1; i++)
00433                 {
00434                         JPanel panel = new JPanel();
00435                         panel.setBackground(c);
00436                         selectFeaturesPanels.add(panel);
00437                         
00438                         selectFeaturesPanel.add(panel);
00439                 }
00440                 
00441                 featExtractorControlsPanel.add(selectFeaturesPanel);
00442                 
00443                 for (int i = 0; i < classNames.size(); i++)
00444                 {
00445                         String name = (String)classNames.elementAt(i);
00446                         //not using actions, we'll just check their states 
00447                         //when the GO! button is hit...
00448                         JCheckBox cb = new JCheckBox(name);
00449                         featureCheckBoxes.add(cb);
00450                         cb.setBackground(c);
00451                         cb.setToolTipText((String)featureDescriptions.elementAt(i));
00452                         
00453                         int whichPanel = i/4;
00454                         
00455                         JPanel panel = (JPanel)selectFeaturesPanels.elementAt(whichPanel);
00456                         panel.add(cb);
00457                 }
00458                 
00459                 JPanel extractorOutputFNPanel = new JPanel();
00460                 extractorOutputFNPanel.setBackground(c);
00461                 JLabel fEONL = new JLabel("output features file: ");
00462                 extractorOutputFNPanel.add(fEONL);
00463                 outputFeaturesFileLabel = new JLabel(" temp.feat ");
00464                 outputFeaturesFileLabel.setOpaque(true);
00465                 outputFeaturesFileLabel.setBackground(c.darker());
00466                 extractorOutputFNPanel.add(outputFeaturesFileLabel);
00467                 featExtractorControlsPanel.add(extractorOutputFNPanel);
00468                 
00469                 JPanel displayFeaturesPanel = new JPanel();
00470                 displayFeaturesPanel.setBackground(c);
00471                 displayFeaturesButton = new JButton("display extracted features");
00472                 displayFeaturesButton.setEnabled(false);
00473                 displayFeaturesButton.addActionListener(this);
00474                 displayFeaturesButton.setActionCommand("displayFeatures");
00475                 displayFeaturesButton.setBackground(c);
00476                 displayFeaturesPanel.add(displayFeaturesButton);
00477                 featExtractorControlsPanel.add(displayFeaturesPanel);
00478                 
00479                 featExtractorPanel.add(featExtractorControlsPanel);
00480                 tabs.addTab("feature extractors", featExtractorPanel);
00481                 tabs.setBackgroundAt(1, c);
00482         }
00483         
00484         private void BuildComposersGUI()
00485         {
00486                 composerControlsPanels = new Vector();
00487                 
00488                 composersPanel = new JPanel();
00489                 Color c = new Color((int)(Math.random() * 127 + 127),
00490                                         (int)(Math.random() * 127 + 127),
00491                                         (int)(Math.random() * 127 + 127));
00492                 stripes[2].setBackground(c);
00493                 composersPanel.setBackground(c);
00494                 BoxLayout cbl = new BoxLayout(composersPanel, BoxLayout.Y_AXIS);
00495                 composersPanel.setLayout(cbl);
00496                 
00497                 JPanel enableComposersPanel = new JPanel();
00498                 enableComposersPanel.setBackground(c);
00499                 
00500                 enableComposersBox = new JCheckBox("ENABLE COMPOSERS");
00501                 enableComposersBox.setBackground(c);
00502                 enableComposersBox.setSelected(true);
00503                 enableComposersPanel.add(enableComposersBox);
00504 
00505                 composersPanel.add(enableComposersPanel);
00506 
00507                 JPanel composersInputFileNamePanel = new JPanel();
00508                 composersInputFileNamePanel.setBackground(c);
00509                 JLabel cINL = new JLabel("input features file: ");
00510                 composersInputFileNamePanel.add(cINL);
00511                 composersInputFileNameLabel = new JLabel(" temp.feat ");
00512                 composersInputFileNameLabel.setOpaque(true);
00513                 composersInputFileNameLabel.setBackground(c.darker());
00514                 composersInputFileNamePanel.add(composersInputFileNameLabel);
00515                 composersPanel.add(composersInputFileNamePanel);
00516 
00517         
00518                 selectComposerPanel = new JPanel();
00519                 selectComposerPanel.setBackground(c);
00520                 selectComposerPanel.add(new JLabel("select a composer: "));
00521                 
00522                 
00523                 ButtonGroup composerButtons = new ButtonGroup();
00524                 
00525                 composerControlsPanels.add(BuildSortComposerGUI(c, composerButtons));
00526                 composerControlsPanels.add(BuildNearestNeighborComposerGUI(c, composerButtons));
00527                 composerControlsPanels.add(BuildBlipComposerGUI(c, composerButtons));
00528                 composerControlsPanels.add(BuildMashupComposerGUI(c, composerButtons)); 
00529                 composerControlsPanels.add(BuildMeapaeMComposerGUI(c, composerButtons));        
00530                 composerControlsPanels.add(BuildIntraChunkShuffleComposerGUI(c, composerButtons));
00531                 
00532                 composersPanel.add(selectComposerPanel);
00533 
00534                 composerControlsPanel = new JPanel();
00535                 composerControlsPanel.setBackground(c);
00536 
00537                 composerControlsPanel.add((JPanel)composerControlsPanels.elementAt(0));
00538 
00539                 selectedComposer = "SortComposer";
00540                 
00541                 composersPanel.add(composerControlsPanel);              
00542 
00543         JPanel chunkPanel = new JPanel(new GridLayout(2, 1));
00544                 chunkPanel.setBackground(c);
00545         TitledBorder title = BorderFactory.createTitledBorder(
00546             BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00547             "Universal Chunk Operations");
00548         title.setTitleJustification(TitledBorder.CENTER);
00549         chunkPanel.setBorder(title);
00550         JPanel chunkCommandPanel = new JPanel();
00551                 chunkCommandPanel.setBackground(c);
00552         composersReverseChunks = new JCheckBox("reverse");
00553         composersReverseChunks.setBackground(c);
00554                 composersReverseChunks.setToolTipText("Reverse audio in each chunk");
00555         chunkCommandPanel.add(composersReverseChunks);
00556                 composersFadeInOutChunks = new JCheckBox("apply fade in/out");
00557                 composersFadeInOutChunks.addActionListener(this);
00558         composersFadeInOutChunks.setBackground(c);
00559                 composersFadeInOutChunks.setToolTipText("Fade in/out on each chunk of audio");
00560         composersFadeInOutChunks.setActionCommand("fade");
00561         chunkCommandPanel.add(composersFadeInOutChunks);
00562         composersCrossfadeChunks = new JCheckBox("crossfade");
00563                 composersCrossfadeChunks.addActionListener(this);
00564         composersCrossfadeChunks.setBackground(c);
00565                 composersCrossfadeChunks.setToolTipText("Overlap fades from chunk to chunk");
00566         composersCrossfadeChunks.setActionCommand("fade");
00567         chunkCommandPanel.add(composersCrossfadeChunks);
00568         chunkPanel.add(chunkCommandPanel);
00569         JPanel crossfadePanel = new JPanel();
00570         crossfadePanel.setBackground(c);
00571                 JLabel crossfadeLabel = new JLabel("fade length (ms): ");
00572         crossfadePanel.add(crossfadeLabel);
00573         composersFadeDurationSlider = new JSlider(JSlider.HORIZONTAL, 0, 50, 0);
00574                 composersFadeDurationSlider.setBackground(c);
00575                 composersFadeDurationSlider.setToolTipText("Duration of fades");
00576                 composersFadeDurationSlider.setValue(0);
00577                 composersFadeDurationSlider.setEnabled(false);
00578                 composersFadeDurationSlider.setPaintLabels(true);
00579                 composersFadeDurationSlider.setMajorTickSpacing(10);
00580                 composersFadeDurationSlider.setMinorTickSpacing(2);
00581                 composersFadeDurationSlider.setPaintTicks(true);
00582         crossfadePanel.add(composersFadeDurationSlider);
00583         chunkPanel.add(crossfadePanel);
00584 
00585                 composersPanel.add(chunkPanel);
00586 
00587                 JPanel composersOutputFileNamePanel = new JPanel();
00588                 composersOutputFileNamePanel.setBackground(c);
00589                 JLabel cONL = new JLabel("output edl file: ");
00590                 composersOutputFileNamePanel.add(cONL);
00591                 composersOutputFileNameLabel = new JLabel(" temp.edl ");
00592                 composersOutputFileNameLabel.setOpaque(true);
00593                 composersOutputFileNameLabel.setBackground(c.darker());
00594                 composersOutputFileNamePanel.add(composersOutputFileNameLabel);
00595                 
00596                 composersPanel.add(composersOutputFileNamePanel);
00597 
00598                 JPanel displayComposerFeaturesPanel = new JPanel();
00599                 displayComposerFeaturesPanel.setBackground(c);
00600                 displayComposerFeaturesButton = new JButton("display composed features");
00601                 displayComposerFeaturesButton.setEnabled(false);
00602                 displayComposerFeaturesButton.addActionListener(this);
00603                 displayComposerFeaturesButton.setActionCommand("displayComposerFeatures");
00604                 displayComposerFeaturesButton.setBackground(c);
00605                 displayComposerFeaturesPanel.add(displayComposerFeaturesButton);
00606                 
00607                 composersPanel.add(displayComposerFeaturesPanel);
00608                 
00609                 panel.add(composersPanel);
00610 
00611                 tabs.addTab("composers", composersPanel);
00612                 tabs.setBackgroundAt(2, c);
00613         }
00614         
00615         private JPanel BuildSortComposerGUI(Color c, ButtonGroup composerButtons)
00616         {               
00617                 //sort composer
00618                 JPanel sortComposerPanel = new JPanel();
00619                 BoxLayout bl = new BoxLayout(sortComposerPanel, BoxLayout.Y_AXIS);
00620                 sortComposerPanel.setLayout(bl);
00621                 sortComposerPanel.setBackground(c);
00622 
00623                 enableSortComposerButton = new JRadioButton("simple sort");
00624                 enableSortComposerButton.setBackground(c);
00625                 composerButtons.add(enableSortComposerButton);
00626                 enableSortComposerButton.setSelected(true);
00627                 enableSortComposerButton.addActionListener(this);
00628                 //set the action command to the name of the composer class!
00629                 enableSortComposerButton.setActionCommand("SortComposer");
00630                 selectComposerPanel.add(enableSortComposerButton);
00631                 
00632                 JTextArea description = new JTextArea(SortComposer.description);
00633                 description.setColumns(50);
00634                 description.setLineWrap(true);
00635                 description.setWrapStyleWord(true);
00636                 description.setBackground(c);
00637                 description.setEditable(false);
00638                 sortComposerPanel.add(description);
00639                 
00640                 JPanel controlsPanel = new JPanel();
00641                 controlsPanel.setBackground(c);
00642                 TitledBorder title = BorderFactory.createTitledBorder(
00643                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00644                         "SimpleSort Controls");
00645                 title.setTitleJustification(TitledBorder.CENTER);
00646                 controlsPanel.setBorder(title);
00647                 reverseSortComposerBox = new JCheckBox("reverse sort");
00648                 reverseSortComposerBox.setBackground(c);
00649                 controlsPanel.add(reverseSortComposerBox);
00650                 
00651                 sortComposerPanel.add(controlsPanel);
00652                 
00653                 
00654 
00655                 
00656                 //selectComposerPanel.add(sortComposerPanel);
00657                 return sortComposerPanel;
00658         }
00659         
00660         private JPanel BuildNearestNeighborComposerGUI(Color c, ButtonGroup composerButtons)
00661         {
00662                 //nearest neighbor composer
00663                 JPanel nNComposerPanel = new JPanel();
00664                 nNComposerPanel.setBackground(c);
00665                 enableNNComposerButton = new JRadioButton("nearest neighbor");
00666                 enableNNComposerButton.setBackground(c);
00667                 composerButtons.add(enableNNComposerButton);
00668                 enableNNComposerButton.setSelected(false);
00669                 enableNNComposerButton.addActionListener(this);
00670                 //set the action command to the name of the composer class!
00671                 enableNNComposerButton.setActionCommand("NNComposer");
00672                 selectComposerPanel.add(enableNNComposerButton);
00673                 
00674                 JTextArea description = new JTextArea(NNComposer.description);
00675                 description.setColumns(50);
00676                 description.setLineWrap(true);
00677                 description.setWrapStyleWord(true);
00678                 description.setBackground(c);
00679                 description.setEditable(false);
00680                 nNComposerPanel.add(description);
00681                 
00682                 
00683                 return nNComposerPanel;
00684         }
00685         
00686         private JPanel BuildBlipComposerGUI(Color c, ButtonGroup composerButtons)
00687         {
00688                 
00689                 // blip composer
00690                 JPanel bLComposerPanel = new JPanel();
00691                 bLComposerPanel.setBackground(c);
00692                 enableBLComposerButton = new JRadioButton("add blips");
00693                 enableBLComposerButton.setBackground(c);
00694                 composerButtons.add(enableBLComposerButton);
00695                 enableBLComposerButton.setSelected(false);
00696                 enableBLComposerButton.addActionListener(this);
00697                 //set the action command to the name of the composer class!
00698                 enableBLComposerButton.setActionCommand("BlipComposer");
00699                 selectComposerPanel.add(enableBLComposerButton);
00700                 
00701                 JTextArea description = new JTextArea(BlipComposer.description);
00702                 description.setColumns(50);
00703                 description.setLineWrap(true);
00704                 description.setWrapStyleWord(true);
00705                 description.setBackground(c);
00706                 description.setEditable(false);
00707                 bLComposerPanel.add(description);
00708                 
00709                 return bLComposerPanel;
00710         }
00711         
00712         private JPanel BuildMashupComposerGUI(Color c, ButtonGroup composerButtons)
00713         {
00714                 //mashup composer
00715                 JPanel mUComposerPanel = new JPanel();
00716                 BoxLayout bl = new BoxLayout(mUComposerPanel, BoxLayout.Y_AXIS);
00717                 mUComposerPanel.setLayout(bl);
00718                 mUComposerPanel.setBackground(c);
00719                 enableMUComposerButton = new JRadioButton("mashup!");
00720                 enableMUComposerButton.setBackground(c);
00721                 composerButtons.add(enableMUComposerButton);
00722                 enableMUComposerButton.setSelected(false);
00723                 enableMUComposerButton.addActionListener(this);
00724                 //set the action command to the name of the composer class!
00725                 enableMUComposerButton.setActionCommand("MashupComposer");
00726                 selectComposerPanel.add(enableMUComposerButton);
00727                 
00728                 JTextArea description = new JTextArea(MashupComposer.description);
00729                 description.setColumns(50);
00730                 description.setLineWrap(true);
00731                 description.setWrapStyleWord(true);
00732                 description.setBackground(c);
00733                 description.setEditable(false);
00734                 mUComposerPanel.add(description);
00735                 
00736                 JPanel controlsPanel = new JPanel();
00737                 controlsPanel.setBackground(c);
00738                 TitledBorder title = BorderFactory.createTitledBorder(
00739                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00740                         "Mashup Controls");
00741                 title.setTitleJustification(TitledBorder.CENTER);
00742                 controlsPanel.setBorder(title);
00743                 
00744                 JLabel mULabel = new JLabel("target features file:");
00745                 controlsPanel.add(mULabel);
00746                 mashupTargetFileField = new JTextField("target .feat file");
00747                 mashupTargetFileField.setColumns(20);
00748                 mashupTargetFileField.setEditable(false);
00749                 controlsPanel.add(mashupTargetFileField);
00750                 JButton mUBrowseButton = new JButton("browse");
00751                 mUBrowseButton.setBackground(c);
00752                 mUBrowseButton.addActionListener(this);
00753                 mUBrowseButton.setActionCommand("setMUTargetFeaturesFile");
00754                 controlsPanel.add(mUBrowseButton);
00755                 
00756                 mUComposerPanel.add(controlsPanel);
00757 
00758                 //selectComposerPanel.add(mUComposerPanel);
00759                 return mUComposerPanel;
00760         }
00761 
00762         private JPanel BuildMeapaeMComposerGUI(Color c, ButtonGroup composerButtons)
00763         {
00764                 
00765                 // MeapaeM composer
00766                 JPanel MeapaeMComposerPanel = new JPanel();
00767                 MeapaeMComposerPanel.setBackground(c);
00768                 enableMMComposerButton = new JRadioButton("MeapaeM");
00769                 enableMMComposerButton.setBackground(c);
00770                 composerButtons.add(enableMMComposerButton);
00771                 enableMMComposerButton.setSelected(false);
00772                 enableMMComposerButton.addActionListener(this);
00773                 //set the action command to the name of the composer class!
00774                 enableMMComposerButton.setActionCommand("MeapaeMComposer");
00775                 selectComposerPanel.add(enableMMComposerButton);
00776                 
00777                 JTextArea description = new JTextArea(MeapaeMComposer.description);
00778                 description.setColumns(50);
00779                 description.setLineWrap(true);
00780                 description.setWrapStyleWord(true);
00781                 description.setBackground(c);
00782                 description.setEditable(false);
00783                 MeapaeMComposerPanel.add(description);
00784                 
00785                 return MeapaeMComposerPanel;
00786         }
00787         
00788         private JPanel BuildIntraChunkShuffleComposerGUI(Color c, ButtonGroup composerButtons)
00789         {
00790                 
00791                 // IntraChunkShuffle composer
00792                 JPanel IntraChunkShuffleComposerPanel = new JPanel();
00793                 IntraChunkShuffleComposerPanel.setBackground(c);
00794                 BoxLayout bl = new BoxLayout(IntraChunkShuffleComposerPanel, BoxLayout.Y_AXIS);
00795                 IntraChunkShuffleComposerPanel.setLayout(bl);
00796                 enableICSComposerButton = new JRadioButton("IntraChunkShuffle");
00797                 enableICSComposerButton.setBackground(c);
00798                 composerButtons.add(enableICSComposerButton);
00799                 enableICSComposerButton.setSelected(false);
00800                 enableICSComposerButton.addActionListener(this);
00801                 //set the action command to the name of the composer class!
00802                 enableICSComposerButton.setActionCommand("IntraChunkShuffleComposer");
00803                 selectComposerPanel.add(enableICSComposerButton);
00804                 
00805                 JTextArea description = new JTextArea(IntraChunkShuffleComposer.description);
00806                 description.setColumns(50);
00807                 description.setLineWrap(true);
00808                 description.setWrapStyleWord(true);
00809                 description.setBackground(c);
00810                 description.setEditable(false);
00811                 IntraChunkShuffleComposerPanel.add(description);
00812                 
00813                 JPanel controlsPanel = new JPanel();
00814                 controlsPanel.setBackground(c);
00815                 TitledBorder title = BorderFactory.createTitledBorder(
00816                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00817                         "IntraChunkShuffle Controls");
00818                 title.setTitleJustification(TitledBorder.CENTER);
00819                 controlsPanel.setBorder(title);
00820                 
00821                 JLabel iCSLabel = new JLabel("number of sub chunks:");
00822                 controlsPanel.add(iCSLabel);
00823                 intraChunkShuffleNumChunksField = new JTextField("4");
00824                 controlsPanel.add(intraChunkShuffleNumChunksField);
00825                 
00826                 IntraChunkShuffleComposerPanel.add(controlsPanel);
00827                 
00828                 return IntraChunkShuffleComposerPanel;
00829         }
00830         
00831         private void BuildSynthesizerGUI()
00832         {
00833                 synthPanel = new JPanel();
00834                 Color c = new Color((int)(Math.random() * 127 + 127),
00835                                         (int)(Math.random() * 127 + 127),
00836                                         (int)(Math.random() * 127 + 127));
00837                 stripes[3].setBackground(c);
00838                 synthPanel.setBackground(c);
00839                 BoxLayout synthbl = new BoxLayout(synthPanel, BoxLayout.Y_AXIS);
00840                 synthPanel.setLayout(synthbl);
00841                 
00842                 JPanel enableSynthPanel = new JPanel();
00843                 enableSynthPanel.setBackground(c);
00844                 
00845                 enableSynthBox = new JCheckBox("ENABLE SYNTHESIZER");
00846                 enableSynthBox.setBackground(c);
00847                 enableSynthBox.setSelected(true);
00848                 enableSynthPanel.add(enableSynthBox);
00849 
00850                 synthPanel.add(enableSynthPanel);
00851                 
00852                 JPanel synthFileIOPanel = new JPanel();
00853                 synthFileIOPanel.setBackground(c);
00854                 
00855                 JLabel sNL = new JLabel("input edl file: ");
00856                 synthFileIOPanel.add(sNL);
00857                 synthFileNameLabel = new JLabel(" temp.edl ");
00858                 synthFileNameLabel.setOpaque(true);
00859                 synthFileNameLabel.setBackground(c.darker());
00860                 synthFileIOPanel.add(synthFileNameLabel);
00861                 synthPanel.add(synthFileIOPanel);
00862                 
00863                 JPanel synthControlsPanel = new JPanel();
00864                 synthControlsPanel.setBackground(c);
00865                 TitledBorder title = BorderFactory.createTitledBorder(
00866                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00867                         "Synthesizer Controls");
00868                 title.setTitleJustification(TitledBorder.CENTER);
00869                 synthControlsPanel.setBorder(title);
00870                 BoxLayout scp = new BoxLayout(synthControlsPanel, BoxLayout.Y_AXIS);
00871                 synthControlsPanel.setLayout(scp);
00872                 
00873                 JPanel outputFileNamePanel = new JPanel();
00874                 outputFileNamePanel.setBackground(c);
00875                 
00876                 JLabel outputFileNameBoxLabel = new JLabel("output sound file:");
00877                 outputFileNamePanel.add(outputFileNameBoxLabel);
00878         
00879                 outputFileNameField = new JTextField("output wav file");
00880                 outputFileNameField.setColumns(20);
00881                 outputFileNameField.setEditable(false);
00882                 outputFileNamePanel.add(outputFileNameField);
00883                 
00884                 JButton outputBrowseButton = new JButton("browse");
00885                 outputBrowseButton.setBackground(c);
00886                 outputBrowseButton.addActionListener(this);
00887                 outputBrowseButton.setActionCommand("setOutputFile");
00888                 outputFileNamePanel.add(outputBrowseButton);
00889                 
00890                 
00891                 listenButton = new JButton("listen");
00892                 listenButton.setBackground(c);
00893                 listenButton.addActionListener(this);
00894                 listenButton.setActionCommand("listen");
00895                 outputFileNamePanel.add(listenButton);
00896                 
00897                 
00898                 synthControlsPanel.add(outputFileNamePanel);
00899                 
00900                 synthPanel.add(synthControlsPanel);
00901                 tabs.addTab("synthesizer", synthPanel);
00902                 tabs.setBackgroundAt(3, c);
00903         }
00904         
00905         private void BuildPrefsGUI()
00906         {
00907                 prefsPanel = new JPanel();
00908                 Color c = new Color((int)(Math.random() * 127 + 127),
00909                                         (int)(Math.random() * 127 + 127),
00910                                         (int)(Math.random() * 127 + 127));
00911                 stripes[4].setBackground(c);
00912                 prefsPanel.setBackground(c);
00913                 BoxLayout prefsBL = new BoxLayout(prefsPanel, BoxLayout.Y_AXIS);
00914                 prefsPanel.setLayout(prefsBL);
00915                 
00916                 prefsPanel = new JPanel();
00917                 prefsPanel.setBackground(c);
00918                 JLabel dataBaseNameLabel = new JLabel("data base name: ");
00919                 prefsPanel.add(dataBaseNameLabel);              
00920                 dataBaseNameField = new JTextField("temp");
00921                 dataBaseNameField.setColumns(10);
00922                 prefsPanel.add(dataBaseNameField);
00923                 JButton dataBaseNameUpdateButton = new JButton("update");
00924                 dataBaseNameUpdateButton.setBackground(c);
00925                 dataBaseNameUpdateButton.addActionListener(this);
00926                 dataBaseNameUpdateButton.setActionCommand("dataBaseName");
00927                 prefsPanel.add(dataBaseNameUpdateButton);
00928                 
00929                 tabs.addTab("preferences", prefsPanel); 
00930 
00931         }
00932         
00933         private Vector SniffFeatureExtractors()
00934         {
00935         Vector v = null;
00936         try 
00937         {
00938             v = RTSI.findnames("com.meapsoft.featextractors", Class.forName("com.meapsoft.featextractors.FeatureExtractor"));
00939             // \todo{where else should we look for feature extractors?}
00940             // also check current directory:
00941             Vector v2 = RTSI.findnames(System.getProperty("user.dir"), Class.forName("com.meapsoft.featextractors.FeatureExtractor")); 
00942             if(v2 != null)
00943                 v.addAll(v2);
00944             
00945             for (int i = 0; i < v.size(); i++)
00946             {
00947                                 FeatureExtractor f = null;
00948                                 
00949                                 try
00950                                 {
00951                                         String name = "com.meapsoft.featextractors." + (String)v.elementAt(i);
00952                                         //String description = Class.forName(name).newInstance().description;
00953                                         f = (FeatureExtractor)(Class.forName(name).newInstance());
00954                                         featureDescriptions.add(f.description());
00955                                 }
00956                                 catch (InstantiationException e1)
00957                                 {
00958                                         // TODO Auto-generated catch block
00959                                         e1.printStackTrace();
00960                                 }
00961                                 catch (IllegalAccessException e1)
00962                                 {
00963                                         // TODO Auto-generated catch block
00964                                         e1.printStackTrace();
00965                                 }
00966             }
00967         }
00968         catch(ClassNotFoundException e)
00969         {
00970             e.printStackTrace();
00971             return(null);
00972         }
00973 
00974         return v;
00975         }
00976         
00977         private String[] FileSelector(int mode)
00978         {               
00979                 JFileChooser chooser = new JFileChooser();
00980                 
00981                 chooser.setCurrentDirectory(new File(dataDirectory));
00982                 int returnVal = 0;
00983                 
00984                 if (mode == OPEN)
00985                         returnVal = chooser.showOpenDialog(null);
00986                 else if (mode == SAVE)
00987                         returnVal = chooser.showSaveDialog(null);
00988                 else if (mode == DIR)
00989                 {
00990                         chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
00991                         returnVal = chooser.showOpenDialog(this);
00992                 }
00993                 else
00994                         return null;
00995                         
00996                 String[] name = new String[2];
00997                 
00998                 if(returnVal == JFileChooser.APPROVE_OPTION) 
00999                 {
01000                         try
01001                         {
01002                                 name[0] = chooser.getCurrentDirectory().getCanonicalPath() +
01003                                         slash +
01004                                         chooser.getSelectedFile().getName();
01005                                 name[1] = chooser.getSelectedFile().getName();
01006 
01007                         }
01008                         catch (IOException e)
01009                         {
01010                                 e.printStackTrace();
01011                                 return null;
01012                         }
01013                 }
01014                 
01015                 return name;
01016         }
01017 
01018     private void initSegmentFile()
01019     {        
01020         String fn = inputSoundFileNameFull;
01021 
01022         if(segmentFile == null || segmentFile.filename != fn)
01023             segmentFile = new FeatFile(fn);
01024     }
01025 
01026     private void initFeatFile()
01027     {
01028         String fn = dataDirectory + slash + outputFeaturesFileName;
01029 
01030         if(featFile == null || featFile.filename != fn)
01031             featFile = new FeatFile(fn);
01032     }
01033 
01034     private void initEDLFile()
01035     {        
01036         String fn = dataDirectory + slash + outputEDLFileName;
01037 
01038         if(edlFile == null || edlFile.filename != fn)
01039             edlFile = new EDLFile(fn);
01040     }
01041 
01042         private void DoSegmenter()
01043         {               
01044                 //value will be 0-9, we want 1-5
01045                 double bandThresh = 4.0 - (segmentThresholdSlider.getValue()/4.0);
01046                 double bandFrac = 0.3;
01047                 
01048                 boolean beatOnsetDetector = beatStyleButton.isSelected();
01049                 boolean firstFrameOnset = firstFrameBox.isSelected();
01050                 
01051                 String segmentsFileName = dataDirectory + slash + outputSegmentsFileName;
01052                 
01053                 Segmenter segmenter = new Segmenter(inputSoundFileNameFull,
01054                         segmentsFileName, 0, bandThresh, bandFrac, beatOnsetDetector, firstFrameOnset);
01055 
01056         try
01057         {
01058             segmentFile = segmenter.processAudioFile(inputSoundFileNameFull);
01059             segmentFile.writeFile();
01060         }
01061         catch (Exception e)
01062         {
01063             e.printStackTrace();
01064         }
01065         }
01066 
01067         private void DoFeatureExtractor()
01068         {
01069         Vector featExts = new Vector();
01070                 for(int i = 0; i < featureCheckBoxes.size(); i++)       
01071         {
01072                         JCheckBox cb = (JCheckBox)featureCheckBoxes.elementAt(i);
01073                         
01074             try
01075             {
01076                 if (cb.isSelected())
01077                     featExts.add(Class.forName("com.meapsoft.featextractors." + cb.getText())
01078                                  .newInstance());
01079             }
01080             catch(Exception e)
01081             {
01082                 System.out.println("featextractor error");
01083                 e.printStackTrace();
01084             }
01085         }
01086 
01087         FeatExtractor featExtractor = 
01088             new FeatExtractor(segmentFile, featFile, featExts);
01089         
01090         try
01091         {                               
01092             // clear whatever chunks may have already been calculated
01093             featFile.clearChunks();
01094             
01095             featExtractor.setup();
01096             featExtractor.processFeatFiles();
01097             featFile.writeFile();
01098         }
01099         catch (Exception e)
01100         {
01101             e.printStackTrace();
01102         }
01103 
01104         displayFeaturesButton.setEnabled(true);
01105         }
01106         
01107         private int DoComposer()
01108         {       
01109                 /*
01110                 String composerName = null;
01111                 
01112                 for (int i = 0; i < composerRadioButtons.size(); i++)
01113                 {
01114                         JRadioButton rb = (JRadioButton)composerRadioButtons.elementAt(i);
01115                         if (rb.isSelected())
01116                                 composerName = rb.getActionCommand();
01117                 }
01118                 
01119                 //System.out.println("composer: " + composerName);
01120                 */
01121                 
01122         Composer composer = null;
01123                 if (selectedComposer.equals("SortComposer"))
01124                 {
01125                         composer = new SortComposer(featFile, edlFile);
01126             ((SortComposer)composer).setReverseSort(reverseSortComposerBox.isSelected());
01127                 }
01128                 else if (selectedComposer.equals("NNComposer"))
01129                 {
01130                         composer = new NNComposer(featFile, edlFile);
01131                 }
01132                 else if (selectedComposer.equals("BlipComposer"))
01133                 {
01134                         composer = new BlipComposer(featFile, edlFile);
01135                 }
01136                 else if (selectedComposer.equals("MashupComposer"))
01137                 {
01138                         edlFile = new EDLFile(dataDirectory + //dataDirectoryNameField.getText() + 
01139                                 slash + dataBaseName + "_using_" + 
01140                                 targetFeaturesNameShort + ".edl");
01141 
01142             FeatFile targetFile = new FeatFile(targetFeaturesNameFull);
01143                                 
01144             composer = new MashupComposer(featFile, targetFile, edlFile);
01145                 }
01146                 else if (selectedComposer.equals("MeapaeMComposer"))
01147                 {
01148                         composer = new MeapaeMComposer(featFile, edlFile);
01149                 }
01150                 else if (selectedComposer.equals("IntraChunkShuffleComposer"))
01151                 {
01152                         int numSubChunks = 4;
01153                         
01154                         try
01155                         {
01156                                 numSubChunks = new Integer(intraChunkShuffleNumChunksField.getText()).intValue();
01157                         }
01158                         catch (Exception e)
01159                         {
01160                                 System.out.println(e);
01161                                 return -1;
01162                         }
01163                         composer = new IntraChunkShuffleComposer(featFile, edlFile, numSubChunks);
01164                 }
01165                 else
01166                 {
01167                         System.out.println("I don't recognize that composer!");
01168                         return -1;
01169                 }
01170                 
01171         lastEDLFileName = edlFile.filename; 
01172 
01173         double crossfade = (double)composersFadeDurationSlider.getValue()/1000;
01174         if(composersFadeInOutChunks.isSelected() & crossfade > 0)
01175             composer.addCommand("fade("+crossfade+")");
01176         if(composersCrossfadeChunks.isSelected() & crossfade > 0)
01177             composer.addCommand("crossfade("+crossfade+")");
01178         if(composersReverseChunks.isSelected())
01179             composer.addCommand("reverse");
01180         
01181         composer.go();
01182 
01183         displayComposerFeaturesButton.setEnabled(true);
01184         
01185         return 0;
01186     }
01187         
01188         private void DoSynth()
01189         {       
01190                 Synthesizer synth = new Synthesizer(edlFile, outputSoundFileNameFull);
01191         synth.go();
01192         }
01193         
01194         private void UpdateFileNames()
01195         {
01196                 //segmenter
01197                 outputSegmentsFileName = dataBaseName + ".seg";
01198                 //features
01199                 inputSegmentsFileName = dataBaseName + ".seg";
01200                 outputFeaturesFileName = dataBaseName + ".feat";
01201                 //composer
01202                 inputFeaturesFileName = dataBaseName + ".feat";
01203                 outputEDLFileName = dataBaseName + ".edl";
01204                 //synth
01205                 inputEDLFileName = dataBaseName + ".edl";
01206         }
01207         
01208         private void UpdateInfoTexts()
01209         {       
01210                 //segmenter
01211                 //segmenterInputSoundFileField.setText(inputSoundFileNameShort);
01212                 segmenterOutputSegFileLabel.setText(" " + outputSegmentsFileName + " ");
01213                 //features
01214                 inputSegmentsFileLabel.setText(" " + inputSegmentsFileName + " ");
01215                 outputFeaturesFileLabel.setText(" " + outputFeaturesFileName + " ");
01216                 //composer
01217                 composersInputFileNameLabel.setText(" " + inputFeaturesFileName + " ");
01218                 composersOutputFileNameLabel.setText(" " + outputEDLFileName + " ");
01219                 //synth
01220                 synthFileNameLabel.setText(" " + inputEDLFileName + " ");
01221                 pack(); 
01222 
01223                 initSegmentFile();
01224                 initFeatFile();
01225                 initEDLFile();
01226         }
01227         
01228         public void actionPerformed(ActionEvent arg0)
01229         {
01230 
01231                 String command = arg0.getActionCommand();
01232                 //System.out.println("command: " + command);
01233 
01234                 if (command.equals("setInputFile"))
01235                 {
01236                         String names[] = FileSelector(OPEN);
01237                         
01238                         if (names[0] == null)
01239                                 return;
01240                         inputSoundFileNameFull = names[0];
01241                         inputSoundFileNameShort = names[1];
01242                         dataBaseName = inputSoundFileNameShort;
01243                         segmenterInputSoundFileField.setText(inputSoundFileNameShort);
01244                         UpdateFileNames();
01245                         UpdateInfoTexts();
01246                 }
01247                 else if (command.equals("setOutputFile"))
01248                 {
01249                         String names[] = FileSelector(SAVE);
01250                         
01251                         if (names[0] == null)
01252                                 return;
01253                                 
01254                         outputSoundFileNameFull = names[0];
01255                         outputSoundFileNameShort = names[1];
01256                         outputFileNameField.setText(outputSoundFileNameShort);
01257                 }
01258                 else if (command.equals("SortComposer"))
01259                 {
01260                         //System.out.println("adding sort composer gui...");
01261                         selectedComposer = command;
01262                         composerControlsPanel.removeAll();
01263                         composerControlsPanel.add((JPanel)composerControlsPanels.elementAt(0));
01264                         pack();
01265                         repaint();
01266                 }
01267                 else if (command.equals("NNComposer"))
01268                 {
01269                         //System.out.println("adding NN composer gui...");
01270                         selectedComposer = command;
01271                         composerControlsPanel.removeAll();
01272                         composerControlsPanel.add((JPanel)composerControlsPanels.elementAt(1));
01273                         pack();
01274                         repaint();
01275                 }
01276                 else if (command.equals("BlipComposer"))
01277                 {
01278                         //System.out.println("adding blip composer gui...");
01279                         selectedComposer = command;
01280                         composerControlsPanel.removeAll();
01281                         composerControlsPanel.add((JPanel)composerControlsPanels.elementAt(2));
01282                         pack();
01283                         repaint();
01284                 }
01285                 else if (command.equals("MashupComposer"))
01286                 {
01287                         //System.out.println("adding mashup composer gui...");
01288                         selectedComposer = command;
01289                         composerControlsPanel.removeAll();
01290                         composerControlsPanel.add((JPanel)composerControlsPanels.elementAt(3));
01291                         pack();
01292                         repaint();
01293                 }
01294                 else if (command.equals("MeapaeMComposer"))
01295                 {
01296                         //System.out.println("adding MeapaeM composer gui...");
01297                         selectedComposer = command;
01298                         composerControlsPanel.removeAll();
01299                         composerControlsPanel.add((JPanel)composerControlsPanels.elementAt(4));
01300                         pack();
01301                         repaint();
01302                 }
01303                 else if (command.equals("IntraChunkShuffleComposer"))
01304                 {
01305                         //System.out.println("adding IntraChunkShuffleComposer composer gui...");
01306                         selectedComposer = command;
01307                         composerControlsPanel.removeAll();
01308                         composerControlsPanel.add((JPanel)composerControlsPanels.elementAt(5));
01309                         pack();
01310                         repaint();
01311                 }
01312                 else if (command.equals("setMUTargetFeaturesFile"))
01313                 {
01314                         String names[] = FileSelector(OPEN);
01315                         targetFeaturesNameFull = names[0];
01316                         targetFeaturesNameShort = names[1];
01317                         if (targetFeaturesNameShort.endsWith("feat"))
01318                                 mashupTargetFileField.setText(targetFeaturesNameShort);
01319                         else
01320                                 mashupTargetFileField.setText("error! use only .feat files!");
01321                 }
01322                 else if (command.equals("dataBaseName"))
01323                 {
01324                         dataBaseName = dataBaseNameField.getText();
01325                         UpdateFileNames();
01326                         UpdateInfoTexts();
01327                 }
01328                 else if (command.equals("fade"))
01329         {
01330             boolean enable = composersFadeInOutChunks.isSelected() 
01331                 || composersCrossfadeChunks.isSelected();
01332             composersFadeDurationSlider.setEnabled(enable);
01333         }
01334                 else if (command.equals("displayFeatures") ||
01335                         command.equals("displayComposerFeatures"))
01336                 {
01337                         DataDisplayPanel fp;
01338                         
01339             String frameName;
01340                         if (command.equals("displayFeatures"))
01341             {
01342                                 fp = new DataDisplayPanel(featFile);
01343                 frameName = outputFeaturesFileName;
01344             }
01345                         else 
01346             {
01347                                 fp = new DataDisplayPanel((FeatFile)edlFile);
01348                 frameName = edlFile.filename;
01349             }                   
01350 
01351                         try
01352                         {
01353                                 fp.setup();
01354 
01355                  JFrame jframe = new JFrame(frameName);
01356                  jframe.setContentPane(fp);
01357                  jframe.pack();
01358                  jframe.setVisible(true);
01359                         }
01360                         catch (Exception e)
01361                         {
01362                                 System.out.println("problem with ImagePanel.");
01363                                 e.printStackTrace();
01364                         }
01365                 }
01366                 else if (command.equals("go"))
01367                 {       
01368                         Container c = getContentPane();  // get the window's content pane
01369                         c.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
01370                         
01371                         if (enableSegmenterBox.isSelected())
01372                         {
01373                                 if (inputSoundFileNameFull == null)
01374                                 {
01375                                         JOptionPane.showMessageDialog(this,
01376                                                 "You need to pick an input file!!!");
01377                                         c.setCursor(Cursor.getDefaultCursor());
01378                                         return;
01379                                 }
01380                                 DoSegmenter();  
01381                         }
01382                         if (enableFeatExtractorBox.isSelected())
01383                                 DoFeatureExtractor();
01384                         if (enableComposersBox.isSelected())
01385                                 DoComposer();
01386                         if (enableSynthBox.isSelected())
01387                         {
01388                                 if (outputSoundFileNameFull == null)
01389                                 {
01390                                         JOptionPane.showMessageDialog(this,
01391                                                 "You need to pick an output file!!!");
01392                                         c.setCursor(Cursor.getDefaultCursor());
01393                                         return;
01394                                 }
01395                                 DoSynth();
01396                         }
01397                         
01398                         c.setCursor(Cursor.getDefaultCursor());
01399                         
01400                         JOptionPane.showMessageDialog(this,
01401                                 "Finished MEAPing!!!");
01402                 }
01403                 //Bagging this, it only works on OSX. Bummer!
01404                 
01405                 else if (command.equals("listen"))
01406                 {
01407                         if (outputSoundFileNameFull == null)
01408                         {
01409                                 JOptionPane.showMessageDialog(this,
01410                                         "You need to pick an output file!!!");
01411                                 return;
01412                         }
01413                         try
01414                         {
01415                                 Process p = null;
01416                                 if (System.getProperty("os.name").equals("Mac OS X"))
01417                                         p = Runtime.getRuntime().exec("open " + outputSoundFileNameFull);
01418                                 else if (System.getProperty("os.name").equals("Linux"))
01419                                         p = Runtime.getRuntime().exec("play " + outputSoundFileNameFull);
01420                                 else
01421                                         JOptionPane.showMessageDialog(this,
01422                                                 "Listen only works on OSX and Linux. Sorry!");
01423                         }
01424                         catch (IOException e)
01425                         {
01426                                 e.printStackTrace();
01427                         }
01428                 }
01429         }
01430         
01431 
01432         public static void main(String[] args)
01433         {       
01434                 //Schedule a job for the event-dispatching thread:
01435                 //creating and showing this application's GUI.
01436                 javax.swing.SwingUtilities.invokeLater(new Runnable() {
01437                         public void run() 
01438                         {
01439                                 new MEAPsoftGUI();
01440                         }
01441                 });
01442 
01443         }
01444 }

Generated on Thu May 11 15:04:10 2006 for MEAPsoft by doxygen1.2.18