com.soundhelix.misc
Class Track

java.lang.Object
  extended by com.soundhelix.misc.Track

public class Track
extends Object

Represents a track. A track consists of an arbitrary number of sequences and a type. The type can either be MELODIC, which means that the sequences contain melodic notes which are subject for transposition, or it can be RHYTHMIC, which means the sequences contain rhythm notes which must never be transposed. For example, for drum machines, RHYTHMIC must be used, because each pitch of a sequence selects a drum sample to play (c' might be the base drum, c#' might be the snare and so on) rather than a frequency of a tone to play. Only a whole track can be assigned to an instrument, so all contained sequences use the same instrument for playback. If different instruments are needed, the sequences must each be put into a track individually. The assignment of a whole track to an instrument is also the reason why it doesn't make sense to individually assign the types to sequences. If you have an instrument where part of the keys should use RHYTHMIC, the others should use MELODIC, you should split these off into two different tracks and assign them to the same MIDI channel for playback.

Author:
Thomas Schuerger (thomas@schuerger.com)

Nested Class Summary
static class Track.TrackType
          The possible track types.
 
Constructor Summary
Track(Track.TrackType type)
          Constructor.
 
Method Summary
 void add(Sequence sequence)
          Adds the given sequence to this track.
 Sequence get(int index)
          Returns the sequence with the given index.
 Track.TrackType getType()
          Returns the track's type.
 Iterator<Sequence> iterator()
          Returns an iterator that iterates over this track's sequences.
 int size()
          Returns the number of sequences this track contains.
 void transpose(int halftones)
          Transposes all sequences of this track up by the given number of halftones.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Track

public Track(Track.TrackType type)
Constructor.

Parameters:
type - the type
Method Detail

add

public void add(Sequence sequence)
Adds the given sequence to this track.

Parameters:
sequence - the sequence to add

size

public int size()
Returns the number of sequences this track contains.

Returns:
the number of sequences

getType

public Track.TrackType getType()
Returns the track's type.

Returns:
the type

get

public Sequence get(int index)
Returns the sequence with the given index.

Parameters:
index - the index
Returns:
the sequence

iterator

public Iterator<Sequence> iterator()
Returns an iterator that iterates over this track's sequences.

Returns:
the iterator

transpose

public void transpose(int halftones)
Transposes all sequences of this track up by the given number of halftones. If the number of halftones is not zero, the track type must not be RHYTHMIC.

Parameters:
halftones - the number of halftones (positive or negative)