private void readChannel(TGSong song, TGTrack track, List channels) throws IOException {
    int index = (readInt() - 1);
    int effectChannel = (readInt() - 1);
    if (index >= 0 && index < channels.size()) {
      TGChannel channel = getFactory().newChannel();

      ((TGChannel) channels.get(index)).copy(channel);
      if (channel.getProgram() < 0) {
        channel.setProgram((short) 0);
      }
      if (!channel.isPercussionChannel()) {
        channel.setEffectChannel((short) effectChannel);
      }

      // ------------------------------------------//
      for (int i = 0; i < song.countChannels(); i++) {
        TGChannel channelAux = song.getChannel(i);
        if (channelAux.getChannel() == channel.getChannel()) {
          channel.setChannelId(channelAux.getChannelId());
        }
      }
      if (channel.getChannelId() <= 0) {
        channel.setChannelId(song.countChannels() + 1);
        channel.setName(("#" + channel.getChannelId()));
        song.addChannel(channel);
      }
      track.setChannelId(channel.getChannelId());
    }
  }
示例#2
0
  private TGChannel readChannel(List<TGChannel> channels) throws IOException {
    TGChannel result = null;

    int index = (readInt() - 1);
    int effectChannel = (readInt() - 1);
    if (index >= 0 && index < channels.size()) {
      result = channels.get(index).clone();
      if (result.getInstrument() < 0) {
        result.setInstrument((short) 0);
      }
      if (!result.isPercussionChannel()) {
        result.setEffectChannel((short) effectChannel);
      }
    }

    return result;
  }
 private List readChannels() throws IOException {
   List channels = new ArrayList();
   for (int i = 0; i < 64; i++) {
     TGChannel channel = getFactory().newChannel();
     channel.setChannel((short) i);
     channel.setEffectChannel((short) i);
     channel.setProgram((short) readInt());
     channel.setVolume(toChannelShort(readByte()));
     channel.setBalance(toChannelShort(readByte()));
     channel.setChorus(toChannelShort(readByte()));
     channel.setReverb(toChannelShort(readByte()));
     channel.setPhaser(toChannelShort(readByte()));
     channel.setTremolo(toChannelShort(readByte()));
     channels.add(channel);
     skip(2);
   }
   return channels;
 }