예제 #1
0
        public void PatternToConsole()
        {
            int    offset  = 0;
            int    channel = 0;
            byte   row     = 0;
            XMNote xmnote  = new XMNote();

            while (offset < PatternData.Length)
            {
                xmnote.TryParseNextNoteFrom(ref offset, PatternData);
                if (channel == 0)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write(row.ToString("D2"));
                    Console.ResetColor();
                    Console.Write("|");
                }
                xmnote.ToConsole();
                channel++;
                if (channel == xmheader.NumberOfChannels)
                {
                    channel = 0;
                    row++;
                    Console.WriteLine();
                }
            }
        }
예제 #2
0
        public ITFHeader ToITF()
        {
            ITFHeader result = new ITFHeader();

            result.BeatPerMinute = Header.DefaultBPM;
            result.TickPerRow    = Header.DefaultTempo;

            foreach (var pat in Patterns)
            {
                ITFPattern itfp         = new ITFPattern();
                bool       emptypattern = true;
                for (int row = 0; row < pat.NumberOfRows; row++)
                {
                    ITFRow itfr     = new ITFRow();
                    bool   emptyrow = true;
                    for (int channel = 0; channel < Header.NumberOfChannels; channel++)
                    {
                        XMNote  xmnote = pat.PatArr[row, channel];
                        ITFNote itfn   = null;

                        if (xmnote != null)
                        {
                            emptyrow     = false;
                            emptypattern = false;
                            itfn         = new ITFNote();
                            if (xmnote.Instrument != 0)
                            {
                                itfn.Instrument = xmnote.Instrument;
                            }
                            if (xmnote.Note != 0)
                            {
                                itfn.Note = xmnote.Note;
                            }
                            itfn.Volume      = xmnote.Volume;
                            itfn.NoteOff     = xmnote.noteoff;
                            itfn.Effect      = xmnote.Effect;
                            itfn.EffectParam = xmnote.EffectParam;
                        }
                        itfr.Channels.Add(itfn);
                    }
                    if (emptyrow)
                    {
                        itfr = null;
                    }
                    itfp.Rows.Add(itfr);
                }
                if (emptypattern)
                {
                    itfp = null;
                }
                result.Patterns.Add(itfp);
            }

            foreach (byte item in Header.PatternOrderTable)
            {
                result.PlayOrder.Add(result.Patterns[item]);
            }

            return(result);
        }
예제 #3
0
        private void PatternToArray()
        {
            patarr = new XMNote[NumberOfRows, xmheader.NumberOfChannels];
            int  offset  = 0;
            int  channel = 0;
            byte row     = 0;


            while (offset < PatternData.Length)
            {
                XMNote xmnote = new XMNote();
                PatArr[row, channel] = xmnote;
                xmnote.TryParseNextNoteFrom(ref offset, PatternData);
                channel++;
                if (channel == xmheader.NumberOfChannels)
                {
                    channel = 0;
                    row++;
                }
            }
        }