Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        private void ReadWbk1Chunk()
        {
            int chunkSize = Util.GetInt(CurrentPcgMemory.Content, Index + 4, 4);

            CurrentPcgMemory.Chunks.Collection.Add(new Chunk("WBK1", Index, chunkSize));

            int startIndex = Index;

            Index += 12; // LV? Wbk1NumberOfWaveSequencesOffset; override for various synths?
            int numberOfWaveSeqsInBank = Util.GetInt(CurrentPcgMemory.Content, Index, 4);

            Index += 4;
            int sizeOfAWaveSeq = Util.GetInt(CurrentPcgMemory.Content, Index, 4);

            // ReSharper disable RedundantStringFormatCall
            Console.WriteLine($" Size of a waveseq: {sizeOfAWaveSeq}");
            // ReSharper restore RedundantStringFormatCall
            Index += 4;
            int bankId    = Util.GetInt(CurrentPcgMemory.Content, Index, 4);
            int bankIndex = WaveSequenceBankId2WaveSequenceIndex(bankId);

            Index += 4;

            WaveSequenceBank waveSeqBank = (WaveSequenceBank)CurrentPcgMemory.WaveSequenceBanks[bankIndex];

            waveSeqBank.ByteOffset = startIndex;
            waveSeqBank.PatchSize  = sizeOfAWaveSeq;
            waveSeqBank.IsWritable = true;
            waveSeqBank.IsLoaded   = true;

            for (int index = 0; index < numberOfWaveSeqsInBank; index++)
            {
                // Place in PcgMemory.
                WaveSequence waveSeq = (WaveSequence)waveSeqBank[index];
                waveSeq.ByteOffset = Index;
                waveSeq.ByteLength = sizeOfAWaveSeq;
                waveSeq.IsLoaded   = true;

                Index += sizeOfAWaveSeq;
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="waveSeqBank"></param>
 /// <param name="index"></param>
 public KronosWaveSequence(WaveSequenceBank waveSeqBank, int index)
     : base(waveSeqBank, index)
 {
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="waveSeqBank"></param>
 /// <param name="index"></param>
 public NautilusWaveSequence(WaveSequenceBank waveSeqBank, int index)
     : base(waveSeqBank, index)
 {
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="lines"></param>
        private void ParseItems(TextWriter writer, List <string> lines)
        {
            foreach (IBank bank in _list)
            {
                string        bankType        = string.Empty;
                string        contentType     = string.Empty;
                string        bankId          = string.Empty;
                int           writablePatches = 0;
                int           filledPatches   = 0;
                int           emptyPatches    = 0;
                List <IPatch> filledPatchList = new List <IPatch>();

                ProgramBank bank1 = bank as ProgramBank;
                if (bank1 != null)
                {
                    ProgramBank programBank = bank1;

                    bankType    = "ProgramBank";
                    bankId      = programBank.Id;
                    contentType =
                        $"{ProgramBank.SynthesisTypeAsString(programBank.BankSynthesisType)} {Strings.Programs}";
                    writablePatches = programBank.Patches.Count(program => programBank.IsWritable);
                    filledPatches   = programBank.CountFilledAndNonEmptyPatches;
                    emptyPatches    = writablePatches - filledPatches;

                    filledPatchList.AddRange(
                        programBank.Patches.Where(program => programBank.IsLoaded && !program.IsEmptyOrInit));
                }
                else
                {
                    CombiBank combiBank1 = bank as CombiBank;
                    if (combiBank1 != null)
                    {
                        CombiBank combiBank = combiBank1;

                        bankType        = "CombiBank";
                        bankId          = combiBank.Id;
                        contentType     = "Combis";
                        writablePatches = combiBank.Patches.Count(combi => combiBank.IsWritable);
                        filledPatches   = combiBank.CountFilledPatches;
                        emptyPatches    = writablePatches - filledPatches;

                        IEnumerable <IPatch> filledCombis = combiBank.Patches.Where(combi => combiBank.IsLoaded && !combi.IsEmptyOrInit);
                        filledPatchList.AddRange(filledCombis);
                    }
                    else
                    {
                        SetList list = bank as SetList;
                        if (list != null)
                        {
                            SetList setList = list;

                            bankType        = "SetList";
                            bankId          = setList.Id;
                            contentType     = "SetListSlots";
                            writablePatches = setList.Patches.Count(setListSlot => setList.IsWritable);
                            filledPatches   = setList.CountFilledPatches;
                            emptyPatches    = writablePatches - filledPatches;

                            filledPatchList.AddRange(setList.Patches.Where(
                                                         setListSlot => setList.IsLoaded && !setListSlot.IsEmptyOrInit));
                        }
                        else
                        {
                            WaveSequenceBank seqBank = bank as WaveSequenceBank;
                            if (seqBank != null)
                            {
                                WaveSequenceBank waveSeqBank = seqBank;

                                bankType        = "WaveSeqBank";
                                bankId          = waveSeqBank.Id;
                                contentType     = "WaveSequences";
                                writablePatches = waveSeqBank.Patches.Count(waveSeq => waveSeqBank.IsWritable);
                                filledPatches   = waveSeqBank.CountFilledPatches;
                                emptyPatches    = writablePatches - filledPatches;

                                filledPatchList.AddRange(waveSeqBank.Patches.Where(
                                                             waveSeq => waveSeqBank.IsLoaded && !waveSeq.IsEmptyOrInit));
                            }
                            else
                            {
                                DrumKitBank kitBank = bank as DrumKitBank;
                                if (kitBank != null)
                                {
                                    DrumKitBank drumKitBank = kitBank;

                                    bankType        = "DrumKitBank";
                                    bankId          = drumKitBank.Id;
                                    contentType     = "DrumKits";
                                    writablePatches = drumKitBank.Patches.Count(drumKit => drumKitBank.IsWritable);
                                    filledPatches   = drumKitBank.CountFilledPatches;
                                    emptyPatches    = writablePatches - filledPatches;

                                    filledPatchList.AddRange(drumKitBank.Patches.Where(
                                                                 drumKit => drumKitBank.IsLoaded && !drumKit.IsEmptyOrInit));
                                }
                                else
                                {
                                    DrumPatternBank patternBank = bank as DrumPatternBank;
                                    if (patternBank != null)
                                    {
                                        DrumPatternBank drumPatternBank = patternBank;

                                        bankType        = "DrumPatternBank";
                                        bankId          = drumPatternBank.Id;
                                        contentType     = "DrumPatterns";
                                        writablePatches = drumPatternBank.Patches.Count(
                                            drumPattern => drumPatternBank.IsWritable);
                                        filledPatches = drumPatternBank.CountFilledPatches;
                                        emptyPatches  = writablePatches - filledPatches;

                                        filledPatchList.AddRange(drumPatternBank.Patches.Where(
                                                                     drumPattern => drumPatternBank.IsLoaded && !drumPattern.IsEmptyOrInit));
                                    }
                                    else
                                    {
                                        Debug.Fail("Error in switch");
                                    }
                                }
                            }
                        }
                    }
                }


                WriteItem(writer, lines, bankType, contentType, bankId, writablePatches, filledPatches, emptyPatches, filledPatchList);
            }
        }