本文整理汇总了Java中com.sun.media.sound.MidiUtils类的典型用法代码示例。如果您正苦于以下问题:Java MidiUtils类的具体用法?Java MidiUtils怎么用?Java MidiUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MidiUtils类属于com.sun.media.sound包,在下文中一共展示了MidiUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ImmutableEndOfTrack
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
private ImmutableEndOfTrack() {
super(new byte[3]);
data[0] = (byte) META;
data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
data[2] = 0;
}
示例2: updateTempoLabel
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
private void updateTempoLabel()
{
int mpq = sequenceInfo.getDataCache().getTempoMPQ(sequencer.getThumbTick());
int bpm = (int) Math.round(MidiUtils.convertTempo(mpq) * getCurrentTempoFactor());
if (bpm != lastRenderedBPM)
{
currentTempoLabel.setText(bpm + " BPM ");
lastRenderedBPM = bpm;
}
}
示例3: tempoToNoteId
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
private int tempoToNoteId(int tempoMPQ, int minBPM, int maxBPM)
{
int bpm = (int) Math.round(MidiUtils.convertTempo(tempoMPQ));
float tempoFactor = getCurrentTempoFactor();
minBPM = Math.round(minBPM * tempoFactor);
maxBPM = Math.round(maxBPM * tempoFactor);
bpm = Math.round(bpm * tempoFactor);
return (bpm - minBPM) * (Note.MAX.id - Note.MIN.id) / (maxBPM - minBPM) + Note.MIN.id;
}
示例4: fromAbc
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
public static SequenceInfo fromAbc(AbcToMidi.Params params) throws InvalidMidiDataException, ParseException
{
if (params.abcInfo == null)
params.abcInfo = new AbcInfo();
SequenceInfo sequenceInfo = new SequenceInfo(params.filesData.get(0).file.getName(), AbcToMidi.convert(params));
sequenceInfo.title = params.abcInfo.getTitle();
sequenceInfo.composer = params.abcInfo.getComposer();
sequenceInfo.primaryTempoMPQ = (int) Math.round(MidiUtils.convertTempo(params.abcInfo.getPrimaryTempoBPM()));
return sequenceInfo;
}
示例5: tickToMicros
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
@Override public long tickToMicros(long tick)
{
if (divisionType != Sequence.PPQ)
return (long) (TimingInfo.ONE_SECOND_MICROS * ((double) tick / (double) (divisionType * tickResolution)));
TempoEvent te = getTempoEventForTick(tick);
return te.micros + MidiUtils.ticks2microsec(tick - te.tick, te.tempoMPQ, tickResolution);
}
示例6: microsToTick
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
@Override public long microsToTick(long micros)
{
if (divisionType != Sequence.PPQ)
return (long) (divisionType * tickResolution * micros / (double) TimingInfo.ONE_SECOND_MICROS);
TempoEvent te = getTempoEventForMicros(micros);
return te.tick + MidiUtils.microsec2ticks(micros - te.micros, te.tempoMPQ, tickResolution);
}
示例7: microsToTick
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
@Override public long microsToTick(long micros)
{
if (getSequence() == null)
return 0;
return MidiUtils.microsecond2tick(getSequence(), micros, tempoCache);
}
示例8: tickToMicros
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
@Override public long tickToMicros(long tick)
{
if (getSequence() == null)
return 0;
return MidiUtils.tick2microsecond(getSequence(), tick, tempoCache);
}
示例9: getDragTick
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
public long getDragTick()
{
if (getSequence() == null)
return 0;
return MidiUtils.microsecond2tick(getSequence(), getDragPosition(), tempoCache);
}
示例10: setDragTick
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
public void setDragTick(long tick)
{
if (getSequence() == null)
return;
setDragPosition(MidiUtils.tick2microsecond(getSequence(), tick, tempoCache));
}
示例11: tickToMicrosecond
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
@Override public long tickToMicrosecond(long tick) {
//recompute tempo cache if required
if (tempoCache == null)
tempoCache = new TempoCache(sequence);
//compute position
return MidiUtils.tick2microsecond(sequence, tick, tempoCache);
}
示例12: getMicrosecondLength
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
/**
* 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);
}
示例13: TempoPanel
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
public TempoPanel(SequenceInfo sequenceInfo, SequencerWrapper sequencer, SequencerWrapper abcSequencer)
{
super(new TableLayout(LAYOUT_COLS, LAYOUT_ROWS));
TableLayout tableLayout = (TableLayout) getLayout();
tableLayout.setHGap(TrackPanel.HGAP);
setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, ColorTable.PANEL_BORDER.get()));
this.sequenceInfo = sequenceInfo;
this.sequencer = sequencer;
this.abcSequencer = abcSequencer;
int minBPM = 50;
int maxBPM = 200;
for (TempoEvent event : sequenceInfo.getDataCache().getTempoEvents().values())
{
int bpm = (int) Math.round(MidiUtils.convertTempo(event.tempoMPQ));
if (bpm < minBPM)
minBPM = bpm;
if (bpm > maxBPM)
maxBPM = bpm;
}
JPanel gutter = new JPanel();
gutter.setOpaque(true);
gutter.setBackground(ColorTable.PANEL_HIGHLIGHT_OTHER_PART.get());
this.tempoGraph = new TempoNoteGraph(sequenceInfo, sequencer, minBPM, maxBPM);
setBackground(ColorTable.GRAPH_BACKGROUND_DISABLED.get());
JLabel titleLabel = new JLabel("Tempo");
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
titleLabel.setForeground(ColorTable.PANEL_TEXT_DISABLED.get());
currentTempoLabel = new JLabel();
currentTempoLabel.setForeground(ColorTable.PANEL_TEXT_DISABLED.get());
updateTempoLabel();
add(gutter, GUTTER_COLUMN + ", 0");
add(titleLabel, TITLE_COLUMN + ", 0");
add(currentTempoLabel, TEMPO_COLUMN + ", 0, R, C");
add(tempoGraph, GRAPH_COLUMN + ", 0");
sequencer.addChangeListener(sequencerListener);
abcSequencer.addChangeListener(sequencerListener);
}
示例14: roundTempoMPQ
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
/**
* Rounds the given MPQ tempo so it corresponds to a whole-number of beats per minute.
*/
public static double roundTempoMPQ(double tempoMPQ)
{
return MidiUtils.convertTempo(Math.round(MidiUtils.convertTempo(tempoMPQ)));
}
示例15: getTempoBPM
import com.sun.media.sound.MidiUtils; //导入依赖的package包/类
public int getTempoBPM()
{
return (int) Math.round(MidiUtils.convertTempo(tempoMPQ));
}