Esempio n. 1
0
 /// <summary>
 /// This constructs an InputNoteDef that, when the noteOff arrives, turns off all the trks it has turned on. 
 /// </summary>
 /// <param name="notatedMidiPitch">In range 0..127</param>
 /// <param name="noteOnSeqDefs">Must contain at least one SeqDef</param>
 /// <param name="pressures">Can be null or empty</param>
 /// <param name="inputControls">Can be null</param>
 public InputNoteDef(byte notatedMidiPitch, TrkOns noteOnSeqDef, Pressures pressures, InputControls inputControls)
     : this(notatedMidiPitch, noteOnSeqDef, null, pressures, null, null, inputControls)
 {
     Debug.Assert(noteOnSeqDef != null);
     List<TrkOff> trkOffs = new List<TrkOff>();
     foreach(TrkOn trkOn in NoteOnTrkOns)
     {
         TrkOff trkOff = new TrkOff(trkOn.TrkMidiChannel, trkOn.TrkMsPosition, inputControls);
         trkOffs.Add(trkOff);
     }
     NoteOffTrkOffs = new TrkOffs(trkOffs, null);
 }
Esempio n. 2
0
        /// <summary>
        /// This constructs an InputNoteDef that, when the noteOff arrives, turns off all the trks it has turned on.
        /// </summary>
        /// <param name="notatedMidiPitch">In range 0..127</param>
        /// <param name="noteOnSeqDefs">Must contain at least one SeqDef</param>
        /// <param name="pressures">Can be null or empty</param>
        /// <param name="inputControls">Can be null</param>
        public InputNoteDef(byte notatedMidiPitch, TrkOns noteOnSeqDef, Pressures pressures, InputControls inputControls)
            : this(notatedMidiPitch, noteOnSeqDef, null, pressures, null, null, inputControls)
        {
            Debug.Assert(noteOnSeqDef != null);
            List <TrkOff> trkOffs = new List <TrkOff>();

            foreach (TrkOn trkOn in NoteOnTrkOns)
            {
                TrkOff trkOff = new TrkOff(trkOn.TrkMidiChannel, trkOn.TrkMsPosition, inputControls);
                trkOffs.Add(trkOff);
            }
            NoteOffTrkOffs = new TrkOffs(trkOffs, null);
        }
