예제 #1
0
        private static void ListInstrumentsJSON(WebContext context, Song s)
        {
            JSONWriter jw = new JSONWriter();
            jw.Array();

            for (int k = 0; k < s.Instruments.Count; k++)
            {
                Instrument ins = s.Instruments[k];

                jw.Class();
                jw.Field("id", ins.ID);
                jw.Field("name", ins.Name);
                jw.Field("device", ins.MidiDevice);
                jw.Field("channel", ins.MidiChannel);
                jw.Field("patch", ins.MidiPatch);
                jw.Field("type", ins.Type);
                jw.End();
            }

            jw.End();

            context.Response.Write("g_Instruments = ");
            context.Response.Write(jw.ToString(JSONFormatting.Pretty));
            context.Response.Write(";\n");
        }
예제 #2
0
        private static void ListAutomationChannelsJSON(WebContext context, Song s)
        {
            JSONWriter jw = new JSONWriter();
            jw.Array();

            for (int j = 0; j < s.Tracks.Count; j++)
            {
                // SongTrack st = s.Tracks[j];
                jw.Class();
                jw.Field("id", j);
                jw.Field("name", "Automation #" + j);
                jw.End();
            }

            jw.End();

            context.Response.Write("g_AutomationTracks = ");
            context.Response.Write(jw.ToString(JSONFormatting.Pretty));
            context.Response.Write(";\n");
        }
예제 #3
0
        private static void ListMidiDevicesJSON(WebContext context, Song s)
        {
            JSONWriter jw = new JSONWriter();
            jw.Array();

            List<int> ids = MidiWrapper.GetDeviceIDs();

            for (int k = 0; k < ids.Count; k++)
            {
                string nam = MidiWrapper.GetDeviceName(ids[k]);
                jw.Class();
                jw.Field("id", ids[k]);
                jw.Field("name", nam);
                jw.End();
            }

            jw.End();

            context.Response.Write("g_MidiDevices = ");
            context.Response.Write(jw.ToString(JSONFormatting.Pretty));
            context.Response.Write(";\n");
        }
예제 #4
0
        private static void ListTracksJSON(WebContext context, Song s)
        {
            JSONWriter jw = new JSONWriter();
            jw.Array();

            for (int j = 0; j < s.Tracks.Count; j++)
            {
                SongTrack st = s.Tracks[j];
                jw.Class();
                jw.Field("id", st.ID);
                jw.Field("name", st.Name);

                if (st.CurrentPatternID != null)
                    jw.Field("pattern", st.CurrentPatternID);
                else
                    jw.Field("pattern", "");

                if (st.CuedPatternID != null)
                    jw.Field("cued", st.CuedPatternID);
                else
                    jw.Field("cued", "");

                jw.Field("volume", st.Volume);
                jw.Field("transpose", st.Transpose);
                jw.Field("mute", st.Muted ? 1 : 0);
                jw.Field("solo", st.Solo ? 1 : 0);
                jw.End();
            }

            jw.End();

            context.Response.Write("g_Tracks = ");
            context.Response.Write(jw.ToString(JSONFormatting.Pretty));
            context.Response.Write(";\n");
        }
예제 #5
0
        private static void ListSongJSON(WebContext context, Song s)
        {
            JSONWriter jw = new JSONWriter();
            jw.Class();
            jw.Field("bpm", s.BPM);
            jw.Field("beats1", s.Beats1);
            jw.Field("beats2", s.Beats2);
            jw.End();

            context.Response.Write("g_Song = ");
            context.Response.Write(jw.ToString(JSONFormatting.Pretty));
            context.Response.Write(";\n");
        }
예제 #6
0
        private static void ListPatternsJSON(WebContext context, Song s)
        {
            JSONWriter jw = new JSONWriter();
            jw.Array();

            for (int j = 0; j < s.Patterns.Count; j++)
            {
                Pattern p = s.Patterns[j];

                jw.Class();

                jw.Field("id", p.ID);
                jw.Field("instrument", p.InstrumentID);
                jw.Field("name", p.Name);
                jw.Field("duration", p.Duration);

                jw.Array("notes");
                for (int k = 0; k < p.Notes.Count; k++)
                {
                    PatternNote pn = p.Notes[k];
                    jw.Class();
                    jw.Field("id", pn.ID);
                    jw.Field("from", pn.From);
                    jw.Field("to", pn.To);
                    jw.Field("note", pn.Note);
                    jw.Field("velocity", pn.Velocity);
                    jw.End();
                }
                jw.End();

                jw.Array("automations");
                for (int k = 0; k < p.Automations.Count; k++)
                {
                    PatternAutomation pa = p.Automations[k];
                    jw.Class();
                    jw.Field("id", pa.ID);
                    jw.Field("macro", pa.Macro);
                    jw.Field("channel", pa.Channel);
                    jw.Array("keys");
                    for (int u = 0; u < pa.Keys.Count; u++)
                    {
                        jw.Class();
                        jw.Field("id", pa.Keys[u].ID);
                        jw.Field("time", pa.Keys[u].Time);
                        jw.Field("value", pa.Keys[u].Value);
                        jw.End();
                    }
                    jw.End();
                    jw.End();
                }
                jw.End();

                jw.End();
            }

            jw.End();

            context.Response.Write("g_Patterns = ");
            context.Response.Write(jw.ToString(JSONFormatting.Pretty));
            context.Response.Write(";\n");
        }
예제 #7
0
 public MasterSequencer()
 {
     CurrentSong = null;
 }
예제 #8
0
파일: Song.cs 프로젝트: possan/randomjunk
        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;
        }
예제 #9
0
파일: Song.cs 프로젝트: possan/randomjunk
        public static Song CreateFromFile(string filename)
        {
            Song ret = null;

            Song t = new Song();
            if (t.LoadFromFile(filename))
                ret = t;

            return ret;
        }