コード例 #1
0
        /// <summary>
        /// Метод определение катинки ноты, которая соответствует заданой длине
        /// </summary>
        /// <param name="duration">Длина звучания ноты</param>
        private void getNoteImage(int duration)
        {
            switch (duration)
            {
            case 62:
                image    = Resources.SixteenthNoteSmall2323;
                NoteType = NoteLength.Sixteenth;
                break;

            case 125:
                image    = Resources.EighthNoteSmall2323;
                NoteType = NoteLength.Eighth;
                break;

            case 250:
                image    = Resources.QuarterNoteSmall2323;
                NoteType = NoteLength.QuarterNote;
                break;

            case 500:
                image    = Resources.HalfNoteSmall2323;
                NoteType = NoteLength.HalfNote;
                break;

            case 1000:
                image    = Resources.WholeNoteSmall2323;
                NoteType = NoteLength.WholeNote;
                break;
            }
        }
コード例 #2
0
        public void executeChangeMeasureTimeSigFromMenu(NodeClick click, int beats, NoteLength type)
        {
            selections.NumBeats = beats;
            selections.BeatType = type;

            executeChangeMeasureTimeSig(click);
        }
コード例 #3
0
 public ChangeMeasureTimeSigCom(Part p, Measure m, int n, NoteLength b)
 {
     part      = p;
     measure   = m;
     num_beats = n;
     beat_type = b;
 }
コード例 #4
0
ファイル: ChordGenerator.cs プロジェクト: Jbtyson/cis598
        public Chord GenerateMajor(Pitch root, int inversion, int startInterval, NoteLength noteLength, byte velocity = 100)
        {
            var inversionOffset = new int[3];

            switch (inversion)
            {
                case 0:
                    inversionOffset = NoInversion;
                    break;
                case 1:
                    inversionOffset = FirstInversion;
                    break;
            };

            int note1 = (int)root + inversionOffset[0];
            int note2 = (int)root + inversionOffset[1];
            int note3 = (int)root + inversionOffset[2];

            var notes = new List<Note>
            {
                new Note(PitchCode.GetNoteName(note1), startInterval, noteLength, velocity),
                new Note(PitchCode.GetNoteName(note2), startInterval, noteLength, velocity),
                new Note(PitchCode.GetNoteName(note3), startInterval, noteLength, velocity)
            };

            return new Chord
            {
                Notes = notes
            };
        }
コード例 #5
0
ファイル: MenuEvents.cs プロジェクト: NathanielBeen/GuitarTab
 public TupletSelectEventArgs(NodeClick click, Action <NodeClick, NoteLength> command, TupletType type, NoteLength length)
 {
     Click    = click;
     Delegate = (c, l) => command(c, l);
     Type     = type;
     Length   = length;
 }
コード例 #6
0
 public void SetSelectedNote(int newId, NoteLength newLength)
 {
     if (song != null)
     {
         song[selectedIndex] = new Note(newId, newLength);
         Invalidate();
     }
 }
コード例 #7
0
        public PercussionNote Drums;              //!< The @link Music::PercussionNote drum note@endlink.

        public CombinedNote(MelodyNote aMelodyNote, PercussionNote aPercussionNote, NoteLength aOffset)
        {
            MusicalNote        = aMelodyNote;
            NumPitches         = MusicalNote.NumPitches;
            Drums              = aPercussionNote;
            NumDrums           = Drums.NumHits;
            OffsetFromPrevNote = aOffset;
        }
コード例 #8
0
 public void setTimeSignature(int num_beats, NoteLength beat_type)
 {
     if (canSetTimeSignature(num_beats, beat_type))
     {
         NumberOfBeats = num_beats;
         BeatType      = beat_type;
     }
 }
コード例 #9
0
ファイル: Note.cs プロジェクト: Jbtyson/cis598
      public Note(string pitch, int startInterval, NoteLength noteLength, byte velocity = 100)
      {
         this.Pitch = pitch;
         this.noteLength = noteLength;
         this.velocity = velocity;

         StartInterval = startInterval;
         EndInterval = startInterval + (int)noteLength;
      }
