Ejemplo n.º 1
0
 private void readMidiChannels()
 {
     /*Read MIDI channels.
      *
      * Guitar Pro format provides 64 channels(4 MIDI ports by 16
      * channels), the channels are stored in this order:
      *
      * -port1 / channel1
      * - port1 / channel2
      * - ...
      * - port1 / channel16
      * - port2 / channel1
      * - ...
      * - port4 / channel16
      *
      * Each channel has the following form:
      * -Instrument: :ref:`int`.
      * -Volume: :ref:`byte`.
      * -Balance: :ref:`byte`.
      * -Chorus: :ref:`byte`.
      * -Reverb: :ref:`byte`.
      * -Phaser: :ref:`byte`.
      * -Tremolo: :ref:`byte`.
      * -blank1: :ref:`byte`.
      * -blank2: :ref:`byte`.*/
     MidiChannel[] _channels = new MidiChannel[64];
     for (int i = 0; i < 64; i++)
     {
         var newChannel = new MidiChannel();
         newChannel.channel       = i;
         newChannel.effectChannel = i;
         var instrument = GPBase.readInt()[0];
         if (newChannel.isPercussionChannel() && instrument == -1)
         {
             instrument = 0;
         }
         newChannel.instrument = instrument;
         newChannel.volume     = toChannelShort(GPBase.readByte()[0]);
         newChannel.balance    = toChannelShort(GPBase.readByte()[0]);
         newChannel.chorus     = toChannelShort(GPBase.readByte()[0]);
         newChannel.reverb     = toChannelShort(GPBase.readByte()[0]);
         newChannel.phaser     = toChannelShort(GPBase.readByte()[0]);
         newChannel.tremolo    = toChannelShort(GPBase.readByte()[0]);
         _channels[i]          = newChannel;
         GPBase.skip(2);
     }
     channels = _channels;
 }
Ejemplo n.º 2
0
    private MidiChannel readChannel(MidiChannel[] channels)
    { /*Read MIDI channel.
       *
       * MIDI channel in Guitar Pro is represented by two integers. First
       * is zero-based number of channel, second is zero-based number of
       * channel used for effects.*/
        var         index         = GPBase.readInt()[0] - 1;
        MidiChannel trackChannel  = new MidiChannel();
        var         effectChannel = GPBase.readInt()[0] - 1;

        if (0 <= index && index < channels.Length)
        {
            trackChannel = channels[index];
            if (trackChannel.instrument < 0)
            {
                trackChannel.instrument = 0;
            }
            if (!trackChannel.isPercussionChannel())
            {
                trackChannel.effectChannel = effectChannel;
            }
        }
        return(trackChannel);
    }