<commit_before>
package micromod;

public class Note {
	public int key, instrument, effect, parameter;

	private static final String  hexToString = "0123456789ABCDEF";
	private static final String  keyToString = "<KEY>";
	private static final byte[]  stringToKey = { -2, 0, 1, 3, 5, 6, 8, 10 };
	private static final short[] keyToPeriod = { 1814,
	/*   C-0   C#0   D-0   D#0   E-0   F-0   F#0   G-0   G#0   A-1  A#1  B-1 */
		1712, 1616, 1524, 1440, 1356, 1280, 1208, 1140, 1076, 1016, 960, 907,
		 856,  808,  762,  720,  678,  640,  604,  570,  538,  508, 480, 453,
		 428,  404,  381,  360,  339,  320,  302,  285,  269,  254, 240, 226,
		 214,  202,  190,  180,  170,  160,  151,  143,  135,  127, 120, 113,
		 107,  101,   95,   90,   85,   80,   75,   71,   67,   63,  60,  56,
		  53,   50,   47,   45,   42,   40,   37,   35,   33,   31,  30,  28,
		  26
	};

	public int getPeriod() {
		int period = 0;
		if( key > 0 && key < 73 ) {
			period = keyToPeriod[ key ];
		}
		return period;
	}
	
	/* Adjust the relative key (0 for no change). */
	public void transpose( int key ) {
		/* Todo: Adjust portamento rates, slide rates and vibrato depth. */
		this.key += key;
	}
	
	/* Set the note volume. The effect command may be replaced. */
	public void setVolume( int volume, Module module ) {
		/* Todo: Adjust, slide rates and tremolo depth. */
		if( instrument != 0 ) {
			effect = 0xC;
			parameter = module.getInstrument( instrument ).getVolume();
		}
		if( effect == 0xC ) {
			parameter = ( parameter * volume ) >> 6;
		}
	}

	public int load( byte[] input, int offset ) {
		int period = ( ( input[ offset ] & 0xF ) << 8 ) | ( input[ offset + 1 ] & 0xFF );<commit_msg>Handle effects in note transpose.<commit_after>
package micromod;

public class Note {
	public int key, instrument, effect, parameter;

	private static final String  hexToString = "0123456789ABCDEF";
	private static final String  keyToString = "<KEY>";
	private static final byte[]  stringToKey = { -2, 0, 1, 3, 5, 6, 8, 10 };
	private static final short[] keyToPeriod = { 1814,
	/*   C-0   C#0   D-0   D#0   E-0   F-0   F#0   G-0   G#0   A-1  A#1  B-1 */
		1712, 1616, 1524, 1440, 1356, 1280, 1208, 1140, 1076, 1016, 960, 907,
		 856,  808,  762,  720,  678,  640,  604,  570,  538,  508, 480, 453,
		 428,  404,  381,  360,  339,  320,  302,  285,  269,  254, 240, 226,
		 214,  202,  190,  180,  170,  160,  151,  143,  135,  127, 120, 113,
		 107,  101,   95,   90,   85,   80,   75,   71,   67,   63,  60,  56,
		  53,   50,   47,   45,   42,   40,   37,   35,   33,   31,  30,  28,
		  26
	};

	public int getPeriod() {
		int period = 0;
		if( key > 0 && key < 73 ) {
			period = keyToPeriod[ key ];
		}
		return period;
	}
	
	/* Adjust the relative pitch (0 for no change). */
	public void transpose( int semitones ) {
		if( key > 0 ) {
			key = key + semitones;
			if( key < 1 ) key = 0;
		}
		if( semitones < -36 ) semitones = -36;
		if( semitones >  36 ) semitones =  36;
		switch( effect ) {
			case 0x1: case 0x2: case 0x3:
				/* Adjust portamento rate.*/
				parameter = parameter * keyToPeriod[ semitones + 37 ] / 214;
				if( parameter > 255 ) parameter = 255;
				break;
			case 0x4:
				/* Adjust vibrato depth.*/
				int depth = ( parameter & 0xF ) * keyToPeriod[ semitones + 37 ] / 214;
				if( depth > 15 ) depth = 15;
				parameter = ( parameter & 0xF0 ) + depth;
				break;
		}
	}
	
	/* Set the note volume. The effect command may be replaced. */
	public void setVolume( int volume, Module module ) {
		if( volume < 0 ) volume = 0;
		if( volume > 64 ) volume = 64;
		if( instrument > 0 && volume < 64 ) {
			effect = 0xC;
			parameter = module.getInstrument( instrument ).getVolume();
		}
		if( effect == 0xC ) {
			parameter = ( parameter * volume ) >> 6;
		}
		/* Todo: Adjust, slide rates and tremolo depth. */
	}

	public int load( byte[] input, int offset ) {
		int period = ( ( input[ offset ] & 0xF ) << 8 ) | ( input[ offset + 1 ] & 0xFF );
{'fraction_non_alphanumeric': 0.14177215189873418, 'fraction_numerical': 0.14126582278481012, 'mean_word_length': 2.368286445012788, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '872961', 'n_tokens_mistral': 2004, 'n_tokens_neox': 1488, 'n_words': 522}