コード例 #10
0
 public void resetBars(NoteLength length)
 {
     updateNoteLength(length);
     RightConnected = 0;
     LeftConnected  = 0;
     RightSingle    = 0;
     LeftSingle     = 0;
     LeftDot        = false;
     RightDot       = false;
 }
コード例 #11
0
        public void drawMeasureTimeSig(int num_notes, NoteLength note_type, DrawingContext dc)
        {
            var text = new FormattedText(num_notes.ToString(), CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight,
                                         info.DrawingObjects.TypeFace, info.Dimensions.LargeFontSize, info.DrawingObjects.Brush);
            var second_text = new FormattedText((note_type.getVisualNoteLength()).ToString(), CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight,
                                                info.DrawingObjects.TypeFace, info.Dimensions.LargeFontSize, info.DrawingObjects.Brush);

            dc.DrawText(text, new Point(5, info.Dimensions.StringHeight));
            dc.DrawText(second_text, new Point(5, info.Dimensions.StringHeight * 3));
        }
コード例 #12
0
 public static Length createInstance(NoteLength length, TupletType type)
 {
     if (type != TupletType.None)
     {
         return(TupleLength.createInstance(length, type));
     }
     else
     {
         return(createInstance(length));
     }
 }
コード例 #13
0
        public void setTupleLength(TupleLength length)
        {
            HasTuple          = true;
            Left              = false;
            Right             = false;
            DrawNumber        = true;
            NumberRightOffset = false;

            Type       = length.TupleType;
            NoteLength = length.NoteType;
        }
コード例 #14
0
        public void setStandardLength(Length length)
        {
            HasTuple          = false;
            Left              = false;
            Right             = false;
            DrawNumber        = false;
            NumberRightOffset = false;

            Type       = default(TupletType);
            NoteLength = length.NoteType;
        }
コード例 #15
0
 public static TupleLength createInstance(NoteLength note_length, TupletType type)
 {
     if (note_length != NoteLength.None && type != TupletType.None)
     {
         return(new TupleLength(note_length, type));
     }
     else
     {
         return(null);
     }
 }
コード例 #16
0
    /**
     * @brief Gets the @link Music::NoteLength length of a note@endlink relative to a quarter note.
     * @param[in] aNoteLength The @link Music::NoteLength length of the note@endlink being compared.
     * @return The ratio of @link Music::NoteLength the note length@endlink relative to a quarter note.
     */
    public static float GetNoteLengthRelativeToQuarterNote(NoteLength aNoteLength)
    {
        // Declare a variable to return the ratio
        float ratio = 1f;

        // Make sure there is a length.
        if (aNoteLength.BaseLength == NOTE_LENGTH_BASE.NONE)
        {
            return(0);
        }

        // Set the ratio according to the base length.
        switch (aNoteLength.BaseLength)
        {
        case NOTE_LENGTH_BASE.TS:
            ratio /= 8f;
            break;

        case NOTE_LENGTH_BASE.S:
            ratio /= 4f;
            break;

        case NOTE_LENGTH_BASE.E:
            ratio /= 2f;
            break;

        case NOTE_LENGTH_BASE.Q:
            break;

        case NOTE_LENGTH_BASE.H:
            ratio *= 2f;
            break;

        case NOTE_LENGTH_BASE.W:
            ratio *= 4f;
            break;

        default:
            break;
        }

        // Apply the dot and triplet modifiers if needed.
        if (aNoteLength.Dot)
        {
            ratio *= DOT_MODIFIER;
        }
        if (aNoteLength.Triplet)
        {
            ratio *= TRIPLET_MODIFIER;
        }

        // Return the ratio.
        return(ratio);
    }
コード例 #17
0
 public static Length createInstance(NoteLength length)
 {
     if (length == NoteLength.None)
     {
         return(null);
     }
     else
     {
         return(new Length(length));
     }
 }
