public JsonResult SaveSong(Song song)
 {
     int compID = Convert.ToInt32(System.Web.HttpContext.Current.Session["CompositionID"] as string);
     using (var db = new CompositionContext())
     {
         Composition c;
         if (compID == 0)
         {
             c = new Composition();
         }
         else
         {
             c = db.Compositions.Find(compID);
         }
         song.getMetaData(c);
         c.Content = song.getContent();
         c.TabContent = song.getTabContent();
         c.User = User.Identity.Name;
        if (compID == 0)
         {
             db.Compositions.Add(c);
         }
         db.SaveChanges();
         song.setMetaData(c);
         song.SongId = c.CompositionID;
     }
     foreach (var p in song.Pages)
     {
         while (p.Measures.Count() < 28)
         {
             p.Measures.Add(new Measure());
         }
     }
     return Json(song, JsonRequestBehavior.AllowGet);
 }
        public ActionResult GetSong()
        {
            Song song = new Song();
            if (System.Web.HttpContext.Current.Session["CompositionID"] as string == "0")
            {
                song.Pages.Add(new Page());
                song.Artist = "N/A";
                song.Title = "New Song";
                song.Author = "N/A";
                song.BeatsPerMeasure = 4;
                song.Difficulty = "Easy";
                song.SingleBeat = 4;
                song.KeySignature = "C";
            }
            else
            {
                Composition c;
                int compID = Convert.ToInt32(System.Web.HttpContext.Current.Session["CompositionID"] as string);
                using (var db = new CompositionContext())
                {
                    c = db.Compositions.Where(x => x.CompositionID == compID).Single();
                    song.setMetaData(c);
                    song.setContent(c.Content, c.TabContent);
                }
            }

            return Json(song, JsonRequestBehavior.AllowGet);
        }
 public ActionResult GetSongFromComposition(Composition c)
 {
     Song song = new Song();
     using (var db = new CompositionContext())
     {
         song.setMetaData(c);
         song.setContent(c.Content, c.TabContent);
     }
     return Json(song, JsonRequestBehavior.AllowGet);
 }
 public void EditorDrawsChromaticScale()
 {
     Song song = new Song();
     Page page = new Page(new List<Measure> {
         new Measure(new List<Note> {
             new Note(new List<Tone> { new Tone("e/3", "") }, new List<TabTone>(), "q"),
             new Note(new List<Tone> { new Tone("f/3", "") }, new List<TabTone>(), "q"),
             new Note(new List<Tone> { new Tone("f/3", "#") }, new List<TabTone>(), "q"),
             new Note(new List<Tone> { new Tone("g/3", "") }, new List<TabTone>(),  "q")
         }),
         new Measure(new List<Note> {
             new Note(new List<Tone> { new Tone("e/3", "") }, new List<TabTone>(), "q"),
             new Note(new List<Tone> { new Tone("f/3", "") }, new List<TabTone>(), "q"),
             new Note(new List<Tone> { new Tone("f/3", "#") }, new List<TabTone>(), "q"),
             new Note(new List<Tone> { new Tone("g/3", "") }, new List<TabTone>(), "q")
         }),
         new Measure(new List<Note> {
             new Note(new List<Tone> { new Tone("e/3", "") }, new List<TabTone>(), "q"),
             new Note(new List<Tone> { new Tone("f/3", "") }, new List<TabTone>(), "q"),
             new Note(new List<Tone> { new Tone("f/3", "#") }, new List<TabTone>(), "q"),
             new Note(new List<Tone> { new Tone("g/3", "") }, new List<TabTone>(), "q")
         }),
         new Measure(new List<Note> {
             new Note(new List<Tone> { new Tone("g/3", "#") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("a/3", "") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("a/3", "#") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("b/3", "") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("c/4", "") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("c/4", "#") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("d/4", "") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("d/4", "#") }, new List<TabTone>(), "8")
         }),
         new Measure(new List<Note> {
             new Note(new List<Tone> { new Tone("e/4", "") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("f/4", "") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("f/4", "#") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("g/4", "") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("g/4", "#") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("a/4", "") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("a/4", "#") }, new List<TabTone>(), "8"),
             new Note(new List<Tone> { new Tone("b/4", "") }, new List<TabTone>(), "8")
         })
     });
     song.Pages.Add(page);
     // Arrange
     EditorController controller = new EditorController();
 }
 public JsonResult TabulateSong(Song song)
 {
     Tabulator.Tabulator tab = new SimpleTabulator();
     Song s = new Song();
     foreach (var page in song.Pages)
     {
         Page p = new Page();
         p.Measures = new List<Measure>();
         foreach (var measure in page.Measures)
         {
             Measure m = new Measure();
             foreach (var note in measure.Notes)
             {
                 Note n = new Note();
                 n.Beat = note.Beat;
                 foreach (var tone in note.Tones)
                 {
                     n.Tones.Add(tone);
                     n.TabTones.Add(tab.getTabNote(tone));
                 }
                 m.Notes.Add(n);
             }
             p.Measures.Add(m);
         }
         s.Pages.Add(p);
     }
     Composition c = new Composition();
     song.getMetaData(c);
     s.setMetaData(c);
     foreach (var p in s.Pages)
     {
         while (p.Measures.Count() < 28)
         {
             p.Measures.Add(new Measure());
         }
     }
     return Json(s, JsonRequestBehavior.AllowGet);
 }