Java Code Examples for javax.sound.midi.Patch#getProgram()

The following examples show how to use javax.sound.midi.Patch#getProgram() . 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: DLSSoundbank.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch) patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch) patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
Example 2
Source File: SF2Soundbank.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch)patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch) patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
Example 3
Source File: SimpleSoundbank.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch)patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch)patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
Example 4
Source File: SimpleSoundbank.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch)patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch)patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
Example 5
Source File: DLSSoundbank.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch) patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch) patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
Example 6
Source File: SF2Soundbank.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Instrument getInstrument(Patch patch) {
    int program = patch.getProgram();
    int bank = patch.getBank();
    boolean percussion = false;
    if (patch instanceof ModelPatch)
        percussion = ((ModelPatch)patch).isPercussion();
    for (Instrument instrument : instruments) {
        Patch patch2 = instrument.getPatch();
        int program2 = patch2.getProgram();
        int bank2 = patch2.getBank();
        if (program == program2 && bank == bank2) {
            boolean percussion2 = false;
            if (patch2 instanceof ModelPatch)
                percussion2 = ((ModelPatch) patch2).isPercussion();
            if (percussion == percussion2)
                return instrument;
        }
    }
    return null;
}
 
Example 7
Source File: ModelAbstractOscillator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Instrument getInstrument(Patch patch) {
    Instrument ins = getInstrument();
    Patch p = ins.getPatch();
    if (p.getBank() != patch.getBank())
        return null;
    if (p.getProgram() != patch.getProgram())
        return null;
    if (p instanceof ModelPatch && patch instanceof ModelPatch) {
        if (((ModelPatch)p).isPercussion()
                != ((ModelPatch)patch).isPercussion()) {
            return null;
        }
    }
    return ins;
}
 
Example 8
Source File: ModelInstrumentComparator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public int compare(Instrument arg0, Instrument arg1) {
    Patch p0 = arg0.getPatch();
    Patch p1 = arg1.getPatch();
    int a = p0.getBank() * 128 + p0.getProgram();
    int b = p1.getBank() * 128 + p1.getProgram();
    if (p0 instanceof ModelPatch) {
        a += ((ModelPatch)p0).isPercussion() ? 2097152 : 0;
    }
    if (p1 instanceof ModelPatch) {
        b += ((ModelPatch)p1).isPercussion() ? 2097152 : 0;
    }
    return a - b;
}
 
Example 9
Source File: SF2Instrument.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setPatch(Patch patch) {
    if (patch instanceof ModelPatch && ((ModelPatch) patch).isPercussion()) {
        bank = 128;
        preset = patch.getProgram();
    } else {
        bank = patch.getBank() >> 7;
        preset = patch.getProgram();
    }
}
 
Example 10
Source File: ModelInstrument.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public final Patch getPatchAlias() {
    Patch patch = getPatch();
    int program = patch.getProgram();
    int bank = patch.getBank();
    if (bank != 0)
        return patch;
    boolean percussion = false;
    if (getPatch() instanceof ModelPatch)
        percussion = ((ModelPatch)getPatch()).isPercussion();
    if (percussion)
        return new Patch(0x78 << 7, program);
    else
        return new Patch(0x79 << 7, program);
}
 
Example 11
Source File: SimpleInstrument.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setPatch(Patch patch) {
    if (patch instanceof ModelPatch && ((ModelPatch)patch).isPercussion()) {
        percussion = true;
        bank = patch.getBank();
        preset = patch.getProgram();
    } else {
        percussion = false;
        bank = patch.getBank();
        preset = patch.getProgram();
    }
}
 
Example 12
Source File: ModelAbstractOscillator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Instrument getInstrument(Patch patch) {
    Instrument ins = getInstrument();
    Patch p = ins.getPatch();
    if (p.getBank() != patch.getBank())
        return null;
    if (p.getProgram() != patch.getProgram())
        return null;
    if (p instanceof ModelPatch && patch instanceof ModelPatch) {
        if (((ModelPatch)p).isPercussion()
                != ((ModelPatch)patch).isPercussion()) {
            return null;
        }
    }
    return ins;
}
 
Example 13
Source File: DLSInstrument.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setPatch(Patch patch) {
    if (patch instanceof ModelPatch && ((ModelPatch)patch).isPercussion()) {
        druminstrument = true;
        bank = patch.getBank();
        preset = patch.getProgram();
    } else {
        druminstrument = false;
        bank = patch.getBank();
        preset = patch.getProgram();
    }
}
 
Example 14
Source File: ModelInstrumentComparator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public int compare(Instrument arg0, Instrument arg1) {
    Patch p0 = arg0.getPatch();
    Patch p1 = arg1.getPatch();
    int a = p0.getBank() * 128 + p0.getProgram();
    int b = p1.getBank() * 128 + p1.getProgram();
    if (p0 instanceof ModelPatch) {
        a += ((ModelPatch)p0).isPercussion() ? 2097152 : 0;
    }
    if (p1 instanceof ModelPatch) {
        b += ((ModelPatch)p1).isPercussion() ? 2097152 : 0;
    }
    return a - b;
}
 
Example 15
Source File: SF2Instrument.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setPatch(Patch patch) {
    if (patch instanceof ModelPatch && ((ModelPatch) patch).isPercussion()) {
        bank = 128;
        preset = patch.getProgram();
    } else {
        bank = patch.getBank() >> 7;
        preset = patch.getProgram();
    }
}
 
Example 16
Source File: ModelInstrument.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public final Patch getPatchAlias() {
    Patch patch = getPatch();
    int program = patch.getProgram();
    int bank = patch.getBank();
    if (bank != 0)
        return patch;
    boolean percussion = false;
    if (getPatch() instanceof ModelPatch)
        percussion = ((ModelPatch)getPatch()).isPercussion();
    if (percussion)
        return new Patch(0x78 << 7, program);
    else
        return new Patch(0x79 << 7, program);
}
 
Example 17
Source File: SimpleInstrument.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setPatch(Patch patch) {
    if (patch instanceof ModelPatch && ((ModelPatch)patch).isPercussion()) {
        percussion = true;
        bank = patch.getBank();
        preset = patch.getProgram();
    } else {
        percussion = false;
        bank = patch.getBank();
        preset = patch.getProgram();
    }
}
 
Example 18
Source File: DLSInstrument.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void setPatch(Patch patch) {
    if (patch instanceof ModelPatch && ((ModelPatch)patch).isPercussion()) {
        druminstrument = true;
        bank = patch.getBank();
        preset = patch.getProgram();
    } else {
        druminstrument = false;
        bank = patch.getBank();
        preset = patch.getProgram();
    }
}
 
Example 19
Source File: SoftSynthesizer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private String patchToString(Patch patch) {
    if (patch instanceof ModelPatch && ((ModelPatch) patch).isPercussion())
        return "p." + patch.getProgram() + "." + patch.getBank();
    else
        return patch.getProgram() + "." + patch.getBank();
}
 
Example 20
Source File: SoftSynthesizer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private String patchToString(Patch patch) {
    if (patch instanceof ModelPatch && ((ModelPatch) patch).isPercussion())
        return "p." + patch.getProgram() + "." + patch.getBank();
    else
        return patch.getProgram() + "." + patch.getBank();
}