コード例 #1
0
  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 boolean isPercussionChannel(TGSong song, int channelId) {
   Iterator it = song.getChannels();
   while (it.hasNext()) {
     TGChannel channel = (TGChannel) it.next();
     if (channel.getChannelId() == channelId) {
       return channel.isPercussionChannel();
     }
   }
   return false;
 }
コード例 #3
0
 public int getPercussionChannelId() {
   Iterator tgChannels = this.songManager.getSong().getChannels();
   while (tgChannels.hasNext()) {
     TGChannel tgChannel = (TGChannel) tgChannels.next();
     if (tgChannel.isPercussionChannel()) {
       return tgChannel.getChannelId();
     }
   }
   return -1;
 }
コード例 #4
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;
  }