net.beadsproject.beads.data
Class SampleManager

java.lang.Object
  extended by net.beadsproject.beads.data.SampleManager

public class SampleManager
extends java.lang.Object

SampleManager provides a static repository for Sample data and provides methods to organise samples into groups.


Constructor Summary
SampleManager()
           
 
Method Summary
static void destroyGroup(java.lang.String groupName)
          Removes the specified group, and removes all of the samples found in the group from the sample repository.
static FeatureSet featuresForSample(Sample sample)
          Gets the FeatureSet for a given Sample.
static Sample fromGroup(java.lang.String groupName, int index)
          Gets the Sample at the specified index from the specified group.
static java.util.ArrayList<Sample> getGroup(java.lang.String groupName)
          Gets the specified group in the form ArrayList<Sample>.
static java.util.List<java.lang.String> getSampleNameList()
          Returns an ArrayList containing all of the Sample names.
static void group(java.lang.String groupName, Sample[] sampleList)
          Generates a new group with the given group name and list of Samples to be added to the group.
static void group(java.lang.String groupName, java.lang.String folderName)
          Generates a new group with the given group name and a string that specifies where to load samples to be added to the group.
static void group(java.lang.String groupName, java.lang.String[] fileNameList)
          Generates a new group with the given group name and a list of file names to be added to the group.
static java.util.Set<java.lang.String> groups()
          Gets the set of group names.
static boolean isVerbose()
          Determines if SampleManager is being verbose.
static void printSampleList()
          Prints a list of all Samples to System.out.
static Sample randomFromGroup(java.lang.String groupName)
          Gets a random sample from the specified group.
static void removeGroup(java.lang.String groupName)
          Removes the specified group, without removing the samples.
static void removeSample(Sample sample)
          Removes the Sample.
static void removeSample(java.lang.String sampleName)
          Removes the named Sample.
static Sample sample(java.lang.String fn)
          Returns a new Sample from the given filename.
static void sample(java.lang.String name, Sample sample)
          Adds a sample by name to the sample list.
static Sample sample(java.lang.String ref, java.lang.String fn)
          Like sample(String) but with the option to specify the name with which this Sample is indexed.
static void setBufferingRegime(Sample.Regime r)
          Set the buffering regime to use when loading all future samples.
static void setVerbose(boolean verbose)
          Tells SampleManager to produce verbose output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SampleManager

public SampleManager()
Method Detail

sample

public static Sample sample(java.lang.String fn)
Returns a new Sample from the given filename. If the Sample has already been loaded, it will not be loaded again, but will simply be retrieved from the static repository.

Parameters:
fn - the file path.
Returns:
the sample.

sample

public static void sample(java.lang.String name,
                          Sample sample)
Adds a sample by name to the sample list. This lets you load samples with a different buffering regime.

Parameters:
name -
sample -

sample

public static Sample sample(java.lang.String ref,
                            java.lang.String fn)
                     throws javax.sound.sampled.UnsupportedAudioFileException,
                            java.io.IOException
Like sample(String) but with the option to specify the name with which this Sample is indexed.

Parameters:
ref - the name with which to index this Sample.
fn - the file path.
Returns:
the sample.
Throws:
java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException

group

public static void group(java.lang.String groupName,
                         Sample[] sampleList)
Generates a new group with the given group name and list of Samples to be added to the group.

Parameters:
groupName - the group name.
sampleList - the sample list.

group

public static void group(java.lang.String groupName,
                         java.lang.String folderName)
Generates a new group with the given group name and a string that specifies where to load samples to be added to the group. The string is interpreted firstly as a URL, and if that fails, as a folder path.

Parameters:
groupName - the group name.
folderName - the folder address (URL or file path).

group

public static void group(java.lang.String groupName,
                         java.lang.String[] fileNameList)
Generates a new group with the given group name and a list of file names to be added to the group.

Parameters:
groupName - the group name.
fileNameList - the file name list.

groups

public static java.util.Set<java.lang.String> groups()
Gets the set of group names.

Returns:
Set of Strings representing group names.

getGroup

public static java.util.ArrayList<Sample> getGroup(java.lang.String groupName)
Gets the specified group in the form ArrayList<Sample>.

Parameters:
groupName - the group name.
Returns:
the group.

randomFromGroup

public static Sample randomFromGroup(java.lang.String groupName)
Gets a random sample from the specified group.

Parameters:
groupName - the group.
Returns:
a random Sample.

fromGroup

public static Sample fromGroup(java.lang.String groupName,
                               int index)
Gets the Sample at the specified index from the specified group. If index is greater than the size of the group then the value index % sizeOfGroup is used.

Parameters:
groupName - the group name.
index - the index.
Returns:
the Sample.

removeSample

public static void removeSample(java.lang.String sampleName)
Removes the named Sample.

Parameters:
sampleName - the sample name.

removeSample

public static void removeSample(Sample sample)
Removes the Sample.

Parameters:
sample - the Sample.

removeGroup

public static void removeGroup(java.lang.String groupName)
Removes the specified group, without removing the samples.

Parameters:
groupName - the group name.

destroyGroup

public static void destroyGroup(java.lang.String groupName)
Removes the specified group, and removes all of the samples found in the group from the sample repository.

Parameters:
groupName - the group name.

printSampleList

public static void printSampleList()
Prints a list of all Samples to System.out.


getSampleNameList

public static java.util.List<java.lang.String> getSampleNameList()
Returns an ArrayList containing all of the Sample names.

Returns:
ArrayList of Sample names.

setBufferingRegime

public static void setBufferingRegime(Sample.Regime r)
Set the buffering regime to use when loading all future samples. By default the regime is null, and reverts to the default regime used in Sample (which is TOTAL).

Parameters:
r - The regime.

isVerbose

public static boolean isVerbose()
Determines if SampleManager is being verbose.

Returns:
true if verbose.

setVerbose

public static void setVerbose(boolean verbose)
Tells SampleManager to produce verbose output.

Parameters:
verbose - true for verbose output.

featuresForSample

public static FeatureSet featuresForSample(Sample sample)
Gets the FeatureSet for a given Sample. The method first checks to see if the FeatureSet is already stored in memory. If not it looks for a file with the same file name as the Sample (including the file type), but with the suffix ".features". Once loaded, the FeatureSet is stored in memory.

Parameters:
sample - the Sample to search for features of.
Returns:
the FeatureSet.