예제 #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);
  }
 public void wdgmsg(Widget sender, String msg, Object... args) {
   int id;
   synchronized (this) {
     if (!rwidgets.containsKey(sender))
       throw (new UIException(
           "Wdgmsg sender (" + sender.getClass().getName() + ") is not in rwidgets", msg, args));
     id = rwidgets.get(sender);
   }
   if (rcvr != null) rcvr.rcvmsg(id, msg, args);
 }
예제 #3
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);
 }
예제 #4
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);
  }
예제 #5
0
 public void connect(String user, String pass) {
   if (!connected) {
     try {
       socket = new Socket(domain, 4446);
       out = new PrintWriter(socket.getOutputStream(), true);
       // in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
       in = new ObjectInputStream(socket.getInputStream());
     } catch (java.net.UnknownHostException e) {
       System.err.println("Don't know about host");
       return;
     } catch (IOException e) {
       System.err.println("Couldn't get I/O for the connection to");
       return;
     }
     this.connected = true;
     rec = new Receiver(in);
     rec.start();
   }
 }
예제 #6
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);
  }
예제 #7
0
 private void sendValue(Receiver rx, int channel, byte cc, byte value) throws Exception {
   rx.send(new ShortMessage(CONTROL_CHANGE, channel, cc, value), -1);
 }
예제 #8
0
 /**
  * Test for the presence of incoming packets.
  *
  * @return true if there are packets available to be received.
  */
 public boolean incoming() {
   return rcvr.incoming();
 }
예제 #9
0
 /**
  * Retrieve the next packet from the substrate.
  *
  * @return the next incoming packet
  */
 public Packet receive() {
   return rcvr.receive();
 }
예제 #10
0
 /** Wait for Substrate to stop. */
 public void join() throws Exception {
   sndr.join();
   rcvr.join();
 }
예제 #11
0
 /** Start Substrate running. */
 public void start() {
   sndr.start();
   rcvr.start();
 }