// GET: CSEQs/Create public ActionResult Create() { CSEQ cSEQ = new CSEQ(); ViewBag.EQCAT = cSEQ.category; return(View()); }
private void LoadCseq(string fn) { //Log.Clear(); sequenceBox.Items.Clear(); trackBox.Items.Clear(); string name = Path.GetFileNameWithoutExtension(fn); for (int i = 0; i < comboBox1.Items.Count; i++) { if (name.Contains(comboBox1.Items[i].ToString())) { comboBox1.SelectedIndex = i; } } seq = new CSEQ(); if (seq.Read(fn)) { FillUI(fn); } else { MessageBox.Show("Failed to read CTR sequence!"); } }
public ActionResult Create([Bind(Include = "EQCODE,EQDESC,EQCAT,STAMP")] CSEQ cSEQ) { if (ModelState.IsValid) { try { cSEQ.STAMP = 0; db.CSEQs.Add(cSEQ); db.SaveChanges(); return(RedirectToAction("Index")); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { //string message = string.Format("{0}:{1}", // validationErrors.Entry.Entity.ToString(), // validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage); } } } catch (DbUpdateException ex) { UpdateException updateException = (UpdateException)ex.InnerException; if (updateException != null) { if (updateException.InnerException != null) { var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException; foreach (var error in sqlException.Errors) { if (error.Message != null) { ModelState.AddModelError(string.Empty, error.Message); } } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } } ViewBag.EQCAT = cSEQ.category; return(View(cSEQ)); }
public ActionResult DeleteConfirmed(string id) { CSEQ cSEQ = db.CSEQs.Find(MyHtmlHelpers.ConvertByteStrToId(id)); try { db.CSEQs.Remove(cSEQ); db.SaveChanges(); return(RedirectToAction("Index")); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { //string message = string.Format("{0}:{1}", // validationErrors.Entry.Entity.ToString(), // validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage); } } } catch (DbUpdateException ex) { UpdateException updateException = (UpdateException)ex.InnerException; if (updateException != null) { if (updateException.InnerException != null) { var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException; foreach (var error in sqlException.Errors) { if (error.Message != null) { ModelState.AddModelError(string.Empty, error.Message); } } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } else { ModelState.AddModelError(string.Empty, updateException.Message); } } return(View(cSEQ)); }
private void testJsonToolStripMenuItem_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { string[] files = Directory.GetFiles(fbd.SelectedPath); List <string> x = new List <string>(); foreach (string s in files) { CSEQ c = CSEQ.FromFile(s); foreach (SampleDef sd in c.samples) { if (!x.Contains(sd.Tag)) { x.Add(sd.Tag); } } foreach (SampleDefReverb sd in c.samplesReverb) { if (!x.Contains(sd.Tag)) { x.Add(sd.Tag); } } } x.Sort(); StringBuilder sb = new StringBuilder(); foreach (string s in x) { sb.AppendLine(s); } textBox1.Text = sb.ToString(); } /* * string track = "canyon"; * string instr = "long"; * int id = 0; * * * MetaInst info = CTRJson.GetMetaInst(track, instr, id); * textBox1.Text += "" + info.Midi + " " + info.Key + " " + info.Title + " " + info.Pitch; */ }
public void Read(BinaryReaderEx br) { if (File.Exists(Meta.SmplPath)) { ReadSampleNames(Meta.SmplPath); } header = new HowlHeader(br); for (int i = 0; i < header.cntUnk; i++) { if (br.ReadUInt16() != 0) { Console.WriteLine("HOWL Read: upper word not 0."); } unk.Add(br.ReadUInt16()); } for (int i = 0; i < header.cntSfx; i++) { samples1.Add(new SampleDef(br)); } for (int i = 0; i < header.cntEngineSfx; i++) { samples2.Add(new SampleDef(br)); } for (int i = 0; i < header.cntBank; i++) { ptrBanks.Add(br.ReadUInt16() * Meta.SectorSize); } for (int i = 0; i < header.cntSeq; i++) { ptrSeqs.Add(br.ReadUInt16() * Meta.SectorSize); } foreach (var ptr in ptrBanks) { br.Jump(ptr); banks.Add(new Bank(br)); } foreach (var ptr in ptrSeqs) { br.Jump(ptr); sequences.Add(CSEQ.FromReader(br)); } }
// GET: CSEQs/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSEQ cSEQ = db.CSEQs.Find(MyHtmlHelpers.ConvertByteStrToId(id)); if (cSEQ == null) { return(HttpNotFound()); } return(View(cSEQ)); }
public void Read(BinaryReaderEx br) { ReadSampleNames(); header = HowlHeader.FromReader(br); for (int i = 0; i < header.cntUnk; i++) { if (br.ReadUInt16() != 0) { Helpers.Panic(this, "upper word is not 0."); } unk.Add(br.ReadUInt16()); } samples1 = InstanceList <SampleDef> .FromReader(br, (uint)br.BaseStream.Position, (uint)header.cntSfx); samples2 = InstanceList <SampleDef> .FromReader(br, (uint)br.BaseStream.Position, (uint)header.cntEngineSfx); /* * for (int i = 0; i < header.cntSfx; i++) * samples1.Add(SampleDef.FromReader(br)); * * for (int i = 0; i < header.cntEngineSfx; i++) * samples2.Add(SampleDef.FromReader(br)); */ for (int i = 0; i < header.cntBank; i++) { ptrBanks.Add(br.ReadUInt16() * Meta.SectorSize); } for (int i = 0; i < header.cntSeq; i++) { ptrSeqs.Add(br.ReadUInt16() * Meta.SectorSize); } foreach (var ptr in ptrBanks) { br.Jump(ptr); banks.Add(new Bank(br)); } foreach (var ptr in ptrSeqs) { br.Jump(ptr); sequences.Add(CSEQ.FromReader(br)); } }
// GET: CSEQs/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CSEQ cSEQ = db.CSEQs.Find(MyHtmlHelpers.ConvertByteStrToId(id)); if (cSEQ == null) { return(HttpNotFound()); } ViewBag.EQCAT = cSEQ.category; return(View(cSEQ)); }
private void importMIDIToolStripMenuItem_Click(object sender, EventArgs e) { if (seq == null) { seq = new CSEQ(); } OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "MIDI File (*.mid)|*.mid"; if (ofd.ShowDialog() == DialogResult.OK) { MidiFile midi = new MidiFile(ofd.FileName); Sequence newMidi = new Sequence(); for (int i = 0; i < midi.Tracks; i++) { CTrack track = new CTrack(); track.trackNum = i; track.name = $"track_{i.ToString("00")}"; track.FromMidiEventList(midi.Events.GetTrackEvents(i).ToList()); newMidi.tracks.Add(track); } foreach (var x in newMidi.tracks) { Command c = new Command(); c.evt = CSEQEvent.ChangePatch; c.pitch = (byte)x.trackNum; c.wait = 0; x.cmd.Insert(0, c); } seq.sequences.Add(newMidi); FillUI(loadedfile); } }
public CSEQViewer(CSEQ Sequence) { this.Sequence = Sequence; InitializeComponent(); }