コード例 #18
0
        public Dictionary <NoteLength, string> getRestImagePaths(Dictionary <string, string> file_names)
        {
            var image_dict = new Dictionary <NoteLength, string>();

            foreach (string length_name in file_names.Keys)
            {
                NoteLength length = NoteLengthExtensions.getNoteLengthFromString(length_name);
                image_dict.Add(length, file_names[length_name]);
            }

            return(image_dict);
        }
コード例 #19
0
        private void HandleShorterClick(object sender, EventArgs e)
        {
            int        startLength = (int)pianoStaff.Selection.Length;
            NoteLength newLength   = pianoStaff.Selection.Length;

            if (startLength > 1)
            {
                newLength = (NoteLength)(startLength / 2);
            }

            pianoStaff.SetSelectedNote(pianoStaff.Selection.Id, newLength);
        }
コード例 #20
0
        //get length data from the user controls
        private NoteLength GetNoteLength()
        {
            int  fraction  = int.Parse(LengthMenu.SelectedItem.Title.Substring(2));
            bool isDotted  = IsDottedCheck.State == NSCellStateValue.On,
                 isTriplet = IsTripletCheck.State == NSCellStateValue.On;
            var n          = new NoteLength
            {
                Length       = 1,
                NotesPerBeat = 1
            };

            if (isTriplet)
            {
                if (fraction > 8)
                {
                    n.Length       = 1;
                    n.NotesPerBeat = fraction / 16;
                }
                else
                {
                    n.NotesPerBeat = 3;
                    n.Length       = 8 / fraction;
                }
            }
            else
            {
                if (fraction < 4)
                {
                    if (isDotted)
                    {
                        n.Length = 3;
                    }
                    else
                    {
                        n.Length = 2;
                    }
                    if (fraction == 1)
                    {
                        n.Length *= 2;
                    }
                }
                else
                {
                    n.NotesPerBeat = fraction / 4;
                    if (isDotted)
                    {
                        n.Length        = 3;
                        n.NotesPerBeat *= 2;
                    }
                }
            }
            return(n);
        }
コード例 #21
0
    /**
     * @brief Gets the percentage that a note length takes up in a measure for the given time signature.
     * @param[in] aLength the given NOTE_LENGTH_BASE that represents the length of a note.
     * @param[in] aTimeSignature The given TimeSignature
     */
    public static float GetNoteLengthRelativeToMeasure(NoteLength aLength, TimeSignature aTimeSignature)
    {
        // Relate everything to quarter notes.
        float quarterNoteLength = 1f;

        // Get the ratio of quarter note to beat.
        quarterNoteLength = GetNoteLengthRelativeToQuarterNote(new NoteLength(aTimeSignature.BaseBeat));

        // Get the percentage that a quarter note takes up in the measure.
        quarterNoteLength /= (float)aTimeSignature.BeatsPerMeasure;

        return(GetNoteLengthRelativeToQuarterNote(aLength) * quarterNoteLength);
    }
コード例 #22
0
        public static bool isDotted(this NoteLength length)
        {
            switch (length)
            {
            case NoteLength.DottedQuarter:
            case NoteLength.DottedHalf:
            case NoteLength.DottedEighth:
            case NoteLength.DottedSixeteenth:
                return(true);

            default:
                return(false);
            }
        }
コード例 #23
0
ファイル: MotifMatrix.cs プロジェクト: Jbtyson/cis598
      public NoteLength GetNextNoteLength(NoteLength prevNote)
      {
         var rand = random.Next(100);

         if (rand < 50)
            return NoteLength.Quarter;
         if (rand < 75)
            return NoteLength.Eigth;
         if (rand < 85)
            return NoteLength.Half;
         if (rand < 95)
            return NoteLength.Quarter;
         return NoteLength.Sixteenth;
      }
コード例 #24
0
ファイル: LengthView.cs プロジェクト: NathanielBeen/GuitarTab
        public Dictionary <NoteLength, ImageBrush> getLengthImages(Dictionary <string, string> uri_dict)
        {
            var image_dict = new Dictionary <NoteLength, ImageBrush>();

            foreach (var entry in uri_dict)
            {
                NoteLength length = NoteLengthExtensions.getNoteLengthFromString(entry.Key);
                var        brush  = new ImageBrush();
                brush.ImageSource = SettingsReader.getImageFromLocation(entry.Value);

                image_dict[length] = brush;
            }

            return(image_dict);
        }
