Exemplo n.º 1
0
 public TrackInclusionRec(TrackObjectRec Track, Source source)
     : base(source, Source.IncludedTracks_PropertyName)
 {
     this.Track                  = Track;
     this._Included              = Track.IncludeThisTrackInFinalPlayback;
     this.Track.PropertyChanged += Track_PropertyChanged;
 }
Exemplo n.º 2
0
        public TrackWindow(Registration registration, TrackObjectRec trackObject, IMainWindowServices mainWindow)
        {
            this.registration = registration;
            this.trackObject  = trackObject;
            this.mainWindow   = mainWindow;

            InitializeComponent();
            this.Icon = OutOfPhase.Properties.Resources.Icon2;

            // By default make new tracks take up most of the horizontal screen width.
            SetDesktopBounds(DesktopBounds.X, DesktopBounds.Y, Screen.PrimaryScreen.Bounds.Width - DesktopBounds.X - 100, DesktopBounds.Height);

            menuStripManager.SetGlobalHandler(mainWindow);

            GlobalNameChanged();

            registration.Register(trackObject, this);

            backgroundToolStripMenuItem = new ToolStripMenuItem("Background", null, new EventHandler(backgroundMenuItem_Click));
            menuStripManager.ContainedMenuStrip.Items.Add(backgroundToolStripMenuItem);
            inlineEditToolStripMenuItem = new ToolStripMenuItem("Inline", null, new EventHandler(inlineEditMenuItem_Click));
            menuStripManager.ContainedMenuStrip.Items.Add(inlineEditToolStripMenuItem);

            trackEditControl.Init(trackObject, mainWindow, menuStripManager, backgroundToolStripMenuItem, inlineEditToolStripMenuItem);

            trackObject.PropertyChanged += TrackObject_PropertyChanged;

            // Change font if preferences have scale factor. Use 'force' to ensure note view and parma strip always compute the
            // correct height even if font hasn't changed to prevent layout glitch.
            DpiChangeHelper.ScaleFont(this, Program.Config.AdditionalUIZoom, true /*force*/);
        }
Exemplo n.º 3
0
        private void buttonEditSection_Click(object sender, EventArgs e)
        {
            {
                SectionObjectRec selectedSection = myListBoxSections.SelectedItem as SectionObjectRec;
                if (selectedSection != null)
                {
                    if (!registration.Activate(selectedSection))
                    {
                        new SectionWindow(registration, selectedSection, mainWindow).Show();
                    }
                    return;
                }
            }

            {
                TrackObjectRec selectedTrack = myListBoxSections.SelectedItem as TrackObjectRec;
                if (selectedTrack != null)
                {
                    if (selectedTrack.Section != null)
                    {
                        if (!registration.Activate(selectedTrack.Section))
                        {
                            new SectionWindow(registration, selectedTrack.Section, mainWindow).Show();
                        }
                    }
                    return;
                }
            }
        }
        public TrackAttributeDialog(TrackObjectRec track)
        {
            this.track = track;

            InitializeComponent();
            this.Icon = OutOfPhase.Properties.Resources.Icon2;

            DpiChangeHelper.ScaleFont(this, Program.Config.AdditionalUIZoom);

            foreach (string item in EnumUtility.GetDescriptions(TrackObjectRec.DefaultReleasePoint1ModeFlagAllowedValues, TrackObjectRec.DefaultReleasePoint1ModeFlag_EnumCategoryName))
            {
                comboBoxDefaultReleasePoint1Flags.Items.Add(item);
            }
            foreach (string item in EnumUtility.GetDescriptions(TrackObjectRec.DefaultReleasePoint2ModeFlagAllowedValues, TrackObjectRec.DefaultReleasePoint2ModeFlag_EnumCategoryName))
            {
                comboBoxDefaultReleasePoint2Flags.Items.Add(item);
            }
            foreach (string item in EnumUtility.GetDescriptions(TrackObjectRec.DefaultPitchDisplacementStartPointModeFlagAllowedValues, TrackObjectRec.DefaultPitchDisplacementStartPointModeFlag_EnumCategoryName))
            {
                comboBoxDefaultPitchDisplacementStartFlags.Items.Add(item);
            }
            foreach (string item in EnumUtility.GetDescriptions(TrackObjectRec.DefaultDurationModeFlagAllowedValues, TrackObjectRec.DefaultDurationModeFlag_EnumCategoryName))
            {
                comboBoxDefaultDurationAdjustModeFlags.Items.Add(item);
            }
            foreach (string item in EnumUtility.GetDescriptions(TrackObjectRec.DefaultDetuneModeFlagAllowedValues, TrackObjectRec.DefaultDetuneModeFlag_EnumCategoryName))
            {
                comboBoxDefaultDetuningModeFlags.Items.Add(item);
            }

            trackObjectRecBindingSource.Add(track);
        }
