示例#1
0
        public OrnamentSettings(PaletteForm paletteform)
        {
            OrnamentsForm osf = paletteform.OrnamentsForm;

            Debug.Assert(osf != null && osf.Ornaments != null);

            BasicChordFormSettings bcs = new BasicChordFormSettings();

            /// relative durations
            bcs.Durations = M.StringToIntList(osf.BasicChordControl.DurationsTextBox.Text, ',');
            /// velocity increments
            bcs.Velocities = M.StringToByteList(osf.BasicChordControl.VelocitiesTextBox.Text, ',');
            /// transposition intervals
            bcs.MidiPitches             = M.StringToByteList(osf.BasicChordControl.MidiPitchesTextBox.Text, ',');
            bcs.ChordOffs               = M.StringToBoolList(osf.BasicChordControl.ChordOffsTextBox.Text, ',');
            bcs.ChordDensities          = M.StringToByteList(osf.BasicChordControl.ChordDensitiesTextBox.Text, ',');
            bcs.Inversions              = paletteform.GetLinearInversions(osf.BasicChordControl.RootInversionTextBox.Text);
            bcs.InversionIndices        = M.StringToIntList(osf.BasicChordControl.InversionIndicesTextBox.Text, ',');
            bcs.VerticalVelocityFactors = M.StringToFloatList(osf.BasicChordControl.VerticalVelocityFactorsTextBox.Text, ',');

            BasicChordMidiSettings = new BasicChordMidiSettings(bcs);
            // if BankIndices or PatchIndices != null, their values override the values in the upper BasicMidiChord
            if (osf.BankIndicesTextBox.Text == "")
            {
                BankIndices = null;
            }
            else
            {
                BankIndices = M.StringToByteList(osf.BankIndicesTextBox.Text, ',');
            }
            if (osf.PatchIndicesTextBox.Text == "")
            {
                PatchIndices = null;
            }
            else
            {
                PatchIndices = M.StringToByteList(osf.PatchIndicesTextBox.Text, ',');
            }

            OrnamentValues = osf.Ornaments;
        }
示例#2
0
        public Palette(PaletteForm paletteForm)
        {
            BasicChordFormSettings bcfs = new BasicChordFormSettings();

            bcfs.Durations               = M.StringToIntList(paletteForm.BasicChordControl.DurationsTextBox.Text, ',');
            bcfs.Velocities              = M.StringToByteList(paletteForm.BasicChordControl.VelocitiesTextBox.Text, ',');
            bcfs.MidiPitches             = M.StringToByteList(paletteForm.BasicChordControl.MidiPitchesTextBox.Text, ',');
            bcfs.ChordOffs               = M.StringToBoolList(paletteForm.BasicChordControl.ChordOffsTextBox.Text, ',');
            bcfs.ChordDensities          = M.StringToByteList(paletteForm.BasicChordControl.ChordDensitiesTextBox.Text, ',');
            bcfs.Inversions              = paletteForm.GetLinearInversions(paletteForm.BasicChordControl.RootInversionTextBox.Text);
            bcfs.InversionIndices        = M.StringToIntList(paletteForm.BasicChordControl.InversionIndicesTextBox.Text, ',');
            bcfs.VerticalVelocityFactors = M.StringToFloatList(paletteForm.BasicChordControl.VerticalVelocityFactorsTextBox.Text, ',');

            _basicChordMidiSettings = new BasicChordMidiSettings(bcfs);

            _bankIndices              = M.StringToByteList(paletteForm.BankIndicesTextBox.Text, ',');
            _patchIndices             = M.StringToByteList(paletteForm.PatchIndicesTextBox.Text, ',');
            _pitchwheelDeviations     = M.StringToByteList(paletteForm.PitchwheelDeviationsTextBox.Text, ',');
            _pitchwheelEnvelopes      = M.StringToByteLists(paletteForm.PitchwheelEnvelopesTextBox.Text);
            _panEnvelopes             = M.StringToByteLists(paletteForm.PanEnvelopesTextBox.Text);
            _modulationWheelEnvelopes = M.StringToByteLists(paletteForm.ModulationWheelEnvelopesTextBox.Text);
            _expressionEnvelopes      = M.StringToByteLists(paletteForm.ExpressionEnvelopesTextBox.Text);

            _ornamentNumbers        = M.StringToIntList(paletteForm.OrnamentNumbersTextBox.Text, ',');
            _ornamentMinMsDurations = M.StringToIntList(paletteForm.MinMsDurationsTextBox.Text, ',');

            _ornamentSettings = null;
            if (paletteForm.OrnamentsForm != null)
            {
                _ornamentSettings = new OrnamentSettings(paletteForm);
            }

            for (int chordIndex = 0; chordIndex < _basicChordMidiSettings.Durations.Count; ++chordIndex)
            {
                DurationDef dd = GetDurationDef(chordIndex);
                _durationDefs.Add(dd);
            }

            _isPercussionPalette = paletteForm.IsPercussionPalette;
        }