コード例 #25
0
        public BPMTimeSigView(CommandSelections s, GuiCommandExecutor e, Selected se, Dictionary <string, string> length_uri, Dictionary <string, string> other_uri, int b, int n, NoteLength bl)
        {
            selections = s;
            executor   = e;
            selected   = se;
            selections.PropertyChanged += handlePropertyChanged;

            BPM      = b;
            NumBeats = n;
            BeatType = bl;

            LengthImages = getLengthImages(length_uri);
            getOtherImages(other_uri);
            initCommands();
        }
コード例 #26
0
        public void executeInitPart(NodeClick click, int bpm, int num_beats, NoteLength beat_type)
        {
            //once menus are put in to init files, replace below
            selections.BPM      = bpm;
            selections.NumBeats = num_beats;
            selections.BeatType = beat_type;
            selections.Position = 0;

            var builder = new InitPartBld(selections);

            executor.executeCommand(builder);

            Updater.setTreePart(selections.SelectedPart);
            Updater.populateMouseClick(click);

            executeCommandBase(click, CommandType.AddMeasureToPart, UpdateType.UpdatePart, false, false);
        }
コード例 #27
0
        public int getTotalBars(NoteLength length)
        {
            switch (length)
            {
            case NoteLength.ThirtySecond:
                return(3);

            case NoteLength.Sixeteenth:
            case NoteLength.DottedSixeteenth:
                return(2);

            case NoteLength.Eighth:
            case NoteLength.DottedEighth:
                return(1);

            default:
                return(0);
            }
        }
コード例 #28
0
        public override void submitChanges()
        {
            int        beat_type_i = (Int32.TryParse(BeatType, out int beat)) ? beat : 0;
            NoteLength beat_type_n = NoteLengthExtensions.getNoteLengthFromVisualLength(beat_type_i);

            if (NumBeatsError == String.Empty || BeatTypeError == String.Empty || BpmError == String.Empty || !Int32.TryParse(NumBeats, out int num_beats_i) ||
                beat_type_n == NoteLength.None || !Int32.TryParse(BPM, out int bpm_i))
            {
                return;
            }

            if (num_beats_i != measure.TimeSignature.NumberOfBeats || beat_type_n != measure.TimeSignature.BeatType)
            {
                executor.executeChangeMeasureTimeSigFromMenu(getClickCopy(), num_beats_i, beat_type_n);
            }
            if (bpm_i != measure.Bpm)
            {
                executor.executeChangeMeasureBpmFromMenu(getClickCopy(), bpm_i);
            }
        }
コード例 #29
0
ファイル: MusicManager.cs プロジェクト: SeanSoraghan/GGJ2021
    public void TriggerNote(int index, NoteLength noteLength, bool reverse = false)
    {
        int currentSource = currentSourcePerNote[(int)noteLength][index];
        int sourceIndex   = index * numSourcesPerNote + currentSource;

        audioSources[(int)noteLength][sourceIndex].Stop();
        if (reverse)
        {
            audioSources[(int)noteLength][sourceIndex].pitch = -1.0f;
            audioSources[(int)noteLength][sourceIndex].time  = audioSources[(int)noteLength][sourceIndex].clip.length - 0.01f;
        }
        else
        {
            audioSources[(int)noteLength][sourceIndex].pitch = 1.0f;
            audioSources[(int)noteLength][sourceIndex].time  = 0.0f;
        }
        audioSources[(int)noteLength][sourceIndex].Play();

        currentSourcePerNote[(int)noteLength][index] = (currentSourcePerNote[(int)noteLength][index] + 1) % numSourcesPerNote;
    }
