private PatternElement createNewPatternElement ( int pattNum , int row , int channel , int note ) { PatternElement pe = new PatternElement ( pattNum , row , channel ) ; pe . setInstrument ( ( note & 0xF80000 ) >> 19 ) ; int oktave = ( note & 0xF0000000 ) >> 28 ; if ( oktave != - 1 ) { int ton = ( note & 0x0F000000 ) >> 24 ; int index = ( oktave + 3 ) * 12 + ton ; // fit to it octaves pe . setPeriod ( ( index < Helpers . noteValues . length ) ? Helpers . noteValues [ index ] : 0 ) ; pe . setNoteIndex ( index + 1 ) ; } else { pe . setPeriod ( 0 ) ; pe . setNoteIndex ( 0 ) ; } pe . setEffekt ( ( note & 0xF00 ) >> 8 ) ; pe . setEffektOp ( note & 0xFF ) ; if ( pe . getEffekt ( ) == 0x01 ) // set Tempo needs correction. Do not ask why! { int effektOp = pe . getEffektOp ( ) ; pe . setEffektOp ( ( ( effektOp & 0x0F ) << 4 ) | ( ( effektOp & 0xF0 ) >> 4 ) ) ; } int volume = ( ( note & 0x70000 ) >> 16 ) | ( ( note & 0xF000 ) >> 9 ) ; if ( volume <= 64 ) { pe . setVolumeEffekt ( 1 ) ; pe . setVolumeEffektOp ( volume ) ; } return pe ; }
Read the STM pattern data