예제 #1
0
        public void AddTrack(string TrackName, List <TLBaseKeyFrame> KeyFrames)
        {
            Track t = new Track();

            MetaTextBuilder mtBuilder = new MetaTextBuilder(MetaType.TrackName, TrackName);

            mtBuilder.Build();
            t.Insert(0, mtBuilder.Result);

            foreach (TLMidiKeyFrame mk in KeyFrames)
            {
                ChannelMessageBuilder cmBuilder = new ChannelMessageBuilder();
                cmBuilder.Command     = ChannelCommand.NoteOn;
                cmBuilder.MidiChannel = mk.Channel;
                cmBuilder.Data1       = mk.Note;
                cmBuilder.Data2       = mk.Velocity;
                cmBuilder.Build();
                t.Insert((int)(mk.Time / SecondsPerMidiUnit), cmBuilder.Result);

                cmBuilder.Command = ChannelCommand.NoteOff;
                cmBuilder.Data1   = mk.Note;
                cmBuilder.Data2   = 0;
                cmBuilder.Build();
                t.Insert((int)(mk.End / SecondsPerMidiUnit), cmBuilder.Result);
            }

            FSequence.Add(t);
        }
예제 #2
0
        private Sequence CreateSequence()
        {
            if (tunes == null || tunes.Count < 2)
            {
                return(null);
            }

            selectedTune = 1;

            SetDefaultValues();
            nextNote = TimeSpan.Zero;
            SetHeaderValues();
            SetHeaderValues(selectedTune, true);
            StartMeasure();

            sequence        = new Sequence(Ppqn);
            sequence.Format = 1;
            metaTrack       = new Track();
            mainTrack       = new Track();
            sequence.Add(metaTrack);
            TempoChangeBuilder tempoBuilder = new TempoChangeBuilder();

            tempoBuilder.Tempo = Tempo;
            tempoBuilder.Build();
            metaTrack.Insert(0, tempoBuilder.Result);
            TimeSignatureBuilder timeBuilder = new TimeSignatureBuilder();

            timeBuilder.Numerator   = timeSigNumerator;
            timeBuilder.Denominator = timeSigDenominator;
            timeBuilder.Build();
            metaTrack.Insert(0, timeBuilder.Result);
            sequence.Add(mainTrack);

            MetaTextBuilder textBuilder = new MetaTextBuilder();

            textBuilder.Type = MetaType.TrackName;
            textBuilder.Text = "Tempo Track";
            textBuilder.Build();
            metaTrack.Insert(0, textBuilder.Result);

            textBuilder      = new MetaTextBuilder();
            textBuilder.Type = MetaType.TrackName;
            textBuilder.Text = "Tune 1";
            textBuilder.Build();
            mainTrack.Insert(0, textBuilder.Result);

            while (tokenIndex < tokens.Count)
            {
                AddNextNote();
            }

            return(sequence);
        }