Exemplo n.º 5
0
        private void EditTrackProperties()
        {
            TrackObjectRec copy = TrackObjectRec.CloneProperties(trackObject, new Document());

            using (TrackAttributeDialog trackAttributeDialog = new TrackAttributeDialog(copy))
            {
                DialogResult result = trackAttributeDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    trackObject.CopyPropertiesFrom(copy);
                }
            }
        }
Exemplo n.º 6
0
        private void buttonChangeSection_Click(object sender, EventArgs e)
        {
            TrackObjectRec track = myListBoxSections.SelectedItem as TrackObjectRec;

            if (track != null)
            {
                using (SectionChooseDialog dialog = new SectionChooseDialog(document.SectionList, track.Section))
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        SectionObjectRec section = dialog.SelectedSection;
                        track.Section = section;
                        RebuildScrollingList();
                    }
                }
            }
        }
Exemplo n.º 7
0
 public SynthesizerGeneratorParams(
     IMainWindowServices mainWindow,
     Document document,
     List <TrackObjectRec> listOfTracks,
     TrackObjectRec keyTrack,
     int frameToStartAt,
     int samplingRate,
     int envelopeRate,
     NumChannelsType channels,
     LargeBCDType defaultBeatsPerMinute,
     double overallVolumeScalingReciprocal,
     LargeBCDType scanningGap,
     NumBitsType bits,
     bool clipWarn,
     int oversamplingFactor,
     bool showSummary,
     bool deterministic,// now ignored - control by setting randomSeed to null or int
     int?randomSeed,
     Synthesizer.AutomationSettings automationSettings)
 {
     this.mainWindow                     = mainWindow;
     this.document                       = document;
     this.listOfTracks                   = listOfTracks;
     this.keyTrack                       = keyTrack;
     this.frameToStartAt                 = frameToStartAt;
     this.samplingRate                   = samplingRate;
     this.envelopeRate                   = envelopeRate;
     this.channels                       = channels;
     this.defaultBeatsPerMinute          = defaultBeatsPerMinute;
     this.overallVolumeScalingReciprocal = overallVolumeScalingReciprocal;
     this.scanningGap                    = scanningGap;
     this.bits               = bits;
     this.clipWarn           = clipWarn;
     this.oversamplingFactor = oversamplingFactor;
     this.showSummary        = showSummary;
     this.deterministic      = deterministic;
     this.randomSeed         = randomSeed;
     this.automationSettings = automationSettings;
 }
Exemplo n.º 8
0
        /* insert rests */
        private static void InsertRests(
            FractionRec Now,
            FractionRec Target,
            TrackObjectRec NoteTrack,
            OpDurRec[] OpcodeDurationTable,
            int OpcodeDurationTableLength)
        {
            while (FractionRec.FracGreaterThan(Target, Now))
            {
                FractionRec       Difference;
                NoteFlags         Opcode;
                FractionRec       OpcodesDuration;
                NoteNoteObjectRec Note;
                FrameObjectRec    Frame;

                /* how much time left */
                FractionRec.SubFractions(Target, Now, out Difference);
                /* search for appropriate opcode */
                Opcode = GetMaxDurationOpcode(Difference, out OpcodesDuration, OpcodeDurationTable, OpcodeDurationTableLength);

                /* add duration to Now */
                FractionRec.AddFractions(Now, OpcodesDuration, out Now);

                /* create the note */
                Note = new NoteNoteObjectRec(NoteTrack);
                Note.PutNoteDuration(Opcode & NoteFlags.eDurationMask);
                Note.PutNoteDurationDivision(Opcode & NoteFlags.eDivisionMask);
                Note.PutNoteDotStatus((Opcode & NoteFlags.eDotModifier) != 0);
                Note.PutNotePitch(Constants.CENTERNOTE);
                Note.PutNoteIsItARest(true);
                /* create the frame */
                Frame = new FrameObjectRec();
                Frame.Add(Note);
                NoteTrack.FrameArray.Add(Frame);
            }
        }
