  * Read the next line in the pattern from the current file position.
  */
 void readLine() {
-  // Reset note data on each channel.
-  for (byte i = 0; i < 9; i ++) {
-    channelNote[i] = 0x0000;
-  }
-
-  // If the previous line was the last line of the pattern then we're done.
-  if (endOfPattern) {
-    return;
-  }
-
-  // If the next line number does not match our current line then it's empty
-  // so there's nothing to do for us here.
-  byte lineNumber = radFile.read();
-  if ((lineNumber & 0x3F) != line) {
-    radFile.seekSet(radFile.curPosition() - 1);
-    return;
-  }
-
-  // Set end of pattern marker if this is the last line in the pattern.
-  endOfPattern = lineNumber & 0x80;
-
-  // Read note and effect data for each channel.
-  bool isLastChannel = false;
-  do {
-    byte channelNumber = radFile.read();
-    isLastChannel = channelNumber & 0x80;
-    channelNumber = channelNumber & 0x0F;
-
-    channelNote[channelNumber]  = radFile.read() << 8;
-    channelNote[channelNumber] += radFile.read();
-    if (channelNote[channelNumber] & 0x000F) {
-      efftectParameter[channelNumber] = radFile.read();
-    } else {
-      efftectParameter[channelNumber] = 0x00;
-    }
-  } while(!isLastChannel);
+	// Reset note data on each channel.
+	for (byte i = 0; i < 9; i ++) {
+		channelNote[i] = 0x0000;
+	}
+
+	// If the previous line was the last line of the pattern then we're done.
+	if (endOfPattern) {
+		return;
+	}
+
+	// If the next line number does not match our current line then it's empty
+	// so there's nothing to do for us here.
+	byte lineNumber = radFile.read();
+	if ((lineNumber & 0x3F) != line) {
+		radFile.seekSet(radFile.curPosition() - 1);
+		return;
+	}
+
+	// Set end of pattern marker if this is the last line in the pattern.
+	endOfPattern = lineNumber & 0x80;
+
+	// Read note and effect data for each channel.
+	bool isLastChannel = false;
+	do {
+		byte channelNumber = radFile.read();
+		isLastChannel = channelNumber & 0x80;
+		channelNumber = channelNumber & 0x0F;
+
+		channelNote[channelNumber]  = radFile.read() << 8;
+		channelNote[channelNumber] += radFile.read();
+		if (channelNote[channelNumber] & 0x000F) {
+			efftectParameter[channelNumber] = radFile.read();
+		} else {
+			efftectParameter[channelNumber] = 0x00;
+		}
+	} while(!isLastChannel);
 }
 
 

 * Load instrument data for the given channel.
 */
void setInstrument(byte channel, byte instrumentIndex) {
  byte registerOffset;

  registerOffset = opl2.getRegisterOffset(channel, CARRIER);
  opl2.setRegister(0x20 + registerOffset, instruments[instrumentIndex][0]);
  opl2.setRegister(0x40 + registerOffset, instruments[instrumentIndex][2]);
  opl2.setRegister(0x60 + registerOffset, instruments[instrumentIndex][4]);
  opl2.setRegister(0x80 + registerOffset, instruments[instrumentIndex][6]);
  opl2.setRegister(0xE0 + registerOffset, instruments[instrumentIndex][9] & 0x0F);

  registerOffset = opl2.getRegisterOffset(channel, MODULATOR);
  opl2.setRegister(0x20 + registerOffset, instruments[instrumentIndex][1]);
  opl2.setRegister(0x40 + registerOffset, instruments[instrumentIndex][3]);
  opl2.setRegister(0x60 + registerOffset, instruments[instrumentIndex][5]);
  opl2.setRegister(0x80 + registerOffset, instruments[instrumentIndex][7]);
  opl2.setRegister(0xE0 + registerOffset, (instruments[instrumentIndex][9] & 0xF0) >> 4);

  opl2.setRegister(0xC0 + channel, instruments[instrumentIndex][8]);
}



 * Slide the pitch of a channel by a given F-number amount and return the new block + F-number.
 */
unsigned int pitchAdjust(byte channel, short amount) {
	byte block = opl2.getBlock(channel);
	short fNumber = opl2.getFNumber(channel);
	fNumber = max(0x000, min(fNumber + amount, 0x3FF));

	// Drop one octave (if possible) when the F-number drops below octave minimum.
	if (fNumber < FNUMBER_MIN) {
		if (block > 0) {
			block --;
			fNumber = FNUMBER_MAX - (FNUMBER_MIN - fNumber);
		}

	// Increase one octave (if possible) when the F-number reaches above octave maximum.
	} else if (fNumber > FNUMBER_MAX) {
		if (block < 7) {
			block ++;
			fNumber = FNUMBER_MIN + (fNumber - FNUMBER_MAX);
		}
	}

	// Set new octave and frequency and return combind octave + F-number value.
	opl2.setBlock(channel, block);
	opl2.setFNumber(channel, fNumber);
	return (block << 12) + fNumber;
}


