Merged Synthesizer from alexguirre (WIP)

This commit is contained in:
dexy 2022-01-27 15:19:12 +11:00
parent adcb997808
commit 8207da8d70
5 changed files with 2496 additions and 3 deletions

View File

@ -32,6 +32,10 @@
<ProjectReference Include="..\CodeWalker.WinForms\CodeWalker.WinForms.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Windows.Forms.DataVisualization" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>

View File

@ -29,6 +29,9 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RelForm));
this.RelPropertyGrid = new CodeWalker.WinForms.PropertyGridFix();
this.MainTabControl = new System.Windows.Forms.TabControl();
@ -44,6 +47,17 @@
this.SearchTextBox = new System.Windows.Forms.TextBox();
this.SearchButton = new System.Windows.Forms.Button();
this.SearchResultsGrid = new CodeWalker.WinForms.PropertyGridFix();
this.SynthsTabPage = new System.Windows.Forms.TabPage();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SynthVariablesTextBox = new System.Windows.Forms.TextBox();
this.SynthOutputsTextBox = new System.Windows.Forms.TextBox();
this.SynthBufferChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.SynthPlayButton = new System.Windows.Forms.Button();
this.SynthCopyXMLButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SynthsComboBox = new System.Windows.Forms.ComboBox();
this.SynthTextBox = new FastColoredTextBoxNS.FastColoredTextBox();
this.MainToolbar = new System.Windows.Forms.ToolStrip();
this.NewButton = new System.Windows.Forms.ToolStripSplitButton();
this.OpenButton = new System.Windows.Forms.ToolStripSplitButton();
@ -64,12 +78,16 @@
this.wIPToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.OpenFileDialog = new System.Windows.Forms.OpenFileDialog();
this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.SynthStopButton = new System.Windows.Forms.Button();
this.MainTabControl.SuspendLayout();
this.XmlTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.XmlTextBox)).BeginInit();
this.DetailsTabPage.SuspendLayout();
this.NameTableTabPage.SuspendLayout();
this.SearchTabPage.SuspendLayout();
this.SynthsTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.SynthBufferChart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.SynthTextBox)).BeginInit();
this.MainToolbar.SuspendLayout();
this.MainStatusStrip.SuspendLayout();
this.MainMenu.SuspendLayout();
@ -92,6 +110,7 @@
this.MainTabControl.Controls.Add(this.DetailsTabPage);
this.MainTabControl.Controls.Add(this.NameTableTabPage);
this.MainTabControl.Controls.Add(this.SearchTabPage);
this.MainTabControl.Controls.Add(this.SynthsTabPage);
this.MainTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.MainTabControl.Location = new System.Drawing.Point(0, 49);
this.MainTabControl.Margin = new System.Windows.Forms.Padding(0);
@ -136,6 +155,7 @@
this.XmlTextBox.DelayedEventsInterval = 1;
this.XmlTextBox.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))));
this.XmlTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.XmlTextBox.Font = new System.Drawing.Font("Courier New", 9.75F);
this.XmlTextBox.IsReplaceMode = false;
this.XmlTextBox.Language = FastColoredTextBoxNS.Language.XML;
this.XmlTextBox.LeftBracket = '<';
@ -270,6 +290,166 @@
this.SearchResultsGrid.Size = new System.Drawing.Size(822, 423);
this.SearchResultsGrid.TabIndex = 1;
//
// SynthsTabPage
//
this.SynthsTabPage.Controls.Add(this.SynthStopButton);
this.SynthsTabPage.Controls.Add(this.label3);
this.SynthsTabPage.Controls.Add(this.label2);
this.SynthsTabPage.Controls.Add(this.SynthVariablesTextBox);
this.SynthsTabPage.Controls.Add(this.SynthOutputsTextBox);
this.SynthsTabPage.Controls.Add(this.SynthBufferChart);
this.SynthsTabPage.Controls.Add(this.SynthPlayButton);
this.SynthsTabPage.Controls.Add(this.SynthCopyXMLButton);
this.SynthsTabPage.Controls.Add(this.label1);
this.SynthsTabPage.Controls.Add(this.SynthsComboBox);
this.SynthsTabPage.Controls.Add(this.SynthTextBox);
this.SynthsTabPage.Location = new System.Drawing.Point(4, 22);
this.SynthsTabPage.Name = "SynthsTabPage";
this.SynthsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.SynthsTabPage.Size = new System.Drawing.Size(831, 460);
this.SynthsTabPage.TabIndex = 4;
this.SynthsTabPage.Text = "Synths";
this.SynthsTabPage.UseVisualStyleBackColor = true;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(8, 59);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 13);
this.label3.TabIndex = 42;
this.label3.Text = "Variables:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 33);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(47, 13);
this.label2.TabIndex = 41;
this.label2.Text = "Outputs:";
//
// SynthVariablesTextBox
//
this.SynthVariablesTextBox.Location = new System.Drawing.Point(64, 56);
this.SynthVariablesTextBox.Multiline = true;
this.SynthVariablesTextBox.Name = "SynthVariablesTextBox";
this.SynthVariablesTextBox.Size = new System.Drawing.Size(293, 87);
this.SynthVariablesTextBox.TabIndex = 40;
//
// SynthOutputsTextBox
//
this.SynthOutputsTextBox.Location = new System.Drawing.Point(64, 30);
this.SynthOutputsTextBox.Name = "SynthOutputsTextBox";
this.SynthOutputsTextBox.Size = new System.Drawing.Size(293, 20);
this.SynthOutputsTextBox.TabIndex = 39;
//
// SynthBufferChart
//
this.SynthBufferChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
chartArea2.Name = "ChartArea1";
this.SynthBufferChart.ChartAreas.Add(chartArea2);
legend2.Name = "Legend1";
this.SynthBufferChart.Legends.Add(legend2);
this.SynthBufferChart.Location = new System.Drawing.Point(363, 31);
this.SynthBufferChart.Name = "SynthBufferChart";
series2.ChartArea = "ChartArea1";
series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
series2.IsXValueIndexed = true;
series2.Legend = "Legend1";
series2.Name = "Buffer";
this.SynthBufferChart.Series.Add(series2);
this.SynthBufferChart.Size = new System.Drawing.Size(460, 112);
this.SynthBufferChart.TabIndex = 38;
this.SynthBufferChart.Text = "chart1";
//
// SynthPlayButton
//
this.SynthPlayButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.SynthPlayButton.Location = new System.Drawing.Point(615, 2);
this.SynthPlayButton.Name = "SynthPlayButton";
this.SynthPlayButton.Size = new System.Drawing.Size(104, 23);
this.SynthPlayButton.TabIndex = 37;
this.SynthPlayButton.Text = "Play";
this.SynthPlayButton.UseVisualStyleBackColor = true;
this.SynthPlayButton.Click += new System.EventHandler(this.SynthPlayButton_Click);
//
// SynthCopyXMLButton
//
this.SynthCopyXMLButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.SynthCopyXMLButton.Location = new System.Drawing.Point(463, 2);
this.SynthCopyXMLButton.Name = "SynthCopyXMLButton";
this.SynthCopyXMLButton.Size = new System.Drawing.Size(146, 23);
this.SynthCopyXMLButton.TabIndex = 35;
this.SynthCopyXMLButton.Text = "Copy XML to clipboard";
this.SynthCopyXMLButton.UseVisualStyleBackColor = true;
this.SynthCopyXMLButton.Click += new System.EventHandler(this.SynthCopyXMLButton_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(8, 6);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(37, 13);
this.label1.TabIndex = 33;
this.label1.Text = "Synth:";
//
// SynthsComboBox
//
this.SynthsComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.SynthsComboBox.FormattingEnabled = true;
this.SynthsComboBox.Location = new System.Drawing.Point(64, 3);
this.SynthsComboBox.Name = "SynthsComboBox";
this.SynthsComboBox.Size = new System.Drawing.Size(393, 21);
this.SynthsComboBox.TabIndex = 4;
this.SynthsComboBox.SelectedIndexChanged += new System.EventHandler(this.SynthsComboBox_SelectedIndexChanged);
//
// SynthTextBox
//
this.SynthTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.SynthTextBox.AutoCompleteBracketsList = new char[] {
'(',
')',
'{',
'}',
'[',
']',
'\"',
'\"',
'\'',
'\''};
this.SynthTextBox.AutoIndentChars = false;
this.SynthTextBox.AutoIndentCharsPatterns = "";
this.SynthTextBox.AutoIndentExistingLines = false;
this.SynthTextBox.AutoScrollMinSize = new System.Drawing.Size(27, 14);
this.SynthTextBox.BackBrush = null;
this.SynthTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.SynthTextBox.CharHeight = 14;
this.SynthTextBox.CharWidth = 8;
this.SynthTextBox.CommentPrefix = null;
this.SynthTextBox.Cursor = System.Windows.Forms.Cursors.IBeam;
this.SynthTextBox.DelayedEventsInterval = 1;
this.SynthTextBox.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))));
this.SynthTextBox.IsReplaceMode = false;
this.SynthTextBox.Language = FastColoredTextBoxNS.Language.XML;
this.SynthTextBox.LeftBracket = '<';
this.SynthTextBox.LeftBracket2 = '(';
this.SynthTextBox.Location = new System.Drawing.Point(3, 149);
this.SynthTextBox.Name = "SynthTextBox";
this.SynthTextBox.Paddings = new System.Windows.Forms.Padding(0);
this.SynthTextBox.RightBracket = '>';
this.SynthTextBox.RightBracket2 = ')';
this.SynthTextBox.SelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));
this.SynthTextBox.ServiceColors = ((FastColoredTextBoxNS.ServiceColors)(resources.GetObject("SynthTextBox.ServiceColors")));
this.SynthTextBox.Size = new System.Drawing.Size(825, 308);
this.SynthTextBox.TabIndex = 3;
this.SynthTextBox.Zoom = 100;
this.SynthTextBox.TextChangedDelayed += new System.EventHandler<FastColoredTextBoxNS.TextChangedEventArgs>(this.SynthTextBox_TextChangedDelayed);
//
// MainToolbar
//
this.MainToolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -433,6 +613,18 @@
//
this.SaveFileDialog.Filter = "XML files|*.xml|All files|*.*";
//
// SynthStopButton
//
this.SynthStopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.SynthStopButton.Enabled = false;
this.SynthStopButton.Location = new System.Drawing.Point(724, 2);
this.SynthStopButton.Name = "SynthStopButton";
this.SynthStopButton.Size = new System.Drawing.Size(104, 23);
this.SynthStopButton.TabIndex = 43;
this.SynthStopButton.Text = "Stop";
this.SynthStopButton.UseVisualStyleBackColor = true;
this.SynthStopButton.Click += new System.EventHandler(this.SynthStopButton_Click);
//
// RelForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -453,6 +645,10 @@
this.NameTableTabPage.PerformLayout();
this.SearchTabPage.ResumeLayout(false);
this.SearchTabPage.PerformLayout();
this.SynthsTabPage.ResumeLayout(false);
this.SynthsTabPage.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.SynthBufferChart)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.SynthTextBox)).EndInit();
this.MainToolbar.ResumeLayout(false);
this.MainToolbar.PerformLayout();
this.MainStatusStrip.ResumeLayout(false);
@ -500,5 +696,17 @@
private System.Windows.Forms.ToolStripMenuItem wIPToolStripMenuItem1;
private System.Windows.Forms.OpenFileDialog OpenFileDialog;
private System.Windows.Forms.SaveFileDialog SaveFileDialog;
private System.Windows.Forms.TabPage SynthsTabPage;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox SynthsComboBox;
private FastColoredTextBoxNS.FastColoredTextBox SynthTextBox;
private System.Windows.Forms.Button SynthCopyXMLButton;
private System.Windows.Forms.Button SynthPlayButton;
private System.Windows.Forms.DataVisualization.Charting.Chart SynthBufferChart;
private System.Windows.Forms.TextBox SynthOutputsTextBox;
private System.Windows.Forms.TextBox SynthVariablesTextBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button SynthStopButton;
}
}

