当前位置: 首页>>代码示例>>Java>>正文


Java Track.remove方法代码示例

本文整理汇总了Java中javax.sound.midi.Track.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Track.remove方法的具体用法?Java Track.remove怎么用?Java Track.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sound.midi.Track的用法示例。


在下文中一共展示了Track.remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertToType1

import javax.sound.midi.Track; //导入方法依赖的package包/类
/**
 * Separates the MIDI file to have one track per channel (Type 1).
 */
public static void convertToType1(Sequence song)
{
	if (song.getTracks().length == 1)
	{
		Track track0 = song.getTracks()[0];
		Track[] tracks = new Track[CHANNEL_COUNT];

		int trackNumber = 1;
		int i = 0;
		while (i < track0.size())
		{
			MidiEvent evt = track0.get(i);
			if (evt.getMessage() instanceof ShortMessage)
			{
				int chan = ((ShortMessage) evt.getMessage()).getChannel();
				if (tracks[chan] == null)
				{
					tracks[chan] = song.createTrack();
					String trackName = (chan == DRUM_CHANNEL) ? "Drums" : ("Track " + trackNumber);
					trackNumber++;
					tracks[chan].add(MidiFactory.createTrackNameEvent(trackName));
				}
				tracks[chan].add(evt);
				if (track0.remove(evt))
					continue;
			}
			i++;
		}
	}
}
 
开发者ID:digero,项目名称:maestro,代码行数:34,代码来源:SequenceInfo.java

示例2: test_size

import javax.sound.midi.Track; //导入方法依赖的package包/类
/**
 * test method size()
 * @throws Exception
 */
public void test_size() throws Exception {
    /*
     * create an empty Track
     */
    Sequence seq = new Sequence(Sequence.SMPTE_24, 67, 9);
    Track tr = seq.createTrack();
    assertEquals(1, tr.size());
    MidiEvent event1 = new MidiEvent(new MidiMessage1(new byte[] {1, 2, 3}), 10L);
    MidiEvent event2 = new MidiEvent(new MidiMessage1(new byte[] {23, -16, 4}), 0);
    MidiEvent event3 = new MidiEvent(new MidiMessage1(new byte[] {3, -67, -1}), 6L);
    tr.add(event1);
    tr.add(event2); 
    tr.add(event3);
    assertEquals(4, tr.size());
    tr.add(event1); //false; it contains already
    assertEquals(4, tr.size());
    tr.remove(event1);
    tr.remove(event2);
    assertEquals(2, tr.size());
    tr.remove(event3);
    tr.remove(tr.get(0));
    assertEquals(0, tr.size());
    tr.add(new MidiEvent(new MidiMessage1(new byte[] {-1, 47, 0}), 6L));
    assertEquals(1, tr.size());
    tr.remove(tr.get(0));
    assertEquals(0, tr.size());
    try {
        tr.add(event1);
        fail("ArrayIndexOutOfBoundsException expected");
    } catch (ArrayIndexOutOfBoundsException e) {}
    assertEquals(1, tr.size());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:37,代码来源:TrackTest.java

示例3: test_ticks

import javax.sound.midi.Track; //导入方法依赖的package包/类
/**
 * test method ticks()
 * @throws Exception
 */
public void test_ticks() throws Exception {
    /*
     * create an empty Track
     */
    Sequence seq = new Sequence(Sequence.SMPTE_24, 67, 9);
    Track tr = seq.createTrack();
    assertEquals(0, tr.ticks());
    MidiEvent event1 = new MidiEvent(new MidiMessage1(new byte[] {1, 2, 3}), -10L);
    MidiEvent event2 = new MidiEvent(new MidiMessage1(new byte[] {23, -16, 4}), 2L);
    MidiEvent event3 = new MidiEvent(new MidiMessage1(new byte[] {3, -67, -1}), 6L);
    /*
     * values of Track.ticks() only positive;
     * value of Track.ticks() is the biggest value of ticks of events that
     * contain in the Track; 
     * if I remove event with the biggest value of 
     * tick, value that return method Track.ticks() will be the same
     */
    tr.add(event1);
    assertEquals(0, tr.ticks());
    tr.add(event2);
    assertEquals(2, tr.ticks());
    tr.add(event3);
    assertEquals(6, tr.ticks());
    tr.remove(event3); //I remove event with the biggest tick,...
    assertEquals(6, tr.ticks()); //...but value that return method Track.ticks() the same
    tr.remove(event2);
    tr.remove(event1);
    assertEquals(6, tr.ticks()); //and even now...
    tr.add(event2);
    assertEquals(6, tr.ticks()); //and now...
    tr.remove(tr.get(1));
    tr.remove(event2);
    assertEquals(0, tr.size()); //Track is empty
    assertEquals(0, tr.ticks()); //Track is empty, value that return Track.ticks() equals 0
}
 
开发者ID:shannah,项目名称:cn1,代码行数:40,代码来源:TrackTest.java


注:本文中的javax.sound.midi.Track.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。