示例#3
0
文件: Palette.cs 项目: notator/Moritz
        /// <summary>
        /// A temporary palette containing a single DurationDef.
        /// Used just to construct the single DurationDef with the existing code.
        /// </summary>
        /// <param name="paletteChordForm"></param>
        public Palette(PaletteChordForm paletteChordForm)
        {
            BasicChordFormSettings bcfs = new BasicChordFormSettings();
            bcfs.Durations = M.StringToIntList(paletteChordForm.DurationTextBox.Text, ',');
            bcfs.Velocities = M.StringToByteList(paletteChordForm.VelocityTextBox.Text, ',');
            bcfs.MidiPitches = M.StringToByteList(paletteChordForm.BaseMidiPitchTextBox.Text,  ',');
            bcfs.ChordOffs = M.StringToBoolList(paletteChordForm.ChordOffTextBox.Text, ',');
            bcfs.ChordDensities = M.StringToByteList(paletteChordForm.ChordDensityTextBox.Text, ',');
            bcfs.Inversions = paletteChordForm.PaletteForm.GetLinearInversions(paletteChordForm.PaletteForm.BasicChordControl.RootInversionTextBox.Text);
            bcfs.InversionIndices = M.StringToIntList(paletteChordForm.InversionIndexTextBox.Text, ',');
            bcfs.VerticalVelocityFactors = M.StringToFloatList(paletteChordForm.VerticalVelocityFactorTextBox.Text, ',');

            _basicChordMidiSettings = new BasicChordMidiSettings(bcfs);

            _bankIndices = M.StringToByteList(paletteChordForm.BankIndexTextBox.Text, ',');
            _patchIndices = M.StringToByteList(paletteChordForm.PatchIndexTextBox.Text, ',');
            _pitchwheelDeviations = M.StringToByteList(paletteChordForm.PitchwheelDeviationTextBox.Text, ',');

            _pitchwheelEnvelopes = M.StringToByteLists(paletteChordForm.PitchwheelEnvelopeTextBox.Text);
            _panEnvelopes = M.StringToByteLists(paletteChordForm.PanEnvelopeTextBox.Text);
            _modulationWheelEnvelopes = M.StringToByteLists(paletteChordForm.ModulationWheelEnvelopeTextBox.Text);
            _expressionEnvelopes = M.StringToByteLists(paletteChordForm.ExpressionEnvelopeTextBox.Text);

            _ornamentNumbers = M.StringToIntList(paletteChordForm.OrnamentNumberTextBox.Text, ',');
            _ornamentMinMsDurations = M.StringToIntList(paletteChordForm.MinMsDurationTextBox.Text, ',');

            _ornamentSettings = null;
            if(paletteChordForm.PaletteForm.OrnamentsForm != null)
            {
                _ornamentSettings = new OrnamentSettings(paletteChordForm.PaletteForm);
            }

            DurationDef dd = GetDurationDef(0);
            _durationDefs.Add(dd);
        }