View File

@ -1,4 +1,6 @@
using CodeWalker.GameFiles;
using CodeWalker.Utils;
using FastColoredTextBoxNS;
using System;
using System.Collections.Generic;
@ -10,8 +12,10 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using System.Xml;
using Range = FastColoredTextBoxNS.Range;
using TextStyle = FastColoredTextBoxNS.TextStyle;
namespace CodeWalker.Forms
{
@ -173,6 +177,25 @@ namespace CodeWalker.Forms
}
MainTextBox.Text = sb.ToString();
SynthsComboBox.Items.Clear();
SynthTextBox.Language = Language.Custom;
SynthTextBox.Text = "";
SynthTextBox.ClearUndo();
if (rel.RelType == RelDatFileType.Dat10ModularSynth)
{
foreach (var relData in rel.RelDatasSorted)
{
if ((Dat10RelType)relData.TypeID == Dat10RelType.Synth)
{
SynthsComboBox.Items.Add(relData);
}
}
}
else
{
MainTabControl.TabPages.Remove(SynthsTabPage);
}
}
@ -296,6 +319,8 @@ namespace CodeWalker.Forms
Xml = "";
RelPropertyGrid.SelectedObject = null;
MainTextBox.Text = "";
SynthsComboBox.Items.Clear();
SynthTextBox.Text = "";
modified = false;
rpfFileEntry = null;
@ -380,14 +405,73 @@ namespace CodeWalker.Forms
metaFormat = MetaFormat.XML;
}
private byte[] ParseSynthOutputs()
{
var outputs = SynthOutputsTextBox.Text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var outputsIndices = new byte[4];
for (int i = 0; i < outputsIndices.Length; i++)
{
if (outputs.Length <= i)
break;
outputsIndices[i] = byte.Parse(outputs[i].Substring(1));
}
return outputsIndices;
}
private Dat10SynthVariable[] ParseSynthVariables()
{
var variablesLines = SynthVariablesTextBox.Text.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
var variables = new Dat10SynthVariable[variablesLines.Length];
for (int i = 0; i < variablesLines.Length; i++)
{
var parts = variablesLines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
variables[i] = new Dat10SynthVariable
{
Name = XmlMeta.GetHash(parts[0]),
Value = FloatUtil.Parse(parts[1]),
};
}
return variables;
}
private Dat10Synth AssembleSynth()
{
var outputs = ParseSynthOutputs();
var variables = ParseSynthVariables();
bool error = false;
var result = Dat10Synth.Assemble(SynthTextBox.Text, variables, (errorMsg, lineNumber) => error = true);
if (error)
return null;
return new Dat10Synth(CurrentFile)
{
BuffersCount = result.BuffersCount,
RegistersCount = result.RegistersCount,
StateBlocksCount = result.StateBlocksCount,
ConstantsCount = result.Constants.Count,
Constants = result.Constants.ToArray(),
Bytecode = result.Bytecode,
OutputsCount = outputs.Length,
OutputsIndices = outputs,
VariablesCount = variables.Length,
Variables = variables,
RuntimeCost = 123
};
}
Style BlueStyle = new TextStyle(Brushes.Blue, null, FontStyle.Regular);
Style RedStyle = new TextStyle(Brushes.Red, null, FontStyle.Regular);
Style MaroonStyle = new TextStyle(Brushes.Maroon, null, FontStyle.Regular);
Style OrangeRedStyle = new TextStyle(Brushes.OrangeRed, null, FontStyle.Regular);
Style GreenStyle = new TextStyle(Brushes.Green, null, FontStyle.Regular);
Style ErrorStyle = new TextStyle(Brushes.Red, null, FontStyle.Underline);
private void HTMLSyntaxHighlight(Range range)
{
@ -439,7 +523,7 @@ namespace CodeWalker.Forms
{
if (textsearch)
{
if (((rd.Name?.ToLowerInvariant().Contains(textl))??false) || (rd.NameHash == hash) || (rd.NameHash == hashl) ||
if (((rd.Name?.ToLowerInvariant().Contains(textl)) ?? false) || (rd.NameHash == hash) || (rd.NameHash == hashl) ||
(rd.NameHash.ToString().ToLowerInvariant().Contains(textl)))
{
results.Add(rd);
@ -447,7 +531,7 @@ namespace CodeWalker.Forms
}
else
{
if ((rd.NameHash == hash)||(rd.NameHash == hashl))
if ((rd.NameHash == hash) || (rd.NameHash == hashl))
{
SearchResultsGrid.SelectedObject = rd;
return;
@ -540,5 +624,148 @@ namespace CodeWalker.Forms
HTMLSyntaxHighlight(XmlTextBox.VisibleRange);
}
}
private void SynthAssemblySyntaxHighlight(Range range)
{
//clear style of changed range
range.ClearStyle(GreenStyle, OrangeRedStyle, BlueStyle, MaroonStyle);
// comments
range.SetStyle(GreenStyle, @";.*");
// registers/variables/buffers
range.SetStyle(MaroonStyle, @"(?<![a-zA-Z_0-9])[RVB][0-9]+");
// numbers
range.SetStyle(BlueStyle, @"(?<![a-zA-Z_0-9])[0-9]+(.[0-9]+)*");
// inputs/outputs separator
range.SetStyle(OrangeRedStyle, @"=>");
}
private void SynthsComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
Dat10Synth synth = (Dat10Synth)SynthsComboBox.SelectedItem;
if (synth == null)
{
return;
}
SynthTextBox.Text = Dat10Synth.Disassemble(synth.Bytecode, synth.Constants, synth.Variables, false).Disassembly;
SynthTextBox.ClearUndo();
SynthAssemblySyntaxHighlight(SynthTextBox.Range);
SynthVariablesTextBox.Clear();
SynthVariablesTextBox.Text = string.Join(Environment.NewLine, synth.Variables.Select(v => $"{RelXml.HashString(v.Name)} {FloatUtil.ToString(v.Value)}"));
SynthOutputsTextBox.Clear();
SynthOutputsTextBox.Text = string.Join(" ", synth.OutputsIndices.Take(synth.OutputsCount).Select(bufferIdx => $"B{bufferIdx}"));
}
private void SynthTextBox_TextChangedDelayed(object sender, TextChangedEventArgs e)
{
string errors = "";
SynthTextBox.Range.ClearStyle(ErrorStyle);
SynthAssemblySyntaxHighlight(SynthTextBox.Range);
var variables = ParseSynthVariables();
Dat10Synth.Assemble(SynthTextBox.Text, variables, (errorMsg, lineNumber) =>
{
errors += $"Line {lineNumber}: {errorMsg}" + Environment.NewLine;
var line = SynthTextBox.GetLine(lineNumber - 1);
line.ClearStyle(GreenStyle, OrangeRedStyle, BlueStyle, MaroonStyle, RedStyle);
line.SetStyle(ErrorStyle);
});
StatusLabel.Text = errors;
}
private void SynthCopyXMLButton_Click(object sender, EventArgs e)
{
var newSynth = AssembleSynth();
if (newSynth == null)
{
StatusLabel.Text = "Failed to assemble synth";
}
else
{
var sb = new StringBuilder();
newSynth.WriteXml(sb, 0);
Clipboard.SetText(sb.ToString());
}
}
private Synthesizer synthesizer = null; // TODO(alexguirre): dispose synthesizer
private void SynthPlayButton_Click(object sender, EventArgs e)
{
var newSynth = AssembleSynth();
if (newSynth == null)
{
StatusLabel.Text = "Failed to assemble synth";
}
else
{
//#if !DEBUG
try
{
//#endif
if (synthesizer == null)
{
synthesizer = new Synthesizer();
synthesizer.Stopped += (t, _) =>
{
BeginInvoke((Action)(() =>
{
SynthPlayButton.Enabled = true;
SynthStopButton.Enabled = false;
}));
};
synthesizer.FrameSynthesized += (t, _) =>
{
float[][] buffersCopy = new float[synthesizer.Buffers.Length][];
for (int i = 0; i < buffersCopy.Length; i++)
{
buffersCopy[i] = new float[synthesizer.Buffers[i].Length];
Array.Copy(synthesizer.Buffers[i], buffersCopy[i], synthesizer.Buffers[i].Length);
}
BeginInvoke((Action)(() =>
{
//for (int i = 0; i < buffersCopy.Length; i++)
int i = synthesizer.Synth.OutputsIndices[0];
{
var series = SynthBufferChart.Series[$"B{i}"];
series.Points.Clear();
foreach (var v in buffersCopy[i])
series.Points.AddY(v);
}
}));
};
}
SynthBufferChart.Series.Clear();
for (int i = 0; i < newSynth.BuffersCount; i++)
{
var series = SynthBufferChart.Series.Add($"B{i}");
series.IsXValueIndexed = true;
series.ChartType = SeriesChartType.FastLine;
}
SynthPlayButton.Enabled = false;
SynthStopButton.Enabled = true;
synthesizer.Play(newSynth);
//#if !DEBUG
}
catch (Exception ex)
{
SynthPlayButton.Enabled = true;
SynthStopButton.Enabled = false;
StatusLabel.Text = $"Synthesizer error: {ex}";
}
//#endif
}
}
private void SynthStopButton_Click(object sender, EventArgs e)
{
if (synthesizer != null)
synthesizer.Stop();
}
}
}
}

