FileDocCategorySizeDatePackage
Sequence.javaAPI DocAndroid 1.5 API4590Wed May 06 22:41:02 BST 2009javax.sound.midi

Sequence

public class Sequence extends Object

Fields Summary
public static final float
PPQ
public static final float
SMPTE_24
public static final float
SMPTE_25
public static final float
SMPTE_30
public static final float
SMPTE_30DROP
protected float
divisionType
protected int
resolution
protected Vector
tracks
private Vector
patches
Constructors Summary
public Sequence(float divisionType, int resolution)


           
        if (divisionType != Sequence.PPQ &&
                divisionType != Sequence.SMPTE_24 &&
                divisionType != Sequence.SMPTE_25 &&
                divisionType != Sequence.SMPTE_30 &&
                divisionType != Sequence.SMPTE_30DROP ) {
            // sound.0B=Unsupported division type: {0}
            throw new InvalidMidiDataException(Messages.getString("sound.0B", divisionType));       //$NON-NLS-1$
        }
        this.divisionType = divisionType;
        this.resolution = resolution;
        this.tracks = new Vector<Track>();
        this.patches = new Vector<Patch>();
        
    
public Sequence(float divisionType, int resolution, int numTracks)

        if (divisionType != Sequence.PPQ &&
                divisionType != Sequence.SMPTE_24 &&
                divisionType != Sequence.SMPTE_25 &&
                divisionType != Sequence.SMPTE_30 &&
                divisionType != Sequence.SMPTE_30DROP ) {
            // sound.0B=Unsupported division type: {0}
            throw new InvalidMidiDataException(Messages.getString("sound.0B", divisionType));       //$NON-NLS-1$
        }
        this.divisionType = divisionType;
        this.resolution = resolution;
        this.patches = new Vector<Patch>();
        this.tracks = new Vector<Track>();
        if (numTracks > 0) {
            for (int i = 0; i < numTracks; i++) {
                tracks.add(new Track());
            }
        }
    
Methods Summary
public javax.sound.midi.TrackcreateTrack()

        /*
         * new Tracks accrue to the end of vector
         */
        Track tr = new Track();
        tracks.add(tr);
        return tr;
    
public booleandeleteTrack(javax.sound.midi.Track track)

        return tracks.remove(track);
    
public floatgetDivisionType()

        return divisionType;
    
public longgetMicrosecondLength()

        float divisionType;
        if (this.divisionType == 0.0f) {
            divisionType = 2;
        } else {
            divisionType = this.divisionType;
        }
        return (long) (1000000.0 * getTickLength() / 
                (divisionType * this.resolution * 1.0f));
    
public javax.sound.midi.Patch[]getPatchList()

        //FIXME
        /*
         * I don't understand how to works this method, and so
         * I simply return an empty array. 'patches' initializes
         * in the constructor as empty vector 
         */
        Patch[] patch = new Patch[patches.size()];
        patches.toArray(patch);
        return patch;
    
public intgetResolution()

        return resolution;
    
public longgetTickLength()

        /*
         * this method return the biggest value of tick of 
         * all tracks contain in the Sequence
         */
        long maxTick = 0;
        for (int i = 0; i < tracks.size(); i++) {
            if (maxTick < tracks.get(i).ticks()) {
                maxTick = tracks.get(i).ticks();
            }
        }
        return maxTick;
    
public javax.sound.midi.Track[]getTracks()

        Track[] track = new Track[tracks.size()];
        tracks.toArray(track);
        return track;