示例#4
0
文件: Palette.cs 项目: notator/Moritz
        public Palette(PaletteForm paletteForm)
        {
            Name = paletteForm.PaletteName;

            BasicChordFormSettings bcfs = new BasicChordFormSettings();
            bcfs.Durations = M.StringToIntList(paletteForm.BasicChordControl.DurationsTextBox.Text, ',');
            bcfs.Velocities = M.StringToByteList(paletteForm.BasicChordControl.VelocitiesTextBox.Text, ',');
            bcfs.MidiPitches = M.StringToByteList(paletteForm.BasicChordControl.MidiPitchesTextBox.Text, ',');
            bcfs.ChordOffs = M.StringToBoolList(paletteForm.BasicChordControl.ChordOffsTextBox.Text, ',');
            bcfs.ChordDensities = M.StringToByteList(paletteForm.BasicChordControl.ChordDensitiesTextBox.Text, ',');
            bcfs.Inversions = paletteForm.GetLinearInversions(paletteForm.BasicChordControl.RootInversionTextBox.Text);
            bcfs.InversionIndices = M.StringToIntList(paletteForm.BasicChordControl.InversionIndicesTextBox.Text, ',');
            bcfs.VerticalVelocityFactors = M.StringToFloatList(paletteForm.BasicChordControl.VerticalVelocityFactorsTextBox.Text, ',');

            _basicChordMidiSettings = new BasicChordMidiSettings(bcfs);

            _bankIndices = M.StringToByteList(paletteForm.BankIndicesTextBox.Text, ',');
            _patchIndices = M.StringToByteList(paletteForm.PatchIndicesTextBox.Text, ',');
            _pitchwheelDeviations = M.StringToByteList(paletteForm.PitchwheelDeviationsTextBox.Text, ',');
            _pitchwheelEnvelopes = M.StringToByteLists(paletteForm.PitchwheelEnvelopesTextBox.Text);
            _panEnvelopes = M.StringToByteLists(paletteForm.PanEnvelopesTextBox.Text);
            _modulationWheelEnvelopes = M.StringToByteLists(paletteForm.ModulationWheelEnvelopesTextBox.Text);
            _expressionEnvelopes = M.StringToByteLists(paletteForm.ExpressionEnvelopesTextBox.Text);

            _ornamentNumbers = M.StringToIntList(paletteForm.OrnamentNumbersTextBox.Text, ',');
            _ornamentMinMsDurations = M.StringToIntList(paletteForm.MinMsDurationsTextBox.Text, ',');

            _ornamentSettings = null;
            if(paletteForm.OrnamentsForm != null)
            {
                _ornamentSettings = new OrnamentSettings(paletteForm);
            }

            for(int chordIndex = 0; chordIndex < _basicChordMidiSettings.Durations.Count; ++chordIndex)
            {
                DurationDef dd = GetDurationDef(chordIndex);
                _durationDefs.Add(dd);
            }

            _isPercussionPalette = paletteForm.IsPercussionPalette;
        }
示例#5
0
文件: Palette.cs 项目: notator/Moritz
        public OrnamentSettings(PaletteForm paletteform)
        {
            OrnamentsForm osf = paletteform.OrnamentsForm;
            Debug.Assert(osf != null && osf.Ornaments != null);

            BasicChordFormSettings bcs = new BasicChordFormSettings();
            /// relative durations
            bcs.Durations = M.StringToIntList(osf.BasicChordControl.DurationsTextBox.Text, ',');
            /// velocity increments
            bcs.Velocities = M.StringToByteList(osf.BasicChordControl.VelocitiesTextBox.Text, ',');
            /// transposition intervals
            bcs.MidiPitches = M.StringToByteList(osf.BasicChordControl.MidiPitchesTextBox.Text, ',');
            bcs.ChordOffs = M.StringToBoolList(osf.BasicChordControl.ChordOffsTextBox.Text, ',');
            bcs.ChordDensities = M.StringToByteList(osf.BasicChordControl.ChordDensitiesTextBox.Text, ',');
            bcs.Inversions = paletteform.GetLinearInversions(osf.BasicChordControl.RootInversionTextBox.Text);
            bcs.InversionIndices = M.StringToIntList(osf.BasicChordControl.InversionIndicesTextBox.Text, ',');
            bcs.VerticalVelocityFactors = M.StringToFloatList(osf.BasicChordControl.VerticalVelocityFactorsTextBox.Text, ',');

            BasicChordMidiSettings = new BasicChordMidiSettings(bcs);
            // if BankIndices or PatchIndices != null, their values override the values in the upper BasicMidiChord
            if(osf.BankIndicesTextBox.Text == "")
            {
                BankIndices = null;
            }
            else
            {
                BankIndices = M.StringToByteList(osf.BankIndicesTextBox.Text, ',');
            }
            if(osf.PatchIndicesTextBox.Text == "")
            {
                PatchIndices = null;
            }
            else
            {
                PatchIndices = M.StringToByteList(osf.PatchIndicesTextBox.Text, ',');
            }

            OrnamentValues = osf.Ornaments;
        }
