public NoteMapper(TextReader settings, int key) { var notes = Notes.Instance.NotesNameIndex; foreach (var fromNote in notes.Dict2To1.Keys) { var fromNoteValue = (fromNote + key) % 12; var fromNoteName = notes[fromNoteValue]; Console.WriteLine($"{notes[fromNote]} Mapping\n#########"); Console.WriteLine($"Enter octave modifier (int):"); var newOctaveModifier = Int32.Parse(settings.ReadLine()); Console.WriteLine($"Enter new note (0 - 11):"); var toNote = Int32.Parse(settings.ReadLine()); Console.WriteLine($"Enter new pitch shift in semitones (double):"); var newPitchShiftInSemitones = Double.Parse(settings.ReadLine()); var noteMapping = new NoteMapping(); noteMapping.FromNote = fromNoteName; var toNoteName = notes[(toNote + key) % 12]; noteMapping.NewPitchShiftInSemitones = newPitchShiftInSemitones; noteMapping.PitchShiftCorrection = CalculatePitchShiftCorrection(newOctaveModifier * 12 + ((toNote + key) % 12 - fromNoteValue)); noteMapping.ToNote = toNoteName; noteMapping.OctaveModifier = newOctaveModifier; NoteMappings.Add(noteMapping); } }
public NoteMapper(string key, int octaveModifier) { var notes = Notes.Instance.NotesNameIndex; foreach (var fromNote in notes.Dict1To2.Keys) { int newOctaveModifier = octaveModifier; var noteMapping = new NoteMapping(); noteMapping.FromNote = fromNote; // Determine new note. We are doing inversion around major/minor mediant int distanceFromKeyNote = notes[fromNote] - notes[key]; int newDistanceFromKeyNote = 7 - distanceFromKeyNote; var toNote = (newDistanceFromKeyNote + notes[key]); if (toNote > 11) { toNote %= 12; } if (toNote < 0) { toNote += 12; } var toNoteName = notes[toNote]; if (Global.notesToLower.Contains(toNote)) { newOctaveModifier -= 1; } if (Global.notesToRaise.Contains(toNote)) { newOctaveModifier += 1; } noteMapping.PitchShiftCorrection = -1 * CalculatePitchShiftCorrection(newOctaveModifier * 12 + (toNote - notes[fromNote])); noteMapping.ToNote = toNoteName; noteMapping.OctaveModifier = newOctaveModifier; NoteMappings.Add(noteMapping); } }