Esempio n. 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="notatedMidiPitch">In range 0..127</param>
        /// <param name="noteOnTrkOns">Can be null or empty</param>
        /// <param name="noteOnTrkOffs">Can be null or empty</param>
        /// <param name="pressures">Can be null or empty</param>
        /// <param name="noteOffTrkOns">Can be null or empty</param>
        /// <param name="noteOffTrkOffs">Can be null or empty</param>
        /// <param name="inputControls">Can be null</param>
        public InputNoteDef(byte notatedMidiPitch,
							TrkOns noteOnTrkOns, TrkOffs noteOnTrkOffs,
							Pressures pressures,
							TrkOns noteOffTrkOns, TrkOffs noteOffTrkOffs,
							InputControls inputControls)
        {
            Debug.Assert(notatedMidiPitch >= 0 && notatedMidiPitch <= 127);
            // If inputControls is null, the higher level inputControls are used.

            NotatedMidiPitch = notatedMidiPitch;
            NoteOnTrkOns = noteOnTrkOns;
            NoteOnTrkOffs = noteOnTrkOffs;
            NotePressures = pressures;
            NoteOffTrkOns = noteOffTrkOns;
            NoteOffTrkOffs = noteOffTrkOffs;
            InputControls = inputControls;
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="notatedMidiPitch">In range 0..127</param>
        /// <param name="noteOnTrkOns">Can be null or empty</param>
        /// <param name="noteOnTrkOffs">Can be null or empty</param>
        /// <param name="pressures">Can be null or empty</param>
        /// <param name="noteOffTrkOns">Can be null or empty</param>
        /// <param name="noteOffTrkOffs">Can be null or empty</param>
        /// <param name="inputControls">Can be null</param>
        public InputNoteDef(byte notatedMidiPitch,
                            TrkOns noteOnTrkOns, TrkOffs noteOnTrkOffs,
                            Pressures pressures,
                            TrkOns noteOffTrkOns, TrkOffs noteOffTrkOffs,
                            InputControls inputControls)
        {
            Debug.Assert(notatedMidiPitch >= 0 && notatedMidiPitch <= 127);
            // If inputControls is null, the higher level inputControls are used.

            NotatedMidiPitch = notatedMidiPitch;
            NoteOnTrkOns     = noteOnTrkOns;
            NoteOnTrkOffs    = noteOnTrkOffs;
            NotePressures    = pressures;
            NoteOffTrkOns    = noteOffTrkOns;
            NoteOffTrkOffs   = noteOffTrkOffs;
            InputControls    = inputControls;
        }
Esempio n. 5
0
        List<VoiceDef> CreateBar1()
        {
            List<VoiceDef> bar = new List<VoiceDef>();

            byte channel = 0;
            foreach(Palette palette in _palettes)
            {
                TrkDef trkDef = new TrkDef(channel, new List<IUniqueDef>());
                bar.Add(trkDef);
                WriteVoiceMidiDurationDefs1(trkDef, palette);
                ++channel;
            }

            InputVoiceDef inputVoiceDef = new InputVoiceDef();
            VoiceDef bottomOutputVoice = bar[0];

            foreach(IUniqueDef iud in bottomOutputVoice.UniqueDefs)
            {
                MidiChordDef mcd = iud as MidiChordDef;
                RestDef rd = iud as RestDef;
                if(mcd != null)
                {
                    List<IUniqueDef> iuds = new List<IUniqueDef>() { (IUniqueDef)mcd };

                    // Note that the msPosition of the trkDef is trkDef.StartMsPosition (= iuds[0].msPosition),
                    // which may be greater than the InputChordDef's msPosition
                    TrkDef trkDef = new TrkDef(bottomOutputVoice.MidiChannel, iuds);

                    // If non-null, arg2 overrides the inputControls attached to the InputNote or InputChord.
                    TrkOn trkRef = new TrkOn(trkDef, null);
                    List<TrkOn> trkRefs = new List<TrkOn>() { trkRef };
                    TrkOns trkOns = new TrkOns(trkRefs, null);

                    byte displayPitch = (byte)(mcd.NotatedMidiPitches[0] + 36);
                    Pressure pressure = new Pressure(0, null);
                    Pressures pressures = new Pressures(new List<Pressure>() {pressure}, null);
                    TrkOff trkOff = new TrkOff(trkRef.TrkMidiChannel, mcd.MsPosition, null);
                    List<TrkOff> noteOffTrkOffs = new List<TrkOff>() { trkOff };
                    TrkOffs trkOffs = new TrkOffs(noteOffTrkOffs, null);

                    InputNoteDef inputNoteDef = new InputNoteDef(displayPitch,
                                                                    trkOns, null,
                                                                    pressures,
                                                                    null, trkOffs,
                                                                    null);

                    List<InputNoteDef> inputNoteDefs = new List<InputNoteDef>() { inputNoteDef };

                    // The InputChordDef's msPosition must be <= the msPosition of any of the contained trkRefs
                    InputChordDef icd = new InputChordDef(mcd.MsPosition, mcd.MsDuration, inputNoteDefs);

                    inputVoiceDef.UniqueDefs.Add(icd);
                }
                else if(rd != null)
                {
                    RestDef newRest = new RestDef(rd.MsPosition, rd.MsDuration);
                    inputVoiceDef.UniqueDefs.Add(newRest);
                }
            }

            #region set cascading inputControls on the first InputChordDef  (for testing)
            InputChordDef inputChordDef1 = inputVoiceDef.UniqueDefs[0] as InputChordDef; // no need to check for null here.

            InputControls chordInputControls = new InputControls();

            chordInputControls.VelocityOption = VelocityOption.overridden;
            chordInputControls.MinimumVelocity = 19;
            inputChordDef1.InputControls = chordInputControls;

            InputControls noteInputControls = new InputControls();
            noteInputControls.VelocityOption = VelocityOption.scaled;
            noteInputControls.MinimumVelocity = 20;
            inputChordDef1.InputNoteDefs[0].InputControls = noteInputControls;

            #endregion

            bar.Add(inputVoiceDef);

            return bar;
        }