using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace Mtrk2Mbseq { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //only reads first track string inputFile = @"c:\temp\mtrkbassline.csv"; int lineCount = File.ReadLines(inputFile).Count(); string notesAgain = string.Empty; List noteCollection = new List(); foreach (string line in File.ReadLines(inputFile)) { if (line.Substring(0,1) == ";"){ string[] rowData = line.Split(';'); string note = rowData[5].Trim(); if ((note.Length > 0) && (note != "off")) { string octave = note.Substring(2, 1); note = note.Substring(0, 2).Replace("-", string.Empty); string midiNote = getNoteValue(note, octave); noteCollection.Add(midiNote); } else { note = "x"; noteCollection.Add(note); } notesAgain = string.Join(" ", noteCollection.ToArray()); } } Console.WriteLine("1:" + notesAgain.ToString()); } private string getNoteValue(string note, string octave) { Dictionary midiNoteValues = new Dictionary() { //midi note, octave 0 values {"C", 0},{"C#", 1},{"D", 2},{"D#", 3},{"E", 4},{"F", 5},{"F#", 6},{"G", 7}, {"G#", 8},{"A", 9},{"A#", 10},{"B", 11}, }; int octavevalue = Convert.ToInt32(octave) * 12 -12; //drop 1 oct after convert .. buzz is higher string midiNote = (midiNoteValues[note] + octavevalue).ToString(); return midiNote; } } }