📄 fssound.java
字号:
Gets the sample number at which the sound reaches full volume when fading in.
@return the in point
*/
public int getInPoint() { return inPoint; }
/**
Gets the sample number at which the sound starts to fade.
@return the out point
*/
public int getOutPoint() { return outPoint; }
/**
Gets the number of times the sound will be repeated.
@return the Loop Count.
*/
public int getLoopCount() { return loopCount; }
/**
Gets the array of FSEnvelope objects that control the levels the sound is played.
@return an array of FSEnvelope objects.
*/
public ArrayList getEnvelopes() { return envelopes; }
/** Sets the identifier of the sound to the played.
@param anIdentifier the identifier for the sound to be played.
*/
public void setIdentifier(int anIdentifier)
{
identifier = anIdentifier;
}
/** Sets how the sound is synchronised when the frames are displayed: Start - start playing the sound, Continue - do not play the sound if it is already playing and Stop - stop playing the sound.
@param aMode how the sound is played.
*/
public void setMode(int aMode)
{
mode = aMode;
}
/** Sets the sample number at which the sound reaches full volume when fading in. May be set to zero if the sound does not fade in.
@param aNumber the sample number which the sound fades in to.
*/
public void setInPoint(int aNumber)
{
inPoint = aNumber;
}
/** Sets the sample number at which the sound starts to fade. May be set to zero if the sound does not fade out.
@param aNumber the sample number at which the sound starts to fade.
*/
public void setOutPoint(int aNumber)
{
outPoint = aNumber;
}
/** Sets the number of times the sound is repeated. May be set to zero if the sound will not be repeated.
@param aNumber the number of times the sound is repeated.
*/
public void setLoopCount(int aNumber)
{
loopCount = aNumber;
}
/** Sets the array of FSEnvelope objects that define the levels at which a sound is played over the duration of the sound. May be set to null if no envelope is defined.
@param anArray an array of FSEnvelope objects.
*/
public void setEnvelopes(ArrayList anArray)
{
envelopes = anArray;
}
public Object clone()
{
FSSound anObject = (FSSound)super.clone();
anObject.envelopes = new ArrayList();
for (Iterator i = envelopes.iterator(); i.hasNext();)
anObject.envelopes.add(((FSEnvelope)i.next()).clone());
return anObject;
}
public boolean equals(Object anObject)
{
boolean result = false;
if (super.equals(anObject))
{
FSSound typedObject = (FSSound)anObject;
result = identifier == typedObject.identifier;
result = result && mode == typedObject.mode;
result = result && inPoint == typedObject.inPoint;
result = result && outPoint == typedObject.outPoint;
result = result && loopCount == typedObject.loopCount;
if (envelopes != null)
result = result && envelopes.equals(typedObject.envelopes);
else
result = result && envelopes == typedObject.envelopes;
}
return result;
}
public void appendDescription(StringBuffer buffer, int depth)
{
buffer.append(name());
if (depth > 0)
{
buffer.append(": { ");
Transform.append(buffer, "identifier", identifier);
Transform.append(buffer, "mode", mode);
Transform.append(buffer, "inPoint", inPoint);
Transform.append(buffer, "outPoint", outPoint);
Transform.append(buffer, "loopCount", loopCount);
Transform.append(buffer, "envelopes", envelopes, depth);
buffer.append("}");
}
}
public int length(FSCoder coder)
{
boolean _containsInPoint = containsInPoint();
boolean _containsOutPoint = containsOutPoint();
boolean _containsLoopCount = containsLoopCount();
boolean _containsEnvelopes = containsEnvelopes();
int length = 3;
length += (_containsInPoint) ? 4 : 0;
length += (_containsOutPoint) ? 4 : 0;
length += (_containsLoopCount) ? 2 : 0;
length += (_containsEnvelopes) ? 1 : 0;
length += (_containsEnvelopes) ? envelopes.size()*8 : 0;
return length;
}
public void encode(FSCoder coder)
{
boolean _containsInPoint = containsInPoint();
boolean _containsOutPoint = containsOutPoint();
boolean _containsLoopCount = containsLoopCount();
boolean _containsEnvelopes = containsEnvelopes();
coder.writeWord(identifier, 2);
coder.writeBits(mode, 4);
coder.writeBits(_containsEnvelopes ? 1 : 0, 1);
coder.writeBits(_containsLoopCount ? 1 : 0, 1);
coder.writeBits(_containsOutPoint ? 1 : 0, 1);
coder.writeBits(_containsInPoint ? 1 : 0, 1);
if (_containsInPoint)
coder.writeWord(inPoint, 4);
if (_containsOutPoint)
coder.writeWord(outPoint, 4);
if (_containsLoopCount)
coder.writeWord(loopCount, 2);
if (_containsEnvelopes)
{
coder.writeWord(envelopes.size(), 1);
for (int i=0; i<envelopes.size(); i++)
((FSTransformObject)envelopes.get(i)).encode(coder);
}
}
public void decode(FSCoder coder)
{
boolean _containsInPoint = false;
boolean _containsOutPoint = false;
boolean _containsLoopCount = false;
boolean _containsEnvelopes = false;
envelopes = new ArrayList();
int envelopeCount = 0;
identifier = coder.readWord(2, false);
mode = coder.readBits(4, false);
_containsEnvelopes = coder.readBits(1, false) != 0 ? true : false;
_containsLoopCount = coder.readBits(1, false) != 0 ? true : false;
_containsOutPoint = coder.readBits(1, false) != 0 ? true : false;
_containsInPoint = coder.readBits(1, false) != 0 ? true : false;
if (_containsInPoint)
inPoint = coder.readWord(4, false);
if (_containsOutPoint)
outPoint = coder.readWord(4, false);
if (_containsLoopCount)
loopCount = coder.readWord(2, false);
if (_containsEnvelopes)
{
envelopeCount = coder.readWord(1, false);
for (int i=0; i<envelopeCount; i++)
envelopes.add(new FSEnvelope(coder));
}
}
private boolean containsInPoint()
{
return inPoint != 0;
}
private boolean containsOutPoint()
{
return outPoint != 0;
}
private boolean containsLoopCount()
{
return loopCount != 0;
}
private boolean containsEnvelopes()
{
return envelopes != null && envelopes.size() > 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -