Exemple #1
0
      private void sendMusic() {
        Midi midi = null;

        if (editor != null) {
          midi = editor.getSelection(true, true);
        }

        if (midi == null) {
          CommonDialog.showOkay(this, "Please select some music and try again.");
          return;
        }

        String base64 = midi.toBase64();
        String errorMessage = sendBlocks(sessionName, base64);
        if (errorMessage == null) {
          MusicMessageListElement musicMessageListElement =
              new MusicMessageListElement(new Date(), userId, midi);
          addRecentMessage(musicMessageListElement);
          messageTextField.setText("");
        }
      }
Exemple #2
0
 private Midi receiveBlocks(MessageBuffer messageBuffer, String message) {
   Midi midi = null;
   try {
     int comma = message.indexOf(',', RSJM.length());
     int equals = message.indexOf('=', comma);
     int blockNumber = Integer.parseInt(message.substring(RSJM.length(), comma));
     int blockCount = Integer.parseInt(message.substring(comma + 1, equals));
     String block = message.substring(equals + 1);
     messageBuffer.addBlock(blockNumber, blockCount, block);
     if (messageBuffer.getBlockCount() == blockCount) {
       String base64 = messageBuffer.consume();
       midi = Midi.fromBase64(base64);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return midi;
 }
Exemple #3
0
 public MusicMessageListElement(Date timestamp, String user, Midi midi) {
   this.timestamp = timestamp;
   this.user = user;
   this.midi = midi;
   this.text = "Music message containing " + midi.size() + " elements";
 }