View File

@ -117,6 +117,24 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="SynthTextBox.ServiceColors" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdGYXN0Q29sb3JlZFRleHRCb3gsIFZlcnNpb249Mi4xNi4yNC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWZiOGFhMTJiOTk0ZWY2MWIMAwAAAFFTeXN0
ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2Vu
PWIwM2Y1ZjdmMTFkNTBhM2EFAQAAACJGYXN0Q29sb3JlZFRleHRCb3hOUy5TZXJ2aWNlQ29sb3JzBgAA
ACg8Q29sbGFwc2VNYXJrZXJGb3JlQ29sb3I+a19fQmFja2luZ0ZpZWxkKDxDb2xsYXBzZU1hcmtlckJh
Y2tDb2xvcj5rX19CYWNraW5nRmllbGQqPENvbGxhcHNlTWFya2VyQm9yZGVyQ29sb3I+a19fQmFja2lu
Z0ZpZWxkJjxFeHBhbmRNYXJrZXJGb3JlQ29sb3I+a19fQmFja2luZ0ZpZWxkJjxFeHBhbmRNYXJrZXJC
YWNrQ29sb3I+a19fQmFja2luZ0ZpZWxkKDxFeHBhbmRNYXJrZXJCb3JkZXJDb2xvcj5rX19CYWNraW5n
RmllbGQEBAQEBAQUU3lzdGVtLkRyYXdpbmcuQ29sb3IDAAAAFFN5c3RlbS5EcmF3aW5nLkNvbG9yAwAA
ABRTeXN0ZW0uRHJhd2luZy5Db2xvcgMAAAAUU3lzdGVtLkRyYXdpbmcuQ29sb3IDAAAAFFN5c3RlbS5E
cmF3aW5nLkNvbG9yAwAAABRTeXN0ZW0uRHJhd2luZy5Db2xvcgMAAAACAAAABfz///8UU3lzdGVtLkRy
YXdpbmcuQ29sb3IEAAAABG5hbWUFdmFsdWUKa25vd25Db2xvcgVzdGF0ZQEAAAAJBwcDAAAACgAAAAAA
AAAAlgABAAH7/////P///woAAAAAAAAAAKQAAQAB+v////z///8KAAAAAAAAAACWAAEAAfn////8////
CgAAAAAAAAAATgABAAH4/////P///woAAAAAAAAAAKQAAQAB9/////z///8KAAAAAAAAAACWAAEACw==
</value>
</data>
<data name="XmlTextBox.ServiceColors" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdGYXN0Q29sb3JlZFRleHRCb3gsIFZlcnNpb249Mi4xNi4yNC4w

File diff suppressed because it is too large Load Diff