Main Page   Packages   Class Hierarchy   Compound List   File List   Compound Members  

ComposerPanel.java

00001 /*
00002  *  Copyright 2006-2007 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.*;
00026 import java.awt.event.*;
00027 import java.io.*;
00028 import java.util.*;
00029 import javax.swing.*; 
00030 import javax.swing.border.*; 
00031 
00032 import com.meapsoft.visualizer.*;
00033 
00034 import com.meapsoft.*;
00035 import com.meapsoft.composers.*;
00036 //import com.meapsoft.disgraced.*;
00037 
00038 
00045 public class ComposerPanel extends MEAPsoftGUIPanel
00046 {
00047         //composers
00048         String selectedComposer;
00049         JPanel selectComposerPanel;
00050         JPanel controlsPanel;
00051         Vector controlsPanels;
00052         JCheckBox enableBox;
00053     // EDL commands
00054     JCheckBox reverseChunks;
00055     JCheckBox addGainChunks;
00056     JTextField gainValueField;
00057     JCheckBox fadeInOutChunks;
00058     JCheckBox crossfadeChunks;
00059     JSlider fadeDurationSlider;
00060 
00061         JRadioButton enableSortComposerButton;
00062         JRadioButton enableNNComposerButton;
00063         JRadioButton enableBLComposerButton;
00064         JRadioButton enableMUComposerButton;
00065         JRadioButton enableMMComposerButton;
00066         JRadioButton enableICSComposerButton;
00067         JRadioButton enableHBComposerButton;
00068         JRadioButton enableThresholdComposerButton;
00069         JRadioButton enableRotComposerButton;
00070         JRadioButton enableLikelihoodComposerButton;
00071         JRadioButton enableEDLComposerButton;
00072     JRadioButton enableShoobyComposerButton;
00073 
00074     // sort composer controls
00075         JRadioButton highLowSortButton;
00076         JRadioButton lowHighSortButton;
00077     JCheckBox normalizeFeatCB;
00078 
00079         String chunkDBFeaturesNameFull;
00080         String chunkDBFeaturesNameShort;
00081         JLabel inputFileNameLabel;
00082         JLabel outputFileNameLabel;
00083         JTextField mashupChunkDBFileField;
00084         JSlider headbangBinSlider;
00085         JSlider headbangLengthSlider;
00086         JTextField intraChunkShuffleNumChunksField;
00087         JTextField thresholdTopField;
00088         JTextField thresholdBottomField;
00089         JRadioButton insideThresholdButton;
00090         JRadioButton outsideThresholdButton;
00091         JTextField rotBeatsPerMeasureField;
00092         JTextField rotNumPositionsField;
00093         JRadioButton rotLeftButton;
00094         JRadioButton rotRightButton;
00095         JTextField inputEDLFileField;
00096         String inputEDLFileNameFull;
00097         String inputEDLFileNameShort;
00098         JSlider vqNumCodewords;
00099         JSlider vqBeatsPerCW;
00100     JCheckBox vqQuantizeTrainingFile;
00101     JTextField vqFeatFileField;
00102     JButton vqBrowseButton;
00103     String vqFeaturesNameFull = null;
00104     String vqFeaturesNameShort = null;
00105         JSlider hmmNumStates;
00106         JSlider hmmBeatsPerState;
00107         JSlider hmmSequenceLength;
00108         JTextField shoobyFileLengthField;
00109         JTextField shoobyClumpWidthField;
00110         JSlider shoobyDrunkennessSlider;
00111 
00112         JButton displayComposerFeaturesButton;  
00113         
00117     public ComposerPanel(MEAPsoftGUI msg)
00118     {
00119         super(msg);
00120         BuildComposersGUI();
00121 
00122         title = "Composer";
00123         helpURL += "#" + title;
00124     }
00125 
00126 
00127         private void BuildComposersGUI()
00128         {
00129                 controlsPanels = new Vector();
00130                 
00131                 Color c = new Color((int)(Math.random() * 127 + 127),
00132                                         (int)(Math.random() * 127 + 127),
00133                                         (int)(Math.random() * 127 + 127));
00134         color = c;
00135 
00136                 setBackground(c);
00137                 BoxLayout cbl = new BoxLayout(this, BoxLayout.Y_AXIS);
00138                 setLayout(cbl);
00139                 
00140                 JPanel enableComposersPanel = new JPanel();
00141                 enableComposersPanel.setBackground(c);
00142                 
00143                 enableBox = new JCheckBox("ENABLE COMPOSERS");
00144                 enableBox.setBackground(c);
00145                 enableBox.setSelected(true);
00146                 enableComposersPanel.add(enableBox);
00147                 
00148                 enableComposersPanel.add(helpButton);
00149 
00150                 add(enableComposersPanel);
00151                 
00152                 JPanel composersInputFileNamePanel = new JPanel();
00153                 composersInputFileNamePanel.setBackground(c);
00154                 JLabel cINL = new JLabel("input features file: ");
00155                 composersInputFileNamePanel.add(cINL);
00156                 inputFileNameLabel = new JLabel(" " + dataBaseName + ".feat ");
00157                 inputFileNameLabel.setOpaque(true);
00158                 inputFileNameLabel.setBackground(c.darker());
00159                 composersInputFileNamePanel.add(inputFileNameLabel);
00160                 add(composersInputFileNamePanel);
00161 
00162         JPanel selectComposerContainer = new JPanel();
00163                 //BoxLayout bl = new BoxLayout(selectComposerContainer, BoxLayout.Y_AXIS);
00164                 //selectComposerContainer.setLayout(bl);
00165                 selectComposerContainer.add(new JLabel("select a composer: "));
00166         selectComposerContainer.setBackground(c);
00167         
00168         /*
00169                 TitledBorder ct = BorderFactory.createTitledBorder(
00170                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00171                         "Composers");
00172                 ct.setTitleJustification(TitledBorder.CENTER);
00173                 selectComposerContainer.setBorder(ct);
00174                 */
00175 
00176                 selectComposerPanel = new JPanel(new GridLayout(3, 4));
00177                 selectComposerPanel.setBackground(c);
00178 
00179                 ButtonGroup composerButtons = new ButtonGroup();
00180                 
00181                 controlsPanels.add(BuildSortComposerGUI(c, composerButtons));
00182                 controlsPanels.add(BuildNearestNeighborComposerGUI(c, composerButtons));
00183                 controlsPanels.add(BuildBlipComposerGUI(c, composerButtons));
00184                 controlsPanels.add(BuildMashupComposerGUI(c, composerButtons)); 
00185                 controlsPanels.add(BuildMeapaeMComposerGUI(c, composerButtons));        
00186                 controlsPanels.add(BuildIntraChunkShuffleComposerGUI(c, composerButtons));
00187                 controlsPanels.add(BuildHeadBangComposerGUI(c, composerButtons));
00188                 controlsPanels.add(BuildThresholdComposerGUI(c, composerButtons));
00189                 controlsPanels.add(BuildRotComposerGUI(c, composerButtons));
00190                 controlsPanels.add(BuildEDLComposerGUI(c, composerButtons));
00191                 controlsPanels.add(BuildVQComposerGUI(c, composerButtons));
00192                 controlsPanels.add(BuildHMMComposerGUI(c, composerButtons));
00193                 controlsPanels.add(BuildShoobyComposerGUI(c, composerButtons));
00194 
00195                 selectComposerContainer.add(selectComposerPanel);
00196         add(selectComposerContainer);
00197         
00198                 controlsPanel = new JPanel();
00199                 controlsPanel.setBackground(c);
00200 
00201                 controlsPanel.add((JPanel)controlsPanels.elementAt(0));
00202 
00203                 selectedComposer = "SortComposer";
00204                 
00205                 add(controlsPanel);             
00206 
00207         JPanel chunkPanel = new JPanel();
00208         chunkPanel.setLayout(new BoxLayout(chunkPanel, BoxLayout.Y_AXIS));
00209                 chunkPanel.setBackground(c);
00210         TitledBorder title = BorderFactory.createTitledBorder(
00211             BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00212             "Universal Chunk Operations");
00213         title.setTitleJustification(TitledBorder.CENTER);
00214         chunkPanel.setBorder(title);
00215         
00216         JPanel chunkCommandPanel = new JPanel();
00217                 chunkCommandPanel.setBackground(c);
00218                 
00219         reverseChunks = new JCheckBox("reverse");
00220         reverseChunks.setBackground(c);
00221                 reverseChunks.setToolTipText("Reverse audio in each chunk");
00222         chunkCommandPanel.add(reverseChunks);
00223         
00224                 addGainChunks = new JCheckBox("apply gain value");
00225                 addGainChunks.setBackground(c);
00226                 addGainChunks.setToolTipText("Apply gain value to each chunk");
00227                 addGainChunks.addActionListener(this);
00228                 addGainChunks.setActionCommand("gain");
00229                 chunkCommandPanel.add(addGainChunks);
00230 
00231                 fadeInOutChunks = new JCheckBox("apply fade in/out");
00232                 fadeInOutChunks.addActionListener(this);
00233         fadeInOutChunks.setBackground(c);
00234                 fadeInOutChunks.setToolTipText("Fade in/out on each chunk of audio");
00235         fadeInOutChunks.setActionCommand("fade");
00236         chunkCommandPanel.add(fadeInOutChunks);
00237         crossfadeChunks = new JCheckBox("crossfade");
00238                 crossfadeChunks.addActionListener(this);
00239         crossfadeChunks.setBackground(c);
00240                 crossfadeChunks.setToolTipText("Overlap fades from chunk to chunk");
00241         crossfadeChunks.setActionCommand("fade");
00242         chunkCommandPanel.add(crossfadeChunks);
00243         
00244         chunkPanel.add(chunkCommandPanel);
00245 
00246         chunkPanel.add(Box.createRigidArea(new Dimension(0, 10)));
00247         
00248         JPanel gainPanel = new JPanel();
00249         //gainPanel.setLayout(new BoxLayout(gainPanel, BoxLayout.X_AXIS));
00250         gainPanel.setBackground(c);
00251         JLabel gainLabel = new JLabel("gain value: ");
00252         gainPanel.add(gainLabel);
00253         gainValueField = new JTextField("1.0");
00254         gainValueField.setEnabled(false);
00255         gainPanel.add(gainValueField);
00256         
00257         chunkPanel.add(gainPanel);
00258         
00259         JPanel crossfadePanel = new JPanel();
00260         //crossfadePanel.setLayout(new BoxLayout(crossfadePanel, BoxLayout.X_AXIS));
00261         crossfadePanel.setBackground(c);
00262                 JLabel crossfadeLabel = new JLabel("fade length (ms): ");
00263         crossfadePanel.add(crossfadeLabel);
00264         fadeDurationSlider = new JSlider(JSlider.HORIZONTAL, 0, 50, 0);
00265                 fadeDurationSlider.setBackground(c);
00266                 fadeDurationSlider.setToolTipText("Duration of fades");
00267                 fadeDurationSlider.setValue(10);
00268                 fadeDurationSlider.setEnabled(false);
00269                 fadeDurationSlider.setPaintLabels(true);
00270                 fadeDurationSlider.setMajorTickSpacing(10);
00271                 fadeDurationSlider.setMinorTickSpacing(2);
00272                 fadeDurationSlider.setPaintTicks(true);
00273         crossfadePanel.add(fadeDurationSlider);
00274         
00275         chunkPanel.add(crossfadePanel);
00276         
00277                 //JLabel uCPLabel = new JLabel("UCOs apply to all chunks in a file");
00278                 //chunkPanel.add(uCPLabel);
00279 
00280                 add(chunkPanel);
00281 
00282                 JPanel composersOutputFileNamePanel = new JPanel();
00283                 composersOutputFileNamePanel.setBackground(c);
00284                 JLabel cONL = new JLabel("output edl file: ");
00285                 composersOutputFileNamePanel.add(cONL);
00286                 outputFileNameLabel = new JLabel(" " + dataBaseName + ".edl ");
00287                 outputFileNameLabel.setOpaque(true);
00288                 outputFileNameLabel.setBackground(c.darker());
00289                 composersOutputFileNamePanel.add(outputFileNameLabel);
00290         add(Box.createRigidArea(new Dimension(0, 10)));
00291         add(composersOutputFileNamePanel);
00292 
00293                 JPanel displayComposerFeaturesPanel = new JPanel();
00294                 displayComposerFeaturesPanel.setBackground(c);
00295                 displayComposerFeaturesButton = new JButton("display composed features");
00296                 displayComposerFeaturesButton.setEnabled(false);
00297                 displayComposerFeaturesButton.addActionListener(this);
00298                 displayComposerFeaturesButton.setActionCommand("displayComposerFeatures");
00299                 displayComposerFeaturesButton.setBackground(c);
00300                 displayComposerFeaturesPanel.add(displayComposerFeaturesButton);
00301                 
00302                 add(displayComposerFeaturesPanel);
00303                 
00304                 //mainGuiPanel.add(composersPanel);
00305         }
00306         
00307         private JPanel BuildSortComposerGUI(Color c, ButtonGroup composerButtons)
00308         {               
00309                 //sort composer
00310                 JPanel sortComposerPanel = new JPanel();
00311                 BoxLayout bl = new BoxLayout(sortComposerPanel, BoxLayout.Y_AXIS);
00312                 sortComposerPanel.setLayout(bl);
00313 
00314                 enableSortComposerButton = new JRadioButton("simple sort");
00315                 enableSortComposerButton.setBackground(c);
00316                 composerButtons.add(enableSortComposerButton);
00317                 enableSortComposerButton.setSelected(true);
00318                 enableSortComposerButton.addActionListener(this);
00319                 //set the action command to the name of the composer class!
00320                 enableSortComposerButton.setActionCommand("SortComposer");
00321                 selectComposerPanel.add(enableSortComposerButton);
00322                 
00323                 JTextArea description = new JTextArea(SortComposer.description);
00324                 description.setColumns(50);
00325                 description.setLineWrap(true);
00326                 description.setWrapStyleWord(true);
00327                 description.setBackground(c);
00328                 description.setEditable(false);
00329                 sortComposerPanel.add(description);
00330                 
00331                 JPanel controlsPanel = new JPanel();
00332                 controlsPanel.setBackground(c);
00333                 TitledBorder title = BorderFactory.createTitledBorder(
00334                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00335                         "SimpleSort Controls");
00336                 title.setTitleJustification(TitledBorder.CENTER);
00337                 controlsPanel.setBorder(title);
00338                 
00339                 ButtonGroup sortButtonGroup = new ButtonGroup();
00340                 lowHighSortButton = new JRadioButton("low to high");
00341                 lowHighSortButton.setBackground(c);
00342                 sortButtonGroup.add(lowHighSortButton);
00343                 highLowSortButton = new JRadioButton("high to low");
00344                 highLowSortButton.setBackground(c);
00345                 sortButtonGroup.add(highLowSortButton);         
00346                 
00347                 controlsPanel.add(lowHighSortButton);
00348                 controlsPanel.add(highLowSortButton);
00349                 
00350                 highLowSortButton.setSelected(true);
00351                 
00352         normalizeFeatCB = new JCheckBox("normalize features");
00353         normalizeFeatCB.setBackground(c);
00354         normalizeFeatCB.setSelected(true);
00355         controlsPanel.add(normalizeFeatCB);
00356 
00357                 sortComposerPanel.add(controlsPanel);
00358                 
00359                 return sortComposerPanel;
00360         }
00361         
00362         private JPanel BuildNearestNeighborComposerGUI(Color c, ButtonGroup composerButtons)
00363         {
00364                 //nearest neighbor composer
00365                 JPanel nNComposerPanel = new JPanel();
00366                 nNComposerPanel.setBackground(c);
00367                 enableNNComposerButton = new JRadioButton("nearest neighbor");
00368                 enableNNComposerButton.setBackground(c);
00369                 composerButtons.add(enableNNComposerButton);
00370                 enableNNComposerButton.setSelected(false);
00371                 enableNNComposerButton.addActionListener(this);
00372                 //set the action command to the name of the composer class!
00373                 enableNNComposerButton.setActionCommand("NNComposer");
00374                 selectComposerPanel.add(enableNNComposerButton);
00375                 
00376                 JTextArea description = new JTextArea(NNComposer.description);
00377                 description.setColumns(50);
00378                 description.setLineWrap(true);
00379                 description.setWrapStyleWord(true);
00380                 description.setBackground(c);
00381                 description.setEditable(false);
00382                 nNComposerPanel.add(description);
00383                 
00384                 
00385                 return nNComposerPanel;
00386         }
00387         
00388         private JPanel BuildBlipComposerGUI(Color c, ButtonGroup composerButtons)
00389         {
00390                 // blip composer
00391                 JPanel bLComposerPanel = new JPanel();
00392                 bLComposerPanel.setBackground(c);
00393                 enableBLComposerButton = new JRadioButton("add blips");
00394                 enableBLComposerButton.setBackground(c);
00395                 composerButtons.add(enableBLComposerButton);
00396                 enableBLComposerButton.setSelected(false);
00397                 enableBLComposerButton.addActionListener(this);
00398                 //set the action command to the name of the composer class!
00399                 enableBLComposerButton.setActionCommand("BlipComposer");
00400                 selectComposerPanel.add(enableBLComposerButton);
00401                 
00402                 JTextArea description = new JTextArea(BlipComposer.description);
00403                 description.setColumns(50);
00404                 description.setLineWrap(true);
00405                 description.setWrapStyleWord(true);
00406                 description.setBackground(c);
00407                 description.setEditable(false);
00408                 bLComposerPanel.add(description);
00409                 
00410                 return bLComposerPanel;
00411         }
00412 
00413     private JPanel BuildMashupComposerGUI(Color c, ButtonGroup composerButtons)
00414     {
00415         //mashup composer
00416         JPanel mUComposerPanel = new JPanel();
00417         BoxLayout bl = new BoxLayout(mUComposerPanel, BoxLayout.Y_AXIS);
00418         mUComposerPanel.setLayout(bl);
00419         mUComposerPanel.setBackground(c);
00420         enableMUComposerButton = new JRadioButton("mashup!");
00421         enableMUComposerButton.setBackground(c);
00422         composerButtons.add(enableMUComposerButton);
00423         enableMUComposerButton.setSelected(false);
00424         enableMUComposerButton.addActionListener(this);
00425         //set the action command to the name of the composer
00426         //class!
00427         enableMUComposerButton.setActionCommand("MashupComposer");
00428         selectComposerPanel.add(enableMUComposerButton);
00429         
00430         JTextArea description = new JTextArea(MashupComposer.description);
00431         description.setColumns(50);
00432         description.setLineWrap(true);
00433         description.setWrapStyleWord(true);
00434         description.setBackground(c);
00435         description.setEditable(false);
00436         mUComposerPanel.add(description);
00437         
00438         JPanel controlsPanel = new JPanel();
00439         controlsPanel.setBackground(c);
00440         TitledBorder title = BorderFactory.createTitledBorder(
00441             BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
00442             "Mashup Controls");
00443         title.setTitleJustification(TitledBorder.CENTER);
00444         controlsPanel.setBorder(title);
00445         
00446         JLabel mULabel = new JLabel("chunk database features file:");
00447         controlsPanel.add(mULabel);
00448         mashupChunkDBFileField = new JTextField("chunk database .feat file");
00449         mashupChunkDBFileField.setColumns(20);
00450         mashupChunkDBFileField.addActionListener(this);
00451         mashupChunkDBFileField.setActionCommand("setMUChunkDBFeaturesFile");
00452         //mashupChunkDBFileField.setEditable(false);
00453         controlsPanel.add(mashupChunkDBFileField);
00454         JButton mUBrowseButton = new JButton("browse");
00455         mUBrowseButton.setBackground(c);
00456         mUBrowseButton.addActionListener(this);
00457         mUBrowseButton.setActionCommand("browseMUChunkDBFeaturesFile");
00458         controlsPanel.add(mUBrowseButton);
00459         
00460         mUComposerPanel.add(controlsPanel);
00461         
00462         //selectComposerPanel.add(mUComposerPanel);
00463         return mUComposerPanel;
00464     }
00465     
00466     private JPanel BuildMeapaeMComposerGUI(Color c, ButtonGroup composerButtons)
00467     {
00468         // MeapaeM composer
00469         JPanel MeapaeMComposerPanel = new JPanel();
00470         MeapaeMComposerPanel.setBackground(c);
00471         enableMMComposerButton = new JRadioButton("MeapaeM");
00472         enableMMComposerButton.setBackground(c);
00473         composerButtons.add(enableMMComposerButton);
00474         enableMMComposerButton.setSelected(false);
00475         enableMMComposerButton.addActionListener(this);
00476         //set the action command to the name of the composer
00477         //class!
00478         enableMMComposerButton.setActionCommand("MeapaeMComposer");
00479         selectComposerPanel.add(enableMMComposerButton);
00480         
00481         JTextArea description = new JTextArea(MeapaeMComposer.description);
00482         description.setColumns(50);
00483         description.setLineWrap(true);
00484         description.setWrapStyleWord(true);
00485         description.setBackground(c);
00486         description.setEditable(false);
00487         MeapaeMComposerPanel.add(description);
00488         
00489         return MeapaeMComposerPanel;
00490     }
00491     
00492     private JPanel BuildIntraChunkShuffleComposerGUI(Color c, ButtonGroup composerButtons)
00493     {
00494         // IntraChunkShuffle composer
00495         JPanel IntraChunkShuffleComposerPanel = new JPanel();
00496         IntraChunkShuffleComposerPanel.setBackground(c);
00497         BoxLayout bl = new BoxLayout(IntraChunkShuffleComposerPanel, BoxLayout.Y_AXIS);
00498         IntraChunkShuffleComposerPanel.setLayout(bl);
00499         enableICSComposerButton = new JRadioButton("IntraChunkShuffle");
00500         enableICSComposerButton.setBackground(c);
00501         composerButtons.add(enableICSComposerButton);
00502         enableICSComposerButton.setSelected(false);
00503         enableICSComposerButton.addActionListener(this);
00504         //set the action command to the name of the composer
00505         //class!
00506         enableICSComposerButton.setActionCommand("IntraChunkShuffleComposer");
00507         selectComposerPanel.add(enableICSComposerButton);
00508 
00509         JTextArea description = new JTextArea(IntraChunkShuffleComposer.description);
00510         description.setColumns(50);
00511         description.setLineWrap(true);
00512         description.setWrapStyleWord(true);
00513         description.setBackground(c);
00514         description.setEditable(false);
00515         IntraChunkShuffleComposerPanel.add(description);
00516         
00517         JPanel controlsPanel = new JPanel();
00518         controlsPanel.setBackground(c);
00519         TitledBorder title = BorderFactory.createTitledBorder(
00520             BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
00521             "IntraChunkShuffle Controls");
00522         title.setTitleJustification(TitledBorder.CENTER);
00523         controlsPanel.setBorder(title);
00524         
00525         JLabel iCSLabel = new JLabel("number of sub chunks:");
00526         controlsPanel.add(iCSLabel);
00527         intraChunkShuffleNumChunksField = new JTextField("4");
00528         controlsPanel.add(intraChunkShuffleNumChunksField);
00529         
00530         IntraChunkShuffleComposerPanel.add(controlsPanel);
00531         
00532         return IntraChunkShuffleComposerPanel;
00533     }
00534 
00535     private JPanel BuildHeadBangComposerGUI(Color c, ButtonGroup composerButtons)
00536     {
00537         //Headbang composer
00538         JPanel hBComposerPanel = new JPanel();
00539         BoxLayout bl = new BoxLayout(hBComposerPanel, BoxLayout.Y_AXIS);
00540         hBComposerPanel.setLayout(bl);
00541         hBComposerPanel.setBackground(c);
00542         enableHBComposerButton = new JRadioButton("head bang");
00543         enableHBComposerButton.setBackground(c);
00544         composerButtons.add(enableHBComposerButton);
00545         enableHBComposerButton.setSelected(false);
00546         enableHBComposerButton.addActionListener(this);
00547         //set the action command to the name of the composer
00548         //class!
00549         enableHBComposerButton.setActionCommand("HeadBangComposer");
00550         //composerRadioButtons.add(enableHBComposerButton);
00551         selectComposerPanel.add(enableHBComposerButton);
00552         
00553         JTextArea description = new JTextArea(HeadBangComposer.description);
00554         description.setColumns(50);
00555         description.setLineWrap(true);
00556         description.setWrapStyleWord(true);
00557         description.setBackground(c);
00558         description.setEditable(false);
00559         hBComposerPanel.add(description);
00560         
00561         JPanel hBControlPanel = new JPanel();
00562         hBControlPanel.setBackground(c);
00563         TitledBorder title = BorderFactory.createTitledBorder(
00564             BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
00565             "HeadBang Controls");
00566         title.setTitleJustification(TitledBorder.CENTER);
00567         hBControlPanel.setBorder(title);
00568         BoxLayout blInside = new BoxLayout(hBControlPanel, BoxLayout.Y_AXIS);
00569         hBControlPanel.setLayout(blInside);
00570         
00571         //panel for setting the resolution of the length bins.
00572         JPanel chunkResolutionPanel = new JPanel();
00573         chunkResolutionPanel.setBackground(c);
00574         JLabel hBLabel = new JLabel("         chunk length resolution:");
00575         chunkResolutionPanel.add(hBLabel);
00576         headbangBinSlider = new JSlider(JSlider.HORIZONTAL, 100, 12000, 100);
00577         headbangBinSlider.setBackground(c);
00578         headbangBinSlider.setValue(5000);
00579         Hashtable labelTable = new Hashtable();
00580         labelTable.put( new Integer(100), new JLabel("low") );
00581         labelTable.put( new Integer(12000), new JLabel("high") );
00582         headbangBinSlider.setLabelTable( labelTable );
00583         headbangBinSlider.setPaintLabels(true);
00584         headbangBinSlider.setMajorTickSpacing(1000);
00585         headbangBinSlider.setPaintTicks(true);
00586         
00587         //panel for setting the length of the output piece.
00588         JPanel pieceLengthPanel = new JPanel();
00589         pieceLengthPanel.setBackground(c);
00590         JLabel hBLabel2 = new JLabel("length of output piece in number of chunks:");
00591         pieceLengthPanel.add(hBLabel2);
00592         headbangLengthSlider = new JSlider(JSlider.HORIZONTAL, 10, 1000, 100);
00593         headbangLengthSlider.setBackground(c);
00594         headbangLengthSlider.setValue(200);
00595         Hashtable labelTable2 = new Hashtable();
00596         labelTable2.put( new Integer(10), new JLabel("short") );
00597         labelTable2.put( new Integer(1000), new JLabel("long") );
00598         headbangLengthSlider.setLabelTable( labelTable2 );
00599         headbangLengthSlider.setPaintLabels(true);
00600         headbangLengthSlider.setMajorTickSpacing(100);
00601         headbangLengthSlider.setPaintTicks(true);
00602         
00603         pieceLengthPanel.add(headbangLengthSlider);
00604         
00605         hBControlPanel.add(pieceLengthPanel);
00606         
00607         hBComposerPanel.add(hBControlPanel);
00608         
00609         return hBComposerPanel;
00610     }
00611  
00612         private JPanel BuildThresholdComposerGUI(Color c, ButtonGroup composerButtons)
00613         {
00614                 // Threshold composer
00615                 JPanel thresholdComposerPanel = new JPanel();
00616                 thresholdComposerPanel.setBackground(c);
00617                 BoxLayout bl = new BoxLayout(thresholdComposerPanel, BoxLayout.Y_AXIS);
00618                 thresholdComposerPanel.setLayout(bl);
00619                 enableThresholdComposerButton = new JRadioButton("ThresholdComposer");
00620                 enableThresholdComposerButton.setBackground(c);
00621                 composerButtons.add(enableThresholdComposerButton);
00622                 enableThresholdComposerButton.setSelected(false);
00623                 enableThresholdComposerButton.addActionListener(this);
00624                 //set the action command to the name of the composer
00625                 //class!
00626                 enableThresholdComposerButton.setActionCommand("ThresholdComposer");
00627                 selectComposerPanel.add(enableThresholdComposerButton);
00628 
00629                 JTextArea description = new JTextArea(ThresholdComposer.description);
00630                 description.setColumns(50);
00631                 description.setLineWrap(true);
00632                 description.setWrapStyleWord(true);
00633                 description.setBackground(c);
00634                 description.setEditable(false);
00635                 thresholdComposerPanel.add(description);
00636         
00637                 JPanel controlsPanel = new JPanel();
00638                 controlsPanel.setBackground(c);
00639                 TitledBorder title = BorderFactory.createTitledBorder(
00640                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
00641                         "Threshold Composer Controls");
00642                 title.setTitleJustification(TitledBorder.CENTER);
00643                 controlsPanel.setBorder(title);
00644         
00645                 JLabel bottomLabel = new JLabel("bottom threshold:");
00646                 controlsPanel.add(bottomLabel);
00647                 thresholdBottomField = new JTextField("1.0");
00648                 controlsPanel.add(thresholdBottomField);
00649                 
00650                 JLabel topLabel = new JLabel("top threshold:");
00651                 controlsPanel.add(topLabel);
00652                 thresholdTopField = new JTextField("10.0");
00653                 controlsPanel.add(thresholdTopField);
00654         
00655         JPanel chunkSelectionPanel = new JPanel();
00656         chunkSelectionPanel.setBackground(c);
00657                 BoxLayout cSPL = new BoxLayout(chunkSelectionPanel, BoxLayout.Y_AXIS);
00658                 chunkSelectionPanel.setLayout(cSPL);
00659         
00660         ButtonGroup thresholdGroup = new ButtonGroup();
00661         
00662         JLabel chunksLabel = new JLabel("use only chunks: ");
00663                 chunkSelectionPanel.add(chunksLabel);
00664                 insideThresholdButton = new JRadioButton("inside thresholds");
00665                 insideThresholdButton.setBackground(c);
00666                 thresholdGroup.add(insideThresholdButton);
00667                 chunkSelectionPanel.add(insideThresholdButton);
00668                 outsideThresholdButton = new JRadioButton("outside thresholds");
00669                 outsideThresholdButton.setBackground(c);
00670                 thresholdGroup.add(outsideThresholdButton);
00671                 insideThresholdButton.setSelected(true);
00672                 
00673                 chunkSelectionPanel.add(outsideThresholdButton);
00674                 controlsPanel.add(chunkSelectionPanel);
00675                 thresholdComposerPanel.add(controlsPanel);
00676         
00677                 return thresholdComposerPanel;
00678         }
00679 
00680         private JPanel BuildRotComposerGUI(Color c, ButtonGroup composerButtons)
00681         {
00682                 // Rot composer
00683                 JPanel rotComposerPanel = new JPanel();
00684                 rotComposerPanel.setBackground(c);
00685                 BoxLayout bl = new BoxLayout(rotComposerPanel, BoxLayout.Y_AXIS);
00686                 rotComposerPanel.setLayout(bl);
00687                 enableRotComposerButton = new JRadioButton("Rot");
00688                 enableRotComposerButton.setBackground(c);
00689                 composerButtons.add(enableRotComposerButton);
00690                 enableRotComposerButton.setSelected(false);
00691                 enableRotComposerButton.addActionListener(this);
00692                 //set the action command to the name of the composer
00693                 //class!
00694                 enableRotComposerButton.setActionCommand("RotComposer");
00695                 selectComposerPanel.add(enableRotComposerButton);
00696 
00697                 JTextArea description = new JTextArea(RotComposer.description);
00698                 description.setColumns(50);
00699                 description.setLineWrap(true);
00700                 description.setWrapStyleWord(true);
00701                 description.setBackground(c);
00702                 description.setEditable(false);
00703                 rotComposerPanel.add(description);
00704         
00705                 JPanel controlsPanel = new JPanel();
00706                 controlsPanel.setBackground(c);
00707                 TitledBorder title = BorderFactory.createTitledBorder(
00708                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
00709                         "RotComposer Controls");
00710                 title.setTitleJustification(TitledBorder.CENTER);
00711                 controlsPanel.setBorder(title);
00712         
00713                 JLabel bpmLabel = new JLabel("beats per measure:");
00714                 controlsPanel.add(bpmLabel);
00715                 rotBeatsPerMeasureField = new JTextField("4");
00716                 controlsPanel.add(rotBeatsPerMeasureField);
00717                 
00718                 JLabel ptrLabel = new JLabel("beats to rotate:");
00719                 controlsPanel.add(ptrLabel);
00720                 rotNumPositionsField = new JTextField("1");
00721                 controlsPanel.add(rotNumPositionsField);
00722                 
00723                 ButtonGroup directionGroup = new ButtonGroup();
00724                 
00725                 rotLeftButton = new JRadioButton("rotate left");
00726                 rotLeftButton.setBackground(c);
00727                 directionGroup.add(rotLeftButton);
00728                 rotRightButton = new JRadioButton("rotate right");
00729                 rotRightButton.setBackground(c);
00730                 directionGroup.add(rotRightButton);
00731                 rotRightButton.setSelected(true);
00732 
00733                 controlsPanel.add(rotLeftButton);
00734                 controlsPanel.add(rotRightButton);
00735                 
00736                 rotComposerPanel.add(controlsPanel);
00737                 
00738                 return rotComposerPanel;
00739         }
00740         
00741         private JPanel BuildEDLComposerGUI(Color c, ButtonGroup composerButtons)
00742         {               
00743                 JPanel eDLComposerPanel = new JPanel();
00744                 BoxLayout bl = new BoxLayout(eDLComposerPanel, BoxLayout.Y_AXIS);
00745                 eDLComposerPanel.setLayout(bl);
00746 
00747                 enableEDLComposerButton = new JRadioButton("EDL");
00748                 enableEDLComposerButton.setBackground(c);
00749                 composerButtons.add(enableEDLComposerButton);
00750                 enableEDLComposerButton.setSelected(false);
00751                 enableEDLComposerButton.addActionListener(this);
00752                 //set the action command to the name of the composer class!
00753                 enableEDLComposerButton.setActionCommand("EDLComposer");
00754                 selectComposerPanel.add(enableEDLComposerButton);
00755                 
00756                 JTextArea description = new JTextArea(EDLComposer.description);
00757                 description.setColumns(50);
00758                 description.setLineWrap(true);
00759                 description.setWrapStyleWord(true);
00760                 description.setBackground(c);
00761                 description.setEditable(false);
00762                 eDLComposerPanel.add(description);
00763 
00764                 JPanel controlsPanel = new JPanel();
00765                 controlsPanel.setBackground(c);
00766                 TitledBorder title = BorderFactory.createTitledBorder(
00767                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00768                         "EDL Controls");
00769                 title.setTitleJustification(TitledBorder.CENTER);
00770                 controlsPanel.setBorder(title);
00771                 
00772                 JLabel edlComposerLabel = new JLabel("input EDL file:");
00773                 controlsPanel.add(edlComposerLabel);
00774                 inputEDLFileField = new JTextField("input .edl file");
00775                 inputEDLFileField.setColumns(20);
00776                 inputEDLFileField.addActionListener(this);
00777                 inputEDLFileField.setActionCommand("setInputEDLFile");
00778                 controlsPanel.add(inputEDLFileField);
00779                 JButton iEDLBrowseButton = new JButton("browse");
00780                 iEDLBrowseButton.setBackground(c);
00781                 iEDLBrowseButton.addActionListener(this);
00782                 iEDLBrowseButton.setActionCommand("browseInputEDLFile");
00783                 controlsPanel.add(iEDLBrowseButton);
00784 
00785                 eDLComposerPanel.add(controlsPanel);
00786                 
00787                 return eDLComposerPanel;
00788         }
00789 
00790         private JPanel BuildVQComposerGUI(Color c, ButtonGroup composerButtons)
00791         {               
00792                 JPanel panel = new JPanel();
00793                 BoxLayout bl = new BoxLayout(panel, BoxLayout.Y_AXIS);
00794                 panel.setLayout(bl);
00795 
00796                 JRadioButton enableButton = new JRadioButton("VQ");
00797                 enableButton.setBackground(c);
00798                 composerButtons.add(enableButton);
00799                 enableButton.setSelected(false);
00800                 enableButton.addActionListener(this);
00801                 //set the action command to the name of the composer class!
00802                 enableButton.setActionCommand("VQComposer");
00803                 selectComposerPanel.add(enableButton);
00804                 
00805                 JTextArea description = new JTextArea(VQComposer.description);
00806                 description.setColumns(50);
00807                 description.setLineWrap(true);
00808                 description.setWrapStyleWord(true);
00809                 description.setBackground(c);
00810                 description.setEditable(false);
00811                 panel.add(description);
00812 
00813                 JPanel controlsPanel = new JPanel();
00814         bl = new BoxLayout(controlsPanel, BoxLayout.Y_AXIS);
00815                 controlsPanel.setLayout(bl);
00816                 controlsPanel.setBackground(c);
00817                 TitledBorder title = BorderFactory.createTitledBorder(
00818                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00819                         "VQ Controls");
00820                 title.setTitleJustification(TitledBorder.CENTER);
00821                 controlsPanel.setBorder(title);
00822                 
00823         JPanel p = new JPanel();
00824         p.setBackground(c);
00825                 p.add(new JLabel("number of codewords:"));
00826         vqNumCodewords = new JSlider(JSlider.HORIZONTAL, 0, 100, 50);
00827         vqNumCodewords.setBackground(c);
00828         vqNumCodewords.setPaintLabels(true);
00829         vqNumCodewords.setMajorTickSpacing(25);
00830         vqNumCodewords.setPaintTicks(true);             
00831                 p.add(vqNumCodewords);
00832                 controlsPanel.add(p);
00833 
00834         p = new JPanel();
00835         p.setBackground(c);
00836                 p.add(new JLabel("beats per codeword:"));
00837         vqBeatsPerCW = new JSlider(JSlider.HORIZONTAL, 0, 16, 1);
00838         vqBeatsPerCW.setBackground(c);
00839         vqBeatsPerCW.setPaintLabels(true);
00840         vqBeatsPerCW.setMajorTickSpacing(2);
00841         vqBeatsPerCW.setPaintTicks(true);               
00842                 p.add(vqBeatsPerCW);
00843                 controlsPanel.add(p);
00844 
00845         p = new JPanel();
00846         p.setBackground(c);
00847         vqQuantizeTrainingFile = new JCheckBox("quantize training file");
00848         vqQuantizeTrainingFile.setBackground(c);
00849         vqQuantizeTrainingFile.setActionCommand("vqQuantizeTrainingFile");
00850         vqQuantizeTrainingFile.addActionListener(this);
00851         p.add(vqQuantizeTrainingFile);
00852         controlsPanel.add(p);
00853 
00854         p = new JPanel();
00855         p.setBackground(c);
00856         p.add(new JLabel("features file to quantize:"));
00857         vqFeatFileField = new JTextField(".feat file");
00858         vqFeatFileField.setColumns(20);
00859         vqFeatFileField.addActionListener(this);
00860         vqFeatFileField.setActionCommand("setVQFeaturesFile");
00861         p.add(vqFeatFileField);
00862         vqBrowseButton = new JButton("browse");
00863         vqBrowseButton.setBackground(c);
00864         vqBrowseButton.addActionListener(this);
00865         vqBrowseButton.setActionCommand("browseVQFeaturesFile");
00866         p.add(vqBrowseButton);
00867         controlsPanel.add(p);
00868 
00869                 panel.add(controlsPanel);
00870                 
00871                 return panel;
00872         }
00873 
00874         private JPanel BuildHMMComposerGUI(Color c, ButtonGroup composerButtons)
00875         {               
00876                 JPanel panel = new JPanel();
00877                 BoxLayout bl = new BoxLayout(panel, BoxLayout.Y_AXIS);
00878                 panel.setLayout(bl);
00879 
00880                 JRadioButton enableButton = new JRadioButton("HMM");
00881                 enableButton.setBackground(c);
00882                 composerButtons.add(enableButton);
00883                 enableButton.setSelected(false);
00884                 enableButton.addActionListener(this);
00885                 //set the action command to the name of the composer class!
00886                 enableButton.setActionCommand("HMMComposer");
00887                 selectComposerPanel.add(enableButton);
00888                 
00889                 JTextArea description = new JTextArea(HMMComposer.description);
00890                 description.setColumns(50);
00891                 description.setLineWrap(true);
00892                 description.setWrapStyleWord(true);
00893                 description.setBackground(c);
00894                 description.setEditable(false);
00895                 panel.add(description);
00896 
00897                 JPanel controlsPanel = new JPanel();
00898         bl = new BoxLayout(controlsPanel, BoxLayout.Y_AXIS);
00899                 controlsPanel.setLayout(bl);
00900                 controlsPanel.setBackground(c);
00901                 TitledBorder title = BorderFactory.createTitledBorder(
00902                         BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), 
00903                         "HMM Controls");
00904                 title.setTitleJustification(TitledBorder.CENTER);
00905                 controlsPanel.setBorder(title);
00906                 
00907         JPanel p = new JPanel();
00908         p.setBackground(c);
00909                 p.add(new JLabel("number of states:"));
00910         hmmNumStates = new JSlider(JSlider.HORIZONTAL, 0, 100, 25);
00911         hmmNumStates.setBackground(c);
00912         hmmNumStates.setPaintLabels(true);
00913         hmmNumStates.setMajorTickSpacing(25);
00914         hmmNumStates.setPaintTicks(true);               
00915                 p.add(hmmNumStates);
00916                 controlsPanel.add(p);
00917 
00918         p = new JPanel();
00919         p.setBackground(c);
00920                 p.add(new JLabel("beats per state:"));
00921         hmmBeatsPerState = new JSlider(JSlider.HORIZONTAL, 0, 16, 4);
00922         hmmBeatsPerState.setBackground(c);
00923         hmmBeatsPerState.setPaintLabels(true);
00924         hmmBeatsPerState.setMajorTickSpacing(2);
00925         hmmBeatsPerState.setPaintTicks(true);           
00926                 p.add(hmmBeatsPerState);
00927                 controlsPanel.add(p);
00928 
00929         p = new JPanel();
00930         p.setBackground(c);
00931                 p.add(new JLabel("generated sequence length (chunks):"));
00932         hmmSequenceLength = new JSlider(JSlider.HORIZONTAL, 0, 200, 100);
00933         hmmSequenceLength.setBackground(c);
00934         hmmSequenceLength.setPaintLabels(true);
00935         hmmSequenceLength.setMajorTickSpacing(50);
00936         hmmSequenceLength.setPaintTicks(true);          
00937                 p.add(hmmSequenceLength);
00938                 controlsPanel.add(p);
00939 
00940                 panel.add(controlsPanel);
00941                 
00942                 return panel;
00943         }
00944 
00945         private JPanel BuildShoobyComposerGUI(Color c, ButtonGroup composerButtons)
00946         {
00947                 //nearest neighbor composer
00948                 JPanel shoobyComposerPanel = new JPanel();
00949                 BoxLayout bl = new BoxLayout(shoobyComposerPanel, BoxLayout.Y_AXIS);
00950         shoobyComposerPanel.setLayout(bl);
00951 
00952                 shoobyComposerPanel.setBackground(c);
00953                 enableShoobyComposerButton = new JRadioButton("Shooby Taylor");
00954                 enableShoobyComposerButton.setBackground(c);
00955                 composerButtons.add(enableShoobyComposerButton);
00956                 enableShoobyComposerButton.setSelected(false);
00957                 enableShoobyComposerButton.addActionListener(this);
00958                 //set the action command to the name of the composer class!
00959                 enableShoobyComposerButton.setActionCommand("ShoobyComposer");
00960                 selectComposerPanel.add(enableShoobyComposerButton);
00961                 
00962                 JTextArea description = new JTextArea(ShoobyComposer.description);
00963                 description.setColumns(50);
00964         description.setLineWrap(true);
00965         description.setWrapStyleWord(true);
00966         description.setBackground(c);
00967         description.setEditable(false);
00968                 shoobyComposerPanel.add(description);
00969                 
00970                 JPanel controlsPanel = new JPanel();
00971         controlsPanel.setBackground(c);
00972         TitledBorder title = BorderFactory.createTitledBorder(
00973             BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
00974             "Shooby Taylor 'Controls'");
00975         title.setTitleJustification(TitledBorder.CENTER);
00976         controlsPanel.setBorder(title);
00977                 
00978                 JLabel lengthLabel = new JLabel("output file length (secs):");
00979                 controlsPanel.add(lengthLabel);
00980                 shoobyFileLengthField = new JTextField("100");
00981                 controlsPanel.add(shoobyFileLengthField);
00982                 
00983                 JLabel clumpLabel = new JLabel("maximum clump size:");
00984                 controlsPanel.add(clumpLabel);
00985                 shoobyClumpWidthField = new JTextField("4");
00986                 controlsPanel.add(shoobyClumpWidthField);
00987                 
00988                 //panel for setting the Shoobyness.
00989                 JPanel pieceLengthPanel = new JPanel();
00990         JLabel intensityLabel = new JLabel("intensity of Shooby's scat:");
00991         pieceLengthPanel.add(intensityLabel);
00992         shoobyDrunkennessSlider = new JSlider(JSlider.HORIZONTAL, 10, 1000, 100);
00993         shoobyDrunkennessSlider.setBackground(c);
00994         shoobyDrunkennessSlider.setValue(200);
00995         Hashtable labelTable = new Hashtable();
00996         labelTable.put( new Integer(10), new JLabel("shwee") );
00997         labelTable.put( new Integer(1000), new JLabel("nd raaw pd paw") );
00998         shoobyDrunkennessSlider.setLabelTable( labelTable );
00999         shoobyDrunkennessSlider.setPaintLabels(true);
01000         shoobyDrunkennessSlider.setMajorTickSpacing(100);
01001         shoobyDrunkennessSlider.setPaintTicks(true);
01002         controlsPanel.add(shoobyDrunkennessSlider);
01003                 
01004         shoobyComposerPanel.add(controlsPanel);
01005         
01006                 return shoobyComposerPanel;
01007         }
01008 
01009         public void enableDisplayButton(boolean enable)
01010         {
01011                 displayComposerFeaturesButton.setEnabled(enable);               
01012         }
01013 
01014     private String[] browseFile(String extension)
01015     {
01016         String names[] = GUIUtils.FileSelector(GUIUtils.OPEN, dataDirectory, 
01017                                                meapsoftGUI.jframe);
01018 
01019         if(!names[1].endsWith(extension))
01020             GUIUtils.ShowDialog("Please select a ." + extension + " file!", 
01021                                 GUIUtils.MESSAGE, meapsoftGUI.jframe);   
01022         
01023         return names;
01024     }
01025 
01026     private String[] setFile(String name, String extenstion)
01027     {
01028         String fullPath = dataDirectory + slash + name;
01029 
01030         // does name contain a full path?
01031         if((new File(name)).isAbsolute())
01032             fullPath = name;
01033         
01034         String[] nameSplit = name.split("["+slash+"]");
01035         String shortPath = nameSplit[nameSplit.length-1];
01036         
01037         if(!fullPath.endsWith(extenstion))
01038             GUIUtils.ShowDialog("Please select a ." + extenstion + " file!", 
01039                                 GUIUtils.MESSAGE, meapsoftGUI.jframe);
01040 
01041         String[] names = {fullPath, shortPath};
01042 
01043         return names;
01044     }
01045 
01046         public void actionPerformed(ActionEvent arg0)
01047         {
01048                 String command = arg0.getActionCommand();
01049                 
01050                 if (command.equals("browseMUChunkDBFeaturesFile"))
01051                 {
01052                         String names[] = browseFile("feat");
01053                         chunkDBFeaturesNameFull = names[0];
01054                         chunkDBFeaturesNameShort = names[1];
01055             mashupChunkDBFileField.setText(chunkDBFeaturesNameShort);
01056                 }
01057                 else if (command.equals("setMUChunkDBFeaturesFile"))
01058                 {
01059             String[] names = setFile(mashupChunkDBFileField.getText(), "feat");
01060                         chunkDBFeaturesNameFull = names[0];
01061                         chunkDBFeaturesNameShort = names[1];
01062             //mashupChunkDBFileField.setText(chunkDBFeaturesNameShort);
01063                 }
01064                 else if (command.equals("browseInputEDLFile"))
01065                 {
01066                         String names[] = browseFile("edl");
01067                         inputEDLFileNameFull = names[0];
01068                         inputEDLFileNameShort = names[1];
01069                         
01070             dataBaseName = inputEDLFileNameShort.replaceAll(".edl", "");
01071             UpdateFileNames();
01072             outputEDLFileName = dataBaseName + ".out.edl";
01073             inputEDLFileName = outputEDLFileName;
01074             meapsoftGUI.UpdateInfoTexts();
01075             inputEDLFileField.setText(inputEDLFileNameShort);
01076                 }
01077                 else if (command.equals("setInputEDLFile"))
01078                 {
01079                         String[] names = setFile(inputEDLFileField.getText(), "edl");
01080                         inputEDLFileNameFull = names[0];
01081                         inputEDLFileNameShort = names[1];
01082 
01083             dataBaseName = inputEDLFileNameShort.replaceAll(".edl", "");
01084             UpdateFileNames();
01085             meapsoftGUI.UpdateInfoTexts();
01086             //inputEDLFileField.setText(inputEDLFileNameShort);
01087                 }
01088         else if (command.equals("SortComposer"))
01089                 {                       
01090                         //System.out.println("adding sort composer gui...");
01091                         selectedComposer = command;
01092                         controlsPanel.removeAll();
01093                         controlsPanel.add((JPanel)controlsPanels.elementAt(0));
01094                 }
01095                 else if (command.equals("NNComposer"))
01096                 {
01097                         //System.out.println("adding NN composer gui...");
01098                         selectedComposer = command;
01099                         controlsPanel.removeAll();
01100                         controlsPanel.add((JPanel)controlsPanels.elementAt(1));
01101                 }
01102                 else if (command.equals("BlipComposer"))
01103                 {
01104                         //System.out.println("adding blip composer gui...");
01105                         selectedComposer = command;
01106                         controlsPanel.removeAll();
01107                         controlsPanel.add((JPanel)controlsPanels.elementAt(2));
01108                 }
01109                 else if (command.equals("MashupComposer"))
01110                 {
01111                         //System.out.println("adding mashup composer gui...");
01112                         selectedComposer = command;
01113                         controlsPanel.removeAll();
01114                         controlsPanel.add((JPanel)controlsPanels.elementAt(3));
01115                 }
01116                 else if (command.equals("MeapaeMComposer"))
01117                 {
01118                         //System.out.println("adding MeapaeM composer gui...");
01119                         selectedComposer = command;
01120                         controlsPanel.removeAll();
01121                         controlsPanel.add((JPanel)controlsPanels.elementAt(4));
01122                 }
01123                 else if (command.equals("IntraChunkShuffleComposer"))
01124                 {
01125                         //System.out.println("adding IntraChunkShuffleComposer composer gui...");
01126                         selectedComposer = command;
01127                         controlsPanel.removeAll();
01128                         controlsPanel.add((JPanel)controlsPanels.elementAt(5));
01129                 }
01130                 else if (command.equals("HeadBangComposer"))
01131                 {
01132                         selectedComposer = command;
01133                         controlsPanel.removeAll();
01134                         controlsPanel.add((JPanel)controlsPanels.elementAt(6));
01135                 }
01136                 else if (command.equals("ThresholdComposer"))
01137                 {
01138                         selectedComposer = command;
01139                         controlsPanel.removeAll();
01140                         controlsPanel.add((JPanel)controlsPanels.elementAt(7));         
01141                 }
01142                 else if (command.equals("RotComposer"))
01143                 {
01144                         selectedComposer = command;
01145                         controlsPanel.removeAll();
01146                         controlsPanel.add((JPanel)controlsPanels.elementAt(8));
01147                 }
01148                 else if (command.equals("EDLComposer"))
01149                 {
01150                         selectedComposer = command;
01151                         controlsPanel.removeAll();
01152                         controlsPanel.add((JPanel)controlsPanels.elementAt(9));
01153                 }
01154                 else if (command.equals("VQComposer"))
01155                 {
01156                         selectedComposer = command;
01157                         controlsPanel.removeAll();
01158                         controlsPanel.add((JPanel)controlsPanels.elementAt(10));
01159                 }
01160                 else if (command.equals("HMMComposer"))
01161                 {
01162                         selectedComposer = command;
01163                         controlsPanel.removeAll();
01164                         controlsPanel.add((JPanel)controlsPanels.elementAt(11));
01165                 }
01166                 else if (command.equals("ShoobyComposer"))
01167                 {
01168                         //System.out.println("adding Shooby composer gui...");
01169                         selectedComposer = command;
01170                         controlsPanel.removeAll();
01171                         controlsPanel.add((JPanel)controlsPanels.elementAt(12));
01172                 }
01173                 else if (command.equals("fade"))
01174         {
01175             boolean enable = fadeInOutChunks.isSelected() 
01176                 || crossfadeChunks.isSelected();
01177             fadeDurationSlider.setEnabled(enable);
01178         }
01179         else if (command.equals("gain"))
01180         {
01181                         boolean enable = addGainChunks.isSelected();
01182                         gainValueField.setEnabled(enable);
01183         }
01184                 else if (command.equals("displayComposerFeatures"))
01185                 {
01186             DataDisplayPanel.spawnWindow(edlFile.getFeatures(), edlFile.filename);
01187                 }
01188                 else if (command.equals("displayComposedStructure"))
01189                 {               
01190                         Visualizer visualizer = new Visualizer(featFile, edlFile);
01191                 }
01192         else if (command.equals("browseVQFeaturesFile"))
01193                 {
01194                         String names[] = browseFile("feat");
01195                         vqFeaturesNameFull = names[0];
01196                         vqFeaturesNameShort = names[1];
01197             
01198             vqFeatFileField.setText(vqFeaturesNameShort);
01199                 }
01200                 else if (command.equals("setVQFeaturesFile"))
01201                 {
01202             String names[] = setFile(vqFeatFileField.getText(), "feat");
01203                         vqFeaturesNameFull = names[0];
01204                         vqFeaturesNameShort = names[1];
01205             //vqFeatFileField.setText(vqFeaturesNameShort);
01206                 }
01207         else if (command.equals("vqQuantizeTrainingFile"))
01208         {
01209             boolean b = !vqQuantizeTrainingFile.isSelected();
01210             vqFeatFileField.setEnabled(b);
01211             vqBrowseButton.setEnabled(b);
01212         }
01213 
01214                 invalidate();
01215                 validate();
01216                 RefreshGUI();
01217     }    
01218         
01219         public synchronized int run()
01220         {                       
01221         if(!enableBox.isSelected())
01222             return 0;
01223 
01224         Composer composer = null;
01225                 if (selectedComposer.equals("SortComposer"))
01226                 {
01227                         composer = new SortComposer(featFile, edlFile);
01228             ((SortComposer)composer).setReverseSort(highLowSortButton.isSelected());
01229             ((SortComposer)composer).setNormalizeFeatures(normalizeFeatCB.isSelected());
01230                 }
01231                 else if (selectedComposer.equals("NNComposer"))
01232                 {
01233                         composer = new NNComposer(featFile, edlFile);
01234                 }
01235                 else if (selectedComposer.equals("BlipComposer"))
01236                 {
01237                         composer = new BlipComposer(featFile, edlFile);
01238             ((BlipComposer)composer).setBlipWav(dataDirectory+slash+"blip.wav");
01239                 }
01240                 else if (selectedComposer.equals("MashupComposer"))
01241                 {
01242                         if (chunkDBFeaturesNameFull == null)
01243                         {
01244                                 GUIUtils.ShowDialog("MashupComposer: Please select a chunk database features file!", GUIUtils.MESSAGE, meapsoftGUI.jframe);
01245                                 return -1;
01246                         }
01247                         
01248                         edlFile = new EDLFile(dataDirectory + slash + dataBaseName + "_using_" + 
01249                                 chunkDBFeaturesNameShort + ".edl");
01250 
01251             FeatFile chunkDBFile = new FeatFile(chunkDBFeaturesNameFull);
01252             
01253                         if (!(new File(chunkDBFeaturesNameFull).exists()))
01254                         {
01255                                 GUIUtils.ShowDialog("MashupComposer: Please select a chunk database features file!", GUIUtils.MESSAGE, meapsoftGUI.jframe);
01256                                 return -1;
01257                         }
01258                                 
01259             composer = new MashupComposer(featFile, chunkDBFile, edlFile);
01260                 }
01261                 else if (selectedComposer.equals("MeapaeMComposer"))
01262                 {
01263                         composer = new MeapaeMComposer(featFile, edlFile);
01264                 }
01265                 else if (selectedComposer.equals("IntraChunkShuffleComposer"))
01266                 {
01267                         int numSubChunks = 4;
01268                         
01269                         try
01270                         {
01271                                 numSubChunks = new Integer(intraChunkShuffleNumChunksField.getText()).intValue();
01272                         }
01273                         catch (Exception e)
01274                         {
01275                                 GUIUtils.ShowDialog("The number of sub chunks must be >= 2.", GUIUtils.MESSAGE, meapsoftGUI.jframe);
01276                 return -1;
01277                         }
01278                         composer = new IntraChunkShuffleComposer(featFile, edlFile, numSubChunks);
01279                 }
01280                 else if (selectedComposer.equals("HeadBangComposer"))
01281                 {
01282                         composer = new HeadBangComposer(featFile, edlFile, headbangBinSlider.getValue(), headbangLengthSlider.getValue());
01283                 }
01284                 else if (selectedComposer.equals("ThresholdComposer"))
01285                 {
01286                         double top = new Double(thresholdTopField.getText()).doubleValue();
01287                         double bottom = new Double(thresholdBottomField.getText()).doubleValue();
01288                         composer = new ThresholdComposer(featFile, edlFile, top, bottom, insideThresholdButton.isSelected());
01289                 }
01290                 else if (selectedComposer.equals("RotComposer"))
01291                 {
01292                         int bpm = new Integer(rotBeatsPerMeasureField.getText()).intValue();
01293                         int positions = new Integer(rotNumPositionsField.getText()).intValue();
01294                         composer = new RotComposer(featFile, edlFile, bpm, positions, rotLeftButton.isSelected());
01295                 }
01296                 else if (selectedComposer.equals("EDLComposer"))
01297                 {
01298                         EDLFile input = new EDLFile(inputEDLFileNameFull);
01299                         composer = new EDLComposer(input, edlFile);
01300                 }
01301                 else if (selectedComposer.equals("VQComposer"))
01302                 {
01303                         composer = new VQComposer(featFile, edlFile);
01304 
01305             VQComposer vqc = (VQComposer)composer;
01306             vqc.setCodebookSize(vqNumCodewords.getValue());
01307             vqc.setBeatsPerCodeword(vqBeatsPerCW.getValue());
01308 
01309             if(vqFeaturesNameFull != null)
01310             {
01311                 if (!(new File(vqFeaturesNameFull).exists()))
01312                 {
01313                     GUIUtils.ShowDialog("VQComposer: Please select a valid feature file!", 
01314                                         GUIUtils.MESSAGE, meapsoftGUI.jframe);
01315                     return -1;
01316                 }
01317                 else
01318                     vqc.setFeatsToQuantize(new FeatFile(vqFeaturesNameFull));
01319             }
01320 
01321             if(vqQuantizeTrainingFile.isSelected())
01322                 vqc.setFeatsToQuantize(featFile);
01323                 }
01324                 else if (selectedComposer.equals("HMMComposer"))
01325                 {
01326                         composer = new HMMComposer(featFile, edlFile);
01327 
01328             ((HMMComposer)composer).setCodebookSize(
01329                 hmmNumStates.getValue());
01330 
01331             ((HMMComposer)composer).setBeatsPerCodeword(
01332                 hmmBeatsPerState.getValue());
01333 
01334             ((HMMComposer)composer).setSequenceLength(
01335                 hmmSequenceLength.getValue());
01336                 }
01337                 else if (selectedComposer.equals("ShoobyComposer"))
01338                 {
01339                         int outFileLength = new Integer(shoobyFileLengthField.getText()).intValue();
01340                         int maxClumpWidth = new Integer(shoobyClumpWidthField.getText()).intValue();
01341                         composer = new ShoobyComposer(featFile, edlFile, outFileLength, maxClumpWidth, shoobyDrunkennessSlider.getValue());
01342                 }
01343                 else
01344                 {
01345                         GUIUtils.ShowDialog("I don't recognize that composer!", GUIUtils.MESSAGE, meapsoftGUI.jframe);
01346                         return -1;
01347                 }
01348                 
01349         double crossfade = (double)fadeDurationSlider.getValue()/1000;
01350         if(fadeInOutChunks.isSelected() & crossfade > 0)
01351             composer.addCommand("fade("+crossfade+")");
01352         if(crossfadeChunks.isSelected() & crossfade > 0)
01353             composer.addCommand("crossfade("+crossfade+")");
01354         if(reverseChunks.isSelected())
01355             composer.addCommand("reverse");
01356         if(addGainChunks.isSelected())
01357         {
01358                 double gain = Double.parseDouble(gainValueField.getText());
01359                 
01360                 composer.addCommand("gain(" + gain + ")");
01361         }
01362 
01363         composer.writeMEAPFile = meapsoftGUI.writeMEAPFile;
01364         
01365         JPanel progressPanel = new JPanel();
01366         progressPanel.add(new JLabel("Composing: "));
01367         JProgressBar progressBar = new JProgressBar(composer.getProgress());
01368         progressBar.setStringPainted(true);
01369         progressPanel.add(progressBar);
01370         meapsoftGUI.setProgressPanel(progressPanel);
01371 
01372         try
01373         {
01374             composer.doComposer();
01375         }
01376         catch(Exception e)
01377         {
01378                         GUIUtils.ShowDialog(e, "Error running composer", GUIUtils.MESSAGE, meapsoftGUI.jframe);
01379             return -1;
01380         }
01381 
01382         //displayComposerFeaturesButton.setEnabled(true);
01383         enableDisplayButton(true);
01384         
01385         
01386         return 0;
01387     }
01388 }

Generated on Tue Feb 6 19:02:25 2007 for MEAPsoft by doxygen1.2.18