Java 类com.sun.media.sound.MidiUtils 实例源码

项目:maestro    文件:TempoPanel.java   
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;
    }
}
项目:maestro    文件:TempoPanel.java   
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;
}
项目:maestro    文件:SequenceInfo.java   
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;
}
项目:maestro    文件:SequenceDataCache.java   
@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);
}
项目:maestro    文件:SequenceDataCache.java   
@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);
}
项目:maestro    文件:SequencerWrapper.java   
@Override public long microsToTick(long micros)
{
    if (getSequence() == null)
        return 0;

    return MidiUtils.microsecond2tick(getSequence(), micros, tempoCache);
}
项目:maestro    文件:SequencerWrapper.java   
@Override public long tickToMicros(long tick)
{
    if (getSequence() == null)
        return 0;

    return MidiUtils.tick2microsecond(getSequence(), tick, tempoCache);
}
项目:maestro    文件:SequencerWrapper.java   
public long getDragTick()
{
    if (getSequence() == null)
        return 0;

    return MidiUtils.microsecond2tick(getSequence(), getDragPosition(), tempoCache);
}
项目:maestro    文件:SequencerWrapper.java   
public void setDragTick(long tick)
{
    if (getSequence() == null)
        return;

    setDragPosition(MidiUtils.tick2microsecond(getSequence(), tick, tempoCache));
}
项目:Zong    文件:JseMidiSequenceWriter.java   
@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);
}
项目:OpenJSharp    文件:Track.java   
private ImmutableEndOfTrack() {
    super(new byte[3]);
    data[0] = (byte) META;
    data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
    data[2] = 0;
}
项目:OpenJSharp    文件:Sequence.java   
/**
 * 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);
}
项目:jdk8u-jdk    文件:Track.java   
private ImmutableEndOfTrack() {
    super(new byte[3]);
    data[0] = (byte) META;
    data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
    data[2] = 0;
}
项目:jdk8u-jdk    文件:Sequence.java   
/**
 * 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);
}
项目:openjdk-jdk10    文件:Track.java   
private ImmutableEndOfTrack() {
    super(new byte[3]);
    data[0] = (byte) META;
    data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
    data[2] = 0;
}
项目:openjdk9    文件:Track.java   
private ImmutableEndOfTrack() {
    super(new byte[3]);
    data[0] = (byte) META;
    data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
    data[2] = 0;
}
项目:Java8CN    文件:Track.java   
private ImmutableEndOfTrack() {
    super(new byte[3]);
    data[0] = (byte) META;
    data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
    data[2] = 0;
}
项目:Java8CN    文件:Sequence.java   
/**
 * 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);
}
项目:jdk8u_jdk    文件:Track.java   
private ImmutableEndOfTrack() {
    super(new byte[3]);
    data[0] = (byte) META;
    data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
    data[2] = 0;
}
项目:jdk8u_jdk    文件:Sequence.java   
/**
 * 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);
}
项目:lookaside_java-1.8.0-openjdk    文件:Track.java   
private ImmutableEndOfTrack() {
    super(new byte[3]);
    data[0] = (byte) META;
    data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
    data[2] = 0;
}
项目:lookaside_java-1.8.0-openjdk    文件:Sequence.java   
/**
 * 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);
}
项目:infobip-open-jdk-8    文件:Track.java   
private ImmutableEndOfTrack() {
    super(new byte[3]);
    data[0] = (byte) META;
    data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
    data[2] = 0;
}
项目:infobip-open-jdk-8    文件:Sequence.java   
/**
 * 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);
}
项目:jdk8u-dev-jdk    文件:Track.java   
private ImmutableEndOfTrack() {
    super(new byte[3]);
    data[0] = (byte) META;
    data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
    data[2] = 0;
}
项目:jdk8u-dev-jdk    文件:Sequence.java   
/**
 * 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);
}
项目:maestro    文件:TempoPanel.java   
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);
}
项目:maestro    文件:TimingInfo.java   
/**
 * 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)));
}
项目:maestro    文件:TimingInfo.java   
public int getTempoBPM()
{
    return (int) Math.round(MidiUtils.convertTempo(tempoMPQ));
}
项目:maestro    文件:TimingInfo.java   
public int getExportTempoBPM()
{
    return (int) Math.round(MidiUtils.convertTempo((double) tempoMPQ / exportTempoFactor));
}
项目:maestro    文件:QuantizedTimingInfo.java   
public int getPrimaryTempoBPM()
{
    return (int) Math.round(MidiUtils.convertTempo(getPrimaryTempoMPQ()));
}
项目:maestro    文件:QuantizedTimingInfo.java   
public int getPrimaryExportTempoBPM()
{
    return (int) Math.round(MidiUtils.convertTempo((double) primaryTempoMPQ / exportTempoFactor));
}
项目:maestro    文件:QuantizedTimingInfo.java   
@Override public long tickToMicros(long tick)
{
    TimingInfoEvent e = getTimingEventForTick(tick);
    return e.micros + MidiUtils.ticks2microsec(tick - e.tick, e.info.getTempoMPQ(), e.info.getResolutionPPQ());
}
项目:maestro    文件:QuantizedTimingInfo.java   
@Override public long microsToTick(long micros)
{
    TimingInfoEvent e = getTimingEventForMicros(micros);
    return e.tick + MidiUtils.microsec2ticks(micros - e.micros, e.info.getTempoMPQ(), e.info.getResolutionPPQ());
}
项目:maestro    文件:SequenceInfo.java   
public int getPrimaryTempoBPM()
{
    return (int) Math.round(MidiUtils.convertTempo(getPrimaryTempoMPQ()));
}
项目:maestro    文件:SequenceDataCache.java   
public int getTempoBPM(long tick)
{
    return (int) Math.round(MidiUtils.convertTempo(getTempoMPQ(tick)));
}
项目:maestro    文件:SequenceDataCache.java   
public int getPrimaryTempoBPM()
{
    return (int) Math.round(MidiUtils.convertTempo(getPrimaryTempoMPQ()));
}
项目:maestro    文件:SequenceDataCache.java   
public int getMinTempoBPM()
{
    return (int) Math.round(MidiUtils.convertTempo(getMinTempoMPQ()));
}
项目:maestro    文件:SequenceDataCache.java   
public int getMaxTempoBPM()
{
    return (int) Math.round(MidiUtils.convertTempo(getMaxTempoMPQ()));
}
项目:jdk7-jdk    文件:Track.java   
private ImmutableEndOfTrack() {
    super(new byte[3]);
    data[0] = (byte) META;
    data[1] = MidiUtils.META_END_OF_TRACK_TYPE;
    data[2] = 0;
}