All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.nosuch.midi.MidiPhrase

java.lang.Object
   |
   +----com.nosuch.midi.MidiPhrase

public class MidiPhrase
extends Object
implements Cloneable, Serializable
A MidiPhrase is an ordered (by time) list of MidiMsg objects. A MidiPhrase also has a "length" attribute that is the number of clicks from its beginning to its end. This length is used when concatenating phrases, among other things. The length is completely independent of the MidiMsg objects within the phrase, allowing for phrases with leading space, or phrases that are entirely space.


Constructor Index

 o MidiPhrase()
Construct a new phrase with no MidiMsgs and 0 length.
 o MidiPhrase(MidiMsg)
Construct a new phrase with a specified MidiMsg
 o MidiPhrase(MidiMsg, long)
Construct a new phrase with a specified MidiMsg and length
 o MidiPhrase(String)
Construct a new phrase from a KeyKit-style constant string.

Method Index

 o addTime(long)
Add a time to all MidiMsgs in this phrase
 o append(MidiMsg)
Append a MidiMsg to the phrase The starting time of the added MidiMsg is set to the current length of this phrase, and the length of this phrase is incremented by the duration of the MidiMsg.
 o append(MidiPhrase)
Append a MidiPhrase to this phrase The starting time of the added MidiPhrase (i.e.
 o clone()
Return a copy of this phrase
 o cloneStartingFrom(MidiMsg)
Return a copy of this phrase, starting at m
 o equals(MidiPhrase)
 o getAt(int)
Return the Nth (0-based) message of the phrase
 o getEnumeration()
Return an enumeration of the MidiMsgs in the phrase.
 o getLength()
Return the current length of the phrase (in clicks).
 o getNth(int)
Return the Nth (1-based) message of the phrase This method is 1-based to make it easier to convert Keynote code.
 o isEmpty()
Return the first message in the phrase
 o main(String[])
 o merge(MidiMsg)
Merge a MidiMsg into this phrase The new MidiMsg is merged with this phrase, putting it in the appropriate time-ordered location within this phrase's list of MidiMsgs.
 o merge(MidiPhrase)
Merge a Midiphrase into this phrase
 o multiplyVelocity(double)
Adjust by a factor the velocity of all MidiMsgs in this phrase
 o peekFirstMsg()
Return the first message in the phrase.
 o removeFirstMsg()
Return and remove the first message in the phrase
 o removeMsg(MidiMsg)
Remove a particular message from the phrase
 o reOrder()
Make sure the order of MidiMsgs in this phrase is correct.
 o replace(MidiMsg, MidiMsg)
Replace a particular message in the phrase with a new message.
 o setChannel(int)
Set channel of all MidiMsgs in this phrase
 o setDuration(long)
Set duration of all MidiMsgs in this phrase
 o setLength(long)
Set the length of the phrase (in clicks).
 o setPitch(int)
Set pitch of all MidiMsgs in this phrase
 o setTime(long)
Set time of all MidiMsgs in this phrase
 o size()
Return the number of MidiMsgs in the phrase.
 o toString()
Return a human-readable version of this phrase, in KeyKit format.

Constructors

 o MidiPhrase
 public MidiPhrase(MidiMsg n,
                   long l)
Construct a new phrase with a specified MidiMsg and length

Parameters:
n - MidiMsg
l - length of phrase (in clicks)
 o MidiPhrase
 public MidiPhrase(MidiMsg n)
Construct a new phrase with a specified MidiMsg

Parameters:
n - MidiMsg
 o MidiPhrase
 public MidiPhrase()
Construct a new phrase with no MidiMsgs and 0 length.

 o MidiPhrase
 public MidiPhrase(String s)
Construct a new phrase from a KeyKit-style constant string.

Methods

 o getLength
 public long getLength()
Return the current length of the phrase (in clicks).

 o getEnumeration
 public Enumeration getEnumeration()
Return an enumeration of the MidiMsgs in the phrase.

 o size
 public int size()
Return the number of MidiMsgs in the phrase.

 o setLength
 public MidiPhrase setLength(long l)
Set the length of the phrase (in clicks).

Parameters:
l - length (in clicks)
 o isEmpty
 public boolean isEmpty()
Return the first message in the phrase

 o peekFirstMsg
 public MidiMsg peekFirstMsg()
Return the first message in the phrase. The name is peek* so that people won't be tempted to actually modify it.

 o removeFirstMsg
 public MidiMsg removeFirstMsg()
Return and remove the first message in the phrase

 o removeMsg
 public MidiPhrase removeMsg(MidiMsg mtoremove)
Remove a particular message from the phrase

 o getNth
 public MidiMsg getNth(int n)
Return the Nth (1-based) message of the phrase This method is 1-based to make it easier to convert Keynote code. Use getAt() for the 0-based version.

Parameters:
n - Number (1-based) of message to get
 o getAt
 public MidiMsg getAt(int n)
Return the Nth (0-based) message of the phrase

Parameters:
n - Index (0-based) of message to get
 o replace
 public MidiPhrase replace(MidiMsg oldmsg,
                           MidiMsg newmsg)
Replace a particular message in the phrase with a new message.

Parameters:
oldmsg - MidiMsg to look for.
newmsg - MidiMsg to replace it with.
 o append
 public MidiPhrase append(MidiMsg newm)
Append a MidiMsg to the phrase The starting time of the added MidiMsg is set to the current length of this phrase, and the length of this phrase is incremented by the duration of the MidiMsg.

Parameters:
n - MidiMsg to append
 o append
 public MidiPhrase append(MidiPhrase newp)
Append a MidiPhrase to this phrase The starting time of the added MidiPhrase (i.e. of all the MidiMsgs in the phrase) is set to the current length of this phrase, and the length of this phrase is incremented by the length of the added phrase.

Parameters:
newp - MidiPhrase to append
 o merge
 public MidiPhrase merge(MidiMsg newmsg)
Merge a MidiMsg into this phrase The new MidiMsg is merged with this phrase, putting it in the appropriate time-ordered location within this phrase's list of MidiMsgs.

Parameters:
newmsg - MidiMsg to merge.
 o merge
 public MidiPhrase merge(MidiPhrase p)
Merge a Midiphrase into this phrase

Parameters:
newphr - MidiPhrase to merge.
 o clone
 public Object clone()
Return a copy of this phrase

Overrides:
clone in class Object
 o cloneStartingFrom
 public Object cloneStartingFrom(MidiMsg m)
Return a copy of this phrase, starting at m

 o equals
 public boolean equals(MidiPhrase p2)
 o setTime
 public MidiPhrase setTime(long tm)
Set time of all MidiMsgs in this phrase

Parameters:
tm - time (in clicks)
 o setPitch
 public MidiPhrase setPitch(int p)
Set pitch of all MidiMsgs in this phrase

Parameters:
p - pitch (0-127)
 o setChannel
 public MidiPhrase setChannel(int c)
Set channel of all MidiMsgs in this phrase

Parameters:
c - channel (1-16)
 o setDuration
 public MidiPhrase setDuration(long d)
Set duration of all MidiMsgs in this phrase

Parameters:
d - duration (in clicks)
 o addTime
 public MidiPhrase addTime(long tm)
Add a time to all MidiMsgs in this phrase

Parameters:
tm - time (in clicks)
 o multiplyVelocity
 public MidiPhrase multiplyVelocity(double f)
Adjust by a factor the velocity of all MidiMsgs in this phrase

Parameters:
f - multiplication factor
 o reOrder
 public MidiPhrase reOrder()
Make sure the order of MidiMsgs in this phrase is correct. This is used after doing appending and other things that may have resulted in things being out of order.

 o toString
 public String toString()
Return a human-readable version of this phrase, in KeyKit format.

Overrides:
toString in class Object
 o main
 public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index