コード例 #1
0
ファイル: sample.cs プロジェクト: vince94/it2amk
        public void load(byte[] data, int offset, int sample_count)
        {
            try {
                show_verbose("Loading sample {0}...", sample_count + 1);

                if (to_string(data, offset, 4) != "IMPS")
                {
                    throw new InvalidFileException("This is not a valid IT module file. (Incorrect sample header.)");
                }

                _load_metadata(data, offset);
                SampleInfo sp = _load_flags(data, offset);
                _load_mixing_info(data, offset);
                _load_loop_info(data, offset);
                _load_vibrato_info(data, offset);

                if (!has_sample)
                {
                    return;
                }

                if (sp.stereo)
                {
                    show_warning("Sample {0} ({1}) is a stereo sample. It will be changed to mono for conversion.",
                                 sample_count + 1, name);
                }

                if (sus_looped)
                {
                    show_warning("Sample {0} ({1}) has a sustain loop. It will be ignored.",
                                 sample_count + 1, name);
                }

                int length = to_int32(data, offset + 0x30);
                _load_sample_data(data, to_int32(data, offset + 0x48), length, sp.is_16bit, sp.stereo, sp.signed);
            } catch (ArgumentOutOfRangeException) {
                throw new InvalidFileException("This is not a valid IT module file (Out of range error).");
            } catch (IndexOutOfRangeException) {
                throw new InvalidFileException("This is not a valid IT module file (Out of range error).");
            }
        }