package com.meapsoft.applets;
import java.awt.FileDialog;
import java.awt.Frame;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import javax.sound.sampled.UnsupportedAudioFileException;
import com.meapsoft.EDLFile;
import com.meapsoft.FeatExtractor;
import com.meapsoft.FeatFile;
import com.meapsoft.ParserException;
import com.meapsoft.Segmenter;
import com.meapsoft.Synthesizer;
import com.meapsoft.featextractors.FeatureExtractor;
public class MEAPAppletUtils {
public MEAPAppletUtils()
{
}
public static String getAudioFile()
{
Frame parent = new Frame();
FileDialog fd = new FileDialog(parent, "Please choose a file:",
FileDialog.LOAD);
fd.setVisible(true);
String fullPath = fd.getDirectory() + fd.getFile();
if (fullPath == null)
{
// no file selected
System.out.println("nothing selected!");
}
else
{
// read the file
System.out.println("got file " + fullPath);
}
return fullPath;
}
public static FeatFile segment(String soundFileName, boolean beats)
{
String segFileName = soundFileName + ".seg";
Segmenter seg = new Segmenter(soundFileName, segFileName, 1.0, 0.1, beats, true);
try
{
seg.run();
return seg.getSegFile();
}
catch (Exception e)
{
System.out.println("uh oh...");
System.out.println(e.getMessage());
return null;
}
}
public static FeatFile getFeatures(FeatFile segsFile, String[] featureStrings)
{
Vector featureExtractors = new Vector();
for (int i = 0; i < featureStrings.length; i++)
{
try
{
FeatureExtractor fE = (FeatureExtractor)(Class.forName("com.meapsoft.featextractors." + featureStrings[i]).newInstance());
featureExtractors.add(fE);
}
catch (Exception e)
{
System.out.println("uh oh in getFeatures...");
System.out.println(e.getMessage());
}
}
FeatFile featsFile = new FeatFile(segsFile.filename + ".feat");
FeatExtractor extractor = new FeatExtractor(segsFile, featsFile, featureExtractors);
extractor.run();
return featsFile;
}
public static String compose(EDLFile edl, String outputSoundFileName)
{
Synthesizer synth = new Synthesizer(edl, outputSoundFileName);
synth.run();
return null;
}
}