public Instrument Clone() { Instrument ret = new Instrument(); ret.ID = ID; ret.Name = Name; ret.Type = Type; ret.MidiPatch = MidiPatch; ret.MidiChannel = MidiChannel; ret.MidiDevice = MidiDevice; return ret; }
public SongTrack() { ID = ""; Name = ""; InstrumentID = ""; LivePatternID = ""; CuedPatternID = ""; Volume = 100; LastPatternTick = -99; PatternSubTick = 0; LastPatternSubTick = 0; PatternTick = 0; CurrentPatternID = ""; CurrentPatternObj = null; Muted = false; Solo = false; CurrentPatternDurationTicks = 0; CurrentInstrumentObj = null; Items = new List<SongTrackItem>(); Transpose = 0; }
private void CreateInstrument(WebContext context) { string insid = context.Request.GetParameter("createinstrument"); string sid = context.Request.GetParameter("session"); string name = context.Request.GetParameter("name"); Song s = State.CurrentSong; Instrument ins = new Instrument(); ins.ID = insid; ins.Name = name; s.Instruments.Add(ins); Console.WriteLine("Creating instrument: " + name); s.SaveToFile("testsong-temp.xml"); Notifications.QueueToAll(sid, "instrument-created|" + insid); Notifications.QueueToAll(sid, "instrumentlist-changed|" + insid); context.Response.ContentType = "text/plain"; context.Response.Write("OK"); }
void QueuePatternEvents(Pattern p, Instrument ins, float step0, float step1, int transpose, int volume) { // Console.WriteLine("Handle events between step: " + step0.ToString("0.0000") + " - " + step1.ToString("0.0000")); int step0mult = (int)(100.0 * step0); int step1mult = (int)(100.0 * step1); // interpolera fram all automations också! // p.Automations.Count for (int k = 0; k < p.Notes.Count; k++) { PatternNote pn = p.Notes[k]; if (pn.From >= step0mult && pn.From < step1mult) { // Console.WriteLine("Note on - key=" + pn.Note + ", velocity=" + pn.Velocity + ", instrument=" + p.InstrumentID); if (volume > 0) if (ins != null) MidiWrapper.QueueNoteOn(ins.MidiDevice, ins.MidiChannel, pn.Note + transpose, (pn.Velocity * volume) / 100); } else if (pn.To >= step0mult && pn.To < step1mult) { // Console.WriteLine("Note off - key=" + pn.Note + ", instrument=" + p.InstrumentID); if (ins != null) MidiWrapper.QueueNoteOff(ins.MidiDevice, ins.MidiChannel, pn.Note + transpose); } } }
public static Song CreateDummySong() { Song s = new Song(); s.BPM = 150; { SongTrack st = new SongTrack(); st.ID = "trk1"; st.Name = "Lead"; st.InstrumentID = "ins1"; st.LivePatternID = ""; st.Items.Add(new SongTrackItem("item1", 0, 8, "pat1")); st.Items.Add(new SongTrackItem("item2", 10, 18, "pat2")); st.Items.Add(new SongTrackItem("item3", 20, 28, "pat3")); st.CuedPatternID = "pat00001"; s.Tracks.Add(st); } { SongTrack st = new SongTrack(); st.ID = "trk2"; st.Name = "Synth"; st.InstrumentID = "ins2"; s.Tracks.Add(st); } { SongTrack st = new SongTrack(); st.ID = "trk3"; st.Name = "Bass"; st.CuedPatternID = "pat00003"; st.InstrumentID = "ins3"; s.Tracks.Add(st); } { Instrument ins = new Instrument(); ins.ID = "ins1"; ins.Name = "First instrument"; ins.MidiChannel = 1; ins.MidiPatch = 30; ins.Type = ""; s.Instruments.Add(ins); } { Instrument ins = new Instrument(); ins.ID = "ins2"; ins.Name = "Second instrument"; ins.MidiChannel = 1; ins.MidiPatch = 30; ins.Type = ""; s.Instruments.Add(ins); } { Instrument ins = new Instrument(); ins.ID = "ins3"; ins.Name = "Third instrument"; ins.MidiChannel = 1; ins.MidiPatch = 30; ins.Type = ""; s.Instruments.Add(ins); } { Pattern pt = new Pattern(); pt.ID = "pat00001"; pt.InstrumentID = "ins1"; pt.Name = "Lead1"; pt.Duration = 16; pt.Notes.Add(new PatternNote("note11_1", 0L, 400L, 30, 100)); pt.Notes.Add(new PatternNote("note11_2", 200L, 400L, 24, 100)); pt.Notes.Add(new PatternNote("note11_3", 400L, 1600L, 20, 100)); { PatternAutomation pa = new PatternAutomation(); pa.Channel = 85; pa.ID = "aut85"; pa.Keys.Add(new PatternAutomationKey("pa0", 0, 100)); pa.Keys.Add(new PatternAutomationKey("pa1", 100, 10)); pa.Keys.Add(new PatternAutomationKey("pa2", 1300, 0)); pt.Automations.Add(pa); } s.Patterns.Add(pt); } { Pattern pt = new Pattern(); pt.ID = "pat00002"; pt.InstrumentID = "ins1"; pt.Name = "Lead2"; pt.Duration = 2; pt.Notes.Add(new PatternNote("note22_1", 0L, 100L, 30, 100)); pt.Notes.Add(new PatternNote("note22_2", 100L, 200L, 24, 100)); s.Patterns.Add(pt); } { Pattern pt = new Pattern(); pt.ID = "pat00003"; pt.InstrumentID = "ins2"; pt.Name = "Lead3"; s.Patterns.Add(pt); } { Pattern pt = new Pattern(); pt.ID = "pat00004"; pt.InstrumentID = "ins3"; pt.Name = "Lead4"; s.Patterns.Add(pt); } return s; }
public bool LoadFromFile(string filename) { if (!File.Exists(filename)) return false; XmlDocument d = new XmlDocument(); try { d.Load(filename); XmlNode commonnode = d.SelectSingleNode("/song/common"); { XmlNode n = d.SelectSingleNode("/song/common/name"); if (n != null) Name = n.InnerText; } { XmlNode n = d.SelectSingleNode("/song/common/bpm"); if (n != null) { int i = 0; int.TryParse(n.InnerText, out i); BPM = i; } } { XmlNode n = d.SelectSingleNode("/song/common/duration"); if (n != null) { int i = 0; int.TryParse(n.InnerText, out i); Duration = i; } } { XmlNode n = d.SelectSingleNode("/song/common/beats1"); if (n != null) { int i = 0; int.TryParse(n.InnerText, out i); Beats1 = i; } } { XmlNode n = d.SelectSingleNode("/song/common/beats2"); if (n != null) { int i = 0; int.TryParse(n.InnerText, out i); Beats2 = i; } } { XmlNode n = d.SelectSingleNode("/song/common/loopstart"); if (n != null) { int i = 0; int.TryParse(n.InnerText, out i); LoopIn = i; } } { XmlNode n = d.SelectSingleNode("/song/common/loopend"); if (n != null) { int i = 0; int.TryParse(n.InnerText, out i); LoopOut = i; } } { XmlNode n = d.SelectSingleNode("/song/common/looping"); if (n != null) { int i = 0; int.TryParse(n.InnerText, out i); Looping = (i == 1); } } { XmlNode n = d.SelectSingleNode("/song/common/position"); if (n != null) { int i = 0; int.TryParse(n.InnerText, out i); PlayPosition = i; } } XmlNodeList patternlist = d.SelectNodes("/song/patterns/pattern"); for (int j = 0; j < patternlist.Count; j++) { Pattern p = new Pattern(); if (p.LoadFromXML(patternlist[j])) Patterns.Add(p); } XmlNodeList instrumentslist = d.SelectNodes("/song/instruments/instrument"); for (int j = 0; j < instrumentslist.Count; j++) { Instrument i = new Instrument(); if (i.LoadFromXML(instrumentslist[j])) Instruments.Add(i); } XmlNodeList trackslist = d.SelectNodes("/song/tracks/track"); for (int j = 0; j < trackslist.Count; j++) { SongTrack t = new SongTrack(); if (t.LoadFromXML(trackslist[j])) Tracks.Add(t); } } catch (Exception z) { Console.WriteLine(z.ToString()); } return true; }