Beispiel #1
0
        public static Pattern[,] LoadPatterns(Project project, Song song, bool createMissingInstruments, bool createMissingSamples, out Song.PatternCustomSetting[] customSettings)
        {
            var buffer = GetClipboardDataInternal(MagicNumberClipboardPatterns);

            if (buffer == null)
            {
                customSettings = null;
                return(null);
            }

            var decompressedBuffer = Compression.DecompressBytes(buffer, 4);
            var serializer         = new ProjectLoadBuffer(project, decompressedBuffer, Project.Version);

            LoadAndMergeSampleList(serializer, false, createMissingSamples);
            LoadAndMergeInstrumentList(serializer, false, createMissingInstruments);
            LoadAndMergePatternList(serializer, song);

            int numPatterns = 0;
            int numChannels = 0;

            serializer.Serialize(ref numPatterns);
            serializer.Serialize(ref numChannels);

            var patterns = new Pattern[numPatterns, numChannels];

            for (int i = 0; i < numPatterns; i++)
            {
                for (int j = 0; j < numChannels; j++)
                {
                    var patId = -1;
                    serializer.Serialize(ref patId, true);
                    patterns[i, j] = patId == -1 ? null : song.GetPattern(patId);
                }
            }

            var tempoMode         = 0;
            var hasCustomSettings = false;

            serializer.Serialize(ref hasCustomSettings);
            serializer.Serialize(ref tempoMode);

            if (hasCustomSettings && tempoMode == project.TempoMode)
            {
                customSettings = new Song.PatternCustomSetting[numPatterns];
                for (int i = 0; i < numPatterns; i++)
                {
                    customSettings[i] = new Song.PatternCustomSetting();
                    serializer.Serialize(ref customSettings[i].useCustomSettings);
                    serializer.Serialize(ref customSettings[i].patternLength);
                    serializer.Serialize(ref customSettings[i].noteLength);
                    serializer.Serialize(ref customSettings[i].barLength);
                }
            }
            else
            {
                customSettings = null;
            }

            return(patterns);
        }
Beispiel #2
0
        public static Pattern[,] LoadPatterns(Project project, Song song, bool createMissingInstruments)
        {
            var buffer = GetClipboardData(MagicNumberClipboardPatterns);

            if (buffer == null)
            {
                return(null);
            }

            var decompressedBuffer = Compression.DecompressBytes(buffer, 4);
            var serializer         = new ProjectLoadBuffer(project, decompressedBuffer, Project.Version);

            LoadAndMergeInstrumentList(serializer, false, createMissingInstruments);
            int numNonNullPatterns = LoadAndMergePatternList(serializer, song);

            int numPatterns = 0;
            int numChannels = 0;

            serializer.Serialize(ref numPatterns);
            serializer.Serialize(ref numChannels);

            var patterns = new Pattern[numPatterns, numChannels];

            for (int i = 0; i < numPatterns; i++)
            {
                for (int j = 0; j < numChannels; j++)
                {
                    var patId = -1;
                    serializer.Serialize(ref patId, true);
                    patterns[i, j] = patId == -1 ? null : song.GetPattern(patId);
                }
            }

            return(patterns);
        }