/* */ package quicktime.app.audio;
/* */
/* */ import java.util.Enumeration;
/* */ import java.util.Vector;
/* */ import quicktime.QTException;
/* */ import quicktime.QTRuntimeException;
/* */ import quicktime.QTSession;
/* */ import quicktime.app.time.Ticklish;
/* */ import quicktime.app.time.Timer;
/* */ import quicktime.std.clocks.TimeBase;
/* */ import quicktime.std.clocks.TimeCallBack;
/* */ import quicktime.std.music.NoteChannel;
/* */ import quicktime.std.music.NoteRequest;
/* */ import quicktime.std.music.ToneDescription;
/* */
/* */ /** @deprecated */
/* */ public class NoteChannelControl
/* */ implements MusicPart
/* */ {
/* */ private NoteChannel channel;
/* */ private boolean muted;
/* */ private float vol;
/* */ private Timer t;
/* 74 */ private Vector activeNotes = new Vector();
/* */
/* */ /** @deprecated */
/* */ public NoteChannelControl(int paramInt)
/* */ throws QTException
/* */ {
/* 43 */ this(paramInt, 1);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public NoteChannelControl(int paramInt1, int paramInt2)
/* */ throws QTException
/* */ {
/* 54 */ this(new NoteChannel(paramInt1, paramInt2));
/* */ }
/* */
/* */ /** @deprecated */
/* */ public NoteChannelControl(NoteChannel paramNoteChannel)
/* */ throws QTException
/* */ {
/* 62 */ this.channel = paramNoteChannel;
/* 63 */ this.muted = (this.channel.getController(7) <= 0.0F);
/* 64 */ this.vol = getVolume();
/* */ }
/* */
/* */ /** @deprecated */
/* */ public boolean isMuted()
/* */ {
/* 82 */ return this.muted;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public void setMuted(boolean paramBoolean)
/* */ throws QTException
/* */ {
/* 91 */ this.muted = paramBoolean;
/* 92 */ if (this.muted)
/* 93 */ this.channel.setController(7, 0.0F);
/* */ else
/* 95 */ this.channel.setController(7, this.vol * 128.0F);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public void setVolume(float paramFloat)
/* */ throws QTException
/* */ {
/* 103 */ this.vol = paramFloat;
/* 104 */ if (!this.muted)
/* 105 */ this.channel.setController(7, this.vol * 128.0F);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public float getVolume()
/* */ throws QTException
/* */ {
/* 114 */ return this.muted ? this.vol : this.channel.getController(7) / 128.0F;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public void setBalance(float paramFloat)
/* */ throws QTException
/* */ {
/* 122 */ if (paramFloat == 0.0F)
/* 123 */ this.channel.setController(10, paramFloat);
/* */ else
/* 125 */ this.channel.setController(10, paramFloat / 2.0F + 1.5F);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public float getBalance()
/* */ throws QTException
/* */ {
/* 133 */ float f = this.channel.getController(10);
/* 134 */ if (f == 0.0F) return f;
/* 135 */ return (f - 1.5F) * 2.0F;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public void selectInstrument(String paramString)
/* */ throws QTException
/* */ {
/* 148 */ this.channel.pickEditInstrument(paramString, 16);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public String getInstrumentName()
/* */ throws QTException
/* */ {
/* 157 */ return this.channel.getNoteRequest().getToneDescription().getInstrumentName();
/* */ }
/* */
/* */ /** @deprecated */
/* */ public final NoteChannel getNoteChannel()
/* */ {
/* 164 */ return this.channel;
/* */ }
/* */
/* */ /** @deprecated */
/* */ public void playNoteFor(float paramFloat, int paramInt1, int paramInt2)
/* */ throws QTException
/* */ {
/* 174 */ if (this.t == null) {
/* 175 */ this.t = new Timer(1, 1, new TurnOffNotes());
/* 176 */ this.t.setTickling(false);
/* 177 */ this.t.setActive(true);
/* 178 */ this.t.setRate(1.0F);
/* */ } else {
/* 180 */ this.t.setActive(true);
/* */ }
/* 182 */ int i = this.t.getTimeBase().getTime(1000);
/* 183 */ this.channel.playNote(paramFloat, paramInt1);
/* */
/* 185 */ EndNote localEndNote = new EndNote(this.t.getTimeBase(), 1000, i + paramInt2, 1, this.channel, paramFloat);
/* 186 */ localEndNote.callMeWhen();
/* 187 */ this.activeNotes.addElement(localEndNote);
/* */ }
/* */
/* */ protected final void finalize()
/* */ throws Throwable
/* */ {
/* 243 */ Enumeration localEnumeration = this.activeNotes.elements();
/* 244 */ while (localEnumeration.hasMoreElements())
/* 245 */ ((EndNote)localEnumeration.nextElement()).cancelAndCleanup();
/* 246 */ this.activeNotes.removeAllElements();
/* 247 */ super.finalize();
/* */ }
/* */
/* */ static
/* */ {
/* 30 */ if ((QTSession.isCurrentOS(4)) && (QTSession.getJavaVersion() >= 65540))
/* 31 */ throw new QTRuntimeException("Unsupported on Mac OS X and Java 1.4 and higher.");
/* */ }
/* */
/* */ class TurnOffNotes
/* */ implements Ticklish
/* */ {
/* */ TurnOffNotes()
/* */ {
/* */ }
/* */
/* */ public void timeChanged(int paramInt)
/* */ throws QTException
/* */ {
/* 234 */ Enumeration localEnumeration = NoteChannelControl.this.activeNotes.elements();
/* 235 */ while (localEnumeration.hasMoreElements())
/* 236 */ ((NoteChannelControl.EndNote)localEnumeration.nextElement()).execute();
/* */ }
/* */
/* 239 */ public boolean tickle(float paramFloat, int paramInt) throws QTException { return false; }
/* */
/* */ }
/* */
/* */ class EndNote extends TimeCallBack
/* */ {
/* */ float note;
/* */ NoteChannel nc;
/* */
/* */ EndNote(TimeBase paramInt1, int paramInt2, int paramInt3, int paramNoteChannel, NoteChannel paramFloat, float arg7)
/* */ throws QTException
/* */ {
/* 192 */ super(paramInt2, paramInt3, paramNoteChannel);
/* */ Object localObject;
/* 193 */ this.note = localObject;
/* 194 */ this.nc = paramFloat;
/* */ }
/* */
/* */ public void execute()
/* */ {
/* */ try
/* */ {
/* 202 */ this.nc.playNote(this.note, 0);
/* */ } catch (QTException localQTException2) {
/* 204 */ localQTException2.printStackTrace();
/* */ } finally {
/* 206 */ NoteChannelControl.this.activeNotes.removeElement(this);
/* 207 */ if (NoteChannelControl.this.activeNotes.isEmpty()) {
/* */ try {
/* 209 */ NoteChannelControl.this.t.setActive(false);
/* */ } catch (QTException localQTException4) {
/* 211 */ NoteChannelControl.this.t = null;
/* */ }
/* */ }
/* 214 */ cancelAndCleanup();
/* */ }
/* */ }
/* */
/* */ public boolean equals(Object paramObject) {
/* 219 */ if (paramObject == this) return true;
/* 220 */ if ((paramObject instanceof EndNote)) {
/* 221 */ EndNote localEndNote = (EndNote)paramObject;
/* 222 */ return (this.value == localEndNote.value) && (this.note == localEndNote.note) && (this.nc.equals(localEndNote.nc));
/* */ }
/* 224 */ return false;
/* */ }
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name: quicktime.app.audio.NoteChannelControl
* JD-Core Version: 0.6.2
*/