Esempio n. 1
0
  private void readChannel(TGSong song, TGTrack track) {
    TGChannel channel = this.factory.newChannel();
    TGChannelParameter gmChannel1Param = this.factory.newChannelParameter();
    TGChannelParameter gmChannel2Param = this.factory.newChannelParameter();

    // leo el canal
    int channel1 = (readByte() & 0xff);
    gmChannel1Param.setKey(GMChannelRoute.PARAMETER_GM_CHANNEL_1);
    gmChannel1Param.setValue(Integer.toString(channel1));

    // leo el canal de efectos
    int channel2 = (readByte() & 0xff);
    gmChannel2Param.setKey(GMChannelRoute.PARAMETER_GM_CHANNEL_2);
    gmChannel2Param.setValue(Integer.toString(channel2));

    // Parseo el banco de sonidos
    channel.setBank(channel1 == 9 ? TGChannel.DEFAULT_PERCUSSION_BANK : TGChannel.DEFAULT_BANK);

    // leo el instrumento
    channel.setProgram(readByte());

    // leo el volumen
    channel.setVolume(readByte());

    // leo el balance
    channel.setBalance(readByte());

    // leo el chorus
    channel.setChorus(readByte());

    // leo el reverb
    channel.setReverb(readByte());

    // leo el phaser
    channel.setPhaser(readByte());

    // leo el tremolo
    channel.setTremolo(readByte());

    // ------------------------------------------//
    for (int i = 0; i < song.countChannels(); i++) {
      TGChannel channelAux = song.getChannel(i);
      for (int n = 0; n < channelAux.countParameters(); n++) {
        TGChannelParameter channelParameter = channelAux.getParameter(n);
        if (channelParameter.getKey().equals(GMChannelRoute.PARAMETER_GM_CHANNEL_1)) {
          if (Integer.toString(channel1).equals(channelParameter.getValue())) {
            channel.setChannelId(channelAux.getChannelId());
          }
        }
      }
    }
    if (channel.getChannelId() <= 0) {
      channel.setChannelId(song.countChannels() + 1);
      channel.setName(("#" + channel.getChannelId()));
      channel.addParameter(gmChannel1Param);
      channel.addParameter(gmChannel2Param);
      song.addChannel(channel);
    }
    track.setChannelId(channel.getChannelId());
  }
 public void updateParameters(TGChannel tgChannel, TGChannelParameter tgChannelParameter) {
   try {
     getOutputTransmitter()
         .sendParameter(
             tgChannel.getChannelId(), tgChannelParameter.getKey(), tgChannelParameter.getValue());
   } catch (MidiPlayerException e) {
     e.printStackTrace();
   }
 }