示例#6
0
        /// <summary>
        /// Returns either a new RestDef or a new MidiChordDef
        /// In both cases, MsPosition is set to zero, Lyric is set to null.
        /// </summary>
        private DurationDef GetDurationDef(int index)
        {
            DurationDef            rval = null;
            BasicChordMidiSettings bcms = _basicChordMidiSettings;

            if (bcms.MidiPitches[index].Count == 0)
            {
                /// RestDefs are immutable, and have no MsPosition property.
                /// UniqueRestDefs are mutable RestDefs with both MsPositon and MsDuration properties.
                int restMsDuration = bcms.Durations[index];
                rval = new RestDef(0, restMsDuration);
            }
            else
            {
                /// Create a new MidiChordDef (with msPosition=0, lyric=null)
                bool        hasChordOff        = BoolOrDefaultValue(bcms.ChordOffs, index, M.DefaultHasChordOff); // true
                int         duration           = bcms.Durations[index];
                List <byte> rootMidiPitches    = bcms.MidiPitches[index];
                List <byte> rootMidiVelocities = bcms.Velocities[index];

                byte?       bankIndex               = ByteOrNull(_bankIndices, index);
                byte?       patchIndex              = ByteOrNull(_patchIndices, index);
                byte        pitchwheelDeviation     = ByteOrDefaultValue(_pitchwheelDeviations, index, M.DefaultPitchWheelDeviation); // 2
                List <byte> pitchwheelEnvelope      = ListByte(_pitchwheelEnvelopes, index);
                List <byte> panEnvelope             = ListByte(_panEnvelopes, index);
                List <byte> modulationWheelEnvelope = ListByte(_modulationWheelEnvelopes, index);
                List <byte> expressionEnvelope      = ListByte(_expressionEnvelopes, index);

                MidiChordSliderDefs midiChordSliderDefs =
                    new MidiChordSliderDefs(pitchwheelEnvelope,
                                            panEnvelope,
                                            modulationWheelEnvelope,
                                            expressionEnvelope);

                OrnamentSettings         os = _ornamentSettings;
                List <BasicMidiChordDef> basicMidiChordDefs = new List <BasicMidiChordDef>();
                int ornamentNumber;
                if (os == null || _ornamentNumbers[index] == 0)
                {
                    ornamentNumber = 0;
                    BasicMidiChordDef bmcd = new BasicMidiChordDef(duration, bankIndex, patchIndex, hasChordOff, rootMidiPitches, rootMidiVelocities);
                    basicMidiChordDefs.Add(bmcd);
                }
                else
                {
                    ornamentNumber = _ornamentNumbers[index];
                    int ornamentMinMsDuration = IntOrDefaultValue(_ornamentMinMsDurations, index, M.DefaultOrnamentMinimumDuration); // 1

                    List <int> ornamentValues = os.OrnamentValues[_ornamentNumbers[index] - 1];

                    for (int i = 0; i < ornamentValues.Count; ++i)
                    {
                        int         oIndex       = ornamentValues[i] - 1;
                        bool        oHasChordOff = BoolOrDefaultValue(os.BasicChordMidiSettings.ChordOffs, oIndex, M.DefaultHasChordOff);
                        int         oDuration    = os.BasicChordMidiSettings.Durations[oIndex];
                        List <byte> oMidiPitches = os.BasicChordMidiSettings.MidiPitches[oIndex];
                        List <byte> oVelocities  = os.BasicChordMidiSettings.Velocities[oIndex];
                        byte?       oBank        = ByteOrNull(os.BankIndices, oIndex);
                        byte?       oPatch       = ByteOrNull(os.PatchIndices, oIndex);

                        BasicMidiChordDef bmcd = new BasicMidiChordDef(oDuration, oBank, oPatch, oHasChordOff, oMidiPitches, oVelocities);
                        basicMidiChordDefs.Add(bmcd);
                    }

                    // The basicMidiChordDefs currently contain the values from the ornaments form.
                    // All oBank and oPatch values will be null if the corresponding field in the ornament form was empty.
                    // The durations, pitches and velocities are relative to the main palette's values.

                    RemoveDuplicateBankAndPatchValues(basicMidiChordDefs);

                    if (basicMidiChordDefs[0].BankIndex == null)
                    {
                        basicMidiChordDefs[0].BankIndex = bankIndex; // can be null
                    }
                    if (basicMidiChordDefs[0].PatchIndex == null)
                    {
                        basicMidiChordDefs[0].PatchIndex = patchIndex;
                    }

                    Debug.Assert(basicMidiChordDefs[0].PatchIndex != null);

                    basicMidiChordDefs = Moritz.Spec.MidiChordDef.FitToDuration(basicMidiChordDefs, duration, ornamentMinMsDuration);

                    foreach (BasicMidiChordDef b in basicMidiChordDefs)
                    {
                        List <byte> combinedPitches = new List <byte>();
                        foreach (byte pitch in b.Pitches)
                        {
                            foreach (byte rootMidiPitch in rootMidiPitches)
                            {
                                combinedPitches.Add(M.MidiValue(rootMidiPitch + pitch));
                            }
                        }
                        b.Pitches = combinedPitches;

                        List <byte> combinedVelocities = new List <byte>();
                        foreach (byte velocity in b.Velocities)
                        {
                            foreach (byte rootMidiVelocity in rootMidiVelocities)
                            {
                                combinedVelocities.Add(M.MidiValue(rootMidiVelocity + velocity));
                            }
                        }
                        b.Velocities = combinedVelocities;
                    }
                }

                rval = new MidiChordDef(
                    duration,
                    pitchwheelDeviation,
                    hasChordOff,
                    rootMidiPitches,
                    ornamentNumber,
                    midiChordSliderDefs,
                    basicMidiChordDefs);
            }
            return(rval);
        }