    001
    002    package ibxm;
    003
    004    public class Module {
    005        public String song_title;
    006        public boolean linear_periods, fast_volume_slides, pal;
    007        public int global_volume, channel_gain;
    008        public int default_speed, default_tempo;
    009        public int restart_sequence_index;
    010
    011        private int[] initial_panning, sequence;
    012        private Pattern[] patterns;
    013        private Instrument[] instruments;
    014
    015        private Pattern default_pattern;
    016        private Instrument default_instrument;
    017
    018        public Module() {
    019            song_title = IBXM.VERSION;
    020            set_num_channels( 1 );
    021            set_sequence_length( 1 );
    022            set_num_patterns( 0 );
    023            set_num_instruments( 0 );
    024            default_pattern = new Pattern();
    025            default_instrument = new Instrument();
    026        }
    027
    028        public int get_num_channels() {
    029            return initial_panning.length;
    030        }
    031
    032        public void set_num_channels( int num_channels ) {
    033            if( num_channels < 1 ) {
    034                num_channels = 1;
    035            }
    036            initial_panning = new int[ num_channels ];
    037        }
    038
    039        public int get_initial_panning( int channel ) {
    040            int panning;
    041            panning = 128;
    042            if( channel >= 0 && channel < initial_panning.length ) {
    043                panning = initial_panning[ channel ];
    044            }
    045            return panning;
    046        }
    047
    048        public void set_initial_panning( int channel, int panning ) {
    049            if( channel >= 0 && channel < initial_panning.length ) {
    050                initial_panning[ channel ] = panning;
    051            }
    052        }
    053
    054        public int get_sequence_length() {
    055            return sequence.length;
    056        }
    057
    058        public void set_sequence_length( int sequence_length ) {
    059            if( sequence_length < 0 ) {
    060                sequence_length = 0;
    061            }
    062            sequence = new int[ sequence_length ];
    063        }
    064
    065        public void set_sequence( int sequence_index, int pattern_index ) {
    066            if( sequence_index >= 0 && sequence_index < sequence.length ) {
    067                sequence[ sequence_index ] = pattern_index;
    068            }
    069        }
    070
    071        public int get_num_patterns() {
    072            return patterns.length;
    073        }
    074
    075        public void set_num_patterns( int num_patterns ) {
    076            if( num_patterns < 0 ) {
    077                num_patterns = 0;
    078            }
    079            patterns = new Pattern[ num_patterns ];
    080        }
    081
    082        public Pattern get_pattern_from_sequence( int sequence_index ) {
    083            Pattern pattern;
    084            pattern = default_pattern;
    085            if( sequence_index >= 0 && sequence_index < sequence.length ) {
    086                pattern = get_pattern( sequence[ sequence_index ] );
    087            }
    088            return pattern;
    089        }
    090
    091        public Pattern get_pattern( int pattern_index ) {
    092            Pattern pattern;
    093            pattern = null;
    094            if( pattern_index >= 0 && pattern_index < patterns.length ) {
    095                pattern = patterns[ pattern_index ];
    096            }
    097            if( pattern == null ) {
    098                pattern = default_pattern;
    099            }
    100            return pattern;
    101        }
    102
    103        public void set_pattern( int pattern_index, Pattern pattern ) {
    104            if( pattern_index >= 0 && pattern_index < patterns.length ) {
    105                patterns[ pattern_index ] = pattern;
    106            }
    107        }
    108
    109        public int get_num_instruments() {
    110            return instruments.length;
    111        }
    112
    113        public void set_num_instruments( int num_instruments ) {
    114            if( num_instruments < 0 ) {
    115                num_instruments = 0;
    116            }
    117            instruments = new Instrument[ num_instruments ];
    118        }
    119
    120        public Instrument get_instrument( int instrument_index ) {
    121            Instrument instrument;
    122            instrument = null;
    123            if( instrument_index > 0 && instrument_index <= instruments.length ) {
    124                instrument = instruments[ instrument_index - 1 ];
    125            }
    126            if( instrument == null ) {
    127                instrument = default_instrument;
    128            }
    129            return instrument;
    130        }
    131
    132        public void set_instrument( int instrument_index, Instrument instrument ) {
    133            if( instrument_index > 0 && instrument_index <= instruments.length ) {
    134                instruments[ instrument_index - 1 ] = instrument;
    135            }
    136        }
    137    }
    138