com.sun.media.sound.MidiUtils Java Examples
The following examples show how to use
com.sun.media.sound.MidiUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysexMessage.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Sets the data for the system exclusive message. * * @param status the status byte for the message (0xF0 or 0xF7) * @param data the system exclusive message data * @param length the length of the valid message data in the array * @throws InvalidMidiDataException if the status byte is invalid for a * system exclusive message */ public void setMessage(int status, byte[] data, int length) throws InvalidMidiDataException { MidiUtils.checkSysexStatus(status); if (length < 0 || length > data.length) { throw new IndexOutOfBoundsException("length out of bounds: "+length); } this.length = length + 1; if (this.data==null || this.data.length < this.length) { this.data = new byte[this.length]; } this.data[0] = (byte) (status & 0xFF); if (length > 0) { System.arraycopy(data, 0, this.data, 1, length); } }
Example #2
Source File: Sequence.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Obtains the duration of this sequence, expressed in microseconds. * @return this sequence's duration in microseconds. */ public long getMicrosecondLength() { return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null); }
Example #3
Source File: Track.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Adds a new event to the track. However, if the event is already * contained in the track, it is not added again. The list of events * is kept in time order, meaning that this event inserted at the * appropriate place in the list, not necessarily at the end. * * @param event the event to add * @return <code>true</code> if the event did not already exist in the * track and was added, otherwise <code>false</code> */ public boolean add(MidiEvent event) { if (event == null) { return false; } synchronized(eventsList) { if (!set.contains(event)) { int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { // set eotEvent's tick to the last tick of the track eotEvent.setTick(lastEvent.getTick()); } else { // if the events list is empty, just set the tick to 0 eotEvent.setTick(0); } // we needn't check for a duplicate of eotEvent in "eventsList", // since then it would appear in the set. eventsList.add(eotEvent); set.add(eotEvent); eventsCount = eventsList.size(); } // first see if we are trying to add // and endoftrack event. if (MidiUtils.isMetaEndOfTrack(event.getMessage())) { // since end of track event is useful // for delays at the end of a track, we want to keep // the tick value requested here if it is greater // than the one on the eot we are maintaining. // Otherwise, we only want a single eot event, so ignore. if (event.getTick() > eotEvent.getTick()) { eotEvent.setTick(event.getTick()); } return true; } // prevent duplicates set.add(event); // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the // tick value of our eot, so push the eot out. // Always add at the end for better performance: // this saves all the checks and arraycopy when inserting // overwrite eot with new event eventsList.set(eventsCount - 1, event); // set new time of eot, if necessary if (eotEvent.getTick() < event.getTick()) { eotEvent.setTick(event.getTick()); } // add eot again at the end eventsList.add(eotEvent); } else { eventsList.add(i, event); } return true; } } return false; }
Example #4
Source File: Track.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private ImmutableEndOfTrack() { super(new byte[3]); data[0] = (byte) META; data[1] = MidiUtils.META_END_OF_TRACK_TYPE; data[2] = 0; }
Example #5
Source File: Sequence.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Obtains the duration of this sequence, expressed in microseconds. * @return this sequence's duration in microseconds. */ public long getMicrosecondLength() { return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null); }
Example #6
Source File: Track.java From Java8CN with Apache License 2.0 | 4 votes |
/** * Adds a new event to the track. However, if the event is already * contained in the track, it is not added again. The list of events * is kept in time order, meaning that this event inserted at the * appropriate place in the list, not necessarily at the end. * * @param event the event to add * @return <code>true</code> if the event did not already exist in the * track and was added, otherwise <code>false</code> */ public boolean add(MidiEvent event) { if (event == null) { return false; } synchronized(eventsList) { if (!set.contains(event)) { int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { // set eotEvent's tick to the last tick of the track eotEvent.setTick(lastEvent.getTick()); } else { // if the events list is empty, just set the tick to 0 eotEvent.setTick(0); } // we needn't check for a duplicate of eotEvent in "eventsList", // since then it would appear in the set. eventsList.add(eotEvent); set.add(eotEvent); eventsCount = eventsList.size(); } // first see if we are trying to add // and endoftrack event. if (MidiUtils.isMetaEndOfTrack(event.getMessage())) { // since end of track event is useful // for delays at the end of a track, we want to keep // the tick value requested here if it is greater // than the one on the eot we are maintaining. // Otherwise, we only want a single eot event, so ignore. if (event.getTick() > eotEvent.getTick()) { eotEvent.setTick(event.getTick()); } return true; } // prevent duplicates set.add(event); // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the // tick value of our eot, so push the eot out. // Always add at the end for better performance: // this saves all the checks and arraycopy when inserting // overwrite eot with new event eventsList.set(eventsCount - 1, event); // set new time of eot, if necessary if (eotEvent.getTick() < event.getTick()) { eotEvent.setTick(event.getTick()); } // add eot again at the end eventsList.add(eotEvent); } else { eventsList.add(i, event); } return true; } } return false; }
Example #7
Source File: Track.java From Java8CN with Apache License 2.0 | 4 votes |
private ImmutableEndOfTrack() { super(new byte[3]); data[0] = (byte) META; data[1] = MidiUtils.META_END_OF_TRACK_TYPE; data[2] = 0; }
Example #8
Source File: Sequence.java From Java8CN with Apache License 2.0 | 4 votes |
/** * Obtains the duration of this sequence, expressed in microseconds. * @return this sequence's duration in microseconds. */ public long getMicrosecondLength() { return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null); }
Example #9
Source File: Track.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Adds a new event to the track. However, if the event is already * contained in the track, it is not added again. The list of events * is kept in time order, meaning that this event inserted at the * appropriate place in the list, not necessarily at the end. * * @param event the event to add * @return <code>true</code> if the event did not already exist in the * track and was added, otherwise <code>false</code> */ public boolean add(MidiEvent event) { if (event == null) { return false; } synchronized(eventsList) { if (!set.contains(event)) { int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { // set eotEvent's tick to the last tick of the track eotEvent.setTick(lastEvent.getTick()); } else { // if the events list is empty, just set the tick to 0 eotEvent.setTick(0); } // we needn't check for a duplicate of eotEvent in "eventsList", // since then it would appear in the set. eventsList.add(eotEvent); set.add(eotEvent); eventsCount = eventsList.size(); } // first see if we are trying to add // and endoftrack event. if (MidiUtils.isMetaEndOfTrack(event.getMessage())) { // since end of track event is useful // for delays at the end of a track, we want to keep // the tick value requested here if it is greater // than the one on the eot we are maintaining. // Otherwise, we only want a single eot event, so ignore. if (event.getTick() > eotEvent.getTick()) { eotEvent.setTick(event.getTick()); } return true; } // prevent duplicates set.add(event); // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the // tick value of our eot, so push the eot out. // Always add at the end for better performance: // this saves all the checks and arraycopy when inserting // overwrite eot with new event eventsList.set(eventsCount - 1, event); // set new time of eot, if necessary if (eotEvent.getTick() < event.getTick()) { eotEvent.setTick(event.getTick()); } // add eot again at the end eventsList.add(eotEvent); } else { eventsList.add(i, event); } return true; } } return false; }
Example #10
Source File: Track.java From hottub with GNU General Public License v2.0 | 4 votes |
private ImmutableEndOfTrack() { super(new byte[3]); data[0] = (byte) META; data[1] = MidiUtils.META_END_OF_TRACK_TYPE; data[2] = 0; }
Example #11
Source File: Sequence.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Obtains the duration of this sequence, expressed in microseconds. * @return this sequence's duration in microseconds. */ public long getMicrosecondLength() { return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null); }
Example #12
Source File: Track.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Adds a new event to the track. However, if the event is already * contained in the track, it is not added again. The list of events * is kept in time order, meaning that this event inserted at the * appropriate place in the list, not necessarily at the end. * * @param event the event to add * @return <code>true</code> if the event did not already exist in the * track and was added, otherwise <code>false</code> */ public boolean add(MidiEvent event) { if (event == null) { return false; } synchronized(eventsList) { if (!set.contains(event)) { int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { // set eotEvent's tick to the last tick of the track eotEvent.setTick(lastEvent.getTick()); } else { // if the events list is empty, just set the tick to 0 eotEvent.setTick(0); } // we needn't check for a duplicate of eotEvent in "eventsList", // since then it would appear in the set. eventsList.add(eotEvent); set.add(eotEvent); eventsCount = eventsList.size(); } // first see if we are trying to add // and endoftrack event. if (MidiUtils.isMetaEndOfTrack(event.getMessage())) { // since end of track event is useful // for delays at the end of a track, we want to keep // the tick value requested here if it is greater // than the one on the eot we are maintaining. // Otherwise, we only want a single eot event, so ignore. if (event.getTick() > eotEvent.getTick()) { eotEvent.setTick(event.getTick()); } return true; } // prevent duplicates set.add(event); // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the // tick value of our eot, so push the eot out. // Always add at the end for better performance: // this saves all the checks and arraycopy when inserting // overwrite eot with new event eventsList.set(eventsCount - 1, event); // set new time of eot, if necessary if (eotEvent.getTick() < event.getTick()) { eotEvent.setTick(event.getTick()); } // add eot again at the end eventsList.add(eotEvent); } else { eventsList.add(i, event); } return true; } } return false; }
Example #13
Source File: Track.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private ImmutableEndOfTrack() { super(new byte[3]); data[0] = (byte) META; data[1] = MidiUtils.META_END_OF_TRACK_TYPE; data[2] = 0; }
Example #14
Source File: Track.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Adds a new event to the track. However, if the event is already contained * in the track, it is not added again. The list of events is kept in time * order, meaning that this event inserted at the appropriate place in the * list, not necessarily at the end. * * @param event the event to add * @return {@code true} if the event did not already exist in the track and * was added, otherwise {@code false} */ public boolean add(MidiEvent event) { if (event == null) { return false; } synchronized(eventsList) { if (!set.contains(event)) { int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { lastEvent = eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { // set eotEvent's tick to the last tick of the track eotEvent.setTick(lastEvent.getTick()); } else { // if the events list is empty, just set the tick to 0 eotEvent.setTick(0); } // we needn't check for a duplicate of eotEvent in "eventsList", // since then it would appear in the set. eventsList.add(eotEvent); set.add(eotEvent); eventsCount = eventsList.size(); } // first see if we are trying to add // and endoftrack event. if (MidiUtils.isMetaEndOfTrack(event.getMessage())) { // since end of track event is useful // for delays at the end of a track, we want to keep // the tick value requested here if it is greater // than the one on the eot we are maintaining. // Otherwise, we only want a single eot event, so ignore. if (event.getTick() > eotEvent.getTick()) { eotEvent.setTick(event.getTick()); } return true; } // prevent duplicates set.add(event); // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { if (event.getTick() >= (eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the // tick value of our eot, so push the eot out. // Always add at the end for better performance: // this saves all the checks and arraycopy when inserting // overwrite eot with new event eventsList.set(eventsCount - 1, event); // set new time of eot, if necessary if (eotEvent.getTick() < event.getTick()) { eotEvent.setTick(event.getTick()); } // add eot again at the end eventsList.add(eotEvent); } else { eventsList.add(i, event); } return true; } } return false; }
Example #15
Source File: Track.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Adds a new event to the track. However, if the event is already * contained in the track, it is not added again. The list of events * is kept in time order, meaning that this event inserted at the * appropriate place in the list, not necessarily at the end. * * @param event the event to add * @return <code>true</code> if the event did not already exist in the * track and was added, otherwise <code>false</code> */ public boolean add(MidiEvent event) { if (event == null) { return false; } synchronized(eventsList) { if (!set.contains(event)) { int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { // set eotEvent's tick to the last tick of the track eotEvent.setTick(lastEvent.getTick()); } else { // if the events list is empty, just set the tick to 0 eotEvent.setTick(0); } // we needn't check for a duplicate of eotEvent in "eventsList", // since then it would appear in the set. eventsList.add(eotEvent); set.add(eotEvent); eventsCount = eventsList.size(); } // first see if we are trying to add // and endoftrack event. if (MidiUtils.isMetaEndOfTrack(event.getMessage())) { // since end of track event is useful // for delays at the end of a track, we want to keep // the tick value requested here if it is greater // than the one on the eot we are maintaining. // Otherwise, we only want a single eot event, so ignore. if (event.getTick() > eotEvent.getTick()) { eotEvent.setTick(event.getTick()); } return true; } // prevent duplicates set.add(event); // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the // tick value of our eot, so push the eot out. // Always add at the end for better performance: // this saves all the checks and arraycopy when inserting // overwrite eot with new event eventsList.set(eventsCount - 1, event); // set new time of eot, if necessary if (eotEvent.getTick() < event.getTick()) { eotEvent.setTick(event.getTick()); } // add eot again at the end eventsList.add(eotEvent); } else { eventsList.add(i, event); } return true; } } return false; }
Example #16
Source File: Track.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private ImmutableEndOfTrack() { super(new byte[3]); data[0] = (byte) META; data[1] = MidiUtils.META_END_OF_TRACK_TYPE; data[2] = 0; }
Example #17
Source File: Sequence.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Obtains the duration of this sequence, expressed in microseconds. * @return this sequence's duration in microseconds. */ public long getMicrosecondLength() { return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null); }
Example #18
Source File: Track.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Adds a new event to the track. However, if the event is already * contained in the track, it is not added again. The list of events * is kept in time order, meaning that this event inserted at the * appropriate place in the list, not necessarily at the end. * * @param event the event to add * @return <code>true</code> if the event did not already exist in the * track and was added, otherwise <code>false</code> */ public boolean add(MidiEvent event) { if (event == null) { return false; } synchronized(eventsList) { if (!set.contains(event)) { int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { // set eotEvent's tick to the last tick of the track eotEvent.setTick(lastEvent.getTick()); } else { // if the events list is empty, just set the tick to 0 eotEvent.setTick(0); } // we needn't check for a duplicate of eotEvent in "eventsList", // since then it would appear in the set. eventsList.add(eotEvent); set.add(eotEvent); eventsCount = eventsList.size(); } // first see if we are trying to add // and endoftrack event. if (MidiUtils.isMetaEndOfTrack(event.getMessage())) { // since end of track event is useful // for delays at the end of a track, we want to keep // the tick value requested here if it is greater // than the one on the eot we are maintaining. // Otherwise, we only want a single eot event, so ignore. if (event.getTick() > eotEvent.getTick()) { eotEvent.setTick(event.getTick()); } return true; } // prevent duplicates set.add(event); // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the // tick value of our eot, so push the eot out. // Always add at the end for better performance: // this saves all the checks and arraycopy when inserting // overwrite eot with new event eventsList.set(eventsCount - 1, event); // set new time of eot, if necessary if (eotEvent.getTick() < event.getTick()) { eotEvent.setTick(event.getTick()); } // add eot again at the end eventsList.add(eotEvent); } else { eventsList.add(i, event); } return true; } } return false; }
Example #19
Source File: Track.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private ImmutableEndOfTrack() { super(new byte[3]); data[0] = (byte) META; data[1] = MidiUtils.META_END_OF_TRACK_TYPE; data[2] = 0; }
Example #20
Source File: Sequence.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Obtains the duration of this sequence, expressed in microseconds. * @return this sequence's duration in microseconds. */ public long getMicrosecondLength() { return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null); }
Example #21
Source File: Track.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Adds a new event to the track. However, if the event is already * contained in the track, it is not added again. The list of events * is kept in time order, meaning that this event inserted at the * appropriate place in the list, not necessarily at the end. * * @param event the event to add * @return <code>true</code> if the event did not already exist in the * track and was added, otherwise <code>false</code> */ public boolean add(MidiEvent event) { if (event == null) { return false; } synchronized(eventsList) { if (!set.contains(event)) { int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { // set eotEvent's tick to the last tick of the track eotEvent.setTick(lastEvent.getTick()); } else { // if the events list is empty, just set the tick to 0 eotEvent.setTick(0); } // we needn't check for a duplicate of eotEvent in "eventsList", // since then it would appear in the set. eventsList.add(eotEvent); set.add(eotEvent); eventsCount = eventsList.size(); } // first see if we are trying to add // and endoftrack event. if (MidiUtils.isMetaEndOfTrack(event.getMessage())) { // since end of track event is useful // for delays at the end of a track, we want to keep // the tick value requested here if it is greater // than the one on the eot we are maintaining. // Otherwise, we only want a single eot event, so ignore. if (event.getTick() > eotEvent.getTick()) { eotEvent.setTick(event.getTick()); } return true; } // prevent duplicates set.add(event); // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the // tick value of our eot, so push the eot out. // Always add at the end for better performance: // this saves all the checks and arraycopy when inserting // overwrite eot with new event eventsList.set(eventsCount - 1, event); // set new time of eot, if necessary if (eotEvent.getTick() < event.getTick()) { eotEvent.setTick(event.getTick()); } // add eot again at the end eventsList.add(eotEvent); } else { eventsList.add(i, event); } return true; } } return false; }
Example #22
Source File: Track.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private ImmutableEndOfTrack() { super(new byte[3]); data[0] = (byte) META; data[1] = MidiUtils.META_END_OF_TRACK_TYPE; data[2] = 0; }
Example #23
Source File: Sequence.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Obtains the duration of this sequence, expressed in microseconds. * @return this sequence's duration in microseconds. */ public long getMicrosecondLength() { return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null); }
Example #24
Source File: Track.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * Adds a new event to the track. However, if the event is already * contained in the track, it is not added again. The list of events * is kept in time order, meaning that this event inserted at the * appropriate place in the list, not necessarily at the end. * * @param event the event to add * @return <code>true</code> if the event did not already exist in the * track and was added, otherwise <code>false</code> */ public boolean add(MidiEvent event) { if (event == null) { return false; } synchronized(eventsList) { if (!set.contains(event)) { int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { // set eotEvent's tick to the last tick of the track eotEvent.setTick(lastEvent.getTick()); } else { // if the events list is empty, just set the tick to 0 eotEvent.setTick(0); } // we needn't check for a duplicate of eotEvent in "eventsList", // since then it would appear in the set. eventsList.add(eotEvent); set.add(eotEvent); eventsCount = eventsList.size(); } // first see if we are trying to add // and endoftrack event. if (MidiUtils.isMetaEndOfTrack(event.getMessage())) { // since end of track event is useful // for delays at the end of a track, we want to keep // the tick value requested here if it is greater // than the one on the eot we are maintaining. // Otherwise, we only want a single eot event, so ignore. if (event.getTick() > eotEvent.getTick()) { eotEvent.setTick(event.getTick()); } return true; } // prevent duplicates set.add(event); // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the // tick value of our eot, so push the eot out. // Always add at the end for better performance: // this saves all the checks and arraycopy when inserting // overwrite eot with new event eventsList.set(eventsCount - 1, event); // set new time of eot, if necessary if (eotEvent.getTick() < event.getTick()) { eotEvent.setTick(event.getTick()); } // add eot again at the end eventsList.add(eotEvent); } else { eventsList.add(i, event); } return true; } } return false; }
Example #25
Source File: Track.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private ImmutableEndOfTrack() { super(new byte[3]); data[0] = (byte) META; data[1] = MidiUtils.META_END_OF_TRACK_TYPE; data[2] = 0; }
Example #26
Source File: Sequence.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * Obtains the duration of this sequence, expressed in microseconds. * @return this sequence's duration in microseconds. */ public long getMicrosecondLength() { return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null); }
Example #27
Source File: Track.java From JDKSourceCode1.8 with MIT License | 4 votes |
private ImmutableEndOfTrack() { super(new byte[3]); data[0] = (byte) META; data[1] = MidiUtils.META_END_OF_TRACK_TYPE; data[2] = 0; }
Example #28
Source File: Track.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
private ImmutableEndOfTrack() { super(new byte[3]); data[0] = (byte) META; data[1] = MidiUtils.META_END_OF_TRACK_TYPE; data[2] = 0; }
Example #29
Source File: Sequence.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Obtains the duration of this sequence, expressed in microseconds. * @return this sequence's duration in microseconds. */ public long getMicrosecondLength() { return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null); }
Example #30
Source File: Track.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Adds a new event to the track. However, if the event is already * contained in the track, it is not added again. The list of events * is kept in time order, meaning that this event inserted at the * appropriate place in the list, not necessarily at the end. * * @param event the event to add * @return <code>true</code> if the event did not already exist in the * track and was added, otherwise <code>false</code> */ public boolean add(MidiEvent event) { if (event == null) { return false; } synchronized(eventsList) { if (!set.contains(event)) { int eventsCount = eventsList.size(); // get the last event MidiEvent lastEvent = null; if (eventsCount > 0) { lastEvent = (MidiEvent) eventsList.get(eventsCount - 1); } // sanity check that we have a correct end-of-track if (lastEvent != eotEvent) { // if there is no eot event, add our immutable instance again if (lastEvent != null) { // set eotEvent's tick to the last tick of the track eotEvent.setTick(lastEvent.getTick()); } else { // if the events list is empty, just set the tick to 0 eotEvent.setTick(0); } // we needn't check for a duplicate of eotEvent in "eventsList", // since then it would appear in the set. eventsList.add(eotEvent); set.add(eotEvent); eventsCount = eventsList.size(); } // first see if we are trying to add // and endoftrack event. if (MidiUtils.isMetaEndOfTrack(event.getMessage())) { // since end of track event is useful // for delays at the end of a track, we want to keep // the tick value requested here if it is greater // than the one on the eot we are maintaining. // Otherwise, we only want a single eot event, so ignore. if (event.getTick() > eotEvent.getTick()) { eotEvent.setTick(event.getTick()); } return true; } // prevent duplicates set.add(event); // insert event such that events is sorted in increasing // tick order int i = eventsCount; for ( ; i > 0; i--) { if (event.getTick() >= ((MidiEvent)eventsList.get(i-1)).getTick()) { break; } } if (i == eventsCount) { // we're adding an event after the // tick value of our eot, so push the eot out. // Always add at the end for better performance: // this saves all the checks and arraycopy when inserting // overwrite eot with new event eventsList.set(eventsCount - 1, event); // set new time of eot, if necessary if (eotEvent.getTick() < event.getTick()) { eotEvent.setTick(event.getTick()); } // add eot again at the end eventsList.add(eotEvent); } else { eventsList.add(i, event); } return true; } } return false; }