Ejemplo n.º 1
0
  private void sendEnvelopeFrequency(Receiver rx, int channel, byte[] regs) throws Exception {
    int data = (regs[0xc] & 0xff) + ((regs[0xd] << 8) & 0x0f00);
    data = data >> FREQ_SCALE_FACTOR;
    // 16 bit value, divided into 7/7/2

    byte high = (byte) ((data >> 9) & 0x7f); // top 7 bits
    byte med = (byte) ((data >> 7) & 0x7f); // middle 7 bits
    byte low = (byte) (((data >> 2) & 0x03) << 5); // bottom 2 bits

    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_ENVELOPE_FREQ_HIGH, high), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_ENVELOPE_FREQ_MED, med), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_ENVELOPE_FREQ_LOW, low), -1);
  }
Ejemplo n.º 2
0
 private void sendLatch(Receiver rx, int channel, boolean enabled) throws Exception {
   byte value = enabled ? (byte) 64 : (byte) 0;
   if (!enabled) {
     // save registers
     for (int i = 0; i < registers.length; i++) {
       prevRegisters[i] = registers[i];
     }
   }
   rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_LATCH, value), -1);
 }
Ejemplo n.º 3
0
  private void sendFrequency(Receiver rx, int channel, byte[] regs, int startRegister)
      throws Exception {
    int data = (regs[startRegister] & 0xff) + ((regs[startRegister + 1] << 8) & 0x0f00);
    data = data >> FREQ_SCALE_FACTOR;

    byte msb = (byte) ((data >> 5) & 0x7f); // top 7 bits
    byte lsb = (byte) ((data << 2) & 0x7c); // lower 5 bits
    int cc1 = ((startRegister / 2) + CC_CHANNEL_A_FREQ_MSB);
    int cc2 = ((startRegister / 2) + CC_CHANNEL_A_FREQ_LSB);

    rx.send(new ShortMessage(CONTROL_CHANGE, channel, (byte) cc1, msb), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, (byte) cc2, lsb), -1);
  }
Ejemplo n.º 4
0
  private void resetController(Receiver rx, int channel, byte[] regs) throws Exception {
    for (int i = 0; i < 15; i++) {
      regs[i] = 0;
    }

    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_LATCH, 127), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_CHANNEL_A_FREQ_MSB, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_CHANNEL_A_FREQ_LSB, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_CHANNEL_B_FREQ_MSB, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_CHANNEL_B_FREQ_LSB, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_CHANNEL_C_FREQ_MSB, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_CHANNEL_C_FREQ_LSB, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_NOISE_FREQ, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_MIXER, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_CHANNEL_A_LEVEL, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_CHANNEL_B_LEVEL, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_CHANNEL_C_LEVEL, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_ENVELOPE_FREQ_HIGH, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_ENVELOPE_FREQ_MED, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_ENVELOPE_FREQ_LOW, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_ENVELOPE_SHAPE, 0), -1);
    rx.send(new ShortMessage(CONTROL_CHANGE, channel, CC_LATCH, 0), -1);
  }
Ejemplo n.º 5
0
 private void sendValue(Receiver rx, int channel, byte cc, byte value) throws Exception {
   rx.send(new ShortMessage(CONTROL_CHANGE, channel, cc, value), -1);
 }