コード例 #30
0
        public static string getStringFromNoteLength(this NoteLength length)
        {
            switch (length)
            {
            case NoteLength.DottedWhole:
                return("Dotted Whole");

            case NoteLength.Whole:
                return("Whole");

            case NoteLength.DottedHalf:
                return("Dotted Half");

            case NoteLength.Half:
                return("Half");

            case NoteLength.DottedQuarter:
                return("Dotted Quarter");

            case NoteLength.Quarter:
                return("Quarter");

            case NoteLength.DottedEighth:
                return("Dotted Eighth");

            case NoteLength.Eighth:
                return("Eighth");

            case NoteLength.DottedSixeteenth:
                return("Dotted Sixteenth");

            case NoteLength.Sixeteenth:
                return("Sixteenth");

            case NoteLength.ThirtySecond:
                return("Thirty-Second");

            default:
                return("None");
            }
        }
コード例 #31
0
        public bool canCreateTuple()
        {
            NoteLength base_length = NoteLength.None;

            foreach (Chord chord in chords)
            {
                NoteLength prop = getHighestValidTupleBaseLength(chord.Length.NoteType);
                if (base_length == NoteLength.None || prop < base_length)
                {
                    base_length = prop;
                }
            }

            int weight = 0;

            foreach (Chord chord in chords)
            {
                weight += getWeightFromBaseLength(chord.Length.NoteType, base_length);
            }
            return(weight == (int)type && base_length != NoteLength.None);
        }
コード例 #32
0
        public int getWeightOfTuples(List <ChordTuple> tuples)
        {
            NoteLength base_length = NoteLength.None;

            foreach (ChordTuple tuple in tuples)
            {
                NoteLength prop = tuple.getHighestValidTupleBaseLength();
                if (base_length == NoteLength.None || prop < base_length)
                {
                    base_length = prop;
                }
            }

            int weight = 0;

            foreach (ChordTuple tuple in tuples)
            {
                weight += tuple.getWeightFromBaseLength(base_length);
            }
            return(weight);
        }
コード例 #33
0
        public Dictionary <NoteLength, ImageBrush> getLengthImages(Dictionary <string, string> uri_dict)
        {
            var needed_lengths = new List <NoteLength>()
            {
                NoteLength.Half, NoteLength.Quarter, NoteLength.Eighth, NoteLength.Sixeteenth, NoteLength.ThirtySecond
            };
            var image_dict = new Dictionary <NoteLength, ImageBrush>();

            foreach (var entry in uri_dict)
            {
                NoteLength length = NoteLengthExtensions.getNoteLengthFromString(entry.Key);
                if (needed_lengths.Contains(length))
                {
                    var brush = new ImageBrush();
                    brush.ImageSource = SettingsReader.getImageFromLocation(entry.Value);

                    image_dict[length] = brush;
                }
            }

            return(image_dict);
        }
コード例 #34
0
ファイル: Chord.cs プロジェクト: Helpfully/UnityMusicalGame
    public Chord(ChordStream parentStream, float specificLength, params int[] notes)
    {
        Notes = new List<Note>();

        foreach (var item in notes)
        {
            if (item == -1)
            {
                isSilence = true;
                break;
            }
            var note = new Note();
            note.Length = NoteLength.Specific;
            note.length = specificLength;
            note.ParentChord = this;
            note.Tone = (Tones)item;

            Notes.Add(note);
        }
        Length = NoteLength.Specific;
        length = specificLength;
        ParentChordStream = parentStream;
        parentStream.chords.Add(this);
    }
コード例 #35
0
ファイル: Chord.cs プロジェクト: Helpfully/UnityMusicalGame
    private void CreateChord(ChordStream parentStream, int length, int[] notes)
    {
        Notes = new List<Note>();

        foreach (var item in notes)
        {
            if (item == -1)
            {
                isSilence = true;
                break;
            }
            var note = new Note();
            note.Length = (NoteLength)length;
            note.ParentChord = this;
            note.Tone = (Tones)item;

            Notes.Add(note);
        }
        Length = (NoteLength)length;
        ParentChordStream = parentStream;
        parentStream.chords.Add(this);
    }
コード例 #36
0
ファイル: Chord.cs プロジェクト: Helpfully/UnityMusicalGame
 public Chord(ChordStream parentStream, NoteLength length, params int[] notes)
 {
     CreateChord(parentStream, (int)length, notes);
 }