Exemplo n.º 9
0
        /* import midi file from existing file pointer */
        public static void ImportMIDIFileSpecified(string Where)
        {
            RawMIDIScoreRec Score = NewRawMIDIScore();

            using (Stream stream = new FileStream(Where, FileMode.Open, FileAccess.Read, FileShare.Read, Constants.BufferSize))
            {
                using (BinaryReader BufferedFile = new BinaryReader(stream))
                {
                    MIDIParseErrorType result = MIDIParseErrorType.eMIDIParseFileReadError;
                    try
                    {
                        result = ParseMIDIFile(BufferedFile, Score);
                    }
                    catch (InvalidDataException)
                    {
                        // generally - unexpected eof
                        Debug.Assert(result == MIDIParseErrorType.eMIDIParseFileReadError);
                    }
                    switch (result)
                    {
                    default:
                        Debug.Assert(false);
                        throw new ArgumentException();

                    case MIDIParseErrorType.eMIDIParseNoError:
                        break;

                    case MIDIParseErrorType.eMIDIParseFileReadError:
                        MessageBox.Show(
                            "An error occurred while reading the file. Attempting to import as much of the file as possible.",
                            "Import Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                        break;

                    case MIDIParseErrorType.eMIDIParseBadFormat:
                        MessageBox.Show(
                            "The file is not a valid MIDI file. Attempting to import as much of the file as possible.",
                            "Import Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                        break;
                    }
                }
            }
            if (GetRawMIDIScoreNumTracks(Score) > 0)
            {
                /* create the new document to put the tracks into */
                bool     TrackWasCreated = false;
                Document Document        = new Document();

                /* iterate over MIDI tracks */
                int TrackLimit = GetRawMIDIScoreNumTracks(Score);
                for (int TrackScan = 0; TrackScan < TrackLimit; TrackScan++)
                {
                    /* get track */
                    RawMIDITrackRec Track = GetRawMIDIScoreIndexedTrack(Score, TrackScan);

                    /* process channels */
                    for (short ChannelScan = 1; ChannelScan <= 16; ChannelScan++)
                    {
                        bool             KeepFlag;
                        IntervalTrackRec IntervalTrack = NewIntervalTrack();
                        ConvertRawToInterval(Track, IntervalTrack, ChannelScan, out KeepFlag);

                        /* process cooked track into one of our track objects */
                        if (KeepFlag)
                        {
                            QuantizedTrackRec QuantizedTrack;
                            TrackObjectRec    DocumentTrack;

                            /* make sure we can handle this track */
                            if (MIDITimingType.eMIDIMeteredTime != RawMIDIScoreGetTimingMode(Score))
                            {
                                MessageBox.Show(
                                    "Can't import real-time MIDI files.",
                                    "Import Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Stop);
                                return;
                            }

                            QuantizedTrack = NewQuantizedTrack();
                            ConvertIntervalToQuantized(IntervalTrack, QuantizedTrack,
                                                       RawMIDIScoreGetPartsPerQuarterNote(Score));

                            DocumentTrack = new TrackObjectRec(Document);
                            Document.TrackList.Add(DocumentTrack);
                            TrackWasCreated = true;
                            ConvertQuantToNote(QuantizedTrack, DocumentTrack);

                            /* set track release point 1 to be from end */
                            DocumentTrack.DefaultReleasePoint1ModeFlag = NoteFlags.eRelease1FromEnd;
                        }
                    }
                }

                /* clear the dirty flag, since nothing was actually modified */
                Document.Modified = false;

                /* remove track if we didn't actually find anything in the file */
                if (!TrackWasCreated)
                {
                    MessageBox.Show(
                        "No tracks were found in the MIDI file.",
                        "Import Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                    return;
                }

                MainWindow MainWindow = new MainWindow(Document, null);
                MainWindow.Show();
            }
        }
Exemplo n.º 10
0
        /* convert quantized track into native track */
        public static void ConvertQuantToNote(
            QuantizedTrackRec QuantizedTrack,
            TrackObjectRec NoteTrack)
        {
            FractionRec          CurrentTime;
            int                  Index;
            int                  Limit;
            List <QuantEventRec> FrameArray;
            TieMappingRec        TieMapping;
            int                  OpcodeDurationTableLength;

            OpDurRec[] OpcodeDurationTable = new OpDurRec[4 /*divisions*/ * 2 /*dot*/ * 9 /*notetypes*/];

            /* initialize variables */
            InitializeOpcodeDurationTable(OpcodeDurationTable, out OpcodeDurationTableLength);
            CurrentTime.Integer     = 0;
            CurrentTime.Fraction    = 0;
            CurrentTime.Denominator = 1;
            FrameArray = new List <QuantEventRec>();
            TieMapping = NewTieMapping();
            Limit      = GetQuantizedTrackLength(QuantizedTrack);
            Index      = 0;

            /* iterate over variables */
            while (Index < Limit)
            {
                FractionRec   NextTime;
                QuantEventRec QuantEvent;
                bool          Continue;
                int           InspectScan;

                /* reset frame array */
                FrameArray.Clear();

                /* get the start time of the next available event */
                QuantEvent = GetQuantizedTrackIndexedEvent(QuantizedTrack, Index);
                NextTime   = GetQuantizedEventTime(QuantEvent);
                Debug.Assert(FractionIntMultOf64thDiv3(NextTime)); // non-64div3 start time quantization?

                /* sanity check */
                Debug.Assert(!FractionRec.FracGreaterThan(CurrentTime, NextTime)); // next time inconsistency

                /* get all events starting at this time into FrameArray */
                Continue = true;
                while (Continue && (Index < Limit))
                {
                    FractionRec EventTime;

                    /* get the event */
                    QuantEvent = GetQuantizedTrackIndexedEvent(QuantizedTrack, Index);
                    EventTime  = GetQuantizedEventTime(QuantEvent);
                    Debug.Assert(FractionIntMultOf64thDiv3(EventTime)); // non-64div3 start time quantization?
                    if (FractionRec.FractionsEqual(EventTime, NextTime))
                    {
                        /* add event to the list */
                        FrameArray.Add(QuantEvent);
                        /* go past this event */
                        Index += 1;
                    }
                    else
                    {
                        /* end hit so stop */
                        Continue = false;
                    }
                }

                /* insert rests to bring current time up to next time */
                InsertRests(CurrentTime, NextTime, NoteTrack, OpcodeDurationTable, OpcodeDurationTableLength);

                /* remove command events from list */
                InspectScan = 0;
                while (InspectScan < FrameArray.Count)
                {
                    /* get the event */
                    QuantEvent = FrameArray[InspectScan];
                    /* determine if event is a command */
                    if (QuantizedEventGetType(QuantEvent) == QuantEventType.eQuantizedNoteEvent)
                    {
                        /* note events should be skipped */
                        InspectScan += 1;
                    }
                    else
                    {
                        /* command events should be handled */
                        switch (QuantizedEventGetType(QuantEvent))
                        {
                        default:
                            Debug.Assert(false);
                            throw new InvalidOperationException();

                        case QuantEventType.eQuantizedCommentEvent:
                        {
                            string CommentString;
                            CommandNoteObjectRec Note;
                            FrameObjectRec       Frame;
                            FractionRec          unusedf;
                            double unusedd;

                            GetQuantizedCommentEventInfo(QuantEvent, out unusedf, out unusedd, out CommentString);
                            Note = new CommandNoteObjectRec(NoteTrack);
                            Note.PutCommandStringArg1(CommentString);
                            Note.PutCommandOpcode(NoteCommands.eCmdMarker);
                            Frame = new FrameObjectRec();
                            Frame.Add(Note);
                            NoteTrack.FrameArray.Add(Frame);
                        }
                        break;
                        }
                        /* delete event from array */
                        FrameArray.RemoveAt(InspectScan);
                        /* don't increment InspectScan */
                    }
                }

                /* process remaining notes in FrameArray, computing minimum duration */
                /* and updating CurrentTime with minimum duration. */
                if (FrameArray.Count != 0)
                {
                    NoteFlags      DurationOpcode;
                    FrameObjectRec Frame;
                    int            Scan;
                    int            FrameLimit;
                    FractionRec    MinimumDuration;
                    FractionRec    unusedf;
                    double         unusedd;
                    short          unuseds;

                    /* initialize minimum duration */
                    QuantEvent = FrameArray[0];
                    GetQuantizedNoteEventInfo(QuantEvent, out unusedf, out unusedd, out DurationOpcode,
                                              out unusedd, out unuseds, out unuseds, out unuseds);
                    NoteNoteObjectRec.ConvertDurationFrac(DurationOpcode, out MinimumDuration);
                    Debug.Assert(FractionIntMultOf64thDiv3(MinimumDuration)); // non-64div3 duration quantization?

                    /* allocate frame */
                    Frame = new FrameObjectRec();

                    /* process notes in frame */
                    FrameLimit = FrameArray.Count;
                    for (Scan = 0; Scan < FrameLimit; Scan += 1)
                    {
                        FractionRec       StartTime;
                        double            StartTimeAdjust;
                        NoteFlags         Duration;
                        double            DurationAdjust;
                        short             MIDIPitch;
                        short             MIDIAttackVelocity;
                        short             MIDIReleaseVelocity;
                        NoteNoteObjectRec Note;
                        FractionRec       FracDuration;

                        /* get the note */
                        QuantEvent = FrameArray[Scan];
                        Debug.Assert(QuantizedEventGetType(QuantEvent) == QuantEventType.eQuantizedNoteEvent); // non-note in frame array
                        /* get attributes */
                        GetQuantizedNoteEventInfo(QuantEvent, out StartTime, out StartTimeAdjust,
                                                  out Duration, out DurationAdjust, out MIDIPitch, out MIDIAttackVelocity,
                                                  out MIDIReleaseVelocity);
                        Debug.Assert(IntMultOf64thDiv3(Duration));                        // non-64div3 duration quantization?
                        Debug.Assert(FractionRec.FractionsEqual(StartTime, CurrentTime)); // start time inconsistency
                        /* create note */
                        Note = new NoteNoteObjectRec(NoteTrack);
                        Frame.Add(Note);
                        TieMappingAddPair(TieMapping, QuantEvent, Note);
                        /* set note attributes */
                        Note.PutNoteDuration(Duration & NoteFlags.eDurationMask);
                        Note.PutNoteDurationDivision(Duration & NoteFlags.eDivisionMask);
                        Note.PutNoteDotStatus((Duration & NoteFlags.eDotModifier) != 0);
                        Note.EarlyLateAdjust    = StartTimeAdjust;
                        Note.DurationAdjust     = DurationAdjust;
                        Note.DurationAdjustMode = NoteFlags.eDurationAdjustMultiplicative;
                        Note.PutNotePitch((short)(MIDIPitch - MIDIC + Constants.CENTERNOTE));
                        Note.Accent1 = (MIDIAttackVelocity > 0)
                            ? -Math.Log(MIDIAttackVelocity) / Constants.LOG2 + LN127OVERLN2 : 7;
                        Note.Accent2 = (MIDIReleaseVelocity > 0)
                            ? -Math.Log(MIDIReleaseVelocity) / Constants.LOG2 + LN127OVERLN2 : 7;
                        switch ((MIDIPitch - MIDIC + ((MIDIC / 12 + 1) * 12)) % 12)
                        {
                        default:
                            // midi sharp/flat problem
                            Debug.Assert(false);
                            throw new InvalidOperationException();

                        case 0:     /* C */
                        case 2:     /* D */
                        case 4:     /* E */
                        case 5:     /* F */
                        case 7:     /* G */
                        case 9:     /* A */
                        case 11:    /* B */
                            break;

                        case 1:     /* C# */
                        case 3:     /* D# */
                        case 6:     /* F# */
                        case 8:     /* G# */
                        case 10:    /* A# */
                            Note.PutNoteFlatOrSharpStatus(NoteFlags.eSharpModifier);
                            break;
                        }
                        /* do the minimum duration thing */
                        NoteNoteObjectRec.ConvertDurationFrac(Duration, out FracDuration);
                        Debug.Assert(FractionIntMultOf64thDiv3(FracDuration)); // non-64div3 duration quantization?
                        if (FractionRec.FracGreaterThan(MinimumDuration, FracDuration))
                        {
                            MinimumDuration = FracDuration;
                        }
                    }

                    /* add frame to track */
                    NoteTrack.FrameArray.Add(Frame);

                    /* if minimum duration is greater than time to next event, then */
                    /* add rests (one to this frame) to fill in the gap */
                    if (Index < Limit)
                    {
                        FractionRec NextEventTime;
                        FractionRec Difference;

                        /* get the start time of the next available event */
                        QuantEvent    = GetQuantizedTrackIndexedEvent(QuantizedTrack, Index);
                        NextEventTime = GetQuantizedEventTime(QuantEvent);
                        Debug.Assert(FractionIntMultOf64thDiv3(NextEventTime)); // non-64div3 start time quantization?
                        FractionRec.SubFractions(NextEventTime, CurrentTime, out Difference);
                        if (FractionRec.FracGreaterThan(MinimumDuration, Difference))
                        {
                            NoteNoteObjectRec Note;
                            NoteFlags         RestOpcode;
                            FractionRec       OpcodesDuration;

                            /* insert first rest into frame */
                            RestOpcode = GetMaxDurationOpcode(Difference, out OpcodesDuration,
                                                              OpcodeDurationTable, OpcodeDurationTableLength);
                            Debug.Assert(IntMultOf64thDiv3(RestOpcode)); // non-64div3 duration quantization
                            Note = new NoteNoteObjectRec(NoteTrack);
                            Note.PutNoteDuration(RestOpcode & NoteFlags.eDurationMask);
                            Note.PutNoteDurationDivision(RestOpcode & NoteFlags.eDivisionMask);
                            Note.PutNoteDotStatus((RestOpcode & NoteFlags.eDotModifier) != 0);
                            Note.PutNotePitch(Constants.CENTERNOTE);
                            Note.PutNoteIsItARest(true);
                            Frame.Add(Note);
                            /* put new minimum duration in to reflect new rest we added */
                            NoteNoteObjectRec.ConvertDurationFrac(RestOpcode, out MinimumDuration);
                        }
                    }

                    /* advance thing by minimum duration */
                    FractionRec.AddFractions(MinimumDuration, CurrentTime, out CurrentTime);
                    Debug.Assert(FractionIntMultOf64thDiv3(CurrentTime)); // non-64div3 start time quantization?
                }
            }

            /* patch up ties */
            for (Index = 0; Index < Limit; Index += 1)
            {
                QuantEventRec QuantEvent;

                /* get potential event */
                QuantEvent = GetQuantizedTrackIndexedEvent(QuantizedTrack, Index);
                /* see if it ties somewhere */
                if ((QuantEventType.eQuantizedNoteEvent == QuantizedEventGetType(QuantEvent)) &&
                    (GetQuantizedEventTieTarget(QuantEvent) != null))
                {
                    QuantEventRec     TieTarget;
                    NoteNoteObjectRec Source;
                    NoteNoteObjectRec Target;

                    /* get tie target */
                    TieTarget = GetQuantizedEventTieTarget(QuantEvent);
                    /* look up source and target note events */
                    Source = TieMappingLookup(TieMapping, QuantEvent);
                    Target = TieMappingLookup(TieMapping, TieTarget);
                    /* establish tie */
                    Source.PutNoteTieTarget(Target);
                }
            }

            /* look for track name comment */
            for (Index = 0; Index < Limit; Index += 1)
            {
                QuantEventRec QuantEvent;

                /* get potential event */
                QuantEvent = GetQuantizedTrackIndexedEvent(QuantizedTrack, Index);
                /* see if it ties somewhere */
                if (QuantEventType.eQuantizedCommentEvent == QuantizedEventGetType(QuantEvent))
                {
                    string      CommentString;
                    FractionRec unusedf;
                    double      unusedd;

                    GetQuantizedCommentEventInfo(QuantEvent, out unusedf, out unusedd, out CommentString);
                    /* check for track name */
                    if ((CommentString.Length > 11 /*Prefix*/ + Environment.NewLine.Length) &&
                        CommentString.StartsWith("Track Name" + Environment.NewLine))
                    {
                        string NameString = CommentString.Substring(11, CommentString.Length - (11 + 1));
                        NoteTrack.Name = NameString;
                        goto FinishedSettingTrackName;
                    }
                }
            }
            /* if no track name was found, then use the first comment string */
            for (Index = 0; Index < Limit; Index += 1)
            {
                QuantEventRec QuantEvent;

                /* get potential event */
                QuantEvent = GetQuantizedTrackIndexedEvent(QuantizedTrack, Index);
                /* see if it ties somewhere */
                if (QuantEventType.eQuantizedCommentEvent == QuantizedEventGetType(QuantEvent))
                {
                    string      CommentString;
                    FractionRec unusedf;
                    double      unusedd;

                    GetQuantizedCommentEventInfo(QuantEvent, out unusedf, out unusedd, out CommentString);
                    /* check for track name */
                    if ((CommentString.Length > 8 /*Prefix*/ + Environment.NewLine.Length) &&
                        CommentString.StartsWith("Comment" + Environment.NewLine))
                    {
                        string NameString;

                        NameString     = CommentString.Substring(8, CommentString.Length - (8 + 1));
                        NoteTrack.Name = NameString;
                        goto FinishedSettingTrackName;
                    }
                }
            }
FinishedSettingTrackName:
            ;
        }
Exemplo n.º 11
0
        private void RebuildScrollingList()
        {
            object selection = myListBoxSections.SelectedItem;

            displayList.Clear();

            TrackObjectRec[] tracks = new List <TrackObjectRec>(document.TrackList).ToArray();

            /* set stable sort subkey */
            for (int i = 0; i < tracks.Length; i++)
            {
                tracks[i].AuxVal = i;
            }

            Array.Sort(
                tracks,
                delegate(TrackObjectRec left, TrackObjectRec right)
            {
                return(Synthesizer.SynthStateRec.CompareTracksOnSection(left, right, document.SectionList));
            });

            SectionObjectRec section  = null;
            bool             firstTry = true;

            for (int i = 0; i < tracks.Length; i++)
            {
                TrackObjectRec track = tracks[i];

                /* create the section name header */
                if (firstTry || (section != track.Section))
                {
                    firstTry = false;
                    section  = track.Section;
                    if (section == null)
                    {
                        displayList.Add((string)"(Default)");
                    }
                    else
                    {
                        displayList.Add(section);
                    }
                }

                /* add the track item */
                displayList.Add(track);
            }

            /* add any sections we missed */
            for (int j = 0; j < document.SectionList.Count; j++)
            {
                section = document.SectionList[j];

                bool referenced = false;
                for (int i = 0; !referenced && (i < tracks.Length); i++)
                {
                    TrackObjectRec track = document.TrackList[i];
                    if (track.Section == section)
                    {
                        referenced = true;
                    }
                }

                if (!referenced)
                {
                    displayList.Add(section);
                }
            }

            for (int i = 0; i < displayList.Count; i++)
            {
                if (selection == displayList[i])
                {
                    myListBoxSections.SelectItem(i, true /*clearOtherSelections*/);
                }
            }
        }
Exemplo n.º 12
0
 protected override object Load(BinaryReader reader, Document document)
 {
     track = new TrackObjectRec(reader, new LoadContext(Document.CurrentFormatVersionNumber, document, LoadContextState.Paste));
     return(track);
 }
Exemplo n.º 13
0
 public TrackClipboard(TrackObjectRec track, Document document)
     : base(document)
 {
     this.track = track;
 }
Exemplo n.º 14
0
        public void Init(
            TrackObjectRec trackObject,
            IMainWindowServices mainWindow,
            MenuStripManager menuStripManager,
            ToolStripMenuItem backgroundToolStripMenuItem,
            ToolStripMenuItem inlineEditToolStripMenuItem)
        {
            this.trackObject                 = trackObject;
            this.mainWindow                  = mainWindow;
            this.menuStripManager            = menuStripManager;
            this.backgroundToolStripMenuItem = backgroundToolStripMenuItem;
            this.inlineEditToolStripMenuItem = inlineEditToolStripMenuItem;

            noteViewControl.UndoHelper = trackViewControl.UndoHelper;
            noteParamStrip.UndoHelper  = trackViewControl.UndoHelper;

            trackViewControl.NoteView       = noteViewControl;
            trackViewControl.NoteParamStrip = noteParamStrip;
            trackViewControl.ContextUI      = this;

            //documentBindingSource.Add(document);
            trackObjectRecBindingSource.Add(trackObject);

            trackViewControl.SetTrackObject(trackObject);
            trackViewControl.RestoreSavedScrollPosition(trackObject.SavedHScrollPos, trackObject.SavedVScrollPos);
            trackViewControl.Scroll += new ScrollEventHandler(trackViewControl_Scroll);

            ToolStripButton[] group;
            //
            group = new ToolStripButton[] { toolStripButtonArrow, toolStripButtonCommand, toolStripButtonSixtyFourth, toolStripButtonThirtySecond, toolStripButtonSixteenth, toolStripButtonEighth, toolStripButtonQuarter, toolStripButtonHalf, toolStripButtonWhole, toolStripButtonDouble, toolStripButtonQuad };
            SetButton(toolStripButtonArrow, Bitmaps1Class.gdiArrowButtonBits, Bitmaps1Class.gdiArrowButtonSelectedBits, group, new ToolStripButton[] { toolStripButtonQuarter, toolStripButtonDiv1, toolStripButtonNatural, toolStripButtonNoDot, toolStripButtonNoteVsRest });
            toolStripButtonArrow.Checked = true;
            //
            SetButton(toolStripButtonCommand, Bitmaps1Class.gdiCommandButtonBits, Bitmaps1Class.gdiCommandButtonSelectedBits, group, null);
            //
            SetButton(toolStripButtonSixtyFourth, Bitmaps1Class.gdiSixtyFourthButtonBits, Bitmaps1Class.gdiSixtyFourthButtonSelectedBits, group, null);
            SetButton(toolStripButtonThirtySecond, Bitmaps1Class.gdiThirtySecondButtonBits, Bitmaps1Class.gdiThirtySecondButtonSelectedBits, group, null);
            SetButton(toolStripButtonSixteenth, Bitmaps1Class.gdiSixteenthButtonBits, Bitmaps1Class.gdiSixteenthButtonSelectedBits, group, null);
            SetButton(toolStripButtonEighth, Bitmaps1Class.gdiEighthButtonBits, Bitmaps1Class.gdiEighthButtonSelectedBits, group, null);
            SetButton(toolStripButtonQuarter, Bitmaps1Class.gdiQuarterButtonBits, Bitmaps1Class.gdiQuarterButtonSelectedBits, group, null);
            SetButton(toolStripButtonHalf, Bitmaps1Class.gdiHalfButtonBits, Bitmaps1Class.gdiHalfButtonSelectedBits, group, null);
            SetButton(toolStripButtonWhole, Bitmaps1Class.gdiWholeButtonBits, Bitmaps1Class.gdiWholeButtonSelectedBits, group, null);
            SetButton(toolStripButtonDouble, Bitmaps1Class.gdiDoubleButtonBits, Bitmaps1Class.gdiDoubleButtonSelectedBits, group, null);
            SetButton(toolStripButtonQuad, Bitmaps1Class.gdiQuadButtonBits, Bitmaps1Class.gdiQuadButtonSelectedBits, group, null);
            //
            group = new ToolStripButton[] { toolStripButtonSharp, toolStripButtonFlat, toolStripButtonNatural };
            SetButton(toolStripButtonSharp, Bitmaps1Class.gdiSharpButtonBits, Bitmaps1Class.gdiSharpButtonSelectedBits, group, null);
            SetButton(toolStripButtonFlat, Bitmaps1Class.gdiFlatButtonBits, Bitmaps1Class.gdiFlatButtonSelectedBits, group, null);
            SetButton(toolStripButtonNatural, Bitmaps1Class.gdiNaturalButtonBits, Bitmaps1Class.gdiNaturalButtonSelectedBits, group, null);
            toolStripButtonNatural.Checked = true;
            //
            group = new ToolStripButton[] { toolStripButtonNoteVsRest, toolStripButtonNoteVsRest2 };
            SetButton(toolStripButtonNoteVsRest, Bitmaps1Class.gdiNoteVsRestButtonBits, Bitmaps1Class.gdiNoteVsRestButtonSelectedBits, group, null);
            SetButton(toolStripButtonNoteVsRest2, Bitmaps1Class.gdiRestVsNoteButtonBits, Bitmaps1Class.gdiRestVsNoteButtonSelectedBits, group, null);
            toolStripButtonNoteVsRest.Checked = true;
            //
            group = new ToolStripButton[] { toolStripButtonNoDot, toolStripButtonYesDot };
            SetButton(toolStripButtonNoDot, Bitmaps1Class.gdiNoDotButtonBits, Bitmaps1Class.gdiNoDotButtonSelectedBits, group, null);
            SetButton(toolStripButtonYesDot, Bitmaps1Class.gdiYesDotButtonBits, Bitmaps1Class.gdiYesDotButtonSelectedBits, group, null);
            toolStripButtonNoDot.Checked = true;
            //
            group = new ToolStripButton[] { toolStripButtonDiv1, toolStripButtonDiv3, toolStripButtonDiv5, toolStripButtonDiv7 };
            SetButton(toolStripButtonDiv1, Bitmaps1Class.gdiDiv1ButtonBits, Bitmaps1Class.gdiDiv1ButtonSelectedBits, group, null);
            SetButton(toolStripButtonDiv3, Bitmaps1Class.gdiDiv3ButtonBits, Bitmaps1Class.gdiDiv3ButtonSelectedBits, group, null);
            SetButton(toolStripButtonDiv5, Bitmaps1Class.gdiDiv5ButtonBits, Bitmaps1Class.gdiDiv5ButtonSelectedBits, group, null);
            SetButton(toolStripButtonDiv7, Bitmaps1Class.gdiDiv7ButtonBits, Bitmaps1Class.gdiDiv7ButtonSelectedBits, group, null);
            toolStripButtonDiv1.Checked = true;

            PrepareInlineEditingMenu();

            trackViewControl.Focus();
        }