private void timer1_Tick(object sender, EventArgs e) { msec += 10; int BPM = (int)BPMupdown.Value; int TickMsec = 60000 / (96 * BPM / 4); if (Playing) { while (msec > TickMsec) { msec -= TickMsec; TestFrameLoader.Tuesday_ClockTick(1, 1); TestFrameLoader.Tuesday_ClockTick(1, 0); for (int i = 0; i < msec * 2; i++) { TestFrameLoader.Tuesday_DoTimer(); } Gate = TestFrameLoader.Tuesday_GetGate(); Accent = TestFrameLoader.Tuesday_GetAccent(); CVOut = TestFrameLoader.Tuesday_GetCV(); VelOut = TestFrameLoader.Tuesday_GetVel(); //#define DAC_VOLT(x) ((int)((4096.0 * (x)) / (2.5 * 2.048))) //#define DAC_NOTE(x) DAC_VOLT((x) / 12.0) double volt = (CVOut / 4096.0) * (2.5 * 2.048); double note = volt * 12.0; TS.Set(440 * Math.Pow(2, note / 12), Gate ? 0.2 : 0); } } }
private void RebuildEnv(int points = -1) { int l = points; if (points == -1) { l = Math.Min(4000, pictureBox1.Width); } Envelope Envelope2 = new Envelope(); TestFrameLoader.ResetStatic(); for (int i = 0; i < l; i++) { if (i == 10) { Envelope2.TriggerOn(); TestFrameLoader.Trigger(1, 1, (int)EnvMode); } if (i == 210) { Envelope2.TriggerOff(EnvMode); TestFrameLoader.Trigger(0, 1, (int)EnvMode); } double D = 0; triggers2[i] = Envelope2.Trigger; values2[i] = TestFrameLoader.GetEnv(1, Attack.Value * 255, Decay.Value * 255, Sustain.Value * 255, Release.Value * 255, Curvature.Value * 255, (int)TimeScale, (int)EnvMode) / 4095.0; D = TestFrameLoader.GetEnvCurve(1) / 4095.0; linvalues2[i] = D; } }
private void RebuildEnvInt(int points, int a, int d, int s, int r, int curv) { int l = points; if (points == -1) { l = Math.Min(4000, pictureBox1.Width); } Envelope Envelope2 = new Envelope(); TestFrameLoader.ResetStatic(); for (int i = 0; i < l; i++) { if (i == 0) { Envelope2.TriggerOn(); TestFrameLoader.Trigger(1, 1, (int)EnvMode); } if (i == (points * 2) / 4) { Envelope2.TriggerOff(EnvMode); TestFrameLoader.Trigger(0, 1, (int)EnvMode); } double D = 0; triggers2[i] = Envelope2.Trigger; values2[i] = TestFrameLoader.GetEnv(1, a * 255, d * 255, s * 255, r * 255, curv * 255, (int)TimeScale, (int)EnvMode) / 4095.0; D = TestFrameLoader.GetEnvCurve(1) / 4095.0; linvalues2[i] = D; } }
private void RebuildLFO(bool force = false, int defcount = 5000) { int count = defcount; if (force == false) { count = Math.Min(count, pictureBox1.Width); } TestFrameLoader.ResetStatic(); for (int i = 0; i < count; i++) { if (i == 0) { TestFrameLoader.LFOTrigger(1, 1); } if (i == 1) { TestFrameLoader.LFOTrigger(0, 1); } var V = TestFrameLoader.GetLFO(1, Speed.Value, Shape.Value << 8, Mod.Value << 8, Phase.Value << 4); var V2 = TestFrameLoader.GetLFOBasicShape(1); values64[i] = V2; values2[i] = V / 4096.0f; linvalues2[i] = TestFrameLoader.GetLFOPhased(1) / 4096.0f; } }
public TINRS_Tuesday_TestFrame() { TestFrameLoader.Init(); TS.Open(); TS.Play(); TS.Set(440.0, 0); InitializeComponent(); tooEasyRadio.Checked = true; tpb4.Checked = true; beats8.Checked = true; UpdatePattern(); }
private void EnvUpdate_Tick(object sender, EventArgs e) { for (int i = 0; i < 10; i++) { pos = (pos + 1) % 4000; double D = 0; triggers[pos] = Envelope.Trigger; values[pos] = TestFrameLoader.GetEnv(0, Attack.Value * 255, Decay.Value * 255, Sustain.Value * 255, Release.Value * 255, Curvature.Value * 255, (int)TimeScale, (int)EnvMode) / 4095.0; D = TestFrameLoader.GetEnvCurve(0) / 4095.0; linvalues[pos] = D; } }
private void EnvUpdate_Tick(object sender, EventArgs e) { pos = (pos + 1) % 4000; for (int i = 0; i < 10; i++) { double D = 0; values[pos] = TestFrameLoader.GetLFO(0, Speed.Value, Shape.Value << 8, Mod.Value << 8, Phase.Value << 4) / 4096.0f; D = TestFrameLoader.GetLFOPhased(0) / 4096.0f; valuesref[pos] = (TestFrameLoader.GetLFOBasicShape(0) / 65536.0f) / (4096.0f * 4) + 0.50f; linvalues[pos] = D; } }
public EdgeCutterTestFrame() { TestFrameLoader.Init(); for (int i = 0; i < 120000; i++) { values.Add(0); linvalues.Add(0); values2.Add(0); linvalues2.Add(0); triggers.Add(false); triggers2.Add(false); } InitializeComponent(); RebuildEnv(); }
public WobblerTestFrame() { for (int i = 0; i < 120000; i++) { values.Add(0); valuesref.Add(0); linvalues.Add(0); values2.Add(0); values64.Add(0); linvalues2.Add(0); } TestFrameLoader.Init(); InitializeComponent(); RebuildLFO(); //BuildCalibrationTable(); //BuildFreqLerp(); // BuildPoster(); Shape.Value = 255 / 5; }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { var g = e.Graphics; g.Clear(Color.Black); g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.CompositingQuality = CompositingQuality.HighQuality; List <PointF> P = new List <PointF>(pictureBox1.Width); List <PointF> P2 = new List <PointF>(pictureBox1.Width); List <PointF> P3 = new List <PointF>(pictureBox1.Width); List <PointF> P4 = new List <PointF>(pictureBox1.Width); List <PointF> P5 = new List <PointF>(pictureBox1.Width); for (int i = 0; i < pictureBox1.Width; i++) { int p1 = (i + pos + 4000 - pictureBox1.Width) % 4000; P.Add(new PointF(i, ScaleVal(values[p1]))); P5.Add(new PointF(i, ScaleVal(valuesref[p1]))); P2.Add(new PointF(i, ScaleVal(linvalues[p1]))); P3.Add(new PointF(i, (pictureBox1.Height / 2) + ScaleVal(values2[i]))); P4.Add(new PointF(i, (pictureBox1.Height / 2) + ScaleVal(linvalues2[i]))); } g.DrawLines(new Pen(Color.Blue, 1.0f), P5.ToArray()); g.DrawLines(new Pen(Color.Green, 1.0f), P2.ToArray()); g.DrawLines(new Pen(Color.Yellow, 1.0f), P.ToArray()); g.DrawLines(new Pen(Color.Green, 1.0f), P4.ToArray()); g.DrawLines(new Pen(Color.Yellow, 1.0f), P3.ToArray()); g.DrawLine(new Pen(Color.BlueViolet), new PointF(0, ScaleVal(0.5)), new PointF(pictureBox1.Width - 1, ScaleVal(0.5))); g.DrawLine(new Pen(Color.Lime), new PointF(0, ScaleVal(0.95)), new PointF(pictureBox1.Width - 1, ScaleVal(0.95))); g.DrawLine(new Pen(Color.Lime), new PointF(0, ScaleVal(0.05)), new PointF(pictureBox1.Width - 1, ScaleVal(0.05))); g.DrawLine(new Pen(Color.BlueViolet), new PointF(0, (pictureBox1.Height / 2) + ScaleVal(0.5)), new PointF(pictureBox1.Width - 1, (pictureBox1.Height / 2) + ScaleVal(0.5))); for (int i = 0; i < 2; i++) { int B = TestFrameLoader.GetLFOGate(i); if (B > 0) { B = 255; } var C = Color.FromArgb(B, B, 0); Rectangle R = new Rectangle(); R.Width = 10; R.Height = 10; R.X = pictureBox1.Width - 12 - i * 12; R.Y = 2; g.FillRectangle(new SolidBrush(C), R); g.DrawRectangle(new Pen(Color.White, 1), R); } for (int i = 0; i < 18; i++) { int B = Math.Min(255, TestFrameLoader.GetLFOLed(i)); var C = Color.FromArgb(B, B, 0); Rectangle R = new Rectangle(); R.Width = 10; R.Height = 10; R.X = 2 + i * 12; R.Y = 2; g.FillRectangle(new SolidBrush(C), R); g.DrawRectangle(new Pen(Color.White, 1), R); } }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { var g = e.Graphics; g.Clear(Color.Black); g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.CompositingQuality = CompositingQuality.HighQuality; List <PointF> P = new List <PointF>(pictureBox1.Width); List <PointF> P2 = new List <PointF>(pictureBox1.Width); List <PointF> P3 = new List <PointF>(pictureBox1.Width); List <PointF> P4 = new List <PointF>(pictureBox1.Width); for (int i = 0; i < pictureBox1.Width; i++) { int p1 = (i + pos + 4000 - pictureBox1.Width) % 4000; P.Add(new PointF(i, ScaleVal(values[p1]))); P2.Add(new PointF(i, ScaleVal(linvalues[p1]))); P3.Add(new PointF(i, (pictureBox1.Height / 2) + ScaleVal(values2[i]))); P4.Add(new PointF(i, (pictureBox1.Height / 2) + ScaleVal(linvalues2[i]))); } g.DrawLines(new Pen(Color.Green, 2.0f), P2.ToArray()); g.DrawLines(new Pen(Color.Yellow, 2.0f), P.ToArray()); g.DrawLines(new Pen(Color.Green, 2.0f), P4.ToArray()); g.DrawLines(new Pen(Color.Yellow, 2.0f), P3.ToArray()); for (int i = 0; i < 4; i++) { int B = TestFrameLoader.GetGate(i); if (B > 0) { B = 255; } var C = Color.FromArgb(B, B, 0); Rectangle R = new Rectangle(); R.Width = 10; R.Height = 10; R.X = pictureBox1.Width - 12 - i * 12; R.Y = 2; g.FillRectangle(new SolidBrush(C), R); g.DrawRectangle(new Pen(Color.White, 1), R); } for (int i = 0; i < 13; i++) { int B = TestFrameLoader.GetLed(i); var C = Color.FromArgb(B, B, 0); Rectangle R = new Rectangle(); R.Width = 10; R.Height = 10; R.X = 2 + i * 12; R.Y = 14; g.FillRectangle(new SolidBrush(C), R); g.DrawRectangle(new Pen(Color.White, 1), R); } Pen EnvPen = new Pen(Color.FromArgb(200, 200, 200)); g.DrawLine(EnvPen, 5 + 2 + 12 * 0, 12, 5 + 2 + 12 * 3, 2); g.DrawLine(EnvPen, 5 + 2 + 12 * 3, 2, 5 + 2 + 12 * 6, 7); g.DrawLine(EnvPen, 5 + 2 + 12 * 6, 7, 5 + 2 + 12 * 9, 7); g.DrawLine(EnvPen, 5 + 2 + 12 * 9, 7, 5 + 2 + 12 * 12, 12); }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { var G = e.Graphics; G.Clear(Color.Black); G.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; for (int i = 0; i < 5; i++) { TestFrameLoader.RunPendulum(); TestFrameLoader.RunPendulumInt(); //TestFrameLoader.Compare(); } float F1 = TestFrameLoader.RunPendulum(); float F2 = TestFrameLoader.RunPendulum2(); float iF1 = (float)TestFrameLoader.RunPendulumInt(); float iF2 = (float)TestFrameLoader.RunPendulum2Int(); // F1 *= 6.283f / ((float)(1 <<24)) ; // F2 *= 6.283f / ((float)(1 << 24)); F1 /= (float)0xffff; F2 /= (float)0xffff; iF1 *= 1.0f / (float)(1 << 25); iF2 *= 1.0f / (float)(1 << 25); FloatDisp.Update(F1, F2); IntDisp.Update(iF1, iF2); FloatDisp.Render(G, 10, 0); IntDisp.Render(G, 620, 0); float S = (float)Math.Min(pictureBox1.Width / ((10 + 5.08 * 12)), pictureBox1.Height / (10 + 128.5)); //S = 1.0f / S; float S2 = 1.0f / S; G.ScaleTransform(S, S); G.TranslateTransform(5, 5); float H = 128.5f; float Hi = 106.5f; float W = (5.08f * 12); float R = 1.5f; G.DrawRectangle(new Pen(Color.Gray, S2), 0, (H - Hi) / 2, W, Hi); G.DrawRectangle(new Pen(Color.White, S2), 0, 0, W, H); float x1 = -6; float x2 = (W - x1); float W1 = W / 2 - R * 2; float y1 = H - 2.54f - 11; // string RR = ""; // List<string> dnames = new List<string>{ "d10", "d11", "d33", "d4", "d5", "d6", "d7", "d8", "d9" }; for (int i = 0; i < 9; i++) { float p = (i * 3.1415f) / 19.0f - 0.1f; float cx = -(float)Math.Sin(p) * W1; float sx = (float)Math.Cos(p) * W1; int lA = TestFrameLoader.GetWobbleLed(i, 0); int lB = TestFrameLoader.GetWobbleLed(i, 1); G.FillEllipse(new SolidBrush(Color.FromArgb(lA, 0, 0)), x1 + sx - R, y1 + cx - R, R * 2, R * 2); G.FillEllipse(new SolidBrush(Color.FromArgb(lB, 0, 0)), W - (x1 + sx) - R, y1 + cx - R, R * 2, R * 2); G.DrawEllipse(new Pen(Color.Yellow, S2), x1 + sx - R, y1 + cx - R, R * 2, R * 2); G.DrawEllipse(new Pen(Color.Yellow, S2), W - (x1 + sx) - R, y1 + cx - R, R * 2, R * 2); // RR += String.Format("MOVE D{0} ({1} {2}); ", i + 24, (x1 + sx).ToString().Replace(',','.'), (H*2 - ( y1 + cx)).ToString().Replace(',', '.')); // RR += String.Format("MOVE {0} ({1} {2}); ", dnames[i], (W - (x1 + sx)).ToString().Replace(',', '.'), (H * 2 - (y1 + cx)).ToString().Replace(',', '.')); } // Console.WriteLine(RR); //MessageBox.Show(RR); }
void UpdatePattern() { int Algo = 0; int Scale = 0; int Beats = 0; int Ticks = 0; if (TestPatternButton.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_TESTS; } if (TritranceButton.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_TRITRANCE; } if (stomperButton.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_STOMPER; } if (markovButton.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_MARKOV; } ; if (wobbleButton.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_WOBBLE; } if (chiparp1button.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_CHIPARP1; } if (chipArp2Button.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_CHIPARP2; } if (snhButton.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_SNH; } if (saikoButton.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_SAIKO_LEAD; } if (SaikoClassicButton.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_SAIKO_CLASSIC; } if (scaleWalkerRadio.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_SCALEWALKER; } if (tooEasyRadio.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_TOOEASY; } if (randomRadio.Checked) { Algo = (int)TestFrameLoader.ALGONAMES.ALGO_RANDOM; } if (LongNotesCheck.Checked) { Algo += 32; } if (slidesCheck.Checked) { Algo += 16; } if (minorScaleRadio.Checked) { Scale = (int)TestFrameLoader.SCALENAMES.SCALE_MINOR; } if (dorianScaleRadio.Checked) { Scale = (int)TestFrameLoader.SCALENAMES.SCALE_DORIAN; } if (majorScaleRadio.Checked) { Scale = (int)TestFrameLoader.SCALENAMES.SCALE_MAJOR; } if (pentaTonicScaleRadio.Checked) { Scale = (int)TestFrameLoader.SCALENAMES.SCALE_PENTA; } if (BluesRadio.Checked) { Scale = (int)TestFrameLoader.SCALENAMES.SCALE_BLUES; } if (twelveToneRadio.Checked) { Scale = (int)TestFrameLoader.SCALENAMES.SCALE_12TONE; } if (minorTriadRadio.Checked) { Scale = (int)TestFrameLoader.SCALENAMES.SCALE_MINORTRIAD; } if (MajorTriadRadio.Checked) { Scale = (int)TestFrameLoader.SCALENAMES.SCALE_MAJORTRIAD; } if (trans0.Checked) { Scale += 0; } if (trans5.Checked) { Scale += 1 << 4; } if (trans7.Checked) { Scale += 2 << 4; } if (trans12.Checked) { Scale += 3 << 4; } if (tpb2.Checked) { Ticks = 2; } if (tpb3.Checked) { Ticks = 3; } if (tpb4.Checked) { Ticks = 4; } if (tpb5.Checked) { Ticks = 5; } if (beats4.Checked) { Beats = 4; } if (beats8.Checked) { Beats = 8; } if (beats16.Checked) { Beats = 16; } if (beats32.Checked) { Beats = 32; } TicksPerBeat = Ticks; Pattern.Clear(); TestFrameLoader.Tuesday_UpdatePattern(Algo, Scale, Ticks, Beats, 128, 255 - (int)XSlider.Value, 255 - (int)YSlider.Value, (int)ISlider.Value); int PTicks = TestFrameLoader.Tuesday_GetPatternLength(); for (int i = 0; i < PTicks; i++) { Tick T = new Tick(); T.note = TestFrameLoader.Tuesday_GetTickNote(i); T.vel = TestFrameLoader.Tuesday_GetTickVel(i); T.accent = TestFrameLoader.Tuesday_GetTickAccent(i) > 0; T.gate = TestFrameLoader.Tuesday_GetTickGate(i) > 0; T.slide = TestFrameLoader.Tuesday_GetTickSlide(i); T.length = TestFrameLoader.Tuesday_GetTickLength(i); Pattern.Add(T); } pictureBox1.Invalidate(); }
void BuildCalibrationTable() { List <String> HeaderLines = new List <string>(); List <String> HeaderLinesA = new List <string>(); List <String> HeaderLinesB = new List <string>(); int skip = 4; int total = 256 / skip; HeaderLines.Add(String.Format("#define SHAPECOMPENSATIONCOUNT {0}", total)); HeaderLines.Add(""); HeaderLinesB.Add(String.Format("int const BasicShapeMult[SHAPECOMPENSATIONCOUNT] = {{")); HeaderLinesA.Add(String.Format("int const BasicShapeLow[SHAPECOMPENSATIONCOUNT] = {{")); string L = ""; string L2 = ""; for (int i = 0; i < 256; i += skip) { Shape.Value = 0; Phase.Value = 64; Speed.Value = 255; Mod.Value = i; RebuildLFO(true); Int64 vmin = values64[0]; Int64 vmax = values64[0]; for (int j = i; j < 5000; j++) { if (values64[j] < vmin) { vmin = values64[j]; } else { if (values64[j] > vmax) { vmax = values64[j]; } } } if (L.Length == 0) { L += "\t"; } if (L2.Length == 0) { L2 += "\t"; } L += String.Format("{0}", (vmin + vmax) / 2); Int64 range = vmax - vmin; L2 += String.Format("{0}", (vmax - vmin)); if (i < 256 - skip) { L += ", "; L2 += ", "; } ; if ((i / skip) % 8 == 7) { HeaderLinesB.Add(L2); HeaderLinesA.Add(L); L = ""; L2 = ""; } Console.WriteLine("{0} : {1} -> {2}", i, vmin, vmax); } if (L2.Length > 0) { HeaderLinesB.Add(L2); } if (L.Length > 0) { HeaderLinesA.Add(L); } HeaderLinesA.Add("};"); HeaderLinesA.Add(""); HeaderLinesB.Add("};"); HeaderLines.AddRange(HeaderLinesA); HeaderLines.AddRange(HeaderLinesB); System.IO.File.WriteAllLines("BasicShapeCompensation.h", HeaderLines.ToArray()); for (int i = 0; i < 256; i++) { long P = TestFrameLoader.GetLFOPhaseInc(i); float F = (0xffffffff / P) / 2000.0f;; Console.WriteLine("{0:X} -> {1}", P, F); } }
private void button1_MouseUp(object sender, MouseEventArgs e) { TestFrameLoader.LFOTrigger(0, 0); }
private void TriggerButton_Click(object sender, EventArgs e) { TestFrameLoader.TriggerWobbler(); }
private void button1_MouseDown(object sender, MouseEventArgs e) { Envelope.TriggerOn(); TestFrameLoader.Trigger(1, 0, (int)EnvMode); }
private void button1_MouseUp(object sender, MouseEventArgs e) { Envelope.TriggerOff(EnvMode); TestFrameLoader.Trigger(0, 0, (int)EnvMode); }
public WobblerSetup() { InitializeComponent(); TestFrameLoader.Init(); }