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()); } }
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()); }