private void setNotePitch(int midiKey) { int octave = (midiKey / 12) - 1; var x = pitches[midiKey % 12]; var y = midiKey % 12; noteBuilder.SetPitch(pitches[y]); NoteBuilderSetSemitone(y); noteBuilder.ClearOctave(); noteBuilder.ModifyOctave(2); int octaveModifier = midiKey; while (octaveModifier < 60 || octaveModifier > 71) { if (octaveModifier < 60) { noteBuilder.ModifyOctave(-1); octaveModifier += 12; } else if (octaveModifier > 71) { noteBuilder.ModifyOctave(1); octaveModifier -= 12; } } }
public override bool Execute(string s) { foreach (char c in s) { if (char.IsLetter(c)) { NoteBuilder.SetPitch(NoteBuilderResources.GetPitch(c.ToString())); return(true); } } return(false); }
private Note FindNote(LilypondToken currentToken) { string text = currentToken.Value; Regex re = new Regex(@"^([a-g])([eis]*)([,']*)(\d+)([.]*)$"); Match result = re.Match(text); noteBuilder.SetPitch(result.Groups[1].Value); noteBuilder.SetSemitone(pitchModifiers[result.Groups[2].Value]); noteBuilder.ModifyOctave(FindOctaveModifier(result.Groups[3].Value) + RelativeOctaveModifier(result.Groups[1].Value)); noteBuilder.SetDuriation(int.Parse(result.Groups[4].Value)); noteBuilder.SetDotted(result.Groups[5].Value.Length); return(noteBuilder.BuildNote()); }
private void SetNoteSound(ChannelMessage channelMessage) { Pitch pitch; Octave octave; MoleOrCross mole; helper.GetPitch(previousMidiKey, channelMessage.Data1, out pitch, out octave, out mole); // Append the new note. noteBuilder = new NoteBuilder(); noteBuilder.SetPitch(pitch); noteBuilder.SetOctave(octave); noteBuilder.SetMole(mole); previousMidiKey = channelMessage.Data1; startedNoteIsClosed = false; }
// Converts the event to note public void Convert(MidiEvent midiEvent, ref Models.Track track) { var channelMessage = midiEvent.MidiMessage as ChannelMessage; if (channelMessage.Command == ChannelCommand.NoteOn) { if (channelMessage.Data2 > 0) // Data2 = loudness { SetNoteSound(channelMessage); } else if (!startedNoteIsClosed) { FinishNote(midiEvent, track); } else { noteBuilder.SetPitch(Pitch.R); } } }